Skip to content

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

Turso 9 min read How-to mediumAdept

Processing embeddings with libSQL, Redpanda Kafka, and Mixedbread

Embedding generation can be moved out of the request path by publishing successful libSQL writes to a Kafka topic and computing vectors in a background consumer. A libsql-middleware afterExecute hook sends each insert's query and result to a Redpanda Cloud topic via kafkajs. A consumer runs Mixedbread's open-source mxbai-embed-large-v1 locally through transformers.js and writes 1024-dimensional vectors back into an F32_BLOB column with vector32(). Similar movies are then found with Turso's native vector index and vector_top_k. The middleware is presented as a stopgap until Turso ships native change data capture.

Related posts

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

  • Easy Embeddings Indexing Pipelines with Redpanda and Neon

    Neon mediumAdept

    An embeddings indexing pipeline can be built from configuration alone with Redpanda Connect: it consumes e-commerce invoice messages from a Redpanda Serverless topic over SASL/TLS, builds a text description of each order with Bloblang, computes embeddings locally via Ollama's nomic-embed-text model, and flattens items into separate messages before writing them to Neon Postgres with pgvector for natural-language search. The whole setup is a few dozen lines of YAML, and Redpanda serves as a Kafka-compatible buffer that absorbs traffic spikes. Note that the Step 4 output config shown duplicates the processor config, so the actual Postgres sink settings are missing.

  • Local RAG with Ollama, Mistral, and Turso

    Turso mediumAdept

    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.

  • Personal Knowledge Graphs in AI RAG-powered Applications with libSQL

    Turso mediumAdept

    Kin, a local-first mobile personal AI, stores its personal knowledge graph in libSQL so that relational data, graph edges and vector embeddings live in one embeddable single-file database instead of syncing a separate store like faiss. Nodes and edges are ordinary SQLite tables. Each edge carries an F32_BLOB(512) embedding of its normalized subject–predicate–object triple, which makes the triples searchable by vector similarity. The post walks through inserting vectors with the vector() function and shows why brute-force vector_distance_cos scans are slow. It then covers adding a libsql_vector_idx index and querying via vector_top_k joined on rowid, recomputing distances on the small result set and filtering by a cosine threshold.

  • Automatic Embeddings in Postgres

    Supabase mediumAdept

    Supabase moves embedding generation coordination into Postgres. Insert and update triggers enqueue jobs in pgmq, pg_cron batches them, and pg_net calls an Edge Function that hits an embedding API, then writes results into a pgvector column. The design avoids drift between content and vectors and keeps slow inference off the write path. Embeddings are briefly null after a write until the async job completes. A generated-column approach is rejected because it blocks writes unless the model is local and fast.

The quest for software engineering knowledge.

Look:
Layout: