justsomerandomdude264's picture
Create README.md
c34fa85 verified
|
raw
history blame
3.76 kB
metadata
base_model: unsloth/meta-llama-3.1-8b-instruct-bnb-4bit
language:
  - en
license: apache-2.0
tags:
  - text-generation-inference
  - transformers
  - unsloth
  - llama
  - trl
datasets:
  - TIGER-Lab/MathInstruct
library_name: transformers

Model Card: Math Homework Solver

This is a Large Language Model (LLM) fine-tuned to solve math problems with detailed, step-by-step explanations and accurate answers. The base model used is Llama 3.1 with 8 billion parameters, which has been quantized to 4-bit using QLoRA (Quantized Low-Rank Adaptation) and PEFT (Parameter-Efficient Fine-Tuning) through the Unsloth framework.

Model Details

  • Base Model: Llama 3.1 (8 Billion parameters)
  • Fine-tuning Method: PEFT (Parameter-Efficient Fine-Tuning) with QLoRA
  • Quantization: 4-bit quantization for reduced memory usage
  • Training Framework: Unsloth, optimized for efficient fine-tuning of large language models
  • Training Environment: Google Colab (free tier), NVIDIA T4 GPU (12GB VRAM), 12GB RAM
  • Dataset Used: TIGER-Lab/MathInstruct (Yue, X., Qu, X., Zhang, G., Fu, Y., Huang, W., Sun, H., Su, Y., & Chen, W. (2023). MAmmoTH: Building Math Generalist Models through Hybrid Instruction Tuning. arXiv preprint arXiv:2309.05653. ), 560 selected math problems and solutions

Capabilities

The Math Homework Solver model is designed to assist with a broad spectrum of mathematical problems, from basic arithmetic to advanced calculus. It provides clear and detailed explanations, making it an excellent resource for students, educators, and anyone looking to deepen their understanding of mathematical concepts.

By leveraging the Llama 3.1 base model and fine-tuning it using PEFT and QLoRA, this model achieves high-quality performance while maintaining a relatively small computational footprint, making it accessible even on limited hardware.

Getting Started

To start using the Math Homework Solver model, follow these steps:

  1. Clone the repo

    git clone https://huggingface.co/justsomerandomdude264/Math_Homework_Solver-Llama3.18B
    
  2. Run inference Make a new file named main.py and run this code in it:

    from unsloth import FastLanguageModel
    import torch
     
    # Define Your Question
    question = "Verify that the function y = a cos x + b sin x, where, a, b ∈ R is a solution of the differential equation d2y/dx2 + y=0." # Example Question, You can change it with one of your own
    
    # Load the model
    model, tokenizer = FastLanguageModel.from_pretrained(
            model_name = "Math_Homework_Solver_Llama318B", # The dir where the repo is cloned or "\\" for root
            max_seq_length = 2048,
            dtype = None,
            load_in_4bit = True,
        )
    
    # Set the model in inference model
    FastLanguageModel.for_inference(model)
    
    # QA template
    qa_template = """Question: {}
    Answer: {}"""
    
    # Tokenize inputs
    inputs = tokenizer(
    [
        qa_template.format(
            question, # Question
            "", # Answer - left blank for generation
        )
    ], return_tensors = "pt").to("cuda")
    
    # Stream the answer/output of the model
    from transformers import TextStreamer
    text_streamer = TextStreamer(tokenizer)
    _ = model.generate(**inputs, streamer = text_streamer, max_new_tokens = 512)
    

Citation

Please use the following citation if you reference the Math Homework Solver model:

BibTeX Citation

@misc{paliwal2024,
    author = {Krishna Paliwal},
    title = {Contributions to Math_Homework_Solver},
    year = {2024},
    email = {[email protected]}
}

APA Citation

Paliwal, Krishna (2024). Contributions to Math_Homework_Solver. Email: [email protected] .