project-numina/NuminaMath-CoT
Viewer • Updated • 860k • 145k • 624
How to use Kiffaz11/llama-3.2-1b-instruct-math-sft-lora with PEFT:
from peft import PeftModel
from transformers import AutoModelForCausalLM
base_model = AutoModelForCausalLM.from_pretrained("unsloth/Llama-3.2-1B-Instruct")
model = PeftModel.from_pretrained(base_model, "Kiffaz11/llama-3.2-1b-instruct-math-sft-lora")This is a LoRA adapter fine-tuned from meta-llama/Llama-3.2-1B-Instruct for mathematical reasoning.
torchrun --nproc_per_node=2nvidia/OpenMathInstruct-2meta-math/MetaMathQATIGER-Lab/MathInstructAI-MO/NuminaMath-CoTExact decontamination was applied against GSM8K test and MATH-500 test question text hashes.
| Benchmark | Accuracy |
|---|---|
| GSM8K test | 50.57% |
| MATH-500 test | 28.80% |
| Combined average | 39.68% |
from unsloth import FastLanguageModel
model, tokenizer = FastLanguageModel.from_pretrained(
model_name="Kiffaz11/llama-3.2-1b-instruct-math-sft-lora",
max_seq_length=4096,
dtype=None,
load_in_4bit=False,
)
FastLanguageModel.for_inference(model)
messages = [
{
"role": "user",
"content": "Solve step by step. Put the final answer in \\boxed{}. What is 17*23?",
}
]
inputs = tokenizer.apply_chat_template(
messages,
tokenize=True,
add_generation_prompt=True,
return_tensors="pt",
return_dict=True,
).to(model.device)
outputs = model.generate(
**inputs,
max_new_tokens=256,
do_sample=False,
)
print(
tokenizer.decode(
outputs[0][inputs["input_ids"].shape[-1]:],
skip_special_tokens=True,
)
)
Base model
meta-llama/Llama-3.2-1B-Instruct