Update README.md
Browse files
README.md
CHANGED
@@ -19,17 +19,33 @@ language:
|
|
19 |
|
20 |
|
21 |
```python
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
messages = [
|
23 |
{"role": "system", "content": "reasoning language: French\n\nYou are a helpful assistant that can solve mathematical problems."},
|
24 |
{"role": "user", "content": "Résout cette equation pour un élève en classe de seconde : x^4 + 2 = 0."},
|
25 |
]
|
|
|
26 |
inputs = tokenizer.apply_chat_template(
|
27 |
messages,
|
28 |
add_generation_prompt = True,
|
29 |
return_tensors = "pt",
|
30 |
return_dict = True,
|
31 |
-
reasoning_effort = "low",
|
32 |
).to(model.device)
|
33 |
-
|
|
|
34 |
_ = model.generate(**inputs, max_new_tokens = 128, streamer = TextStreamer(tokenizer))
|
|
|
35 |
```
|
|
|
19 |
|
20 |
|
21 |
```python
|
22 |
+
from unsloth import FastLanguageModel
|
23 |
+
from transformers import TextStreamer
|
24 |
+
import torch
|
25 |
+
|
26 |
+
# Load the finetuned model
|
27 |
+
model, tokenizer = FastLanguageModel.from_pretrained(
|
28 |
+
model_name = "papasega/gpt-oss-20b-HF4-Multilingual-Thinking", # Replace with your model name if different
|
29 |
+
max_seq_length = 128, # Set to the max_seq_length you want
|
30 |
+
dtype = None, # Use None for auto detection
|
31 |
+
load_in_4bit = True, # Set to True if you saved in 4bit
|
32 |
+
)
|
33 |
+
|
34 |
+
# Prepare the input message
|
35 |
messages = [
|
36 |
{"role": "system", "content": "reasoning language: French\n\nYou are a helpful assistant that can solve mathematical problems."},
|
37 |
{"role": "user", "content": "Résout cette equation pour un élève en classe de seconde : x^4 + 2 = 0."},
|
38 |
]
|
39 |
+
|
40 |
inputs = tokenizer.apply_chat_template(
|
41 |
messages,
|
42 |
add_generation_prompt = True,
|
43 |
return_tensors = "pt",
|
44 |
return_dict = True,
|
45 |
+
reasoning_effort = "low", # Choose "low", "medium", or "high"
|
46 |
).to(model.device)
|
47 |
+
|
48 |
+
# Generate the response
|
49 |
_ = model.generate(**inputs, max_new_tokens = 128, streamer = TextStreamer(tokenizer))
|
50 |
+
|
51 |
```
|