天天看點

清華等開源工具學習基準ToolBench,微調模型性能超越ChatGPT

作者:新智元

編輯:LRS

【新智元導讀】工具學習的開源時代來了!

人類具有創造和利用工具的能力,使得我們可以突破身體的限制,探索更廣闊的世界。

人工智能基礎模型也類似,如果僅靠訓練階段得到的權重,使用場景就會非常受限,而最近提出的工具學習(tool learning),将特定領域的專用工具與大規模基礎模型相結合,可以實作更高的效率、性能。

不過目前工具學習的相關研究還不夠深入,也缺乏相關的開源資料和代碼。

最近,清華大學自然語言處理實驗室等支援的開源社群OpenBMB (Open Lab for Big Model Base)釋出了ToolBench項目,可以幫助開發者建構開源、大規模、高品質的指令調優資料,促進建構具有通用工具使用能力的大型語言模型。

清華等開源工具學習基準ToolBench,微調模型性能超越ChatGPT

倉庫連結:https://github.com/OpenBMB/ToolBench

ToolBench倉庫中提供了相關資料集、訓練和評估腳本,以及在ToolBench上微調的功能模型ToolLLaMA,具體特點為:

1. 支援單工具和多工具方案

其中單工具設定遵循LangChain提示風格,多工具設定遵循AutoGPT的提示風格。

2. 模型回複不僅包括最終答案,還包含模型的思維鍊過程、工具執行和工具執行結果

3. 支援真實世界級别的複雜性,支援多步工具調用

4. 豐富的API,可用于現實世界中的場景,如天氣資訊、搜尋、股票更新和PowerPoint自動化

5. 所有的資料都是由OpenAI API自動生成并由開發團隊進行過濾,資料的建立過程很容易擴充

不過需要注意的是,目前釋出的資料還不是最終版本,研究人員仍然在對資料進行後處理來提高資料品質,并增加真實世界工具的覆寫範圍。

ToolBench

ToolBench的總體思路是基于BMTools,在有監督資料中訓練大型語言模型。

清華等開源工具學習基準ToolBench,微調模型性能超越ChatGPT

倉庫中包含31.2萬次真實API調用得到的9800條資料,涵蓋單工具場景和多工具場景,下面是單工具的統計資訊。

清華等開源工具學習基準ToolBench,微調模型性能超越ChatGPT

其中每行資料都是一個json dict,包含資料建立的提示模闆、工具使用的人工指令(查詢)、中間思維/工具執行循環和最終答案。

Tool Descrition:
BMTools Tool_name: translation
Tool action: get_translation
action_input: {"text": target texts, "tgt_lang": target language}


Generated Data:
{
    "prompt": "Answer the following questions as best you can. Specifically, you have access to the following APIs:\n\nget_translation: . Your input should be a json (args json schema): {{\"text\" : string, \"tgt_lang\" : string, }} The Action to trigger this API should be get_translation and the input parameters should be a json dict string. Pay attention to the type of parameters.\n\nUse the following format:\n\nQuestion: the input question you must answer\nThought: you should always think about what to do\nAction: the action to take, should be one of [get_translation]\nAction Input: the input to the action\nObservation: the result of the action\n... (this Thought/Action/Action Input/Observation can repeat N times, max 7 times)\nThought: I now know the final answer\nFinal Answer: the final answer to the original input question\n\nBegin! Remember: (1) Follow the format, i.e,\nThought:\nAction:\nAction Input:\nObservation:\nFinal Answer:\n (2) Provide as much as useful information in your Final Answer. (3) Do not make up anything, and if your Observation has no link, DO NOT hallucihate one. (4) If you have enough information and want to stop the process, please use \nThought: I have got enough information\nFinal Answer: **your response. \n The Action: MUST be one of the following:get_translation\nQuestion: {input}\n Agent scratchpad (history actions):\n {agent_scratchpad}",
    "query": "My intention is to convert the data provided in ما هي الأقسام الثلاثة للقوات المسلحة؟ into Arabic(ara).\n",
    "chains": [
        {
            "thought": "I need to use the get_translation API to convert the text into Arabic.",
            "action": "get_translation",
            "action_input": "{\"text\": \"What are the three branches of the military?\", \"tgt_lang\": \"ara\"}",
            "observation": "\"ما هي الفروع الثلاثة للجيش ؟\""
        }
    ],
    "answer": "The translation of \"What are the three branches of the military?\" into Arabic is \"ما هي الفروع الثلاثة للجيش ؟\"."
}

           

模型實驗

機器評估:研究人員對每個工具随機抽取100個鍊步(chain steps)來建構機器評估測試平台,平均27個最終步驟和73個中間工具調用步驟,其中最終步驟的評估使用Rouge-L名額,中間步驟的評估使用ExactMatch名額進行評估。

清華等開源工具學習基準ToolBench,微調模型性能超越ChatGPT

人工評估:在天氣、地圖、股票、翻譯、化學和WolframAlpha工具中随機抽取10個query,然後評估工具調用過程的通過率、最終答案以及和ChatGPT最終答案的比較。

ChatGPT評估:通過ChatGPT對LLaMA和ChatGPT的答案和工具使用鍊進行自動評估。

評估結果如下(分數越高越好),可以看到ToolLLaMA在不同場景下與ChatGPT的性能相同或更好。

清華等開源工具學習基準ToolBench,微調模型性能超越ChatGPT

工具學習

在清華大學、人民大學、北京郵電大學等個國内外知名高校和大學聯合釋出的一篇論文中,對工具學習進行了系統的研究,介紹了工具學習的背景,包括認知起源、基礎模型的範式轉變,以及工具和模型的互補作用。

清華等開源工具學習基準ToolBench,微調模型性能超越ChatGPT

論文連結:https://arxiv.org/pdf/2304.08354.pdf

文中還回顧了現有的工具學習研究,包括工具增強型和工具導向型學習,并制定了一個通用的工具學習架構:從了解使用者指令開始,模型應該學會把一個複雜的任務分解成幾個子任務,通過推理動态地調整計劃,并通過選擇合适的工具有效地征服每個子任務。

文中還讨論了如何訓練模型以提高工具使用能力并促進工具學習的普及。

考慮到之前的工作中缺乏系統的工具學習評估,研究人員用17種有代表性的工具進行了實驗,并展示了目前基礎模型在熟練利用工具方面的潛力。

論文最後讨論了幾個需要進一步研究的工具學習的開放性問題,例如確定安全和可信賴的工具使用、用基礎模型實作工具建立,以及解決個性化的難題。

參考資料:

https://github.com/OpenBMB/ToolBench

繼續閱讀