[{"data":1,"prerenderedAt":122},["ShallowReactive",2],{"term-h\u002Fhnsw":3,"related-h\u002Fhnsw":104},{"id":4,"title":5,"acronym":6,"body":7,"category":83,"description":84,"difficulty":85,"extension":86,"letter":87,"meta":88,"navigation":89,"path":90,"related":91,"seo":97,"sitemap":98,"stem":101,"subcategory":102,"__hash__":103},"terms\u002Fterms\u002Fh\u002Fhnsw.md","HNSW","Hierarchical Navigable Small World",{"type":8,"value":9,"toc":77},"minimark",[10,15,19,23,26,30,66,70,73],[11,12,14],"h2",{"id":13},"eli5-the-vibe-check","ELI5 - The Vibe Check",[16,17,18],"p",{},"HNSW is how a vector database finds your nearest neighbors without checking every single point in a haystack of millions. It builds a multi-layer shortcut graph, kind of like a highway system: start on the sparse top layer to get in the right neighborhood fast, then drop down through denser layers to pinpoint the exact closest matches. It's why semantic search over millions of embeddings still feels instant.",[11,20,22],{"id":21},"real-talk","Real Talk",[16,24,25],{},"HNSW is a graph-based approximate nearest neighbor algorithm that organizes vectors into multiple layers of proximity graphs, with sparser graphs at higher layers enabling fast coarse navigation and denser graphs at lower layers enabling fine-grained search. It offers logarithmic-scale search complexity with strong recall, and is the default index type in most vector databases including pgvector, Qdrant, and Weaviate.",[11,27,29],{"id":28},"show-me-the-code","Show Me The Code",[31,32,37],"pre",{"className":33,"code":34,"language":35,"meta":36,"style":36},"language-sql shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","-- pgvector: create an HNSW index for cosine distance\nCREATE INDEX ON documents\nUSING hnsw (embedding vector_cosine_ops)\nWITH (m = 16, ef_construction = 64);\n","sql","",[38,39,40,48,54,60],"code",{"__ignoreMap":36},[41,42,45],"span",{"class":43,"line":44},"line",1,[41,46,47],{},"-- pgvector: create an HNSW index for cosine distance\n",[41,49,51],{"class":43,"line":50},2,[41,52,53],{},"CREATE INDEX ON documents\n",[41,55,57],{"class":43,"line":56},3,[41,58,59],{},"USING hnsw (embedding vector_cosine_ops)\n",[41,61,63],{"class":43,"line":62},4,[41,64,65],{},"WITH (m = 16, ef_construction = 64);\n",[11,67,69],{"id":68},"when-youll-hear-this","When You'll Hear This",[16,71,72],{},"\"We switched from IVF to HNSW and recall jumped at the same latency.\" \u002F \"Tune ef_search if HNSW results feel imprecise.\"",[74,75,76],"style",{},"html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":36,"searchDepth":50,"depth":50,"links":78},[79,80,81,82],{"id":13,"depth":50,"text":14},{"id":21,"depth":50,"text":22},{"id":28,"depth":50,"text":29},{"id":68,"depth":50,"text":69},"database","HNSW is how a vector database finds your nearest neighbors without checking every single point in a haystack of millions.","advanced","md","h",{},true,"\u002Fterms\u002Fh\u002Fhnsw",[92,93,94,95,96],"Vector Database","Embedding","Cosine Similarity","Semantic Search","Vector",{"title":5,"description":84},{"changefreq":99,"priority":100},"weekly",0.7,"terms\u002Fh\u002Fhnsw",null,"xVDayn98qqmYgWdliiymGPEqCg1yO0_hOg6fXzyMlfY",[105,110,113,116,119],{"title":94,"path":106,"acronym":102,"category":107,"difficulty":108,"description":109},"\u002Fterms\u002Fc\u002Fcosine-similarity","ai","intermediate","Cosine similarity measures how similar two things are by comparing the angles of their vectors.",{"title":93,"path":111,"acronym":102,"category":107,"difficulty":108,"description":112},"\u002Fterms\u002Fe\u002Fembedding","An embedding is turning words, sentences, or entire documents into lists of numbers (vectors) that capture their meaning.",{"title":95,"path":114,"acronym":102,"category":107,"difficulty":108,"description":115},"\u002Fterms\u002Fs\u002Fsemantic-search","Semantic search finds results based on meaning, not just keyword matching.",{"title":96,"path":117,"acronym":102,"category":107,"difficulty":108,"description":118},"\u002Fterms\u002Fv\u002Fvector","In AI, a vector is just a list of numbers. But it's a list of numbers that means something — like [0.23, -0.91, 0.44, ...",{"title":92,"path":120,"acronym":102,"category":107,"difficulty":108,"description":121},"\u002Fterms\u002Fv\u002Fvector-database","A vector database is a special database built to store and search embeddings.",1792528089804]