Model Overview
This model is a fine-tuned version of Llama2 on the GSM8K dataset, designed to enhance mathematical reasoning abilities. The GSM8K dataset consists of grade-school-level math word problems, and this fine-tuning allows the model to better handle complex reasoning steps in mathematical problem-solving.
Base Model: Llama2 Fine-tuned Dataset: GSM8K (Grade School Math 8K) Task: Mathematical Reasoning and Problem Solving
This model is particularly useful for solving math problems that require multiple steps of reasoning, including addition, subtraction, multiplication, division, and understanding word problems. It can be applied in educational tools, tutoring systems, or as a core model for AI math solvers.
💻 Usage
!pip install transformers
!pip install torch
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
# Load the model and tokenizer from Hugging Face
model_name = "hemanth955/Llama-2-7b-math"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name)
# Define the math problem
math_problem = "A train leaves the station at 6:00 PM and travels at a speed of 50 mph. How far will it have traveled by 8:00 PM?"
# Tokenize the input
inputs = tokenizer(math_problem, return_tensors="pt")
# Generate the response from the model
outputs = model.generate(**inputs, max_length=100)
# Decode the output to get the answer
answer = tokenizer.decode(outputs[0], skip_special_tokens=True)
print("Generated Answer:", answer)
# Optional: Use Hugging Face pipeline for easier interaction
math_pipeline = pipeline("text-generation", model=model_name)
response = math_pipeline(math_problem)
print("Pipeline Answer:", response[0]['generated_text'])