DeepMount00
commited on
Commit
•
a6b743d
1
Parent(s):
35076bc
Update README.md
Browse files
README.md
CHANGED
@@ -5,4 +5,35 @@ datasets:
|
|
5 |
- DeepMount00/llm_ita_ultra
|
6 |
language:
|
7 |
- it
|
8 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
- DeepMount00/llm_ita_ultra
|
6 |
language:
|
7 |
- it
|
8 |
+
---
|
9 |
+
|
10 |
+
## How to Use
|
11 |
+
|
12 |
+
```python
|
13 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
14 |
+
import torch
|
15 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
16 |
+
|
17 |
+
MODEL_NAME = "DeepMount00/Llama-3-8b-Ita"
|
18 |
+
|
19 |
+
model = AutoModelForCausalLM.from_pretrained(MODEL_NAME, torch_dtype=torch.bfloat16).eval()
|
20 |
+
model.to(device)
|
21 |
+
tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
|
22 |
+
|
23 |
+
def generate_answer(prompt):
|
24 |
+
messages = [
|
25 |
+
{"role": "user", "content": prompt},
|
26 |
+
]
|
27 |
+
model_inputs = tokenizer.apply_chat_template(messages, return_tensors="pt").to(device)
|
28 |
+
generated_ids = model.generate(model_inputs, max_new_tokens=200, do_sample=True,
|
29 |
+
temperature=0.001)
|
30 |
+
decoded = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)
|
31 |
+
return decoded[0]
|
32 |
+
|
33 |
+
prompt = "Come si apre un file json in python?"
|
34 |
+
answer = generate_answer(prompt)
|
35 |
+
print(answer)
|
36 |
+
```
|
37 |
+
---
|
38 |
+
## Developer
|
39 |
+
[Michele Montebovi]
|