--- base_model: unsloth/gemma-2-9b-bnb-4bit library_name: peft license: mit datasets: - AI-MO/NuminaMath-CoT language: - en new_version: google/gemma-2-9b-it --- # 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 [Base_model](https://huggingface.co/unsloth/gemma-2-9b-bnb-4bit) ## 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 ```python #install required packages !pip install -q -U transformers --upgrade bitsandbytes #import model loading modeules from peft import PeftModel, PeftConfig from transformers import AutoModelForCausalLM , AutoTokenizer #load you token from secrets from kaggle_secrets import UserSecretsClient user_secrets = UserSecretsClient() secret_value_0 = user_secrets.get_secret("HF_TOKEN") #login to hugging face using a token with write privileges from huggingface_hub import login login(token=secret_value_0) #load model configurations, base model and the lora adapters config = PeftConfig.from_pretrained("Koomemartin/unsloth-gemma2-9b-version3-100k") base_model = AutoModelForCausalLM.from_pretrained("unsloth/gemma-2-9b-bnb-4bit") peftmodel = PeftModel.from_pretrained(base_model, "Koomemartin/unsloth-gemma2-9b-version3-100k",config=config) tokenizer = AutoTokenizer.from_pretrained("Koomemartin/unsloth-gemma2-9b-version3-100k") #prompt template to query the model prompt_template=''' You 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. Instruction: {problem} \n Response: {response} ''' #tokenize inputs before querying the model inputs = tokenizer( [ prompt_template.format( 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 response="", ) ], return_tensors = "pt").to("cuda") #stream the response immediately the model starts generating from transformers import TextStreamer text_streamer = TextStreamer(tokenizer) _ = peftmodel.generate(**inputs, streamer = text_streamer, max_new_tokens = 1024) ``` [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](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700). - **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 - PEFT 0.13.2