Files
nexus/wiki/concepts/Semantic-Search.md

37 lines
1.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: "Semantic Search"
type: concept
last_updated: 2026-04-22
---
## Definition
基于 Embedding 向量模型将文本编码为高维向量,通过向量相似度(如余弦相似度)而非关键词匹配来检索相关内容的搜索方式。相比 BM25/BM25 等传统关键词检索,能捕捉语义层面的相关性,例如"我保存的关于 LLM memory 的内容?"能匹配到讨论 agent 记忆机制的文章,即使两者用词不同。
## How It Works
```
用户查询 → Embedding 模型编码 → 高维向量
文档库 → Embedding 模型编码 → 文档向量集合
向量相似度计算ANN 索引)→ Top-K 结果 → LLM 回答
```
## Components
| 组件 | 说明 |
|------|------|
| Embedding 模型 | text-embedding-3-small、BGE、Sentence-BERT 等 |
| ANN 索引 | FAISS / HNSW / ScaNN实现十亿级向量近实时检索 |
| 相似度度量 | 余弦相似度 / 点积 / 欧氏距离 |
## Why It Matters in RAG
关键词搜索依赖字面匹配,容易漏掉同义词/多义词场景。语义搜索理解查询意图,使 [[Knowledge-Base-RAG]] 返回真正相关结果而非机械的字面匹配。
## Connections
- [[Knowledge-Base-RAG]] — 语义搜索是知识库 RAG 的检索层
- [[Vector-Embedding]] — 语义搜索的底层编码技术
- [[Hybrid Search]] — 向量检索 + BM25 关键词检索融合,进一步提升召回率