Views
No views yet
1from unsloth import FastLanguageModel
2from transformers import TextStreamer
3import torch
4
5# Load the finetuned model
6model, tokenizer = FastLanguageModel.from_pretrained(
7 model_name = "papasega/gpt-oss-20b-HF4-Multilingual-Thinking", # Replace with your model name if different
8 max_seq_length = 128, # Set to the max_seq_length you want
9 dtype = None, # Use None for auto detection
10 load_in_4bit = True, # Set to True if you saved in 4bit
11)
12
13# Prepare the input message
14messages = [
15 {"role": "system", "content": "reasoning language: French\n\nYou are a helpful assistant that can solve mathematical problems."},
16 {"role": "user", "content": "Résout cette equation pour un élève en classe de seconde : x^4 + 2 = 0."},
17]
18
19inputs = tokenizer.apply_chat_template(
20 messages,
21 add_generation_prompt = True,
22 return_tensors = "pt",
23 return_dict = True,
24 reasoning_effort = "low", # Choose "low", "medium", or "high"
25).to(model.device)
26
27# Generate the response
28_ = model.generate(**inputs, max_new_tokens = 128, streamer = TextStreamer(tokenizer))
29