COHERE RERANK AND COMMAND.
YOUR DOCS AND A LIVE DATABASE.
CITATIONS YOU CAN CHECK.
A Cohere RAG setup we ran end to end on one machine, modelled on a common private-deployment request. Picture a health insurer that already uses Cohere: a compliance team that lives in NIST frameworks and CMS claims manuals, and an operations team that lives in a Postgres claims table. They want RAG that is private, confident and verifiable: Command answering from both, Rerank ordering the passages, every citation pointing at a file and page, and the data inside their own network. XERJ is the search layer under the models. The documents are 13 real public-domain U.S. government PDFs. The claims table is synthetic, generated by us, 200,000 rows. Every measured number below is from that run, on the Postgres, Rerank and rows-to-facts code that shipped in rc.102 and on XERJ Query-1 from rc.101. The monthly cost comparison is a priced example, not part of the run.
One XERJ node indexed 22.9 MB of regulations and manuals in 7.9 seconds, followed a 200,000-row Postgres claims table live with changes searchable in about 20 milliseconds, answered structured questions with evidence and said UNKNOWN when it could not, and hands the best passages to Cohere Rerank and Command, with citations back to file and page.
The corpus: NIST AI RMF 1.0, the NIST generative AI profile, CSF 2.0, SP 800-53 rev. 5, SP 800-61 rev. 3, SP 800-30, the NIST Privacy Framework, and six chapters of CMS manuals on claims processing, benefit policy and program integrity. All public domain. One command makes them searchable, one record per page or section.
$ xerj autoindex ./corpus --prefix policy indexed: 3033 documents live; this run submitted 3033 source records from 14 files xerj-done ok=true exit=0 reason=completed wall=7.9s files=14 records=3033
Searching it: a full-text match query over the 3,033 records ran at 0.8 ms p50 and 2.3 ms p95 on the same node (search only, no answer generation; our run notes do not record the query set).
The claims table lives in Postgres 16. One command, xerj connect (shipped in rc.102), registers it as a source inside the node: a consistent snapshot, then every insert, update and delete through Postgres logical replication. The node resumes the source after a restart.
$ xerj connect postgres://[email protected]/claims --password-env PG_SRC_PW claims: snapshotting 92% (185000 rows, 47105 rows/s, ETA 0 s) claims: streaming claims is live (streaming). Indices: public.claims -> src-claims-public-claims (200000 rows)
| Measured | Result |
|---|---|
| Snapshot of 200,000 rows | about 47,100 rows/s |
| 60 single-row UPDATEs, commit to visible in XERJ | p50 19.7 ms · p95 21.7 ms · max 34.6 ms |
| A DELETE and an INSERT | the deleted claim is gone (404), the new one is there |
| "Denied claims in the West, and their total": filter plus sum over 200,000 rows | 6,665 claims, $33,459,315, identical to Postgres; 0.5 ms p50 |
For plain-language questions over structured records, we wrote 1,000 claims (an export of the same table) as facts and asked XERJ Query-1. It compiles each question into a small program, runs it over the facts and, for lookups, shows the fact it used (counts cite no records). When it cannot ground an answer it says UNKNOWN; in this run it gave no wrong answers, though counts can be wrong in known cases.
$ xerj autoindex claims.csv --facts claims --key claim_id claims: 1000 rows · key claim_id · wrote 6000 facts, one per column for each of the 1,000 rows (1000 new, 0 changed, 0 unchanged, 0 withdrawn)
The --facts option shipped in rc.102.
| Question | XERJ Query-1 | Correct? |
|---|---|---|
| How many claims have member_region West? | 200 · counting, two models agreed | yes (200) |
| How many claims have status denied and member_region West? | 34 · counting, two models agreed | yes (34) |
| What is the status of CLM-0000002? | approved · evidence: the status fact of CLM-0000002 | yes |
| What is the reviewer of CLM-0000010? | A. Rivera · with evidence | yes |
| What is the amount_usd of CLM-0000007? | 309 · quote "309.00" | yes |
| How many claims have status denied? | UNKNOWN | declined (167) |
| How many claims have provider_type telehealth? | UNKNOWN | declined (166) |
| What is the total amount_usd of claims with status paid? | UNKNOWN (sums are not supported yet) | declined |
Five answers, five correct, three honest declines, about 0.2 to 0.4 seconds each on CPU. For totals, the ordinary aggregation in step 2 is the right tool and is exact.
Rerank runs as a stage of XERJ's own _search. Then the RAG cookbook sends the best passages to Command's Chat endpoint as documents, with each document id set to the XERJ _id, so every citation resolves to a file and a page.
POST /policy-docs/_search
{"query": {"match": {"body": "how long does a beneficiary have to file an appeal of a claim decision"}},
"rerank": {"provider": "cohere", "model": "rerank-v5.0-fast", "window": 30}}
# read _rerank.applied in the response; Cohere search units: _rerank.usage.search_units
$ python3 command_rag.py ask "How long does a beneficiary have to file an appeal of a claim decision?" --assert-citations ... Citations: '<cited text>' -> <file>.pdf page <page> (_id <XERJ _id>)
With --assert-citations, an answer with no citations, or a citation that does not resolve to a stored record, fails the run. How each piece works: Cohere RAG with XERJ.
Everything ran on one laptop-class machine (x86_64). The node with the XERJ Query-1 model used 1.05 GB of RAM. For a larger example workload, 10 GB of text and a million questions a month, we priced (not ran) one 16-vCPU, 32 GB AWS server at about $426 a month. That assumes the questions go to XERJ Query-1 over facts that are already written; XERJ Query-1 does not turn 10 GB of text into facts by itself. We set that against $21,175 to $65,747 for managed vector-RAG and GraphRAG stacks answering the same million questions with Opus 5.5 (ARITHMETIC from list prices fetched on 2026-11-05 at pinecone.io/pricing, neo4j.com/pricing, redis.io/pricing and Anthropic's pricing page). Most of that difference is the per-question language-model bill, not the infrastructure. Method and caveats.
Install XERJ with the XERJ Query-1 model from https://xerj.org/llms.txt and index the folder I point you to. Turn on Cohere Rerank with my COHERE_API_KEY, using https://xerj.org/integrations/cohere, and search with it. Then write the key facts of one table into a facts namespace and ask one question. Show me the hits, the _rerank block, the answer, the program and the evidence.
curl -fsSL https://xerj.org/get | sh -s -- --with-model
Cohere setup: Cohere RAG with XERJ: setup, Cohere RAG with XERJ and docs/COHERE.md. Sources of the documents: nvlpubs.nist.gov and cms.gov, U.S. government works in the public domain.