Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Embedding Pipeline

Bobbin generates 384-dimensional vector embeddings locally using ONNX Runtime with the all-MiniLM-L6-v2 model. No data leaves your machine.

Pipeline Overview

Source File
    │
    ▼
┌────────────────┐
│ Tree-sitter /  │  Parse into semantic chunks
│ pulldown-cmark │  (functions, classes, sections, etc.)
└────────────────┘
    │
    ▼
┌────────────────┐
│ Context        │  Optionally enrich with surrounding lines
│ Enrichment     │  (configurable per language)
└────────────────┘
    │
    ▼
┌────────────────┐
│ ONNX Runtime   │  Generate 384-dim vectors
│ (MiniLM-L6-v2) │  Batched processing (default: 32)
└────────────────┘
    │
    ▼
┌────────────────┐
│ LanceDB        │  Store vectors + metadata
└────────────────┘

Contextual Embedding

By default, chunks are embedded with their literal content. For configured languages (currently Markdown), Bobbin enriches each chunk with surrounding context lines before computing the embedding. This improves retrieval quality by giving the embedding model more semantic signal.

Configuration:

[embedding.context]
context_lines = 5              # Lines before/after each chunk
enabled_languages = ["markdown"] # Languages with context enrichment

Model Details

PropertyValue
Modelall-MiniLM-L6-v2
Dimensions384
RuntimeONNX Runtime (CPU)
Model location~/.cache/bobbin/models/
DownloadAutomatic on first run

Batch Processing

Embeddings are generated in configurable batches (default: 32 chunks per batch) to balance throughput and memory usage. The batch size can be tuned in configuration:

[embedding]
batch_size = 32