You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/semantic-search.md
+26-21Lines changed: 26 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,26 +1,26 @@
1
1
# Semantic Search
2
2
3
-
This guide covers Basic Memory's optional semantic (vector) search feature, which adds meaning-based retrieval alongside the existing full-text search.
3
+
This guide covers Basic Memory's semantic (vector) search feature, which adds meaning-based retrieval alongside the existing full-text search.
4
4
5
5
## Overview
6
6
7
-
Basic Memory's default search uses full-text search (FTS) — keyword matching with boolean operators. Semantic search adds vector embeddings that capture the *meaning* of your content, enabling:
7
+
Basic Memory's search supports both full-text search (FTS) and semantic retrieval. Semantic search adds vector embeddings that capture the *meaning* of your content, enabling:
8
8
9
9
-**Paraphrase matching**: Find "authentication flow" when searching for "login process"
10
10
-**Conceptual queries**: Search for "ways to improve performance" and find notes about caching, indexing, and optimization
11
11
-**Hybrid retrieval**: Combine the precision of keyword search with the recall of semantic similarity
12
12
13
-
Semantic search is **opt-in** — existing behavior is completely unchanged unless you enable it. It works on both SQLite (local) and Postgres (cloud) backends.
13
+
Semantic search is enabled by default when semantic dependencies are available at runtime. It works on both SQLite (local) and Postgres (cloud) backends.
14
14
15
15
## Installation
16
16
17
-
Semantic search dependencies (fastembed, sqlite-vec, openai) are **optional extras** — they are not installed with the base`basic-memory`package. Install them with:
17
+
Semantic search dependencies (fastembed, sqlite-vec, openai) are included in the default`basic-memory`install.
18
18
19
19
```bash
20
-
pip install 'basic-memory[semantic]'
20
+
pip install basic-memory
21
21
```
22
22
23
-
This keeps the base install lightweight and avoids platform-specific issues with ONNX Runtime wheels.
23
+
You can always override with `BASIC_MEMORY_SEMANTIC_SEARCH_ENABLED=true|false`.
24
24
25
25
### Platform Compatibility
26
26
@@ -34,36 +34,40 @@ This keeps the base install lightweight and avoids platform-specific issues with
34
34
35
35
#### Intel Mac Workaround
36
36
37
-
The default FastEmbed provider uses ONNX Runtime, which dropped Intel Mac (x86_64) wheels starting in v1.24. Intel Mac users have two options:
37
+
The default install includes FastEmbed, which depends on ONNX Runtime. ONNX Runtime dropped Intel Mac (x86_64) wheels starting in v1.24, so install with a compatible ONNX Runtime pin first:
38
38
39
-
**Option 1: Use OpenAI embeddings (recommended)**
39
+
```bash
40
+
pip install basic-memory 'onnxruntime<1.24'
41
+
```
40
42
41
-
Install only the OpenAI dependency manually — no ONNX Runtime or FastEmbed needed:
43
+
After installation, Intel Mac users have two runtime options:
FastEmbed's ONNX Runtime dependency is unpinned, so you can constrain it to an older version that still ships Intel Mac wheels by passing both requirements in the same install command:
55
+
Keep the same pinned installation and use FastEmbed (default provider):
@@ -94,7 +98,7 @@ All settings are fields on `BasicMemoryConfig` and can be set via environment va
94
98
95
99
| Config Field | Env Var | Default | Description |
96
100
|---|---|---|---|
97
-
|`semantic_search_enabled`|`BASIC_MEMORY_SEMANTIC_SEARCH_ENABLED`|`false`| Enable semantic search. Required before vector/hybrid modes work. |
101
+
|`semantic_search_enabled`|`BASIC_MEMORY_SEMANTIC_SEARCH_ENABLED`|Auto (`true` when semantic deps are available)| Enable semantic search. Required before vector/hybrid modes work. |
98
102
|`semantic_embedding_provider`|`BASIC_MEMORY_SEMANTIC_EMBEDDING_PROVIDER`|`"fastembed"`| Embedding provider: `"fastembed"` (local) or `"openai"` (API). |
99
103
|`semantic_embedding_model`|`BASIC_MEMORY_SEMANTIC_EMBEDDING_MODEL`|`"bge-small-en-v1.5"`| Model identifier. Auto-adjusted per provider if left at default. |
100
104
|`semantic_embedding_dimensions`|`BASIC_MEMORY_SEMANTIC_EMBEDDING_DIMENSIONS`| Auto-detected | Vector dimensions. 384 for FastEmbed, 1536 for OpenAI. Override only if using a non-default model. |
@@ -112,8 +116,8 @@ FastEmbed runs entirely locally using ONNX models — no API key, no network cal
112
116
-**Tradeoff**: Smaller model, fast inference, good quality for most use cases
113
117
114
118
```bash
115
-
# Install semantic extras and enable
116
-
pip install 'basic-memory[semantic]'
119
+
# Install basic-memory and enable semantic search
120
+
pip install basic-memory
117
121
export BASIC_MEMORY_SEMANTIC_SEARCH_ENABLED=true
118
122
```
119
123
@@ -197,7 +201,8 @@ bm reindex -p my-project
197
201
198
202
### When You Need to Reindex
199
203
200
-
-**First enable**: After turning on `semantic_search_enabled` for the first time
204
+
-**Upgrade note**: Migration now performs a one-time automatic embedding backfill on upgrade.
205
+
-**Manual enable case**: If you explicitly had `semantic_search_enabled=false` and then turn it on
201
206
-**Provider change**: After switching between `fastembed` and `openai`
202
207
-**Model change**: After changing `semantic_embedding_model`
203
208
-**Dimension change**: After changing `semantic_embedding_dimensions`
@@ -145,7 +146,7 @@ class BasicMemoryConfig(BaseSettings):
145
146
# Semantic search configuration
146
147
semantic_search_enabled: bool=Field(
147
148
default_factory=_default_semantic_search_enabled,
148
-
description="Enable semantic search (vector/hybrid retrieval). Works on both SQLite and Postgres backends. Requires semantic extras.",
149
+
description="Enable semantic search (vector/hybrid retrieval). Works on both SQLite and Postgres backends. Requires semantic dependencies (included by default).",
0 commit comments