Skip to content

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

Docker 6 min read How-to mediumAdept

Run Embedding Models and Unlock Semantic Search with Docker Model Runner

Docker Model Runner can serve embedding models locally, so semantic search and RAG pipelines run without sending private data to a hosted API and without per-call costs. Embeddings map text and code to vectors where semantically related items cluster, and cosine similarity ranks documents against a query. Getting started takes two steps: pull a model such as ai/qwen3-embedding, then call the OpenAI-style /engines/v1/embeddings endpoint on localhost. A sketched code-search workflow chunks a codebase, embeds the chunks, stores the vectors (a file in the demo, a vector database like Milvus, Qdrant or pgvector in practice) and ranks them by cosine similarity.

Related posts

  • How Hugging Face Inference Endpoints, Jobs, and Buckets Power Search on Papers with Code

    Hugging Face mediumAdept

    Papers with Code search combines PostgreSQL full-text search with pgvector semantic search over Qwen3-Embedding-0.6B vectors, fused by weighted reciprocal rank fusion (k=60), with exact-title, arXiv-ID and navigational matches pinned on top. Hugging Face Jobs build the full corpus on an L4 GPU from checksummed snapshots stored in immutable run prefixes in Storage Buckets. A scale-to-zero TEI Inference Endpoint embeds live queries and hourly incremental updates. A strict versioned embedding contract (pinned revision, 256-dim Matryoshka vectors, query/document prompts, content hashes) keeps generations reproducible, and pilot tests showed 0.9955 Recall@20 at ~1.3 ms p50 with 27% of the 1024-dim storage. A one-second timeout and circuit breaker fall back to lexical search when the endpoint is cold or unhealthy.

  • Getting Started With Embeddings

    Hugging Face mediumAdept

    Embeddings turn text or images into fixed-length vectors that capture meaning, so semantic similarity becomes a distance calculation. A walkthrough builds a small FAQ matcher: it embeds 13 Medicare FAQs into 384-dimensional vectors with sentence-transformers/all-MiniLM-L6-v2 through the Hugging Face Inference API, hosts the vectors as a CSV dataset on the Hub, then embeds a user query and ranks the top 5 FAQs by cosine similarity with util.semantic_search. Practical notes include retrying the first API call while the model loads, and using FAISS via add_faiss_index as an alternative search path.

  • Storing OpenAI embeddings in Postgres with pgvector

    Supabase mediumAdept

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

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

  • Building AI Search on Heroku

    Heroku Engineering mediumAdept

    A reference RAG architecture on Heroku pairs pgvector cosine-similarity search (top 20 chunks) with a cross-encoder reranker (Cohere Rerank 3.5, top 5), so answers come from documents that actually address the query rather than ones that are merely semantically close. Indexing crawls sites using a junk-content heuristic, splits text into 1000-character chunks with 200-character overlap at paragraph or sentence boundaries, and batch-inserts embeddings with Postgres unnest. Generation uses Claude 3.5 Sonnet, and Server-Sent Events stream pipeline progress and sources to the client. Reranking can be switched off when latency matters more than precision.

The quest for software engineering knowledge.

Look:
Layout: