A Practical Guide to Integrating Structured Data into RAG and Workflow Orchestration

    This guide explains why document-style chunking fails for structured data in RAG pipelines and how to design a better architecture based on a semantic layer, query routing, and dual-channel retrieval. It covers differentiated ingestion strategies for spreadsheets, charts, and semi-structured logs, a retrievable routing pattern, reusable workflow node design, neutral criteria for evaluating open-source solutions, layered evaluation methods, and common pitfalls to avoid. Readers will learn how to build RAG systems that return accurate, verifiable answers over structured business data.

    1. The Core Problem: Structured Data Cannot Follow Document Chunking Logic

    When most teams build retrieval-augmented generation (RAG), their default target is long-form text: chunk, embed, retrieve by similarity, and inject into the prompt. This pipeline breaks down quickly on structured data, for three reasons.

    First, the distribution of semantic density differs. A document paragraph remains readable when stripped of its surrounding context, while a single table row is nearly meaningless once separated from its header and field definitions. Second, aggregation and exact-match requirements dominate. Business questions often look like “the top three product lines by gross margin in East China last quarter” — these require sorting, filtering, and aggregation, which vector similarity cannot guarantee to get numerically right. Third, data lives in mixed modalities. A chart’s “content” simultaneously exists in the rendered image, the underlying data, and the axis semantics; processing only one of these channels inevitably loses information.

    The right approach, therefore, is not to “forcibly textualize” structured data and stuff it into a vector store, but to build an architecture of semantic layer + routing + dual-channel retrieval.

    2. Differentiated Ingestion Strategies for Three Data Types

    2.1 Spreadsheets and Relational Data

    A two-layer approach is recommended:

    • Metadata layer: Generate natural-language descriptions for every table and every field, forming a searchable “table catalog.” Field descriptions should clearly state the business meaning, units, enumerated values, and relationships to primary keys.
    • Data layer: Keep the data in its original queryable form, retrieving it precisely at runtime via query translation (Text2SQL or a structured query DSL).

    An illustrative table semantic description structure:

    1. {
    2. "table": "sales_order",
    3. "description": "East China region sales order details, one row per order",
    4. "primary_key": "order_id",
    5. "fields": [
    6. {"name": "gross_margin", "type": "decimal", "unit": "percent", "desc": "gross margin"},
    7. {"name": "region", "type": "enum", "values": ["East China", "South China", "North China"]}
    8. ],
    9. "join_hint": ["product_line joined via product_id"]
    10. }

    Key point: the quality of field descriptions directly determines query translation accuracy — this is the highest ROI investment in the pipeline.

    2.2 Charts

    Use three parallel channels: the underlying data table (for precise computation), textual semantics such as chart titles and axis labels (for retrieval), and the rendered image (for multimodal models to understand trends and anomalies). At retrieval time, first hit the semantic channel to locate the chart, then go back to the data channel for exact numbers as needed — avoid making the model “read numbers off an image.”

    2.3 JSON and Semi-Structured Logs

    Chunk by business entity, not byte length: treat each object as the atomic unit, using a parent-child chunk structure where child chunks serve precise recall and parent chunks provide full context. For array-type fields, preserve path information (e.g., payload.items[].amount) to support traceability and citation.

    3. Retrieval Routing: Send Different Data Through Different Channels

    A practical routing pseudocode:

    1. def route(query, catalog):
    2. hit = vector_search(query, catalog) # table catalog / chart semantic index
    3. if hit.type == "table" and needs_aggregation(query):
    4. sql = text2sql(query, hit.schema)
    5. return ("query_engine", sql) # precise data retrieval
    6. if hit.type == "chart":
    7. return ("multimodal", hit.image, hit.data)
    8. return ("vector", hit.chunks) # standard semantic recall

    Routing decisions can combine rules (presence of aggregation or comparison keywords) with a lightweight classification model — rules first, model as fallback — balancing cost and stability.

    4. Workflow Orchestration Node Design

    Splitting the pipeline into reusable nodes is the key to maintainability:

    1. Intent recognition node: distinguish “lookup,” “explanation,” “comparison,” and “trend analysis.”
    2. Metadata retrieval node: recall relevant tables and fields.
    3. Query generation and validation node: generate the query, then run syntax and permission checks; on failure, retry once with the error message attached.
    4. Data retrieval node: execute the query and return the result set with column semantics.
    5. Reranking node: rerank multi-channel retrieval results by relevance, controlling noise entering the prompt.
    6. Generation and citation node: output conclusions along with data sources (table names, fields, chart IDs) for verifiability.
    7. Fallback node: explicitly decline to answer when confidence is low, rather than fabricating numbers.

    5. Neutral Criteria for Choosing an Open-Source Solution

    Without endorsing any specific project, evaluate candidates along these dimensions: whether they support deep parsing of diverse file and table formats; whether they offer metadata/field-level semantic description capabilities; whether they can be invoked by external orchestration engines through standard interfaces; whether retrieval supports hybrid search (keyword + vector) and reranking; whether permissions and multi-tenant isolation are complete; and whether community activity and deployment complexity match your team’s operational capacity. Containerized deployment significantly reduces environment drift, but plan ahead for data volume persistence, model weight mounting, and GPU memory limits.

    If you use general-purpose cloud capabilities, you can host raw data in object storage, run inference and retrieval services on a container platform, and use logging and monitoring/alerting services to observe pipeline quality. Baidu AI Cloud offers corresponding capabilities in these general categories that can be combined for this purpose.

    6. Evaluation and Common Pitfalls

    Evaluation must be layered: at the retrieval layer, measure hit rate and metadata accuracy; at the query translation layer, measure execution success rate and result correctness; at the generation layer, measure numerical consistency and citation verifiability. Common pitfalls include: asking the model to do arithmetic in its head; missing field descriptions leading to wrong table selection; dumping the entire result set into the context in one pass, causing truncation; lacking permission filters, enabling unauthorized data access; and ignoring silent errors from inconsistent units and time-zone conventions.