Highlights
- Faithful by design — Trained to follow the supplied passages even when they contradict a fact the model learned during pretraining.
- Answers with citations — The JSON response includes a short answer, a fuller explanation and source IDs your application can link back to the original passages.
- Fewer output tokens — Across the seven benchmark tasks, OCC-RAG-2B generates 468 tokens per response on average, 89% fewer than Qwen3.5-2B in thinking mode (4,281).
Evaluation
MuSiQue uses inclusion accuracy and ConFiQA uses exact match, both over all questions including refusals. For the FinQA and ConvFinQA subsets of T²-RAGBench, we supply the gold report page and use an LLM judge to score the answer. TAT-QA uses official F1. Scores are percentages.
Quickstart
Pass the question as plain text and the retrieved passages as documents, a list of dictionaries with a text field. The chat template numbers documents in the order supplied, so source ID 2 refers to documents[1]. Pass the documents with the final user message.
Both examples load the weights, tokenizer and document-aware chat template from this repository.
Recommended sampling parameters
[!TIP]
OCC-RAG-2B supports thinking mode only. The supplied chat template opens <think> automatically; the model continues the reasoning, closes it with </think>, and then generates the final JSON answer.
Use greedy decoding, as in our benchmark runs.
- Transformers:
do_sample=False
- vLLM:
temperature=0.0. Start the server with --reasoning-parser qwen3 to return the reasoning separately from the JSON.
Load the model and pass the question and documents directly to the tokenizer.
import json import torchfrom transformers import AutoModelForImageTextToText, AutoTokenizer model_path = "occ-ai/OCC-RAG-2B"tokenizer = AutoTokenizer.from_pretrained(model_path)model = AutoModelForImageTextToText.from_pretrained( model_path, dtype="auto", device_map="auto").eval() messages = [{"role": "user", "content": "In which year did the archive open to the public?"}]documents = [ {"text": "The archive was founded in 1987 as a private collection."}, {"text": "The archive opened its doors to the public in 1994."},]inputs = tokenizer.apply_chat_template( messages, documents=documents, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt",).to(model.device)with torch.inference_mode(): output = model.generate(**inputs, max_new_tokens=8192, do_sample=False, use_cache=True) tokens = output[0, inputs.input_ids.shape[1]:].tolist()if tokenizer.eos_token_id in tokens: tokens = tokens[:tokens.index(tokenizer.eos_token_id)]completion = tokenizer.decode(tokens, skip_special_tokens=False)answer = json.loads(completion.rsplit("</think>", 1)[-1].strip())print(answer["answer"], answer["sources"])
vLLM
Start the server with the Qwen reasoning parser to separate the reasoning block from the final JSON.
vllm serve occ-ai/OCC-RAG-2B --reasoning-parser qwen3
Send documents as a request field and use response_format to constrain the final answer to the schema. vLLM structured outputs
from typing import Literal from openai import OpenAIfrom pydantic import BaseModel class Answer(BaseModel): status: Literal["ANSWERABLE", "UNANSWERABLE"] sources: list[int] answer: str full_answer: str question = "In which year did the archive open to the public?"documents = [ {"text": "The archive was founded in 1987 as a private collection."}, {"text": "The archive opened its doors to the public in 1994."},] client = OpenAI(base_url="http://localhost:8000/v1", api_key="local")response = client.chat.completions.create( model="occ-ai/OCC-RAG-2B", messages=[{"role": "user", "content": question}], extra_body={"documents": documents}, response_format={ "type": "json_schema", "json_schema": {"name": "answer", "schema": Answer.model_json_schema()}, }, temperature=0.0, max_tokens=8192,)choice = response.choices[0]if choice.finish_reason != "stop" or not choice.message.content: raise ValueError("Incomplete answer")result = Answer.model_validate_json(choice.message.content)print(result.model_dump())
Example JSON response:
{ "status": "ANSWERABLE", "sources": [2], "answer": "1994", "full_answer": "The archive opened to the public in 1994."}
License
OCC-RAG-2B is released under the Apache 2.0 License. Its base model, Qwen3.5-2B-Unloop, is also licensed under Apache 2.0.