Text Generation
MLX
Safetensors
English
Chinese
longcat_flash_sparse
longcat
lsa
Mixture of Experts
ngram-embedding
conversational
6-bit
Instructions to use mlx-community/LongCat-Flash-Lite-Sparse-6bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use mlx-community/LongCat-Flash-Lite-Sparse-6bit with MLX:
# Make sure mlx-lm is installed # pip install --upgrade mlx-lm # Generate text with mlx-lm from mlx_lm import load, generate model, tokenizer = load("mlx-community/LongCat-Flash-Lite-Sparse-6bit") prompt = "Write a story about Einstein" messages = [{"role": "user", "content": prompt}] prompt = tokenizer.apply_chat_template( messages, add_generation_prompt=True ) text = generate(model, tokenizer, prompt=prompt, verbose=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Pi
How to use mlx-community/LongCat-Flash-Lite-Sparse-6bit with Pi:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "mlx-community/LongCat-Flash-Lite-Sparse-6bit"
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "mlx-lm": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "mlx-community/LongCat-Flash-Lite-Sparse-6bit" } ] } } }Run Pi
# Start Pi in your project directory: pi
- MLX LM
How to use mlx-community/LongCat-Flash-Lite-Sparse-6bit with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Interactive chat REPL mlx_lm.chat --model "mlx-community/LongCat-Flash-Lite-Sparse-6bit"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "mlx-community/LongCat-Flash-Lite-Sparse-6bit" # Calling the OpenAI-compatible server with curl curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mlx-community/LongCat-Flash-Lite-Sparse-6bit", "messages": [ {"role": "user", "content": "Hello"} ] }' - Hermes Agent
How to use mlx-community/LongCat-Flash-Lite-Sparse-6bit with Hermes Agent:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "mlx-community/LongCat-Flash-Lite-Sparse-6bit"
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default mlx-community/LongCat-Flash-Lite-Sparse-6bit
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use mlx-community/LongCat-Flash-Lite-Sparse-6bit with OpenClaw:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "mlx-community/LongCat-Flash-Lite-Sparse-6bit"
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "mlx-community/LongCat-Flash-Lite-Sparse-6bit" \ --custom-provider-id mlx-lm \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
File size: 2,988 Bytes
9d39b38 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | ---
language:
- en
- zh
license: mit
library_name: mlx
tags:
- mlx
- longcat
- lsa
- moe
- ngram-embedding
base_model: meituan-longcat/LongCat-Flash-Lite-Sparse
pipeline_tag: text-generation
---
# LongCat-Flash-Lite-Sparse-6bit (MLX)
6-bit MLX quantization of [meituan-longcat/LongCat-Flash-Lite-Sparse](https://huggingface.co/meituan-longcat/LongCat-Flash-Lite-Sparse) (69B-A3B, `LongcatCausalLM`).
6-bit (~52 GB of weights) is the middle-ground variant, for a 96 GB Mac. Also available: [8-bit](https://huggingface.co/AlazarM/LongCat-Flash-Lite-Sparse-8bit) (~68 GB, 128 GB Macs, near-lossless) and [4-bit](https://huggingface.co/AlazarM/LongCat-Flash-Lite-Sparse-4bit) (~36 GB, 64 GB Macs, fastest).
## What's in this checkpoint
LongCat-Flash-Lite-Sparse adds three things vanilla LongCat-Flash lacks:
- **LongCat Sparse Attention (LSA)** β a DeepSeek-style lightning indexer over MLA, with streaming-aware indexing (fixed sink + local window) and cross-layer index reuse. Native long context.
- **Zero-computation (identity) experts** in the ScMoE decoder (256 routed + 128 identity, top-12).
- **N-gram ("oe") input embedding** β ~46% of the parameters, fused into the token embedding.
## The n-gram fix
The `oe` embedding hash and tables are identical to the published n-gram references (the *Scaling Embeddings* paper, mlx-lm, SGLang, llama.cpp, Meituan's dense modeling). The one difference in `LongcatCausalLM` is the **fusion**: it keeps the word embedding at **full scale** β
`word + Ξ£ projections / (1 + num_embedders)` β rather than the dense form `(word + Ξ£ projections) / (1 + num_embedders)`. Dividing the word by `1 + num_embedders` garbles generation; this build applies the correct fusion.
## Usage
Requires mlx-vlm with `longcat_flash_sparse` support ([PR #2063](https://github.com/Blaizzy/mlx-vlm/pull/2063)):
```bash
pip install git+https://github.com/Lazarus-931/mlx-vlm@add-longcat-flash
```
```python
from mlx_vlm import load, generate
model, processor = load("AlazarM/LongCat-Flash-Lite-Sparse-6bit", trust_remote_code=True)
tok = processor.tokenizer
text = tok.apply_chat_template(
[{"role": "user", "content": "What is the capital of France?"}],
tokenize=False, add_generation_prompt=True,
)
print(generate(model, processor, text, max_tokens=64, temperature=0.0))
# -> The capital of France is Paris.
```
## Throughput (M5 Max, 128 GB, batch 1, greedy)
Decode tok/s across the published quantizations:
| ctx | 4-bit | 6-bit | 8-bit |
|--:|--:|--:|--:|
| 512 | 112 | 87 | 80 |
| 2048 | 85 | 72 | 65 |
| 8192 | 83 | 71 | 65 |
| 32768 | 73 | 64 | 60 |
Batch-1 decode is partly weight-bandwidth-bound, so **lower precision is faster** (~30% spread 4β8-bit); LSA keeps all three nearly flat as context grows. Peak memory across 512β32k: 4-bit ~39β45 GB, **6-bit ~56β63 GB**, 8-bit ~74β80 GB. 6-bit is the balance point β most of 8-bit's quality at ~β
the footprint.
## License
MIT, inherited from the base model.
|