Model Card for Model ID
Unlocking Math Mastery with AI
Model Details
Model Description
Mathlearn model is quantized model based from a quantized gemma2-9b-it model. It is finetuned on 100k samples of Q&A pairs from a custom chain of thought dataset.The model was finetuned for 10 epoch getting a loss close to 1.0 (indicating good performance) and also shown an improvement in step wise problem solving capabilities compared to before finetuning. If prompted effectively, it is able to solve mathematics problems in a step by step approach explaining each step in detail
Model Sources
Usage
When loading this model the following packages are required: transformers and bitsandbytes because the base model is a quantized model. BitsandBytes is currently supported on cuda devices hence can only run on GPU's. Here is how to load and engage with the model
Direct Use
1
2#install required packages
3!pip install -q -U transformers --upgrade bitsandbytes
4
5#import model loading modeules
6from peft import PeftModel, PeftConfig
7from transformers import AutoModelForCausalLM , AutoTokenizer
8
9#load you token from secrets
10from kaggle_secrets import UserSecretsClient
11user_secrets = UserSecretsClient()
12secret_value_0 = user_secrets.get_secret("HF_TOKEN")
13
14#login to hugging face using a token with write privileges
15from huggingface_hub import login
16login(token=secret_value_0)
17
18#load model configurations, base model and the lora adapters
19config = PeftConfig.from_pretrained("Koomemartin/unsloth-gemma2-9b-version3-100k")
20base_model = AutoModelForCausalLM.from_pretrained("unsloth/gemma-2-9b-bnb-4bit")
21
22peftmodel = PeftModel.from_pretrained(base_model, "Koomemartin/unsloth-gemma2-9b-version3-100k",config=config)
23tokenizer = AutoTokenizer.from_pretrained("Koomemartin/unsloth-gemma2-9b-version3-100k")
24
25#prompt template to query the model
26prompt_template='''
27You are a math assistant. Answer the following math problem with a detailed, step-by-step solution. Be clear and concise in each step. If there are multiple approaches, select the most efficient method. Include any formulas or key concepts used, and provide the final answer at the end.
28
29Instruction: {problem} \n
30Response: {response}
31'''
32
33#tokenize inputs before querying the model
34inputs = tokenizer(
35[
36 prompt_template.format(
37 problem="Consider the stationary predictive model: 𝑋𝑡+𝑇̂=𝑎𝑋𝑡−1 + 𝑏𝑋𝑡−3 + 𝑐𝑍𝑡 where 𝑋𝑡+𝑇̂ denotes the estimated value of 𝑋𝑡+𝑇 at T time steps in the future. By minimising the expected mean square error between the predicted estimated value 𝑋𝑡+𝑇̂ and the observed value 𝑋𝑡+𝑇, Find the optimal values of a, b and c in terms of autocorrelation", # instruction
38 response="",
39 )
40], return_tensors = "pt").to("cuda")
41
42#stream the response immediately the model starts generating
43from transformers import TextStreamer
44text_streamer = TextStreamer(tokenizer)
45_ = peftmodel.generate(**inputs, streamer = text_streamer, max_new_tokens = 1024)
46
[More Information Needed]
Downstream Use [optional]
[More Information Needed]
Out-of-Scope Use
[More Information Needed]
Bias, Risks, and Limitations
[More Information Needed]
Recommendations
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
How to Get Started with the Model
Use the code below to get started with the model.
[More Information Needed]
Training Details
Training Data
[More Information Needed]
Training Procedure
Preprocessing [optional]
[More Information Needed]
Training Hyperparameters
- Training regime: [More Information Needed]
Speeds, Sizes, Times [optional]
[More Information Needed]
Evaluation
Testing Data, Factors & Metrics
Testing Data
[More Information Needed]
Factors
[More Information Needed]
Metrics
[More Information Needed]
Results
[More Information Needed]
Summary
Model Examination [optional]
[More Information Needed]
Environmental Impact
Carbon emissions can be estimated using the
Machine Learning Impact calculator presented in
Lacoste et al. (2019).
- Hardware Type: [More Information Needed]
- Hours used: [More Information Needed]
- Cloud Provider: [More Information Needed]
- Compute Region: [More Information Needed]
- Carbon Emitted: [More Information Needed]
Technical Specifications [optional]
Model Architecture and Objective
[More Information Needed]
Compute Infrastructure
[More Information Needed]
Hardware
[More Information Needed]
Software
[More Information Needed]
Citation [optional]
BibTeX:
[More Information Needed]
APA:
[More Information Needed]
Glossary [optional]
[More Information Needed]
More Information [optional]
[More Information Needed]
Model Card Authors [optional]
[More Information Needed]
Model Card Contact
[More Information Needed]
Framework versions