abdouaziiz
commited on
Commit
·
babb81c
1
Parent(s):
42e630d
Update README.md
Browse files
README.md
CHANGED
@@ -32,3 +32,32 @@ The following `bitsandbytes` quantization config was used during training:
|
|
32 |
- PEFT 0.5.0
|
33 |
|
34 |
- PEFT 0.5.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
- PEFT 0.5.0
|
33 |
|
34 |
- PEFT 0.5.0
|
35 |
+
|
36 |
+
## How to Use
|
37 |
+
|
38 |
+
You can load the model and perform inference as follows:
|
39 |
+
|
40 |
+
```python
|
41 |
+
from transformers import AutoTokenizer , AutoModelForCausalLM
|
42 |
+
from peft import PeftConfig , PeftModel
|
43 |
+
|
44 |
+
|
45 |
+
path_or_model_name="llama2-frenchmedmcqa-dpo"
|
46 |
+
|
47 |
+
config = PeftConfig.from_pretrained(path_or_model_name)
|
48 |
+
model = AutoModelForCausalLM.from_pretrained(config.base_model_name_or_path, return_dict=True, load_in_4bit=True, device_map='auto')
|
49 |
+
tokenizer = AutoTokenizer.from_pretrained(config.base_model_name_or_path)
|
50 |
+
|
51 |
+
model = PeftModel.from_pretrained(model ,path_or_model_name)
|
52 |
+
|
53 |
+
|
54 |
+
prompt="### Human: Quelle méthode peut être utilisée pour déterminer la constante d'acidité (7,1 et 10,6) de l'acide valproïque (acide dipropylacétique) ? .\n### Assistant : "
|
55 |
+
|
56 |
+
|
57 |
+
|
58 |
+
input_ids =tokenizer(prompt , return_tensors="pt")
|
59 |
+
output= model.generate(**input_ids , max_length=120)
|
60 |
+
text_generated =tokenizer.decode(output[0] , skip_special_tokens=True)
|
61 |
+
|
62 |
+
print(text_generated)
|
63 |
+
```
|