Instructions to use yfrtn/OCC-RAG-2B-MLX-8bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use yfrtn/OCC-RAG-2B-MLX-8bit 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("yfrtn/OCC-RAG-2B-MLX-8bit") 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
- MLX LM
How to use yfrtn/OCC-RAG-2B-MLX-8bit with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Interactive chat REPL mlx_lm.chat --model "yfrtn/OCC-RAG-2B-MLX-8bit"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "yfrtn/OCC-RAG-2B-MLX-8bit" # Calling the OpenAI-compatible server with curl curl -X POST "http://localhost:8080/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "yfrtn/OCC-RAG-2B-MLX-8bit", "messages": [ {"role": "user", "content": "Hello"} ] }' - Atomic Chat
OCC-RAG-2B โ MLX 8-bit
This is an MLX 8-bit conversion of occ-ai/OCC-RAG-2B for Apple Silicon Macs (mlx-lm, oMLX). All credit for the model goes to the OCC AI team. This repository only changes the weight format.
OCC-RAG-2B is a 2B-parameter model, fine-tuned from Qwen3.5-2B, for faithful question answering over retrieved documents. Given a question and a set of passages, it answers only from those passages, cites the passage IDs it used, and returns UNANSWERABLE when the passages do not contain the answer.
- Original model: https://huggingface.co/occ-ai/OCC-RAG-2B
- Official GGUF: https://huggingface.co/occ-ai/OCC-RAG-2B-GGUF
- Code and paper: https://github.com/optimal-cognitive-core/OCC-RAG
- Paper: Trust the Context, Not the Weights: Faithful Multi-Hop QA via Synthetic Mid-Training (EMNLP 2026 System Demonstrations)
Conversion
| Tool | mlx_lm convert (mlx-lm bundled with oMLX) |
| Quantization | 8-bit, group size 64 (8.5 bits per weight) |
| Size | ~2.0 GB |
| Source dtype | bfloat16 |
| Vision tower | dropped (text-only, as used for RAG) |
| Context (from config) | 262,144 tokens |
The original chat template is kept unchanged, including the documents argument and the thinking prefix.
Usage (mlx-lm)
from mlx_lm import load, generate
model, tokenizer = load("yfrtn/OCC-RAG-2B-MLX-8bit")
documents = [
{"text": "Article 178. The general limitation period is three years."},
{"text": "Article 179. The court applies the limitation period only at a party's request."},
]
prompt = tokenizer.apply_chat_template(
[{"role": "user", "content": "What is the general limitation period?"}],
documents=documents,
add_generation_prompt=True,
tokenize=False,
)
text = generate(model, tokenizer, prompt=prompt, max_tokens=2048)
answer_json = text.split("</think>")[-1].strip()
print(answer_json)
The model outputs reasoning, then </think>, then JSON:
{"status": "ANSWERABLE", "sources": [1], "answer": "Three years", "full_answer": "..."}
Pass documents through the documents argument of the chat template. Pasting passages into the user message works worse, because the model was trained on the dedicated source tokens. Use greedy decoding (temperature 0).
Quick check in Russian
The original authors report English benchmarks only. I ran a small check in Russian on articles from laws of the Republic of Kazakhstan (Civil Code, Marriage and Family Code, Accounting law, Veterinary law). Each question came with 2โ3 article passages, the relevant one mixed with unrelated ones.
| Type | Questions | Correct |
|---|---|---|
| Direct facts (age, periods, dates) | 5 | 5 |
| Reading comprehension (who / can a courtโฆ) | 3 | 3 |
Trap: answer not in passages โ expect UNANSWERABLE |
3 | 3 |
| Counterfactual: passage edited to "five years" instead of "three" โ expect "five years" | 1 | 1 |
| Total | 12 | 12 |
Citations pointed to the correct passage in all answerable cases. The 8-bit MLX version and the official Q4_K_M GGUF (llama.cpp) gave practically identical answers. Minor Russian spelling slips were seen in short answers (for example a misspelled numeral), so review the output before using it in official documents.
This is a small sanity check, not a benchmark. Long contexts with many passages and multi-article reasoning in Russian were not tested.
Benchmark: Kazakhstan law RAG (Russian)
Full pipeline: github.com/YFrtn/kz-law-rag. A raw .docx law goes through article-aware chunking, hybrid search (BM25 + EmbeddingGemma), and this model. All runs were on a Mac.
Raw Labor Code of the Republic of Kazakhstan (Word file from adilet.zan.kz, 218 articles). It has 24 questions: 12 phrased like the law and 12 in everyday language ("I'm being laid off, how much notice should I get?"). There are also 5 trap questions whose answer is not in the code. The model is the same in every row. Only chunking and retrieval change.
| Pipeline | Gold norm in top-5 | Correct | Wrong | Traps |
|---|---|---|---|---|
| A. 1500-char chunks + BM25 | 14/24 | 14/24 | 1 | 5/5 |
| B. Article chunks + BM25 | 13/24 | 13/24 | 1 | 5/5 |
| C. Article chunks + BM25 + EmbeddingGemma | 21/24 | 20/24 | 1 | 5/5 |
| D. Article chunks + EmbeddingGemma only | 23/24 | 20/24 | 2 | 5/5 |
Pre-chunked Criminal Code (Special Part) and Tax Code of the RK (1266 articles):
- Gold article + 4 random distractors: 37/38 correct (29 facts, 7 traps, 2 counterfactual edits).
- BM25 over all articles: 35/36.
Observations:
- When the right passage is retrieved, the model reads Russian legal text well and cites it.
- It returns
UNANSWERABLEinstead of guessing when retrieval misses, on all 19/19 trap questions across runs. - It is cautious with broad questions. For example, "how many vacation days do I get?" returns
UNANSWERABLEbecause the code lists several leave types. A specific question works. - Weak spot: numbers written as words. Once it answered "20 hours" where the text said "one hundred twenty". Twice it took a neighbouring norm with a different deadline. Check numbers against the cited article.
License
Apache 2.0, same as the original model. See LICENSE.
- Downloads last month
- 37
8-bit
Model tree for yfrtn/OCC-RAG-2B-MLX-8bit
Base model
Qwen/Qwen3.5-2B-Base

