Show HN: Building a web search engine from scratch with 3B neural embeddings
TL;DR Highlight
Built a web search engine in two months with 3B embeddings and 500ms query latency
Who Should Read
A backend developer whose RAG search quality suffers from chunking and lost context
Core Mechanics
- Keep only semantic text from HTML
- Kept only p, table, pre, blockquote, ul, ol and dl, and stripped scripts, attributes, empty elements and head.
- Chrome like menus, footers, comments and social buttons dilutes meaning and hurts search quality.
- Removing by class/ID patterns risks cutting real content, so leaving some noise is the safer choice.
- Chunk by sentence, not by character count
- Splitting every n characters cuts words and grammar and destroys meaning.
- spaCy's sentence model handled abbreviations, decimals, URLs and informal text best.
- Sentences pinpoint exact answers and are easy to group into paragraph-sized units.
- Embed document structure as context
- Prepended headings (h1 to h3), the lead-in sentence before a list and table column names to each sentence.
- Table rows were rewritten as 'Environment: Development | Recommended Setting: 100'.
- The version 15 vs 16 tables are told apart only by this context.
- Chain dependent sentences for pronouns
- Trained a DistilBERT classifier to label which earlier sentence each sentence depends on.
- When embedding, followed the dependency chain backwards and included the needed sentences.
- Sentences meaningless on their own were excluded from matching.
- Neural search answered keyword-free queries
- For the S3 docs, 'can I use S3 from Lua?' surfaced the REST API explanation.
- A query about billed usage exceeding actual usage matched answers sharing no words with it.
- The comparison is against traditional keyword search, and no numeric evaluation appears in the excerpt.
- System scale and crawler design
- 200 GPUs produced 3B SBERT embeddings, peak crawl was 50K pages per second, and the index holds 280M.
- Query latency is about 500 ms, with RocksDB and HNSW sharded across 200 cores, 4 TB RAM and 82 TB SSD.
- The crawler used per-origin concurrency and rate limits, jitter and exponential backoff, and manual DNS checks to block private IPs.
Community Reactions
- Opinion that vector-only search fails on keyword queries
- A commenter searched 'garbanzo bean stew' and got irrelevant bean recipes.
- They argue vector-only search fails where keywords matter.
- Counterpoint that embeddings are vulnerable to SEO attacks
- A commenter argued adversarially crafting embeddings is easier because the math is known.
- They also noted there is no separation between prompt and content.
- Hybrid and IVF alternatives raised by commenters
- Commenters asked whether BM25+embedding hybrid search and rerankers were tried.
- One suggested sparse embeddings like SPLADE as a middle ground between keyword and semantic search.
- Another said they used IVF instead of HNSW for job listings because of limited memory.
- Complaint that broad ranking pages win
- A commenter searched for high-resolution ultrawide monitors and said roundup pages outranked specialist spec pages.
- Another speculated that OpenAI's very cheap batch embedding pricing may be a way to gather domain data for training.
How to Apply
- Prepend heading paths to RAG chunks
- Add the h1>h2>h3 headings and any list lead-in sentence on separate lines before each chunk you embed today.
- Compare search results before and after with the same 10 questions.
- Rewrite table rows with column names
- When chunking tables, convert each row to 'column: value | column: value' before embedding.
- Check whether value-only rows stop disappearing from search results.
- Attach the previous sentence to pronoun sentences
- Embed chunks starting with 'This' or 'Therefore' together with the sentence before them.
- Start rule-based, and consider training a dependency classifier if it helps.
- Strip chrome first in content extraction
- Use main>article when present, and drop nav, footer, aside and form from crawled pages.
- Keep class-name pattern rules minimal and sample-check that real content is not cut.
Try It
# Paste into Claude or ChatGPT (simplified version of the article's chunking method)
Turn the document below into chunks for search.
Rules:
1. Split into sentences.
2. Prepend the heading path (h1 > h2 > h3) the sentence belongs to.
3. If a list or table has a lead-in sentence, prepend that too.
4. Rewrite table rows as 'column: value | column: value'.
5. For sentences that depend on earlier ones ('This', 'Therefore', 'It'), include the sentences they depend on.
6. Mark sentences that make no sense alone and should not be returned as matches with matchable: false.
Output a JSON array [{"chunk": "...", "matchable": true}].
Document:
{{document}}Terminology
Related Papers
FutureBench: A Renewable Framework for Evaluating Knowledge-Context Conflict in LLMs
Adding 'verify and prioritize the passage' to RAG prompts raised false-passage adoption; a knowledge-priority warning fixed it.
Faster Retrieval for Better, More Efficient RAG
Small neural nets learned query routing, hitting the same recall up to 8x faster in IVF search
Memorilla: Latent Semantic Memory for LLMs
Compressing documents into 16 memory tokens beat full-context accuracy on FactKG.
What the Author Wrote, What the Agent Reads: Silent Cue Loss in Enterprise Document Ingestion
Preserving red text and highlights in docx ingestion lifted marked-requirement F1 from 0.150 to 0.690.
Multimodal Reranking Is a System One Decision
One multiple-choice question to a VLM over 16 candidates reranks them, beating a dedicated 2B reranker.
You could have invented transformers from memory
Viewing linear, MLP and attention layers as memory stores: capacity goes ~64 to ~2,700 to over a million
Pointing AI at archives found a forgotten meteorite, lost rhinos, and more
Embedding search plus a cheap filter model surfaced unrecorded events in 400 years of archives
EmbeddingGemma 2: An open, lightweight multimodal embedding model
One open 740M model embeds text, images, audio and video into a single shared vector space