Easy Embeddings Indexing Pipelines with Redpanda and Neon
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.
Related posts
- Building a RAG application with Llama 3.1 and pgvector
Neon mediumAdept
A small RAG pipeline built on Neon Postgres with pgvector as the vector store, OctoAI's gte-large embedding model producing 1024-dimensional vectors, and Llama 3.1 405B generating answers. The walkthrough enables the vector extension, creates a table with a VECTOR(1024) column, and embeds and inserts a CSV of fake quotes from Python via psycopg2. At query time it embeds the user input, retrieves the two nearest quotes with a cosine-distance ORDER BY ... LIMIT 2 query, and injects them into the system prompt. Embedding dimension directly drives storage cost, e.g. 1024 for gte-large versus up to 3072 for OpenAI's model.
- Processing embeddings with libSQL, Redpanda Kafka, and Mixedbread
Turso mediumAdeptEmbedding 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.
- Storing OpenAI embeddings in Postgres with pgvector
Supabase mediumAdeptpgvector adds a vector data type and distance operators (Euclidean <->, negative inner product <#>, cosine <=>) to Postgres, so OpenAI text-embedding-ada-002 embeddings (1536 dimensions) can be stored and queried for similarity directly in the database. The walkthrough creates a documents table, a match_documents SQL function that filters by a cosine-similarity threshold, and an IVFFlat index sized at roughly 4 * sqrt(rows) lists. It then generates embeddings in JavaScript and builds Deno Edge Functions for semantic search and for retrieval-augmented answers with text-davinci-003, keeping injected context under about 1500 tokens to fit the 4000-token limit.
- Semantic search using OpenAI, pg_embedding and Neon
Neon mediumAdept
A YC idea-matcher app implements semantic search by embedding ~4,400 YCombinator company descriptions with OpenAI's text-embedding-ada-002 (1536 dimensions) and storing them as real[] columns in Neon Postgres via the pg_embedding extension. Queries embed the user's idea and order rows by cosine distance (<=>) to return the top five matches from a Next.js edge function, which is colocated with the database region and uses the Neon serverless driver, Upstash rate limiting and Zod validation. The full ingestion script and API route are shown. Sequential scan is fine for this small dataset, but larger tables need an HNSW index. pg_embedding has since been deprecated in favor of pgvector.
- On-disk HNSW index for Postgres with pg_embedding
Neon mediumAdept
pg_embedding's new version builds its HNSW vector index on disk rather than in memory and adds cosine, Manhattan and Euclidean (L2) distance support. Benchmarks on an 8 vCPU / 32 GB machine show the in-memory index is roughly 2x faster, but persisting the index lets it work with Neon's autoscaling, scale-to-zero and read replicas for read-heavy similarity search. The post walks through enabling the extension, storing embeddings as real[] and tuning the index parameters dims, m, efConstruction and efSearch, where efSearch should be at least the query's LIMIT k. Neon has since discontinued pg_embedding and recommends pgvector instead.