In our previous lesson, you successfully built your first Retrieval-Augmented Generation (RAG) agent, connecting it to a Qdrant vector database. That was a crucial step in giving your agent a long-term memory. However, the product data we used was simple and clean—a few short, perfectly formatted text strings. Real-world data is rarely so cooperative.
This lesson tackles that challenge directly. Our objective is to design a chunking strategy and metadata schema for indexing an e-commerce product catalog. We'll move beyond the naive data preparation of the last lesson and explore the sophisticated techniques required to build a high-performing, production-ready retrieval system. This is the final and most critical piece of the puzzle for creating an agent with a truly useful and reliable memory.
The Hidden Bottleneck: Why Your Data Prep Matters
When a RAG system provides a wrong or incomplete answer, it's tempting to blame the LLM. However, the root cause is often far more fundamental: the data was poorly prepared. This process of breaking down documents into pieces for storage in a vector database is called chunking.
As Nate Jones explains in the video "Chunking 101," chunking is not just a technical detail; it's a core part of context engineering.
{"type":"video","title":"Chunking 101: The Invisible Bottleneck Killing Enterprise AI Projects","learning_duration":217,"video_id":"pMSXPgAUq_k","par_intro":"This video from AI News & Strategy Daily tells the story of a fintech company's costly failure due to a simple chunking error, highlighting why this process is a critical—and often overlooked—foundation for any successful RAG project.","par_directions":"Watch the first few minutes, from the <span data-type=\"resource_video_timerange\" data-resource-subitem-id=\"af8ccaaf\" data-range-start=\"0\" data-range-end=\"217\">introduction to the fintech story</span>. Pay close attention to how a sentence being split across two chunks led to a completely incorrect, and costly, AI response. This illustrates the core problem we aim to solve.","video_duration":1296,"isV2":true,"blockId":"d01a977c-5f98-457a-9cdf-411f2fb64a1f","lessonId":"549680db-83ae-4b24-babf-f20711d3fccd"}
The key takeaway is that an LLM can only reason with the information it's given. If a crucial piece of context is missing from the retrieved chunks, the model will either "hallucinate" to fill the gap or provide an incomplete answer. This is the "garbage in, garbage out" principle applied to retrieval.
The webscraft.org article on chunking strategies provides excellent examples of this failure mode. While the scenarios involve financial reports and legal documents, the logic applies directly to an e-commerce catalog.
{"type":"reading","par_intro":"This article dives into the practical consequences of poor chunking.","par_directions":"Please read the section titled <span data-type=\"resource_reading_textrange\" data-resource-subitem-id=\"572686f2\" data-range-start=\"What happens without proper chunking\" data-range-end=\"searching for the rest of the information manually\">\"What happens without proper chunking\"</span>. Imagine \"Scenario 1: Financial report with tables\" as a product specification table in your catalog. If the table showing different product sizes and their prices is split, the agent might retrieve the prices without the corresponding sizes, making the information useless.","learning_duration":"5 minutes","url":"https://webscraft.org/blog/chunking-strategies-v-rag-2026-yak-pravilno-rozbivati-dani-dlya-production?lang=en","title":"Chunking Strategies RAG 2026 : Best Ways to Split Data for ...","isV2":true,"blockId":"466055e2-c585-4abc-9adf-f3f0138e9809","lessonId":"549680db-83ae-4b24-babf-f20711d3fccd"}
From Simple Splits to Semantic Units
In our last lesson, we essentially used our entire product description as a single chunk. This works for tiny documents but fails for anything complex. A common starting point is to use a fixed-size or recursive character splitter, which you've likely seen in tutorials.
{"type":"image","url":"https://thumbs.dreamstime.com/z/levels-chunking-strategies-rag-infographic-circles-flowchart-data-computing-systems-visualization-diagram-steps-351328892.jpg","caption":"This infographic illustrates several common chunking strategies. While simple methods like Fixed Size and Recursive chunking are a starting point, more advanced strategies like Semantic and Document-Based chunking are necessary for complex, structured data like a product catalog.","isV2":true,"blockId":"daa2aa4a-5e32-4875-ac07-d397a1bc8796","lessonId":"549680db-83ae-4b24-babf-f20711d3fccd"}
These basic methods, however, are blind to the meaning of the content. They respect character counts or simple separators (like paragraphs), but not the logical structure of the data itself. For a rich, semi-structured source like a product catalog, we need a more intelligent approach.
This is where semantic chunking comes in. Instead of splitting by length, we split by logical, self-contained units of meaning. The article "Structuring ecommerce data for LLM retrieval and RAG" provides a brilliant framework for this.
{"type":"reading","par_intro":"This article is written specifically for our use case and advocates for chunking by logical objects rather than arbitrary lengths.","par_directions":"Read the section <span data-type=\"resource_reading_textrange\" data-resource-subitem-id=\"04fb0cc8\" data-range-start=\"Chunking strategies for product catalogs\" data-range-end=\"retrieval tasks\">\"Chunking strategies for product catalogs\"</span>. The author proposes a strategy of \"semantic chunking by object,\" which is the gold standard for e-commerce. Pay close attention to the three proposed logical units:\n1. **Product Snapshot**\n2. **Category Overview**\n3. **Review Cluster**","learning_duration":"5 minutes","url":"https://contentgecko.io/kb/llmo/structuring-data-for-llm-retrieval/","title":"Structuring ecommerce data for LLM retrieval and RAG","isV2":true,"blockId":"ef040dab-29be-4bb7-b45e-8a95ac29a116","lessonId":"549680db-83ae-4b24-babf-f20711d3fccd"}
This approach ensures that each chunk is a coherent, self-contained piece of information. A "Product Snapshot" chunk might contain the title, SKU, short description, and key attributes. This way, when this chunk is retrieved, the LLM receives a complete, meaningful unit of data, dramatically reducing the risk of context being lost.
The "Weaviate" video on chunking strategies provides a great explanation of the difference between these approaches.
{"type":"video","title":"Dive into Chunking Strategies for RAG with Zain 💚","learning_duration":511,"video_id":"LuhBgmwQeqw","par_intro":"This workshop from Weaviate provides a clear breakdown of different chunking strategies, moving from basic to advanced.","par_directions":"First, watch the overview of <span data-type=\"resource_video_timerange\" data-resource-subitem-id=\"68fe33cb\" data-range-start=\"1502\" data-range-end=\"1656\">fixed-size vs. recursive splitting</span>. This covers the basic methods.\n\nThen, watch the segment on <span data-type=\"resource_video_timerange\" data-resource-subitem-id=\"a63fcefb\" data-range-start=\"1656\" data-range-end=\"1755\">document-aware splitting</span>, which introduces the idea of tailoring your strategy to the data type (e.g., code vs. markdown).\n\nFinally, watch the explanation of <span data-type=\"resource_video_timerange\" data-resource-subitem-id=\"7093958d\" data-range-start=\"1761\" data-range-end=\"2019\">semantic chunking</span>. The visualization of how it groups sentences based on semantic similarity is particularly insightful for understanding the concept.","video_duration":3385,"isV2":true,"blockId":"41ea00dc-26f2-43ee-9837-774fa75fbbdb","lessonId":"549680db-83ae-4b24-babf-f20711d3fccd"}
{
"type": "exercise",
"id": "930cc57a-f45f-4905-8660-bbcaf50abf32"
}
The Non-Negotiable Role of Metadata
Vector search is powerful for finding semantically similar content, but it's not well-suited for exact-match filtering. For example, if a user asks for "running shoes under $100," a pure vector search might return a $150 pair of shoes whose description is a perfect semantic match, ignoring the price constraint.
This is where metadata becomes essential. By storing structured data alongside each chunk's vector, we can perform a two-stage retrieval process:
- Filter: First, narrow down the search space using exact metadata matches (e.g.,
price < 100,in_stock = true). - Search: Then, perform the vector search only on the filtered results.
This hybrid approach combines the precision of structured filtering with the semantic power of vector search. The contentgecko.io article again provides specific, actionable advice for an e-commerce metadata schema.
{"type":"reading","par_intro":"This section explains why metadata is critical and suggests a concrete schema for e-commerce.","par_directions":"Read the section <span data-type=\"resource_reading_textrange\" data-resource-subitem-id=\"175e8c98\" data-range-start=\"Embeddings and metadata filtering\" data-range-end=\"improves overall LLM search performance\">\"Embeddings and metadata filtering\"</span>. Note the four recommended metadata fields for WooCommerce, which are applicable to any e-commerce platform:\n* `price_numeric`\n* `in_stock`\n* `category_slug`\n* `average_rating`","learning_duration":"5 minutes","url":"https://contentgecko.io/kb/llmo/structuring-data-for-llm-retrieval/","title":"Structuring ecommerce data for LLM retrieval and RAG","isV2":true,"blockId":"8bc4824b-e07a-4424-bca4-7076b94f01c0","lessonId":"549680db-83ae-4b24-babf-f20711d3fccd"}
For each of your semantic chunks, you would attach this metadata. For example, every chunk related to the "Ergo-Pro Office Chair" would have metadata like: { "price_numeric": 349.99, "in_stock": true, "category_slug": "office-furniture", "average_rating": 4.8 }. This allows an agent to answer a query like "Show me available office chairs under $400 with a rating of at least 4.5" with high precision.
{
"type": "exercise",
"id": "3b5ab559-1b47-4eb2-accb-a261c3c9b763"
}
Handling a Multi-Format Catalog (Text, Tables, Images)
A real product catalog isn't just a block of text. It contains tables for specifications, images, and other structured data. A robust chunking strategy must account for this.
Tables
Product specification tables are a classic example of where simple splitters fail. You must treat the entire table as a single, coherent chunk. Modern data loaders can help with this.
{"type":"reading","par_intro":"This FAQ section provides a direct answer on how to handle documents with tables.","par_directions":"Read the FAQ entry <span data-type=\"resource_reading_textrange\" data-resource-subitem-id=\"65538558\" data-range-start=\"How to handle PDFs with tables?\" data-range-end=\"to text sections\">\"How to handle PDFs with tables?\"</span>. The key is to use specialized ETL (Extract, Transform, Load) tools like `LlamaParse` to recognize tables and treat them as whole units, preventing them from being broken apart.","learning_duration":"3 minutes","url":"https://webscraft.org/blog/chunking-strategies-v-rag-2026-yak-pravilno-rozbivati-dani-dlya-production?lang=en","title":"Chunking Strategies RAG 2026 : Best Ways to Split Data for ...","isV2":true,"blockId":"f0c6ef56-eae2-4b45-a16e-096f83c4ac6f","lessonId":"549680db-83ae-4b24-babf-f20711d3fccd"}
Images
Images are a vital part of a product catalog. To make them searchable, we can't embed the pixels directly for semantic search. Instead, we use a vision-language model (VLM) to generate a rich, detailed text description of the image. This description is then embedded and stored as a chunk.
{"type":"image","url":"https://mlrwd9rnffxq.i.optimole.com/cb:641c.2be21/w:1024/h:783/q:90/f:best/sm:0/https:/blog.vectorize.io/wp-content/uploads/2024/10/image-12.png","caption":"This diagram shows a multimodal RAG pattern. For images, a vision-language model generates a descriptive text (or a multimodal model creates an embedding directly). This vector, along with metadata and the raw media, is stored in the vector database, making visual information searchable.","isV2":true,"blockId":"c5109f11-7d10-41e1-afb6-fa8be1a05283","lessonId":"549680db-83ae-4b24-babf-f20711d3fccd"}
The Weaviate video explains this process clearly.
{"type":"video","title":"Dive into Chunking Strategies for RAG with Zain 💚","learning_duration":109,"video_id":"LuhBgmwQeqw","par_intro":"This part of the workshop details a practical and effective strategy for making images and charts searchable within a RAG system.","par_directions":"Watch the section on <span data-type=\"resource_video_timerange\" data-resource-subitem-id=\"99cf0830\" data-range-start=\"2753\" data-range-end=\"2862\">indexing images and charts</span>. The strategy is to use a model like GPT-4V or a smaller, fine-tuned model to describe the image in detail. This generated text becomes the \"chunk\" you index. For a product image, this description might include colors, angles, materials, and context of use.","video_duration":3385,"isV2":true,"blockId":"91a1764c-f3d5-43be-8d2c-4363b4d570fc","lessonId":"549680db-83ae-4b24-babf-f20711d3fccd"}
A Design for Your E-commerce Catalog
Let's synthesize everything into a concrete design for indexing a product catalog.
1. Data Extraction (ETL):
- Parse each product page.
- Extract distinct elements:
- Product Title, SKU, Brand
- Short Description, Long Description
- Specification Table (as a structured object, e.g., JSON or Markdown)
- Customer Reviews (as a list of individual reviews)
- Image URLs
- Price, Stock Status, Categories, Average Rating
2. Chunking Strategy:
- Primary Chunks (Product Snapshot): Create one primary chunk per product. This chunk should be a concise summary containing the most critical information: Title, SKU, Brand, and Short Description. This acts as a high-level entry point.
- Secondary Chunks (By Logical Unit):
- Full Description: The long description can be its own chunk. If it's very long, use a
RecursiveCharacterTextSplitteron it. - Specifications: The entire specification table becomes a single chunk, formatted as clean Markdown.
- Reviews: Group 3-5 related reviews into a single "Review Cluster" chunk. You could group by positive sentiment, negative sentiment, or mentions of a specific feature.
- Images: For each image, use a VLM to generate a detailed description (e.g., "Front view of the Ergo-Pro Office Chair in black, showing the mesh back and adjustable armrests."). Each description is a separate chunk.
- Full Description: The long description can be its own chunk. If it's very long, use a
3. Metadata Schema:
For every chunk created, attach a rich metadata object. This ensures that no matter which piece of information is retrieved, you always have the full context.
{
"product_id": "SKU-12345",
"product_name": "Ergo-Pro Office Chair",
"brand": "ErgoComfort",
"price_numeric": 349.99,
"in_stock": true,
"category_path": ["office", "furniture", "chairs"],
"average_rating": 4.8,
"chunk_type": "specs_table", // "snapshot", "description", "review_cluster", "image_desc"
"source_url": "https://example.com/products/ergo-pro-chair"
}
This comprehensive approach ensures that your agent can not only find semantically relevant information but also apply precise business logic through filtering, leading to far more accurate and useful responses.
{
"type": "exercise",
"id": "9bd1cacd-a627-4a17-9317-aaeb70a1080f"
}
Conclusion
In this lesson, we've moved from a simplistic view of data indexing to a professional-grade strategy for a real-world e-commerce use case. You now have a blueprint for preparing complex, multi-format data for a high-performing RAG system.
Here are the key takeaways:
- Chunking is Foundational: Poor chunking is a primary cause of RAG system failures, leading to hallucinations and inaccurate answers.
- Embrace Semantic Chunking: For structured data like product catalogs, chunk by logical units ("Product Snapshots," "Review Clusters") rather than arbitrary character counts.
- Metadata is Non-Negotiable: Use a rich metadata schema to enable hybrid search, combining precise filtering (for price, stock) with semantic vector search.
- One Size Does Not Fit All: Use different strategies for different data types. Treat tables and image descriptions as their own distinct types of chunks.
You have now completed the module on long-term memory. Your agent has a library (the vector DB) and a sophisticated card catalog system (your chunking and metadata strategy) to navigate it. However, to perform complex, long-running tasks, an agent also needs a robust short-term memory and a way to manage its own internal state.
Our next module, Stateful and Cyclic Agent Architectures, will address this. We will begin by exploring why state persistence is critical for interruptible tasks and how graph-based frameworks like LangGraph provide the structure needed for more complex agent workflows.
Can't find a good explanation? Sign up and we'll make it for you