Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,68 @@
|
|
1 |
-
---
|
2 |
-
license: apache-2.0
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
datasets:
|
4 |
+
- motexture/cData
|
5 |
+
language:
|
6 |
+
- en
|
7 |
+
- it
|
8 |
+
- es
|
9 |
+
base_model:
|
10 |
+
- meta-llama/Llama-3.2-3B-Instruct
|
11 |
+
pipeline_tag: text-generation
|
12 |
+
tags:
|
13 |
+
- smoll
|
14 |
+
- coding
|
15 |
+
- coder
|
16 |
+
- model
|
17 |
+
- small
|
18 |
+
---
|
19 |
+
|
20 |
+
# LlamaXCoder-3.2-3B-Instruct
|
21 |
+
|
22 |
+
## Introduction
|
23 |
+
|
24 |
+
LlamaXCoder-3.2-3B-Instruct is a fine-tuned version of meta-llama/Llama-3.2-3B-Instruct, trained on the cData coding dataset to improve its reasoning and coding ability.
|
25 |
+
|
26 |
+
## Quickstart
|
27 |
+
|
28 |
+
Here provides a code snippet with `apply_chat_template` to show you how to load the tokenizer and model and how to generate contents.
|
29 |
+
|
30 |
+
```python
|
31 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
32 |
+
device = "cuda" # the device to load the model onto
|
33 |
+
|
34 |
+
model = AutoModelForCausalLM.from_pretrained(
|
35 |
+
"motexture/LlamaXCoder-3.2-3B-Instruct",
|
36 |
+
torch_dtype="auto",
|
37 |
+
device_map="auto"
|
38 |
+
)
|
39 |
+
tokenizer = AutoTokenizer.from_pretrained("motexture/LlamaXCoder-3.2-3B-Instruct")
|
40 |
+
|
41 |
+
prompt = "Write a C++ program that prints Hello World!"
|
42 |
+
messages = [
|
43 |
+
{"role": "system", "content": "You are a helpful assistant."},
|
44 |
+
{"role": "user", "content": prompt}
|
45 |
+
]
|
46 |
+
text = tokenizer.apply_chat_template(
|
47 |
+
messages,
|
48 |
+
tokenize=False,
|
49 |
+
add_generation_prompt=True
|
50 |
+
)
|
51 |
+
model_inputs = tokenizer([text], return_tensors="pt").to(device)
|
52 |
+
|
53 |
+
generated_ids = model.generate(
|
54 |
+
model_inputs.input_ids,
|
55 |
+
max_new_tokens=4096,
|
56 |
+
do_sample=True,
|
57 |
+
temperature=0.3
|
58 |
+
)
|
59 |
+
generated_ids = [
|
60 |
+
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
|
61 |
+
]
|
62 |
+
|
63 |
+
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
64 |
+
```
|
65 |
+
|
66 |
+
## License
|
67 |
+
|
68 |
+
[Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0)
|