Embeddings and RAG 道练习题
19 道题 · 0 已解决
检索增强生成(Retrieval-augmented generation,简称 RAG)通过先搜索文档库,然后将最相关的段落传递到 prompt 中,为 LLM 提供最新的事实。文档被切分为 chunks 并转化为 embedding 向量,使得语义相似的内容在向量空间中彼此接近。这就像一场开卷考试,核心技能是快速找到正确的页面。这些题目涵盖了检索流水线的每个环节。你将学习在 token 预算内将文档切分为重叠的 chunks 或按句子切分,为查询检索 top-k chunks,使用 BM25 对文档进行排序,结合关键词和向量得分,通过 reciprocal rank fusion 合并排名,使用 maximal marginal relevance 进行多样性重排序,截断 Matryoshka embeddings,通过 Hamming distance 搜索二进制 embeddings,搜索 IVF index,使用 product quantization 对向量评分,以及衡量 recall at k。建议先从 top-k retrieval 和 rank fusion 的 Easy 题目开始。然后进行 chunking 和 hybrid scoring,最后完成 BM25、MMR 和压缩索引相关的题目。RAG 是当今企业构建 LLM 应用时最常用的功能之一,应用 AI 岗位的面试经常要求你设计或调试 RAG 系统。
简单 7
- RAG retrieval: pick the top-k help article chunks for a question
- Merge several retrievers' rankings with reciprocal rank fusion
- Truncate Matryoshka embeddings and renormalise
- Measure recall at k of an approximate index
- Rerank retrieved chunks in two stages with a score threshold
- Reorder retrieved chunks so the best sit at the edges of the prompt
- Score a retriever with recall@k and MRR
中等 8
- Split a document into overlapping chunks
- Combine keyword and vector scores with min-max normalization
- Search binary-quantised embeddings by Hamming distance
- Chunk text by sentences under a token budget
- Chunk a document at semantic breakpoints between sentences
- Pack retrieved chunks into a token budget for the prompt
- Remove near-duplicate chunks with word shingles and Jaccard similarity
- Bucket embeddings with random-hyperplane LSHPro