成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

【RAG】表格場景RAG怎么做?TableRAG:一種增強大規模表格理解框架

人工智能
現有結合大模型的方法通常需要將整個表格作為輸入,這會導致一些挑戰,比如位置偏差、上下文長度限制等,尤其是在處理大型表格時。

前面很多期介紹了密集文檔場景的RAG方法,今天來看看大量表格場景的RAG怎么做的。

現有結合大模型的方法通常需要將整個表格作為輸入,這會導致一些挑戰,比如位置偏差、上下文長度限制等,尤其是在處理大型表格時。為了解決這些問題,文章提出了TableRAG框架,該框架利用查詢擴展結合模式和單元格檢索,以在向LLM提供信息之前精確定位關鍵信息。這種方法能夠更高效地編碼數據和精確檢索,顯著減少提示長度并減輕信息丟失。

圖片表提示技術在LLM中的應用比較

(a) Read Table

語言模型讀取整個表格。這是最直接的方法,但往往不可行,因為大型表格會超出模型的處理能力。陰影區域表示提供給語言模型的數據,包括所有行和列。對于大型表格,這種方法不現實,因為會超過模型的令牌限制。

(b) Read Schema

語言模型只讀取表格的模式(schema),即列名和數據類型。只包含列名和數據類型的信息,不包含表格內容的具體信息。這種方法會導致表格內容的信息丟失。

(c) Row-Column Retrieval

對行和列進行編碼,然后根據它們與問題的相似性進行選擇。只有行和列的交集被呈現給語言模型。 編碼后,基于與問題的相關性選擇行和列。 對于大型表格,編碼所有行和列仍然不可行。

(d) Schema-Cell Retrieval (Ours)

編碼列名和單元格,并根據它們與語言模型生成的關于問題查詢的相關性進行檢索。只有檢索到的模式和單元格提供給語言模型。 包括檢索到的列名和單元格值。 提高了編碼和推理的效率。

(e) Retrieval Performance on ArcadeQA

展示了在 ArcadeQA 數據集上不同方法的檢索結果。TableRAG 在列和單元格檢索方面都優于其他方法,從而提高了后續表格推理過程的性能。

方法

TableRAG ExampleTableRAG Example

核心思想是結合模式檢索和單元格檢索,獲得解決問題的必要信息,通過程序輔助的LLM。實際上,沒必要將整個表格給LLM。相反,關鍵信息通常位于與問題直接相關的特定列名、數據類型和單元格值中。例如,考慮一個問題“錢包的平均價格是多少?”為了解決這個問題,程序可能只需要提取與“錢包”相關的行,然后從價格列計算平均值。僅知道相關列名以及表中“錢包”的表示方式就足以編寫程序。因此,TableRAG解決了RAG的上下文長度限制。

圖片圖片

TableRAG流程圖:表格被用來構建Schema和單元格數據庫。然后通過LLM將問題擴展成多個模式和單元格查詢。這些查詢依次用于Schema檢索和列-單元格對。每個查詢的前K個候選項被組合起來,輸入到LLM求解器的提示中以回答問題。

TableRAG核心組件

  • Tabular Query Expansion(表格查詢擴展)
    為了有效地操作表格,關鍵是要精確地找出查詢所需的列名和單元格值。與之前的方法不同,TableRAG 不僅使用問題本身作為單一查詢,而是為模式和單元格值生成單獨的查詢。例如,對于問題 "What is the average price for wallets?",模型被提示生成針對列名(如 "product" 和 "price")以及相關單元格值(如 "wallet")的潛在查詢。然后,這些查詢被用來從表格中檢索相關的模式和單元格值。
  • Schema Retrieval(Schema檢索)
    在生成查詢后,Schema檢索會使用預訓練的編碼器 fenc 來獲取相關的列名。編碼器將查詢與編碼的列名進行匹配,以確定相關性。檢索到的模式數據包括列名、數據類型和示例值。對于被識別為數值或日期時間類型的列,會顯示最小值和最大值作為示例值;對于分類列,會展示三個最常見的類別作為示例值。通過這種方式,檢索到的模式為表格的格式和內容提供了結構化的概覽,這將用于更有針對性的數據提取。
    相關prompt如下:
