<!-- generated by build_articles.py — edit content/answers/local-rag.md instead -->
---
title: "What is local RAG?"
canonical: "https://xerj.org/answers/local-rag"
updated: "2026-11-14"
source: "content/answers/local-rag.md"
---

# What is local RAG?

**Short answer** (updated 2026-11-14): What is local RAG? It is retrieval-augmented generation that keeps the corpus on your machine. You index the files, retrieve cited passages, then a model answers from those hits. XERJ does the retrieval step in one Apache-2.0 binary, with no separate vector database and no embedding API key.

**Key number:** On main, xerj mcp registers 24 MCP tools, or 21 when the binary has no Corpus Hub key. (as of 2026-10-28; source: [landing/docs/agents/schemas/mcp-tools.json](https://github.com/xerj-org/xerj/blob/main/landing/docs/agents/schemas/mcp-tools.json))

**TL;DR** Local RAG means the corpus stays on your machine. You index the files, retrieve cited passages, then a model writes an answer from those hits. With XERJ the retrieval step is one Apache-2.0 binary: xerj autoindex, then xerj search or a hybrid query. There is no separate vector database. The default embedding mode is lexical, not neural.

## Agent prompt

```text
Act as a coding agent. Read https://xerj.org/llms.txt, start a node with `xerj --insecure --data-dir ./.xerj-data`, index the folder you were handed with `xerj autoindex ./docs --url http://127.0.0.1:9200 --prefix docs --progress plain`, retrieve with `xerj search`, and write the answer only from cited hits. If a fact is not in a hit, say so.
```

## Commands

### Command 1

Note: Install the release binary into ~/.local/bin.

```sh
curl -fsSL https://xerj.org/get | sh
```

### Command 2

Note: Start a local development node. Put the data dir outside the folder you will index.

```sh
xerj --insecure --data-dir ./.xerj-data
```

### Command 3

Note: Build a local index. No schema and no separate vector database.

```sh
xerj autoindex ./docs --url http://127.0.0.1:9200 --prefix docs --progress plain
```

### Command 4

Note: Retrieve cited passages. Hand only those hits to the model.

```sh
xerj search "what is the default timeout"
```

*Figure: This is the local loop on one binary. It is not a new measured RAG cost study. Query-1 compared with RAG lives on its own page.*

## The loop

Retrieval-augmented generation has two parts. Retrieval finds passages. Generation writes an answer from them. Local RAG keeps both the files and the index on your machine. The model should cite the paths it was given, and should say so when a fact is not in those hits.

XERJ is the retrieval step: one Apache-2.0 binary, no separate vector database, no embedding API key. The same design is explained in [RAG without a vector database](/answers/rag-without-vector-database). A local AI search engine, without the generation step, is [What is a local AI search engine?](/answers/local-ai-search-engine).

Why this saves context window space is [What is context engineering?](/science/context-engineering). Published byte and token studies of retrieval against printing matches are on [the retrieval studies page](/answers/rag-vs-grep).

## How to run it

1. Install the binary: `curl -fsSL https://xerj.org/get | sh`.
2. Start a node: `xerj --insecure --data-dir ./.xerj-data`. Put the data dir outside the folder you will index.
3. Index the corpus: `xerj autoindex ./docs --url http://127.0.0.1:9200 --prefix docs --progress plain`.
4. Retrieve: `xerj search "what is the default timeout"`, a hybrid request over the REST API, or `POST /docs-*/_search`.
5. Generate only from those hits, and keep the `ax_path` or file:line next to each claim.

An agent can do the same retrieval through the MCP server. The protocol is [What is the Model Context Protocol?](/science/model-context-protocol). Ranking options are [What is hybrid search?](/science/hybrid-search) and [What is semantic search?](/science/semantic-search).

The default embedding mode is lexical, not neural. Start the node with `--embed-mode neural` when you want the built-in neural embedder.

## What this page does not measure

This page is a how-to. It publishes no new RAG cost or accuracy study. The Query-1 model, which compiles a prompt to a verifiable search program, is compared with RAG on [the Query-1 page](/xerj-query-1). Read that page for those figures. Do not copy them into a new breakdown here.

## Read next

[Cohere RAG with XERJ](/blog/cohere-rag-with-xerj), [reranking](/science/reranking), [grounded answers](/science/grounded-answers) and [a local AI search engine](/answers/local-ai-search-engine).

## FAQ

### What is local RAG?

It is retrieval-augmented generation that keeps the corpus on your machine. You retrieve cited passages from a local index, then a model writes an answer from those hits.

### Do I need a separate vector database?

Not with XERJ. The embedder ships in the binary. See RAG without a vector database for the same point, with more API detail.

### Is there a local RAG MCP server?

xerj mcp is the MCP server in the same binary. On main it registers 24 tools, or 21 with no Corpus Hub key. The agent retrieves from the local index, then writes from the cited hits.

### What is the default embedding mode?

Lexical, not neural. Semantic and hybrid queries still run, but they use word and sub-word overlap plus BM25 unless you start the node with --embed-mode neural.

### How is this different from Query-1?

Local RAG still uses a language model to write the final answer from retrieved hits. The Query-1 model compiles a question into a program the engine runs over your facts. That comparison lives on the Query-1 page.

## Evidence

- On main, xerj mcp registers 24 MCP tools, or 21 when the binary has no Corpus Hub key. — `landing/docs/agents/schemas/mcp-tools.json`

## Related

- [How do I build RAG without a vector database?](/answers/rag-without-vector-database)
- [What is a local AI search engine?](/answers/local-ai-search-engine)
- [RAG vs grep: retrieval compared with printing matches](/answers/rag-vs-grep)
- [What is hybrid search?](/science/hybrid-search)
- [What is semantic search?](/science/semantic-search)
- [What is context engineering?](/science/context-engineering)
- [What is the Model Context Protocol?](/science/model-context-protocol)
- [XERJ Query-1](/xerj-query-1)
- [Can ChatGPT search a folder on my laptop, or do I need something else?](/answers/give-chatgpt-claude-local-file-access) (same intent: Find the right tool)
- [What is XERJ?](/answers/what-is-xerj) (same intent: Find the right tool)
- [What's a local MCP search engine for Claude?](/compare/xerj-vs-localsynapse) (same intent: Find the right tool)
