概念
Optimizing retrieval and embedding models
Tune chunking, top-k, the embedding model, hybrid search, filters and query rewriting, and measure recall.
本课尚未翻译,暂以英文显示。
Chunk size and overlap
- Effect
- Precision against context
- Try
- A few hundred tokens, some overlap
Top-k
- Effect
- Recall against noise
- Try
- Start near 5, then adjust
Embedding model
- Effect
- Meaning match, languages
- Try
- Test two or three models
Vector dimensions
- Effect
- Accuracy against storage
- Try
- Lower them if cost is high
Hybrid search
- Effect
- Exact terms and meaning
- Try
- Add for codes and names
Metadata filter
- Effect
- Narrows the search
- Try
- Product, date, language
Query rewriting
- Effect
- Better search queries
- Try
- Split hard questions
| Setting | Effect | Try |
|---|---|---|
| Chunk size and overlap | Precision against context | A few hundred tokens, some overlap |
| Top-k | Recall against noise | Start near 5, then adjust |
| Embedding model | Meaning match, languages | Test two or three models |
| Vector dimensions | Accuracy against storage | Lower them if cost is high |
| Hybrid search | Exact terms and meaning | Add for codes and names |
| Metadata filter | Narrows the search | Product, date, language |
| Query rewriting | Better search queries | Split hard questions |
1 / 3
Chunk size and overlap
- Effect
- Precision against context
- Try
- A few hundred tokens, some overlap
Top-k
- Effect
- Recall against noise
- Try
- Start near 5, then adjust
Embedding model
- Effect
- Meaning match, languages
- Try
- Test two or three models
| Setting | Effect | Try |
|---|---|---|
| Chunk size and overlap | Precision against context | A few hundred tokens, some overlap |
| Top-k | Recall against noise | Start near 5, then adjust |
| Embedding model | Meaning match, languages | Test two or three models |
2 / 3
Vector dimensions
- Effect
- Accuracy against storage
- Try
- Lower them if cost is high
Hybrid search
- Effect
- Exact terms and meaning
- Try
- Add for codes and names
Metadata filter
- Effect
- Narrows the search
- Try
- Product, date, language
| Setting | Effect | Try |
|---|---|---|
| Vector dimensions | Accuracy against storage | Lower them if cost is high |
| Hybrid search | Exact terms and meaning | Add for codes and names |
| Metadata filter | Narrows the search | Product, date, language |
3 / 3
Query rewriting
- Effect
- Better search queries
- Try
- Split hard questions
| Setting | Effect | Try |
|---|---|---|
| Query rewriting | Better search queries | Split hard questions |
- 1Change one setting.
- 2Run a fixed set of test questions.
- 3Measure retrieval recall and answer quality, then keep what works.
分步说明
- 1Change one setting.
- 2Run a fixed set of test questions.
- 3Measure retrieval recall and answer quality, then keep what works.
Tune by measuring.
是什么
RAG quality depends on whether the right chunk comes back. Start with chunking. Small chunks match precisely but can lose context. Large chunks keep context but dilute the match and use more prompt. Knowledge Bases defaults to about 300 tokens, and fixed-size chunking lets you set the size and an overlap percentage, so a sentence cut at a boundary appears in both chunks. Hierarchical chunking searches small child chunks but returns the larger parent. Semantic chunking splits where the topic changes and costs more, because it calls a foundation model.
是什么
Next, retrieval settings. Top-k is how many chunks you return (5 by default in Knowledge Bases). Too low misses the answer. Too high adds noise, cost and delay. Hybrid search combines vector and keyword search, so exact terms such as product codes are found; Knowledge Bases supports it with some vector stores (Amazon OpenSearch Serverless, Amazon RDS and MongoDB with a text field). Metadata filters limit the search to documents with the right attributes, such as product, year or language. Query rewriting turns a vague question into a better search query, and query decomposition splits a hard question into sub-queries.
是什么
The embedding model matters most. Pick one that supports your languages and domain. A longer vector captures more but costs more to store and search; Amazon Titan Text Embeddings V2 offers 256, 512 or 1,024 dimensions. Keep chunks within the model’s input limit, and use the same model for ingestion and queries. Measure each change: build a test set of questions with known source passages and track retrieval recall (did the right chunk come back in the top k), changing one setting at a time. Reranking has its own lesson.
要记住
- Top-k: too low misses the answer, too high adds noise and cost.
- Hybrid search finds exact terms. Metadata filters narrow the search.
考试中
- “Answers miss exact product codes” points to hybrid search.
- “Search only the 2025 documents for one product line” points to a metadata filter.
- “A chunk is cut mid-sentence and context is lost” points to more overlap or hierarchical chunking.
本任务内容 · 2.2
- Built-in algorithms for tabular data
- Built-in algorithms: clustering, dimensionality reduction, anomaly
- Built-in algorithms: text, sequence and forecasting
- Built-in algorithms: image and video
- Training jobs, script mode and ML libraries
SageMaker AMT
- Reducing training time
- Distributed training and HyperPod
- Overfitting, underfitting and catastrophic forgetting
- Combining models
- Epochs, steps, batch size and learning rate
- Task-specific prompt engineering
- Fine-tuning and continued pre-training in Bedrock
- PEFT, LoRA and fine-tuning on SageMaker
- Model distillation
- Optimizing retrieval and embedding models