========================================= Prompt =========================================
Given a large table regarding "amazon seller order status prediction orders data", I want
to answer a question: "What is the average price for leather wallets?"
Since I cannot view the table directly, please suggest some column names that might contain
the necessary data to answer this question.
Please answer with a list of column names in JSON format without any additional explanation
.
Example:
["column1", "column2", "column3"]
======================================= Completion =======================================
["product_name", "category", "price"]
  • Cell Retrieval(單元格檢索)
    在Schema檢索之后,進行單元格檢索以提取回答查詢所需的特定單元格值。這涉及到構建一個由表格 T 中的不同列-值對組成的數據庫,表示為 $ V = {(C_j, v_{ij})} $,其中 $ C_j $ 是第 $ j $ 列的列名。在實踐中,不同值的數量通常遠小于單元格的總數,這顯著提高了單元格檢索的效率。
    單元格檢索在 TableRAG 中起著至關重要的作用:
    相關prompt如下:
========================================= Prompt =========================================
Given a large table regarding "amazon seller order status prediction orders data", I want
to answer a question: "What is the average price for leather wallets?"
Please extract some keywords which might appear in the table cells and help answer the
question.
The keywords should be categorical values rather than numerical values.
The keywords should be contained in the question.
Please answer with a list of keywords in JSON format without any additional explanation.
Example:
["keyword1", "keyword2", "keyword3"]
======================================= Completion =======================================
["leather wallets", "average price", "amazon seller", "order status prediction", "orders
data"]
  1. 單元格識別:它允許語言模型準確地檢測表格中特定關鍵詞的存在,這對于有效的索引至關重要。
  2. 單元格-列關聯:它還使語言模型能夠將特定單元格與其相關的列名關聯起來,這在問題涉及特定屬性時至關重要。
  • Cell Retrieval with Encoding Budget
    在最壞的情況下,不同值的數量可能與單元格的總數相匹配。為了保持 TableRAG 在這種情況下的可行性,引入了一個單元格編碼預算$ B $。如果不同值的數量超過$ B $,編碼過程將限制在出現頻率最高的 $ B $ 對,從而在處理大型表格時提高效率。
  • Program-Aided Solver(程序輔助求解器)
    在獲得與問題相關的列名和單元格值后,語言模型可以使用這些信息有效地與表格交互。TableRAG 與可以以編程方式與表格交互的語言模型代理兼容。在這項工作中,作者考慮了 ReAct,這是一種流行的擴展語言模型功能的方法,已在最近的文獻中用于在表格 QA 基準測試中取得最先進的結果。
    相關prompt如下:
========================================= Prompt =========================================
You are working with a pandas dataframe regarding "amazon seller order status prediction
orders data" in Python. The name of the dataframe is ‘df‘. Your task is to use ‘
python_repl_ast‘ to answer the question: "What is the average price for leather wallets?"
Tool description:
- ‘python_repl_ast‘: A Python interactive shell. Use this to execute python commands. Input
should be a valid single line python command.
Since you cannot view the table directly, here are some schemas and cell values retrieved
from the table.
Schema Retrieval Results:
{"column_name": "item_total", "dtype": "object", "cell_examples": [’$449.00’, ’$399.00’, ’
$549.00’]}
{"column_name": "quantity", "dtype": "int64", "min": 1, "max": 4}
{"column_name": "order_no", "dtype": "object", "cell_examples": [’402-4845680-8041921’,
’405-9763961-5211537’, ’404-3964908-7850720’]}
...
Cell Retrieval Queries: leather wallets, average price, order status, prediction, amazon
seller
Cell Retrieval Results:
{"column_name": "order_status", "cell_value": "Delivered to buyer"}
{"column_name": "description", "cell_value": "Pure Leather Camel Color Gent’s Wallet with
Coin Compartment and Card Holders | Men’s Ultra Slim Money Organiser (1 pc)"}
...
Strictly follow the given format to respond:
Thought: you should always think about what to do
Action: the single line Python command to execute
Observation: the result of the action
... (this Thought/Action/Observation can repeat N times)
Thought: before giving the final answer, you should think about the observations
Final Answer: the final answer to the original input question (Answer1, Answer2, ...)
Notes:
- Do not use markdown or any other formatting in your responses.
- Ensure the last line is only "Final Answer: Answer1, Answer2, ..." form, no other form.
- Directly output the Final Answer rather than outputting by Python.
- Ensure to have a concluding thought that verifies the table, observations and the
question before giving the final answer.
Now, given a table regarding "amazon seller order status prediction orders data", please
use ‘python_repl_ast‘ with the column names and cell values above to answer the question: "
What is the average price for leather wallets?"
Begin!
======================================= Completion =======================================
Thought: I need to remove the comma in the item_total values before converting them to
float.
Action: df[’item_total’] = df[’item_total’].str.replace(’$’,’’).str.replace(’,’,’’).astype(
float)
Observation: success!
Thought: Now, I can filter out the rows with leather wallets and calculate the average
price.
Action: df[df[’description’].str.contains(’wallet’, case=False)][’item_total’].mean()
Observation: 442.7916666666667
Thought: before giving the final answer, I should consider the observations and ensure that
the calculations are accurate.
Final Answer: The average price for leather wallets is $442.79.

實驗結果

數據集:為了驗證TableRAG在大規模表格上的可擴展性,作者構建了兩個新的基準數據集:ArcadeQA和BirdQA,分別源自Arcade和BIRD-SQL數據集。此外,作者還從TabFact數據集中生成了合成數據,將表格擴展到更大的規模。

并且比較了四種不同的方法,包括ReadTable、ReadSchema、RandRowSampling和RowColRetrieval。所有方法都基于相同的PyReAct求解器實現。

圖片圖片

圖片圖片

圖片圖片

圖片

TableRAG的檢索設計顯著減少了計算成本和token使用,同時保持了高性能。

參考文獻

TableRAG: Million-Token Table Understanding with Language Models,https://arxiv.org/abs/2410.04739v1

責任編輯:武曉燕 來源: 大模型自然語言處理
相關推薦

2024-01-31 13:49:00

敏捷測試SIT開發

2023-06-25 12:42:00

2024-04-30 16:17:34

RAGLLM

2024-08-30 11:27:55

父文檔檢索RAG技術人工智能

2025-02-06 11:20:00

開發工具AI

2025-04-27 00:30:00

RAG檢索增強生成AI

2024-07-31 14:07:00

RAGSQL技術

2025-02-17 03:00:00

RAG開源DeepSeek

2023-10-14 17:46:17

RAG提示工程GPT-3

2025-04-01 09:25:09

2025-04-29 09:15:49

AI數據模型

2025-02-06 13:50:06

2025-05-20 06:00:00

AI人工智能RAG

2024-06-24 14:32:33

2025-04-24 01:10:00

RAGAI人工智能

2024-10-17 09:09:04

2023-10-31 16:37:55

大型語言模型人工智能

2024-10-31 14:46:31

2024-11-19 13:05:40

2024-09-29 10:58:56

點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 日韩天堂av | 91精品国产色综合久久不卡98 | 亚洲一区二区三区免费 | 香蕉视频久久久 | 欧洲精品码一区二区三区免费看 | 欧美精品久久久 | 欧美成人激情 | 欧美一区二区三区精品 | 久久1区| 免费一区 | 久久综合九色综合欧美狠狠 | 色视频在线免费观看 | 亚洲一区二区三区久久久 | 国产99精品 | 欧美日韩久久久 | 成人国产在线视频 | 欧美黑人一级爽快片淫片高清 | 国外成人在线视频网站 | 91大神xh98xh系列全部 | 欧美精品乱码久久久久久按摩 | 国产日韩欧美 | 色婷婷亚洲国产女人的天堂 | 91影库 | 国产欧美精品一区二区三区 | 久久国产精品一区 | h视频在线观看免费 | 国产精品嫩草影院精东 | 欧美在线视频一区二区 | 国产在线观看 | 日韩在线免费播放 | 欧美日本一区二区 | 久久久国产精品视频 | 麻豆国产一区二区三区四区 | 久久久久久久久久久久一区二区 | 亚洲成人中文字幕 | 91久久久www播放日本观看 | 台湾av在线 | 日韩精品1区2区3区 爱爱综合网 | 亚洲精品一区二区 | 视频精品一区二区三区 | 欧美一区二区三区在线观看 |