Instructions to use occ-ai/OCC-RAG-2B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use occ-ai/OCC-RAG-2B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="occ-ai/OCC-RAG-2B") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("occ-ai/OCC-RAG-2B") model = AutoModelForMultimodalLM.from_pretrained("occ-ai/OCC-RAG-2B", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use occ-ai/OCC-RAG-2B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "occ-ai/OCC-RAG-2B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "occ-ai/OCC-RAG-2B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/occ-ai/OCC-RAG-2B
- SGLang
How to use occ-ai/OCC-RAG-2B with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "occ-ai/OCC-RAG-2B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "occ-ai/OCC-RAG-2B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "occ-ai/OCC-RAG-2B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "occ-ai/OCC-RAG-2B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use occ-ai/OCC-RAG-2B with Docker Model Runner:
docker model run hf.co/occ-ai/OCC-RAG-2B
Technical Report | GitHub | GGUF
OCC-RAG-2B
OCC-RAG-2B is a 2B-parameter language model in the Optimal Cognitive Core (OCC) family, specialized for faithful question answering over retrieved documents. Given a question and a set of passages, it reasons across the sources and decides whether they contain enough evidence to answer. It returns its answer in JSON with citations to the supporting passages, or an explicit UNANSWERABLE status when a necessary fact is missing.
With 2B parameters, OCC-RAG-2B outperforms Qwen3.5-4B and Qwen3.5-9B on average across seven tasks spanning multi-hop reasoning, financial question answering, and faithfulness to the supplied context. It is competitive with Qwen3.8-27B, a model over 13 times its size, and ranks first among the models compared on TAT-QA, the ConvFinQA subset of Tยฒ-RAGBench, and the single-hop split of ConFiQA.
We used OCCโs Qwen3.5-2B-Unloop as our base model.
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
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 qwen3to return the reasoning separately from the JSON.
Transformers
Load the model and pass the question and documents directly to the tokenizer.
import json
import torch
from 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 OpenAI
from 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.
- Downloads last month
- 346