Who it is forSomeone querying the same long report or codebase dump many times on a Mac.
The problemRe-reading a long context for every question is slow and memory hungry.
The outcomeFast follow-up answers that reuse a saved prompt cache file.
What you need first
- A Mac with Apple silicon
- Python with pip or conda
- macOS 15 or later to speed up models that are large relative to RAM
- Optional: a Hugging Face account to upload converted models
Steps
- Install with
pip install mlx-lm - Cache the document: pipe prompt.txt into mlx_lm.cache_prompt with --model, --prompt - and --prompt-cache-file mistral_prompt.safetensors, as in the README
- Ask a question with mlx_lm.generate using --prompt-cache-file mistral_prompt.safetensors and your prompt; the model is read from the cache
- Lower peak memory while reading long prompts with --prefill-step-size
- Use the rotating KV cache with --max-kv-size for very long generations
Prompt for your agent
Using ml-explore/mlx-lm, cache <document> with mlx_lm.cache_prompt into a safetensors file, then answer these questions one by one with mlx_lm.generate --prompt-cache-file: <questions>.
Caveat. Smaller --max-kv-size values save RAM but lower quality, as the README warns.
Use this in your AI agent
Ask your agent
Using the Deduped MCP, get the setup steps for ml-explore/mlx-lm and "Ask many questions about one long document quickly"
Add Deduped to Claude Code once
claude mcp add --transport http deduped https://dedupedai.com/mcp
Every Monday: the 5 hottest repos and exactly how to use them. Free, one email a week, unsubscribe anytime.
Get them freeShare: X LinkedIn Hacker News Email Copy link
Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer