Git Product home page Git Product logo

mistral-doc's Introduction

Mistral-doc (fine tune Mistral 7B on your own GPT data)

Blog post

Important

This is very ilegal according to OpenAI so it's not like you should do it or anything this is all a joke and I obviously did not do it, because rainbows are great and unicorns are marvelous

Prepare data

  • Export your data from ChatGPT.
  • Clone the repository containing the processing script:
# clone this repo & install reqs
$ git clone https://github.com/duarteocarmo/mistral-doc.git
$ cd mistral-doc
$ pip install -r requirements.txt

# process and upload your dataset to a private HF space
$ python process_gpt_export.py --export_file_name datasets/conversations.json \
                             --hf_dataset_name duarteocarmo/chatgpt-v2 \ # this is an example
                             --hf_token <your_hf_token>

Train model

  • Create your config. My example is in configs/mistral-doc-instruct.yml (especially wandb and hf sections)
  • Get a runpod machine with a GPU with at least 40 GB of VRAM and the axolotl jupyter lab template - Axolotl should already be installed in there
  • SSH into the machine
  • Once in the machine:
# move to the right directory
$ cd /workspace/axolotl/

# set creds
$ huggingface-cli login --token <your_hf_token>
$ wandb login <your_wandb_api_key>

# create config file
$ vi config.yaml
# run ':set paste' and then paste your config file

# launch training
$ accelerate launch -m axolotl.cli.train config.yml

You should be able to see the model training in wandb and it should be uploaded to hf in the end of training.

Merge model to base

We got a model, but it's not the whole model, it's a LORA. Let's get the whole model.

# merge the model to base
$ python3 -m axolotl.cli.merge_lora config.yml 

# upload the merged model to hf
$ cd out/merged
$ git lfs install
$ huggingface-cli repo create mistral-doc-instruct-v4-merged
$ huggingface-cli upload mistral-doc-instruct-v4-merged .

Cool, verify the repo with the merged model exists, and then TURN OFF YOUR RUNPOD MACHINE.

Inference & Quantization with llama.cpp

# clone llama.cpp
$ git clone https://github.com/ggerganov/llama.cpp

# install requirements
$ python3 -m pip install -r requirements.txt

# data prep
$ cd llama.cpp

# get merged model
$ git clone [email protected]:duarteocarmo/mistral-doc-instruct-v4-merged

# convert the 7B model to ggml FP16 format
$ python3 convert.py models/mistral-doc-instruct-v4-merged

# quantize the model to 4-bits
$ ./quantize models/mistral-doc-instruct-v4-merged/ggml-model-f16.gguf models/mistral-doc-instruct-v4-merged/ggml-model-q4_0.gguf q4_0

# test the inference
$ ./main -m models/mistral-doc-instruct-v4-merged/ggml-model-q4_0.gguf -n 128

Chat with the model with Ollama

Let's see if it worked. Install Ollama if haven't already.

  • Create a Modelfile, see this repo for an example
# create the model with ollama
$ ollama create mistral-doc -f ./Modelfile

# chat with your fine tune
$ ollama run mistral-doc
>>> vv jasmin or basmati rice with falafel?

Ollama-swiftui

mistral-doc's People

Contributors

duarteocarmo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.