Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Turso 8 min read How-to mediumAdept

Local RAG with Ollama, Mistral, and Turso

A 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.

Related posts

  • Building a Retrieval Pipeline with Turso and Voyage AI

    Turso mediumAdept

    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.

  • Building AI Agents That Remember with Mastra and Turso Vector

    Turso mediumAdept

    Mastra, 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.

  • Build a custom RAG AI agent in TypeScript and Jupyter

    Deno mediumAdept

    A local agentic RAG pipeline built in TypeScript inside a Deno Jupyter notebook, using LangChain and LangGraph with Ollama models. Deno blog posts are loaded with Cheerio, split into 500-character chunks, embedded with mxbai-embed-large and stored in an in-memory vector store exposed as a retriever tool. A LangGraph state graph wires an agent node (Llama 3.2 3B, the only small local model the author got tool calling working with) to retrieval, a binary relevance grader, query rewriting and final answer generation with DeepSeek R1 8B. The setup suits confidential documents that must not leave the machine.

  • SQLite Retrieval Augmented Generation and Vector Search

    Turso mediumAdept

    Retrieval-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 mediumAdept

    Turso'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.

The quest for software engineering knowledge.

Look:
Layout: