Instructions to use mlx-community/Llama-2-7b-chat-mlx with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use mlx-community/Llama-2-7b-chat-mlx with MLX:
# Make sure mlx-lm is installed # pip install --upgrade mlx-lm # if on a CUDA device, also pip install mlx[cuda] # Generate text with mlx-lm from mlx_lm import load, generate model, tokenizer = load("mlx-community/Llama-2-7b-chat-mlx") prompt = "Once upon a time in" text = generate(model, tokenizer, prompt=prompt, verbose=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- MLX LM
How to use mlx-community/Llama-2-7b-chat-mlx with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Generate some text mlx_lm.generate --model "mlx-community/Llama-2-7b-chat-mlx" --prompt "Once upon a time"
- Atomic Chat
params.json missing
I downloaded the model form "https://huggingface.co/mlx-llama" and ran python llama.py <path_to_tokenizer.model> "hello". I get params.json missing error, and in the weights the "layers.0.feed_forward.w1.weight" and "output.weight" keys are missing.
Hello @Farzamfan !
The original inference script llama.py has changed in a number of ways:
- The weights filename is now hardcoded.
- It expects a configuration file as you saw.
- Some configurations are taken from the weights themselves.
We need to re-export these models accordingly. Meanwhile, can you please use revision 0bf5d0e3bc1e51b82cf8083be422dc61dc88455b of https://github.com/ml-explore/mlx-examples.git? That revision runs inference fine using this model and the instructions in the model card.
Btw, the HF models should be updated to work with the latest mlx-examples. If you still have issues let me know and/or file an issue in https://github.com/ml-explore/mlx-examples
Thanks a lot @awni , I saw you updated this repo a couple days ago π. I just changed the example to use the --prompt option, so the snippet now works with the latest main. Could you please verify if that's the case for you as well @Farzamfan ?
I'll now go through the other repos and verify whether they work.