---
title: Semantic search
description: Keyword search and meaning search, why the Linux install ships without the second, how low-power machines are detected, and how to switch it on.
section: Linux
order: 30
---

Bridge searches a shared folder two ways:

- **Keyword search** matches text. It is always available, costs almost
  nothing, and needs no download.
- **Meaning search** (semantic search) finds code by what it does rather than
  what it is called. It embeds each file with a small model,
  `BAAI/bge-small-en-v1.5`, entirely on the machine. No code leaves it.

The agent's `codebase_search` tool and the file browser's search use meaning
search when it is ready and fall back to keyword search when it is not, so
nothing breaks without it. Results are just less good at finding things by
description.

## Large folders

Keyword search reads files from disk when you search, so it covers the whole
folder whatever its size. Meaning search keeps an index, and that index covers
at most 20,000 files per shared folder (`AGENT_RAG_MAX_FILES`). Past that,
the agent logs it once, the search pane marks the folder **partly indexed**, and
the rest of the folder is still found by keyword search.

These never count toward the limit:

- Anything `.gitignore` excludes, plus dependency and build folders such as
  `node_modules`, `target`, `dist` and `build`.
- Linked git worktrees inside the folder (a subfolder whose `.git` is a file
  pointing at another repository's `.git/worktrees/`). They are duplicate
  checkouts. Submodules are still indexed.
- Paths listed in a `.bridgeindexignore` file. It uses `.gitignore` syntax, works
  at any depth, and affects only search. The agent's file tools still read those
  paths.

```text
# .bridgeindexignore
artifacts/
third_party/
*.csv
```

The index holds file paths and a compact copy of each vector in memory. File
text is read from disk only while a file is being embedded or a result shown,
so a large folder costs little memory.

## On desktop

The macOS and Windows apps always include it. The model, about 130 MB, downloads
on first start into a user cache, and indexing runs at background priority on at
most half the cores.

## On Linux

The Linux install leaves it out by default, for two reasons:

- **Size.** The embedding engine (candle and tokenizers) is about 4 MB of the
  agent binary, and the model is another 130 MB on disk.
- **CPU.** A first index embeds every file in every shared folder. On a server
  that takes minutes in the background. On a Raspberry Pi it can occupy the
  board for a long time.

So the base `bridge-agent` is built without it, and meaning search is an
optional, separately downloaded [component](/docs/components-and-updates/). The
agent reports its state when it connects, and Fleet shows it.

| state | meaning |
| --- | --- |
| `on` | The engine is installed and switched on. |
| `not_installed` | The slim agent. Keyword search only; can be installed. |
| `low_power` | The slim agent on a low-power machine. Kept off unless someone overrides that. |
| `disabled` | Installed but switched off with `AGENT_RAG_ENABLED=0`. |

## Low-power machines

A machine is low-power if any of these is true:

- `/proc/device-tree/model` contains `Raspberry Pi`.
- `MemTotal` in `/proc/meminfo` is under about 3.5 GiB.
- It has fewer than 4 CPU cores.

The agent (`low_power_from` in `crates/agent/src/component.rs`) and the
installer (`low_power` in `install.sh`) apply the same rule, so they agree.
On such a machine, enabling meaning search requires an explicit override, and
the reason (for example `Raspberry Pi 5 Model B Rev 1.0, 8 GB`) is shown
wherever it is refused.

## Switching it on

Any of these, as the machine's owner:

- `sudo bridgectl semantic enable`, or `--force` on a low-power machine.
- `--semantic` (or `--semantic=force`) on the install command.
- In Bridge, open **Fleet**, expand the machine's row, and click **Enable** next
  to **Semantic search**. On a low-power machine the button is **Enable anyway**,
  behind a confirmation that names the hardware.

Enabling downloads the `semantic` component for the agent's exact version,
verifies its size, SHA-256 and release signature, swaps it in for the slim
agent the same way a self-update does (rolling back if it will not start), sets
`AGENT_RAG_ENABLED=1`, and restarts the agent. From Fleet, the install runs as
its own transient systemd unit (`bridge-component-semantic`), because it
restarts the agent that received the request.

The agent then downloads the model. Each file is checked against a pinned
SHA-256 before it is used, so a mirror or proxy serving different bytes fails
the download instead of loading:

| file | SHA-256 |
| --- | --- |
| `config.json` | `094f8e891b932f2000c92cfc663bac4c62069f5d8af5b5278c4306aef3084750` |
| `tokenizer.json` | `d241a60d5e8f04cc1b2b3e9ef7a4921b27bf526d9f6050ab90f9267a1f9e5c66` |
| `model.safetensors` | `3c9f31665447c8911517620762200d2245a2518d6e7208acc78cd9db317e21ad` |

These are for revision `5c38ec7c405ec4b44b94cc5a9bb96e735b38267a` of the model
repository; the weights' digest is the one Hugging Face publishes for that
revision.

## On the server

Chat, call and issue search on a Bridge server also use meaning search, with
the same model. The server has no embedding engine of its own. It runs the
`bridge-agent` installed beside it in a separate mode:

- `bridge-agent embed-model --dir DIR` downloads the model into the server's
  state directory (`data/models/bge-small-en-v1.5`) and checks it against the
  SHA-256 digests below.
- `bridge-agent embed-worker --dir DIR` is a long-running child of the server.
  It reads JSON requests on stdin and writes vectors on stdout. Its threads run
  at background priority, and it exits when the server closes its stdin.

Because the worker shares a machine with the server it serves, background
indexing is held back so it cannot crowd out chats:

| variable (server environment) | default | effect |
| --- | --- | --- |
| `SEARCH_EMBED_THREADS` | `1` | Threads the worker uses. Passed to it as `AGENT_EMBED_THREADS`, unless that is already set in the server's environment. Raise it on a large machine to finish a first indexing pass sooner. |
| `SEARCH_EMBED_BATCH` | `16` | Most texts sent to the worker in one request. A long call transcript is split into requests of this size rather than sent whole. |
| `SEARCH_EMBED_DUTY` | `0.5` | Share of wall time background indexing may spend embedding. After each batch it pauses in proportion to how long the batch took. `1` turns the pause off. Search queries never pause. |

Chat search embeds three kinds of text:

- **Message chunks.** Each message is cut into overlapping pieces of about
  1,200 characters. A new chunk is embedded with its chat's title in front of
  it, so a reply such as "yes, do the second option" still says what it is
  about. Snippets show the bare text.
- **Chat profiles.** Each chat has one vector for its title, its topic summary
  and the first 800 characters of its opening request. A search that describes
  a chat in other words usually finds it through this vector. All profiles are
  embedded on the first start after an upgrade, which takes a few minutes.
- **The query.** It is embedded with bge's retrieval instruction in front.

Messages embedded before an upgrade keep their old vectors, without a title.
To redo them, an org owner or admin clicks **Re-embed chat history with
context** on the semantic search setting (below), or calls
`POST /api/search/reembed` with an optional `{ "threads": N, "duty": D }`.
The defaults are half the CPU cores and a duty of `0.6`. The job runs in the
background, continues after a restart, and stops with **Stop** or
`DELETE /api/search/reembed`. `GET /api/search/status` reports how many
messages are left.

Cmd+K and the search page rank recent chats first: a chat keeps
`0.15 + 0.85 × 2^(−days/30)` of its score, so a three-month-old chat keeps about
a quarter. A chat whose title is exactly the query stays first. The agent's
`SearchChats` tool uses a small recency bonus only.

The setting is in **Settings → Providers & Models → Optional components**:
**Automatic** (the default), **On** or **Off**. Automatic applies the
low-power test below to the server machine. If the machine passes, the model
downloads in the background at startup without anyone clicking anything.
`SEARCH_SEMANTIC=0` or `1` in the server's environment overrides the setting.

On a Linux server the agent beside the server is the slim build, so server
search stays keyword-only until meaning search is switched on for that
machine's agent (`sudo bridgectl semantic enable`). The settings card says so
rather than offering a download that cannot work. The server looks for the agent
in this order:

1. `BRIDGE_EMBED_AGENT`
2. `../bridge-agent`, next to the server component's directory
3. `../agent/bridge-agent` on the desktop apps

## Switching it off

```bash
sudo bridgectl semantic disable
```

This sets `AGENT_RAG_ENABLED=0` and restarts the agent; the engine stays in the
binary but does nothing, and no model is loaded. `sudo bridgectl component
remove semantic` also forgets the component, so the next self-update installs
the slim agent again.

## Tuning

| variable (in `agent.env`) | default | effect |
| --- | --- | --- |
| `AGENT_RAG_ENABLED` | `0` on Linux installs | `1` to use meaning search, `0` for keyword only. |
| `AGENT_EMBED_THREADS` | half the cores | Threads used for embedding. `1` is the lightest touch. |
| `AGENT_EMBED_DEVICE` | GPU if it checks out | macOS only. On Apple silicon the agent embeds on the GPU (Metal) after checking at load that it matches the CPU. Set to `cpu` to force the CPU. Linux always uses the CPU. |
| `AGENT_RAG_CACHE_DIR` | `/var/lib/bridge/rag` | Where the index lives. |
| `AGENT_RAG_MAX_FILES` | `20000` | Most files one shared folder's meaning-search index covers. Keyword search is not limited. |
| `BRIDGE_MODEL_CACHE_DIR` | `/var/lib/bridge/models` | Where the model lives. |
