Update README.md
Browse files
README.md
CHANGED
@@ -56,3 +56,46 @@ The following `bitsandbytes` quantization config was used during training:
|
|
56 |
|
57 |
|
58 |
- PEFT 0.6.2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
|
57 |
|
58 |
- PEFT 0.6.2
|
59 |
+
|
60 |
+
|
61 |
+
### Try the model!
|
62 |
+
|
63 |
+
```python
|
64 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
65 |
+
from peft import PeftModel
|
66 |
+
import torch
|
67 |
+
|
68 |
+
base_model = "mistralai/Mistral-7B-Instruct-v0.3"
|
69 |
+
adapter_model = 'ifca-advanced-computing/Mistral-7B-Instruct-v0.3-EOSC'
|
70 |
+
|
71 |
+
model = AutoModelForCausalLM.from_pretrained(base_model)
|
72 |
+
model = PeftModel.from_pretrained(model, adapter_model)
|
73 |
+
tokenizer = AutoTokenizer.from_pretrained(base_model)
|
74 |
+
|
75 |
+
model.eval()
|
76 |
+
|
77 |
+
query = [
|
78 |
+
{"role": "user", "content": "What is the EOSC?"},
|
79 |
+
]
|
80 |
+
|
81 |
+
input_ids = tokenizer.apply_chat_template(
|
82 |
+
query,
|
83 |
+
tokenize=True,
|
84 |
+
return_tensors="pt"
|
85 |
+
).to(model.device)
|
86 |
+
|
87 |
+
with torch.no_grad():
|
88 |
+
outputs = model.generate(
|
89 |
+
input_ids=input_ids,
|
90 |
+
max_new_tokens=500,
|
91 |
+
do_sample=True,
|
92 |
+
temperature=0.7,
|
93 |
+
top_p=0.9
|
94 |
+
)
|
95 |
+
|
96 |
+
question = query[0]['content']
|
97 |
+
print(f'QUESTION: {question} \n')
|
98 |
+
|
99 |
+
print('ANSWER:\n')
|
100 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
101 |
+
```
|