Update README.md
#1
by
prithivMLmods
- opened
README.md
CHANGED
@@ -1,6 +1,37 @@
|
|
1 |
-
---
|
2 |
-
license: mit
|
3 |
-
tags:
|
4 |
-
- trl
|
5 |
-
- sft
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: mit
|
3 |
+
tags:
|
4 |
+
- trl
|
5 |
+
- sft
|
6 |
+
- text-generation-inference
|
7 |
+
language:
|
8 |
+
- en
|
9 |
+
- zh
|
10 |
+
base_model:
|
11 |
+
- HuggingFaceTB/SmolLM2-360M-Instruct
|
12 |
+
pipeline_tag: text-generation
|
13 |
+
library_name: transformers
|
14 |
+
---
|
15 |
+
# **SmolR**
|
16 |
+
|
17 |
+
### Transformers
|
18 |
+
```bash
|
19 |
+
pip install transformers
|
20 |
+
```
|
21 |
+
|
22 |
+
```python
|
23 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
24 |
+
checkpoint = "mohamedrasheqA/SmolR"
|
25 |
+
|
26 |
+
device = "cuda" # for GPU usage or "cpu" for CPU usage
|
27 |
+
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
|
28 |
+
# for multiple GPUs install accelerate and do `model = AutoModelForCausalLM.from_pretrained(checkpoint, device_map="auto")`
|
29 |
+
model = AutoModelForCausalLM.from_pretrained(checkpoint).to(device)
|
30 |
+
|
31 |
+
messages = [{"role": "user", "content": "What is gravity?"}]
|
32 |
+
input_text=tokenizer.apply_chat_template(messages, tokenize=False)
|
33 |
+
print(input_text)
|
34 |
+
inputs = tokenizer.encode(input_text, return_tensors="pt").to(device)
|
35 |
+
outputs = model.generate(inputs, max_new_tokens=50, temperature=0.2, top_p=0.9, do_sample=True)
|
36 |
+
print(tokenizer.decode(outputs[0]))
|
37 |
+
```
|