Configuration
brinicle exposes several configuration options for tuning the HNSW algorithm and the lexical encoding system. Understanding these parameters helps you optimize for your specific use case — whether you need maximum recall, minimum latency, or balanced performance.HNSW Parameters
The Hierarchical Navigable Small World (HNSW) algorithm has three primary parameters that control the trade-off between index quality, build time, and search performance.M (Connectivity)
TheM parameter controls the number of bi-directional links per node in the HNSW graph. Higher values create a more connected graph, which generally improves recall at the cost of increased memory usage and build time.
| M Value | Memory | Build Speed | Recall | Use Case |
|---|---|---|---|---|
| 16 | Low | Fast | Good | General purpose, resource-constrained |
| 32 | Medium | Medium | Very Good | Balanced production workloads |
| 48 | High | Slow | Excellent | High-recall requirements |
| 64+ | Very High | Very Slow | Near-Perfect | Maximum accuracy, ample resources |
ef_construction (Build-Time Search Width)
Controls the size of the dynamic candidate list during index construction. Higher values produce better-quality graphs but slow down the build process.| Value | Build Time | Graph Quality | Use Case |
|---|---|---|---|
| 100-200 | Fast | Good | Quick prototyping, small datasets |
| 200-512 | Medium | Very Good | Production workloads |
| 512-1024 | Slow | Excellent | High-recall requirements |
| 1024+ | Very Slow | Near-Perfect | Maximum quality builds |
ef_search (Query-Time Search Width)
Controls the size of the dynamic candidate list during search queries. This is the primary knob for tuning the recall-speed trade-off at query time.| Value | Query Speed | Recall | Use Case |
|---|---|---|---|
| 32-64 | Fast | Good | Autocomplete, exploratory search |
| 64-128 | Medium | Very Good | Most production workloads |
| 128-512 | Slow | Excellent | Accuracy-critical applications |
| 512+ | Very Slow | Near-Perfect | Maximum recall |
ef_search per-query using the efs parameter in search calls, allowing you to balance speed and accuracy for different use cases within the same index.
delta_ratio
Controls the size of the delta segment relative to the main segment. The delta segment holds recently ingested vectors before they are merged into the main graph.| Value | Ingest Performance | Search Performance | Use Case |
|---|---|---|---|
| 0.05 | Slower merges | Best | Read-heavy workloads |
| 0.10 | Balanced | Good | General purpose |
| 0.20-0.50 | Fastest ingest | Degraded | Write-heavy workloads |
seed
The random number generator seed used during graph construction. Setting a fixed seed ensures reproducible builds, which can be useful for testing and benchmarking. Default: 0Lexical Scoring Configuration
LexicalConfig controls how the ItemSearchEngine scores and encodes structured items. These weights determine the relative importance of each field during both indexing and search.
Build-Time Weights
Build-time weights control how much each field contributes to the item vector during indexing:Search-Time Weights
Search-time weights control how much each field contributes to the query encoding and distance calculation:Title Alpha and Beta
These parameters control how title tokens are scored during both build and search:Autocomplete Scoring Configuration
AutocompleteConfig controls how the AutocompleteEngine scores suggestions:
Position Decay
Higher position decay values give more weight to tokens that appear earlier in the suggestion. This is useful for prefix-heavy autocomplete where users typically type from the beginning of a phrase.Length Penalty
Higher length penalty values penalize longer suggestions, making shorter, more concise suggestions rank higher. This is useful when you want to prefer shorter completions over longer ones.Index Path Configuration
When you create an engine, theindex_path parameter determines where the index files are stored on disk. For an index at path "my_index", the following files are created:
/app/data/. You can change this by modifying the store_dir variable in the server code or by mounting a volume in Docker.
HTTP Server Configuration
The FastAPI server can be configured through environment variables and command-line options:| Setting | Default | Description |
|---|---|---|
| Host | 0.0.0.0 | Server bind address |
| Port | 1984 | Server bind port |
| Data directory | /app/data/ | Index storage directory |
| Memory limit | 1GB (Docker) | Container memory limit |
Docker Configuration
Thedocker-compose.yml file provides the default configuration: