Downloads · 30 days
12
3% of all-time downloads
HenryShan/Llama-3.2-3B-GSM8K-CoT
Llama-3.2-3B-GSM8K-CoT is a text generation model from HenryShan. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as llama3.2.
A fine-tuned Llama 3.2 3B parameter language model specialized for mathematical reasoning tasks, trained on the GSM8K (Grade School Math 8K) dataset. This model excels at solving arithmetic, algebra, and word problems…
Downloads · 30 days
12
3% of all-time downloads
All-time downloads
408
Public
Parameters
3.2B
6.4 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors6.4 GB · 100%
From the Hugging Face model README
A fine-tuned Llama 3.2 3B parameter language model specialized for mathematical reasoning tasks, trained on the GSM8K (Grade School Math 8K) dataset. This model excels at solving arithmetic, algebra, and word problems typically found in grade school mathematics.
This model is based on Meta's Llama 3.2 3B Instruct model and has been fine-tuned specifically for mathematical problem-solving. The GSM8K dataset consists of 8,500 high-quality grade school math problems created by human problem writers, making it an excellent benchmark for evaluating mathematical reasoning capabilities in language models.
| Parameter | Value |
|---|---|
| Base Model | Meta Llama 3.2 3B Instruct |
| Parameters | 3,212,749,824 |
| Layers | 28 |
| Attention Heads | 24 |
| Key-Value Heads | 8 |
| Hidden Size | 3,072 |
| Context Length | 131,072 tokens |
| Vocabulary Size | 128,256 |
| Total Model Size | ~6.4 GB |
The model was fine-tuned using parameter-efficient techniques to adapt the base Llama 3.2 model for mathematical reasoning while preserving its general language capabilities.
While specific benchmarks may vary, this model demonstrates strong performance on mathematical reasoning tasks:
pip install torch transformers accelerate
from transformers import AutoTokenizer, AutoModelForCausalLM
model_path = "path/to/your/model"
tokenizer = AutoTokenizer.from_pretrained(model_path)
model = AutoModelForCausalLM.from_pretrained(
model_path,
torch_dtype="auto",
device_map="auto"
)
def solve_math_problem(problem):
messages = [
{"role": "user", "content": f"Solve this math problem step by step: {problem}"}
]
inputs = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
return_tensors="pt"
).to(model.device)
outputs = model.generate(
inputs,
max_new_tokens=512,
temperature=0.7,
do_sample=True,
pad_token_id=tokenizer.eos_token_id
)
response = tokenizer.decode(outputs[0][inputs.shape[1]:], skip_special_tokens=True)
return response
# Example usage
problem = "A bakery sells 3 croissants for $5. How much would it cost to buy 7 croissants?"
solution = solve_math_problem(problem)
print(solution)
def chat_with_model():
print("Math Tutor: Hello! I can help you solve math problems. What would you like to work on?")
while True:
user_input = input("You: ")
if user_input.lower() in ['quit', 'exit', 'bye']:
print("Math Tutor: Goodbye!")
break
messages = [{"role": "user", "content": user_input}]
inputs = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
return_tensors="pt"
).to(model.device)
outputs = model.generate(
inputs,
max_new_tokens=256,
temperature=0.7,
do_sample=True,
pad_token_id=tokenizer.eos_token_id
)
response = tokenizer.decode(outputs[0][inputs.shape[1]:], skip_special_tokens=True)
print(f"Math Tutor: {response}")
# Start chatting
chat_with_model()
User: What is 23 × 47?
Assistant: Let me calculate that step by step:
23 × 47
First, 20 × 47 = 940
3 × 47 = 141
940 + 141 = 1,081
So, 23 × 47 = 1,081
User: Sarah has 3 apples. She buys 2 more apples at the store and then gives 1 apple to her friend. How many apples does Sarah have now?
Assistant: Let's solve this step by step:
1. Sarah starts with 3 apples
2. She buys 2 more apples: 3 + 2 = 5 apples
3. She gives 1 apple to her friend: 5 - 1 = 4 apples
Sarah has 4 apples now.
User: A rectangle has a length of 12 cm and a width of 8 cm. What is the perimeter of the rectangle?
Assistant: To find the perimeter of a rectangle, I use the formula:
Perimeter = 2 × (length + width)
Length = 12 cm
Width = 8 cm
Length + width = 12 + 8 = 20 cm
Perimeter = 2 × 20 = 40 cm
The perimeter is 40 cm.
This model is designed for educational purposes and mathematical problem-solving. Users should:
This model is released under the Llama 3.2 Community License. By using this model, you agree to comply with the license terms and Meta's Acceptable Use Policy.
If you use this model in your research or applications, please cite it as:
@misc{llama3.2-gsm8k,
title={Llama 3.2 3B GSM8K - Mathematical Reasoning Model},
author={Model Creator},
year={2024},
note={Fine-tuned Llama 3.2 model on GSM8K dataset for mathematical reasoning}
}
For questions, issues, or contributions related to this model, please refer to the appropriate channels based on your needs.