hackathon  by mistralai-sf24

Minimal code for running and finetuning a 7B transformer model

created 1 year ago
447 stars

Top 68.2% on sourcepulse

GitHubView on GitHub
1 Expert Loves This Project
Project Summary

This repository provides minimal code for running and fine-tuning Mistral AI's 7B model. It's targeted at developers and researchers looking to deploy or customize the model for various natural language processing tasks. The primary benefit is a streamlined path to interact with and adapt a powerful open-source LLM.

How It Works

The project leverages the Hugging Face transformers library for model inference and fine-tuning. It offers a reference implementation (one_file_ref.py) for a self-contained experience and a deploy folder with code to build a vLLM-compatible Docker image for efficient serving. Fine-tuning supports LoRA (Low-Rank Adaptation) for memory-efficient training, freezing base model weights and learning a small number of additional parameters.

Quick Start & Requirements

  • Download Model: wget https://models.mistralcdn.com/mistral-7b-v0-1/mistral-7B-v0.1.tar followed by tar -xf mistral-7B-v0.1.tar.
  • Installation: Run pip install -r requirements_hackathon.txt within the Docker container.
  • Prerequisites: Docker, Python, PyTorch. GPU is recommended for fine-tuning and efficient inference.
  • Running: python -m main demo /path/to/mistral-7B-v0.1/ or python -m main interactive /path/to/mistral-7B-v0.1/.
  • Fine-tuning: torchrun --nproc-per-node 1 --master_port $RANDOM -m train reference/7B_lora.yaml.
  • Docs: Blog post available at https://mistral.ai/news/announcing-mistral-7b/.

Highlighted Details

  • Supports LoRA fine-tuning for memory efficiency and performance recovery.
  • Includes code for building a vLLM deployment image.
  • Offers both demo and interactive modes for running the model.
  • Provides clear data formatting requirements for pre-training (jsonl with "text" key) and instruction fine-tuning (jsonl with "interactions" key).

Maintenance & Community

Licensing & Compatibility

  • The README does not explicitly state a license for this specific repository. The Mistral 7B model itself is typically released under Apache 2.0, but this code's license should be verified.

Limitations & Caveats

The repository focuses on minimal code for the 7B model; broader model support or advanced features are not detailed. The "hackathon" naming suggests it might be geared towards specific events or experimental use cases, and long-term maintenance status is not specified.

Health Check
Last commit

1 year ago

Responsiveness

Inactive

Pull Requests (30d)
0
Issues (30d)
0
Star History
2 stars in the last 90 days

Explore Similar Projects

Feedback? Help us improve.