A LoRA fine-tune of
Qwen2-7B-Instruct trained with supervised fine-tuning on a curated blend of mathematical reasoning and general instruction-following data. Training was performed using
Unsloth for memory-efficient adaptation on a single GPU.
The model was trained on a concatenated and shuffled mixture of three datasets (seed 3407):
All examples were formatted using the ChatML conversation template before training. The loss was computed on assistant responses only; user turns and system prompts were excluded from the gradient.
It is not intended for safety-critical applications, factual knowledge retrieval, or domains outside its training distribution.
1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3model_id = "x0root/qwen2-7b-orca-math-lora"
4
5tokenizer = AutoTokenizer.from_pretrained(model_id)
6model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto")
7
8messages = [
9 {"role": "user", "content": "A train travels 300 km in 4 hours. What is its average speed?"}
10]
11
12text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
13inputs = tokenizer(text, return_tensors="pt").to(model.device)
14
15outputs = model.generate(**inputs, max_new_tokens=512, temperature=0.7, do_sample=True)
16print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True))
For faster inference with the original 4-bit quantized weights, load via Unsloth:
1from unsloth import FastLanguageModel
2
3model, tokenizer = FastLanguageModel.from_pretrained(
4 model_name="x0root/qwen2-7b-orca-math-lora",
5 max_seq_length=2048,
6 load_in_4bit=True,
7)
8FastLanguageModel.for_inference(model)