Building a Retrieval Pipeline with Turso and Voyage AI
Turso's SQLite-compatible engine with native vector columns, paired with Voyage AI embedding and reranking models, replaces a multi-service RAG stack with a single embeddable database for agent retrieval and memory. Documents are indexed with voyage-4-large and queried with voyage-4-lite in a shared embedding space. Candidates are retrieved via a DiskANN index (vector_top_k) or an exact vector_distance_cos scan, then reranked with instruction-following rerank-2.5. Matryoshka dimensions and int8/binary quantization map onto Turso's F32/F16/1-bit blob columns to cut storage and scan cost 4–32x. The main caveat: Turso's MVCC concurrent-write mode doesn't yet support the DiskANN index, so write-heavy agent memory should use exact scan under MVCC.
Related posts
- Local RAG with Ollama, Mistral, and Turso
Turso mediumAdeptA local retrieval-augmented generation pipeline can be built in TypeScript using Ollama's Mistral model for both embeddings and generation, with libSQL storing documents and 4096-dimension F32_BLOB vectors in a single SQLite file indexed via libsql_vector_idx. Similarity search uses vector_distance_cos in a SQL query, and the top matches are injected as context into a prompt for Ollama's chat API. The setup runs fully offline with no extensions to install, and can be pointed at a Turso URL with embedded replicas to sync vectors across devices.
- Building AI Agents That Remember with Mastra and Turso Vector
Turso mediumAdeptMastra, a TypeScript AI agent framework, can use Turso's libSQL (a SQLite fork with native vector search) as a single database for agent memory, telemetry and vector embeddings. The walkthrough configures LibSQLStore and LibSQLVector, enables Mastra's semanticRecall with OpenAI embeddings, registers multiple named vector stores, and builds a RAG ingestion workflow (recursive chunking at 512 tokens with 50 overlap, embedMany, upsert) plus a vector query tool for a weather agent. Turso's vector support covers six types from FLOAT32 down to 1-bit, giving up to 32x compression, and vectors of up to 65,536 dimensions, with no extensions required.
- SQLite Retrieval Augmented Generation and Vector Search
Turso mediumAdeptRetrieval-augmented generation fixes stale or hallucinated LLM answers by retrieving relevant data, typically via embeddings and vector similarity search, and injecting it into the prompt. libSQL adds native vector search to SQLite: embeddings are stored in an F32_BLOB column (SQLite treats column types as hints), inserted with a vector() function, and queried with vector_distance_cos() plus ORDER BY/LIMIT for exact top-k results. That exact search is a full table scan and only scales to small datasets, so larger collections need approximate nearest-neighbour indexing, which a follow-up post will cover.
- How to Generate & Store OpenAI Vector Embeddings with Turso
Turso mediumAdeptTurso's beta vector support stores OpenAI text-embedding-ada-002 embeddings in a libSQL F32_BLOB(1536) column, whose size matches the model's 1536 dimensions. A DiskANN index with a cosine metric, declared through libsql_vector_idx, handles similarity search. The walkthrough covers creating a vector-enabled group and database with the Turso CLI, generating embeddings with the OpenAI Node SDK, and inserting them as Float32Array buffers in batches of 50 via db.batch transactions. Larger documents such as PDFs need to be chunked before embedding to stay within API limits.
- You Don't Need A Separate Vector Database
Turso easyNoviceVector search belongs in your primary database rather than a separate system like Pinecone, because syncing embeddings across multiple stores adds cost and operational complexity. Turso's libSQL fork adds a native vector datatype (F32_BLOB) and DiskANN-based indexes with options like 1-bit neighbor compression. Similarity search can then be combined with ordinary SQL filters, and data and embeddings can be updated atomically in one transaction. Dedicated vector databases still offer re-ranking, hybrid scoring and compression, but many applications don't need them. Examples include on-device AI assistants and per-agent ephemeral databases.