ladderlore
  • 输入服务名称,例如 S3 或 IAM。

概念 · 基于 AIF-C01

Preparing documents for RAG

Chunking strategies, parsing, and metadata so a knowledge base retrieves the right passage.

本课尚未翻译,暂以英文显示。

你在AI Practitioner中已学过

  • Chunking splits long documents before embedding.
  • There is no best size: test with your documents.
  • Chunks are embedded and stored in a vector database.
阅读AI Practitioner课程
  • Fixed-size

    How it cuts
    Max tokens plus overlap
    Pick it when
    A simple start
  • Hierarchical

    How it cuts
    Child chunks inside parents
    Pick it when
    Precise match, wide context
  • Semantic

    How it cuts
    Cuts where meaning shifts
    Pick it when
    Mixed topics in one file
  • Custom (Lambda)

    How it cuts
    Your own code
    Pick it when
    Special rules
Four chunking strategies.
Documents and metadata
Parse
Chunk
Embed
Vector store
  1. 1Documents and their metadata files sit in S3.
  2. 2A parser extracts text, tables and figures.
  3. 3The chunker splits the text.
  4. 4An embedding model turns each chunk into a vector, stored with its metadata.
Documents are parsed, chunked, embedded and stored.

分步说明

  1. 1Documents and their metadata files sit in S3.
  2. 2A parser extracts text, tables and figures.
  3. 3The chunker splits the text.
  4. 4An embedding model turns each chunk into a vector, stored with its metadata.

Documents are parsed, chunked, embedded and stored.

是什么

Amazon Bedrock Knowledge Bases offer several chunking strategies. Fixed-size chunking sets a maximum number of tokens and an overlap percentage. Hierarchical chunking makes small child chunks inside larger parent chunks: search matches the precise child and the answer gets the parent for more context. Semantic chunking uses a foundation model to cut where the meaning shifts, at extra cost. No chunking keeps each file whole. Custom chunking runs your own AWS Lambda function on the files, for rules the built-ins cannot express. Smaller chunks match precisely but lose context. Larger chunks keep context but dilute the match. Overlap stops an idea from being cut in half.

是什么

AWS advises against hierarchical chunking when the store is an S3 vector bucket.

Parsing decides what text the chunker sees. The default parser reads plain text well but misses tables and figures. A foundation model parser, or Amazon Bedrock Data Automation, reads complex PDFs with tables, charts and images and returns structured text, at extra cost. Use it for scanned or table-heavy files.

是什么

Metadata makes retrieval precise. Put a file next to each document in S3 named like the document with .metadata.json added, holding attributes such as year, department or product. At query time, filter on those attributes, for example only documents from 2026 for one department. Extract metadata automatically with a Lambda function or Amazon Comprehend when files have none.

要记住

  • Fixed-size: max tokens and overlap. Hierarchical: small child chunks match, bigger parent returns.
  • Semantic chunking: cuts by meaning, extra model cost.
  • Custom chunking: a Lambda function for your own rules.
  • Parsers: default for text, foundation model or Data Automation for tables and figures.

要记住

  • Metadata in a .metadata.json file beside each document, used as query filters.

考试中

  • “Precise matching but the answer needs surrounding context” points to hierarchical chunking.
  • “PDF tables are lost during ingestion” points to a foundation model parser.
  • “Return only documents from one department and year” points to metadata filtering.