
COHERE RAG WITH XERJ:
PRIVATE, CONFIDENT, VERIFIABLE.
Ask Command about years of your own documents, code and records. Get an answer you can check, with the file and page it came from.
XERJ is a new way for AI to search for data. It runs on a CPU server next to your data, finds the passages, and hands them to Cohere Rerank and Command. All three Cohere hooks shipped in rc.102.
Point it at the data you already have
Before, giving Command your data meant building a pipeline: export, chunk, embed, store, then keep it in sync. Now you point one binary at the folders and the database where they already live.
"How long does a member have to appeal a claim decision?"
Asked across policy PDFs and claims manuals. Command answers, and each citation names the file and the page.
"Where do we retry a failed payment, and why?"
Asked across your repositories and design docs. The answer cites the files it read.
"How many denied claims in the West, and their total?"
Asked against a live Postgres table. The count and the sum come from the data, not from the model.
Find, order, answer, check
Your data stays where it is
XERJ indexes files, code and live Postgres tables on one CPU server inside your network. A stock node never calls Cohere. Each hook is off until you set a key and an endpoint.
Point those endpoints at a Cohere private deployment, on-prem or in your VPC, and the question, the passages and the answer stay inside. Point them at Cohere's API and this is what leaves:
The query, the model name and the text of up to window hits. Sent to api.cohere.com/v2/rerank, or the endpoint you set.
Good passages in, exact numbers out
- Hybrid retrieval. One
_searchcan run keyword and vector retrieval together and fuse them with RRF. Embed vectors come from Cohere if you turn that on. - Cohere Rerank as a search stage. Add
"rerank": {"provider": "cohere"}and the top hits come back in Rerank's order. An unknown model name is refused before anything is sent. - Counts from the data. Totals come from exact aggregations, not from the model. In our worked example, denied claims in the West over a 200,000-row Postgres table came to 6,665 claims and $33,459,315, identical to Postgres.
- Current data.
xerj connectfollows a live Postgres table, so new rows are searchable without a re-index.
Every citation points at a page
XERJ indexes one record per PDF page or section, and each record keeps its file path and page. The best hits go to Command's Chat endpoint as documents, with the XERJ _id as the document id and the file and page as the source:
{"id": "<XERJ _id>",
"data": {"title": "...", "snippet": "...", "source": "<path>#page=<page>"}}
When Command cites a document, the cookbook reads the record back from XERJ by that id and prints where it came from:
$ python3 command_rag.py ask "What is the appeal deadline?" --assert-citations ... Citations: '<cited text>' -> <path> page <page> (_id <XERJ _id>)
- Both id forms Command can return are handled: the custom document id, and a position such as
doc:0. - With
--assert-citations, an answer with no citations, or a citation that does not resolve to a stored record, fails the run. - Anyone can open the file at that page and check the sentence.
A worked example with 13 public NIST and CMS documents and a live 200,000-row Postgres table is in the Cohere RAG worked example.
One prompt for your agent
Install XERJ from https://xerj.org/llms.txt and index the folder I point you to. Turn on Cohere Rerank for _search with my COHERE_API_KEY, using the setup at https://xerj.org/integrations/cohere. Run one search with and without rerank, and show me both top 5 lists and the _rerank block.
Two blocks of config
# xerj.toml [rerank.cohere] api_key = "co-..." # or COHERE_API_KEY endpoint = "https://api.cohere.com/v2/rerank" # or your private deployment [embedding] mode = "proxy" default_endpoint = "https://api.cohere.ai/compatibility/v1" default_model = "embed-v5.0-pro"
Rerank models accepted: rerank-v5.0-fast, rerank-v5.0-pro, rerank-v3.5. The Command cookbook is in docs/examples/cohere/command-rag, and cohere-tools.json gives Command six XERJ search and memory tools. Full reference: the Cohere integration page and docs/COHERE.md. XERJ is not affiliated with Cohere.