Excel RAG:保留单元格上下文与公式以还原事实
An Excel value needs its worksheet context before it becomes a RAG fact
做结构化数据 RAG 的同学必看,这篇直接指出了 Excel 解析中常见的上下文丢失陷阱,并给出了保留公式和元数据的可落地方案。
Suppose Forecast!F22 contains 180. The column header says “FY2027, USD thousands,” the row says “Contractor costs,” and the formula is =F20+F21.
假设 Forecast!F22 包含数值 180。列标题为“FY2027, USD thousands”(2027财年,千美元),行标签为“Contractor costs”(承包商成本),公式为 =F20+F21。
A retrieved chunk containing only Contractor costs: 180 has lost most of the fact. It could make the writer report $180 of actual spending instead of a $180,000 forecast.
一个仅包含“承包商成本:180”的检索片段丢失了大部分事实。它可能导致撰写者报告 180 美元的實際支出,而非 180,000 美元的预测值。
For an Excel ingestion pipeline, keep the source workbook, sheet and cell address with the value and formula. Carry the relevant row and column headers into the evidence passed to the writer, including the unit, period and actual/forecast status. Those labels may need human confirmation when the workbook is ambiguous.
对于 Excel 数据摄入管道,应保留带有值和公式的源工作簿、工作表及单元格地址。将相关的行和列标题(包括单位、期间以及实际/预测状态)带入传递给撰写器的证据中。当工作簿存在歧义时,这些标签可能需要人工确认。
Univer is useful for the structured-reading part: its spreadsheet model stores cell values and formulas separately, and range APIs let the application inspect the relevant cells without turning the entire workbook into prose. If calculations need refreshing, wait for the results before treating cached values as current.
Univer 在结构化读取部分很有用:其电子表格模型将单元格值和公式分开存储,范围 API 允许应用程序检查相关单元格,而无需将整个工作簿转换为文本。如果需要刷新计算,请在将缓存值视为当前值之前等待结果。
The ingestion code still has to decide what the headers mean, normalize units and build the retrieval index.
摄入代码仍需决定标题的含义、标准化单位并构建检索索引。
The writer's evidence can then say “FY2027 forecast contractor costs: USD 180,000,” while retaining Forecast!F22 and the original formula for verification.
随后,撰写器的证据可以表述为“2027财年预测承包商成本:180,000 美元”,同时保留 Forecast!F22 和原始公式以供验证。
更进一步:量化金融体系
看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力