Skip to content

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

Hugging Face 10 min read Case study mediumAdept

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

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.

Related posts

  • Run Embedding Models and Unlock Semantic Search with Docker Model Runner

    Docker mediumAdept

    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.

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

  • Matryoshka embeddings: faster OpenAI vector search using Adaptive Retrieval

    Supabase mediumAdept

    OpenAI's text-embedding-3 models are trained with Matryoshka Representation Learning, so an embedding can be shortened by truncating trailing dimensions and renormalizing, which reproduces the API's `dimensions` output. Adaptive Retrieval exploits this with a two-pass search: a fast HNSW-indexed ANN pass on a low-dimensional prefix fetches an oversized shortlist, then exact KNN on the full 3072d vectors re-ranks it. Benchmarks on 1M dbpedia embeddings found a 512d first pass (ef_construction=400, m=32, ef_search=200, limit = top_k × 8) reached 99% accuracy against 3072d KNN at about 580 QPS. By comparison, a single pass on 1536d vectors topped out near 89%. The post finishes with a Postgres/pgvector implementation using a sub_vector SQL function.

  • Hugging Face is now supported in Supabase

    Supabase mediumAdept

    Supabase adds first-class Hugging Face support for generating embeddings stored in pgvector, as an open-source, self-hostable alternative to OpenAI's text-embedding-ada-002. The Python vecs client gains "adapters" that chunk text and embed it automatically on upsert and query. Edge Functions can run Transformers.js inference in Deno, and small models can even run in the browser and query pgvector through PostgREST and RLS. Supabase recommends lower-dimension models such as gte-small for cheaper storage and faster retrieval, and notes current limits: 2-6s cold starts from model downloads, and no turnkey audio/image decoding in Deno.

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

The quest for software engineering knowledge.

Look:
Layout: