Instructions to use kalkiai3000/mathAI-Gemma with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use kalkiai3000/mathAI-Gemma with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="kalkiai3000/mathAI-Gemma") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("kalkiai3000/mathAI-Gemma") model = AutoModelForCausalLM.from_pretrained("kalkiai3000/mathAI-Gemma") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use kalkiai3000/mathAI-Gemma with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "kalkiai3000/mathAI-Gemma" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "kalkiai3000/mathAI-Gemma", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/kalkiai3000/mathAI-Gemma
- SGLang
How to use kalkiai3000/mathAI-Gemma with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "kalkiai3000/mathAI-Gemma" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "kalkiai3000/mathAI-Gemma", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "kalkiai3000/mathAI-Gemma" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "kalkiai3000/mathAI-Gemma", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use kalkiai3000/mathAI-Gemma with Docker Model Runner:
docker model run hf.co/kalkiai3000/mathAI-Gemma
mathAI-Gemma
Model Description
mathAI-Gemma is a specialized mathematical reasoning model based on Gemma 2B, fine-tuned specifically for solving JEE (Joint Entrance Examination) level mathematics problems. This model has been trained using Chain-of-Thought reasoning to provide detailed, step-by-step solutions to complex mathematical problems.
Key Features
- 🧮 Mathematical Reasoning: Specialized for JEE-level mathematics
- 🔗 Chain-of-Thought: Provides step-by-step problem solving
- 📚 Educational Focus: Designed for learning and teaching
- 🎯 High Accuracy: Trained on curated JEE problem datasets
- 💡 Formula Integration: Shows relevant formulas and calculations
Training Details
- Base Model: google/gemma-2b
- Training Method: Full fine-tuning with custom data collator
- Training Dataset: JEE Mathematics Problems with Chain-of-Thought reasoning
- Problem Areas: Algebra, Calculus, Geometry, Trigonometry, Physics Mathematics
- Training Framework: Hugging Face Transformers
- Hardware: NVIDIA A100 GPU
Usage
Quick Start
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
# Load model and tokenizer
model = AutoModelForCausalLM.from_pretrained(
"kalkiai3000/mathAI-Gemma",
torch_dtype=torch.bfloat16,
device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained("kalkiai3000/mathAI-Gemma")
# Solve a math problem
question = "Find the derivative of f(x) = x³ + 2x² - 5x + 3"
prompt = f'''Question: {question}
Let me solve this step by step:
'''
inputs = tokenizer(prompt, return_tensors="pt")
with torch.no_grad():
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], skip_special_tokens=True)
print(response)
Advanced Usage
# For better results, use structured prompting
def solve_math_problem(question: str, model, tokenizer):
prompt = f'''Question: {question}
Let me solve this step by step:
Step 1: '''
inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(
**inputs,
max_new_tokens=512,
temperature=0.3, # Lower temperature for more focused responses
do_sample=True,
top_p=0.9,
repetition_penalty=1.1,
pad_token_id=tokenizer.eos_token_id
)
return tokenizer.decode(outputs[0], skip_special_tokens=True)
Model Performance
The model excels at:
- Calculus: Derivatives, integrals, limits, optimization
- Algebra: Quadratic equations, polynomials, systems of equations
- Geometry: Area, volume, coordinate geometry, trigonometry
- Physics Mathematics: Mechanics, waves, thermodynamics calculations
- Step-by-step reasoning: Clear explanation of solution methodology
Example Outputs
Calculus Problem
Question: Find the derivative of f(x) = x³ + 2x² - 5x + 3
Let me solve this step by step:
Step 1: Apply the power rule to each term
Step 2: d/dx(x³) = 3x²
Step 3: d/dx(2x²) = 4x
Step 4: d/dx(-5x) = -5
Step 5: d/dx(3) = 0
Therefore, f'(x) = 3x² + 4x - 5
Limitations
- Domain Specific: Optimized for mathematics, may not perform well on general tasks
- Language: Primarily trained on English mathematical problems
- Complexity: Best suited for JEE-level problems (may struggle with research-level mathematics)
- Format Dependency: Works best with structured prompting format
Responsible AI Usage
- Designed as an educational tool to assist learning
- Should be used alongside human verification for critical applications
- Not intended to replace mathematical education or understanding
- Users should verify results for important calculations
Citation
If you use this model in your research or applications, please cite:
@misc{mathAI-Gemma,
title={MathAI-Gemma: A Specialized Mathematical Reasoning Model for JEE Problems},
author={kalkiai3000},
year={2024},
publisher={Hugging Face},
howpublished={\url{https://huggingface.co/kalkiai3000/mathAI-Gemma}}
}
License
This model is released under the Apache 2.0 License, following the base Gemma model licensing.
Acknowledgments
- Google for the base Gemma 2B model
- Hugging Face for the transformers library and hosting
- JEE problem dataset contributors
- Mathematical education community
Built with ❤️ for mathematical education and learning
- Downloads last month
- 2
Model tree for kalkiai3000/mathAI-Gemma
Base model
google/gemma-2b
docker model run hf.co/kalkiai3000/mathAI-Gemma