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.

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)

kz-law-rag

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.

Answers

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

Retrieval

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 UNANSWERABLE instead 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 UNANSWERABLE because 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
Safetensors
Model size
2B params
Tensor type
U32
ยท
BF16
ยท
MLX
Hardware compatibility
Log In to add your hardware

8-bit

Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for yfrtn/OCC-RAG-2B-MLX-8bit

Finetuned
Qwen/Qwen3.5-2B
Quantized
(4)
this model