Views
No views yet
1from transformers import AutoModelForCausalLM, AutoTokenizer
2import torch
3
4# Load model and tokenizer
5model_name = "ReasoningTransferability/UniReason-Qwen3-14B-think-SFT"
6tokenizer = AutoTokenizer.from_pretrained(model_name)
7model = AutoModelForCausalLM.from_pretrained(
8 model_name,
9 torch_dtype=torch.float16,
10 device_map="auto"
11)
12
13# Example: Math reasoning
14math_prompt = "Solve this step by step: What is the derivative of x^3 + 2x^2 - 5x + 1?"
15inputs = tokenizer(math_prompt, return_tensors="pt")
16outputs = model.generate(**inputs, max_length=32768, temperature=0.7)
17response = tokenizer.decode(outputs[0], skip_special_tokens=True)
18print(response)
19
20# Example: General reasoning
21general_prompt = "Explain the concept of supply and demand in economics."
22inputs = tokenizer(general_prompt, return_tensors="pt")
23outputs = model.generate(**inputs, max_length=32768, temperature=0.7)
24response = tokenizer.decode(outputs[0], skip_special_tokens=True)
25print(response)