A one-off prompt is enough when you need a single answer, but most conversations are not one question long: you tell the model something, then ask about it later. mlx_lm.chat is the MLX LM command for exactly that. It gives you a chat REPL you can use to interact with the LLM, and the chat context is preserved during the lifetime of the REPL — so the model can use what you said earlier when it answers what you ask next.
Start the chat
MLX LM is a Python package for generating text and fine-tuning large language models on Apple silicon with MLX. Install it, then start a chat:
pip install mlx-lm
mlx_lm.chat --model mlx-community/Llama-3.2-3B-Instruct-4bit
The default model for generation and chat is mlx-community/Llama-3.2-3B-Instruct-4bit, so you can also run mlx_lm.chat with no --model flag and get the same model. Thousands of MLX-compatible models are available in the MLX Community organisation on Hugging Face if you want a different one.
Test that the context survives a turn
Give the model a fact in one turn, then ask about it in the next, without repeating the fact:
| Turn | You type | What you should see |
|---|---|---|
| 1 | The lighthouse keeper is named Mara. | The model replies to the statement, for example by acknowledging it |
| 2 | What is the keeper’s name? | The model answers Mara, using the fact from turn 1 |
| 3 | When does she check the lamp? | The model asks for the time, or says it does not know it yet — it was never told |
Turn 3 matters as much as turn 2: a model that remembers the name but invents a checking time is guessing, not remembering. If the second turn does not name Mara, the context was not kept — check that you are still in the same mlx_lm.chat session and did not start a new one. Expected result. We checked the MLX LM README for the chat command and the context rule. We did not run mlx_lm.chat.
Limits
The context is preserved during the lifetime of the REPL, so when you quit the session the conversation is gone — this is a chat, not a saved document. A long conversation still has to fit in the model’s context, and earlier turns can fall out of reach as the chat grows. This needs an Apple Silicon Mac; MLX LM is built for Apple silicon. We did not run mlx_lm.chat, so no reply here is a recorded result.
