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.
1!pip install transformers
2!pip install torch
3
4
5from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
6
7# Load the model and tokenizer from Hugging Face
8model_name = "hemanth955/Llama-2-7b-math"
9tokenizer = AutoTokenizer.from_pretrained(model_name)
10model = AutoModelForCausalLM.from_pretrained(model_name)
11
12# Define the math problem
13math_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?"
14
15# Tokenize the input
16inputs = tokenizer(math_problem, return_tensors="pt")
17
18# Generate the response from the model
19outputs = model.generate(**inputs, max_length=100)
20
21# Decode the output to get the answer
22answer = tokenizer.decode(outputs[0], skip_special_tokens=True)
23print("Generated Answer:", answer)
24
25# Optional: Use Hugging Face pipeline for easier interaction
26math_pipeline = pipeline("text-generation", model=model_name)
27response = math_pipeline(math_problem)
28print("Pipeline Answer:", response[0]['generated_text'])
29