One-shot generation is fine for a single question, but a conversation needs memory. mlx_lm.chat opens a chat REPL in the terminal: you type, the model answers, and the chat context is preserved for the lifetime of the REPL, so follow-up questions work.
Start the chat REPL and talk
Install mlx-lm and run mlx_lm.chat in the terminal. The default model is mlx-community/Llama-3.2-3B-Instruct-4bit; pick another MLX-compatible model with --model. Type your first message, read the answer, then ask a follow-up that refers back to it — the REPL keeps the context, so “and what about the second one?” works the way you expect.
pip install mlx-lm
mlx_lm.chat
# or with a model of your choice:
mlx_lm.chat --model mlx-community/Qwen2.5-7B-Instruct-4bit
The context lives only while the REPL runs: close the terminal and the conversation is gone. It also grows with every turn, so a very long session can get slow — start a fresh REPL when the conversation changes topic.
Try it: four checks
| Check | What you should see | If you do not see it |
|---|---|---|
| REPL starts | mlx_lm.chat opens a chat prompt | Check mlx-lm is installed |
| First answer | The model answers the first message | Check the model finished downloading |
| Follow-up works | A follow-up referring back gets a sensible answer | That is the preserved context working |
| Context ends | Closing the terminal ends the conversation | That is expected, not a bug |
Expected result. We checked the mlx-lm README, which documents mlx_lm.chat as a chat REPL where the chat context is preserved during the lifetime of the REPL, and the default model. We did not run the REPL on this machine.
Limits
This guide covers the chat REPL only. The context is not saved when the REPL closes. We did not test any chat ourselves.
