nvidia/OpenMathInstruct-2
Viewer • Updated • 22M • 105k • 247
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")How to use Kiffaz11/llama-3.2-1b-instruct-math-sft-lora with Unsloth Studio:
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for Kiffaz11/llama-3.2-1b-instruct-math-sft-lora to start chatting
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for Kiffaz11/llama-3.2-1b-instruct-math-sft-lora to start chatting
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for Kiffaz11/llama-3.2-1b-instruct-math-sft-lora to start chatting
pip install unsloth
from unsloth import FastModel
model, tokenizer = FastModel.from_pretrained(
model_name="Kiffaz11/llama-3.2-1b-instruct-math-sft-lora",
max_seq_length=2048,
)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