mlx-examples/mistral
Pedro Cuenca 730c50d00a
Use config.json, add model_type (#157)
* Use config.json, add model_type

* Update convert to generate config.json
2023-12-20 08:39:37 -08:00
..
.gitignore mistral 2023-12-05 11:02:52 -08:00
convert.py Use config.json, add model_type (#157) 2023-12-20 08:39:37 -08:00
mistral.py Use config.json, add model_type (#157) 2023-12-20 08:39:37 -08:00
README.md Add URLs to HF MLX-Community org. (#153) 2023-12-20 06:57:13 -08:00
requirements.txt Add missing numpy dependency 2023-12-06 15:34:55 -08:00
test.py mistral 2023-12-05 11:02:52 -08:00

Mistral

An example of generating text with Mistral using MLX.

Mistral 7B is one of the top large language models in its size class. It is also fully open source with a permissive license1.

Setup

Install the dependencies:

pip install -r requirements.txt

Next, download the model and tokenizer:

curl -O https://files.mistral-7b-v0-1.mistral.ai/mistral-7B-v0.1.tar
tar -xf mistral-7B-v0.1.tar

Then, convert the weights with:

python convert.py

The conversion script will save the converted weights in the same location.

Tip

Alternatively, you can also download a few converted checkpoints from the the MLX Community organisation on Hugging Face and skip the conversion step.

Run

Once you've converted the weights to MLX format, you can generate text with the Mistral model:

python mistral.py --prompt "It is a truth universally acknowledged,"  --temp 0

Run python mistral.py --help for more details.


  1. Refer to the blog post and github repository for more details. ↩︎