自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

檢索感知微調(diào)(RAFT),提升領(lǐng)域RAG效果的新方法

發(fā)布于 2024-4-2 13:09
瀏覽
0收藏

一般來講,讓大模型應(yīng)用到具體的行業(yè)領(lǐng)域,那就必須讓大模型懂得行業(yè)里的知識(shí)。這種知識(shí)的導(dǎo)入一般有三種方法,一種是在預(yù)訓(xùn)練階段喂給模型一些領(lǐng)域的文檔和知識(shí),擴(kuò)充一些領(lǐng)域詞表的方式解決。而更為常用的是另外兩種做法,微調(diào)或者RAG,其中微調(diào)是以問答對的方式將領(lǐng)域知識(shí)訓(xùn)練到模型中,而RAG則是通過在Prompt中增加領(lǐng)域知識(shí)上下文的方式讓大模型獲得相關(guān)領(lǐng)域知識(shí)進(jìn)而回答領(lǐng)域問題。有一個(gè)形象的比喻是,微調(diào)的方式相當(dāng)于是閉卷考試,在Prompt中不添加任何的上下文內(nèi)容(zero-hshot),而RAG相當(dāng)于是開卷考試。雖然RAG在成本上,內(nèi)容時(shí)效性,靈活性上都優(yōu)于微調(diào),但它也同時(shí)受到兩個(gè)問題影響,一個(gè)是提供的上下文知識(shí)并不包含答案,或者是上下文知識(shí)里包含著雜亂,干擾的信息,導(dǎo)致最終導(dǎo)致無法正確回答問題。前者,在前面的RAG2.0中有提到解決思路。??(RAG 2.0來了,它能成為生產(chǎn)落地的福音嗎???)

檢索感知微調(diào)(RAFT),提升領(lǐng)域RAG效果的新方法-AI.x社區(qū)

而后者,近日伯克利大學(xué)、Meta以及微軟的研究者將RAG的思路應(yīng)用到微調(diào)領(lǐng)域,提出了RAFT(Retrieval Aware Fine-Tuning)的方法[1],該方法介于微調(diào)和RAG之間,不同于傳統(tǒng)的微調(diào)方法,樣本是采用Q->A的文檔對構(gòu)成,而RAFT中,增加了一些背景信息內(nèi)容,里面還包含了一些不相干的干擾信息,也就是說在微調(diào)過程中,就讓模型學(xué)會(huì)從干擾信息中獲得正確答案的能力。

檢索感知微調(diào)(RAFT),提升領(lǐng)域RAG效果的新方法-AI.x社區(qū)

訓(xùn)練樣本包含問題、上下文、指令、 CoT 答案和最終答案。在答案中,使用 ##begin_quote## 和 ##end_quote## 表示直接從上下文中復(fù)制粘貼的引用的開頭和結(jié)尾。這是一種防止模型產(chǎn)生幻覺并堅(jiān)持所提供上下文的有效方法。下面是一個(gè)樣本數(shù)據(jù)示例:

Question: The Oberoi family is part of a hotel company that has a head office in what city?


context: [The Oberoi family is an Indian family that is famous for its involvement in hotels, namely through The Oberoi Group]...[It is located in city center of Jakarta, near Mega Kuningan, adjacent to the sister JW Marriott Hotel. It is operated by The Ritz-Carlton Hotel Company. The complex has two towers that comprises a hotel and the Airlangga Apartment respectively]...[The Oberoi Group is a hotel company with its head office in Delhi.]


Instruction: Given the question, context and answer above, provide a logical reasoning for that answer. Please use the format of: ##Reason: {reason} ##Answer: {answer}.


CoT Answer: ##Reason: The document ##begin_quote## The Oberoi family is an Indian family that is famous for its involvement in hotels, namely through The Oberoi Group. ##end_quote## establishes that the Oberoi family is involved in the Oberoi group, and the document ##begin_quote## The Oberoi Group is a hotel company with its head office in Delhi. ##end_quote## establishes the head office of The Oberoi Group. Therefore, the Oberoi family is part of a hotel company whose head office is in Delhi. ##Answer: Delhi

這種思路是符合直覺的,研究者在Medical (PubMed), General-knowledge (HotPotQA)和API (Gorilla) 數(shù)據(jù)集上評估,RAFT性能提升明顯,在llama2-7b+RAG基礎(chǔ)上提升了14.5,超過了GPT-3.5+RAG的性能。

檢索感知微調(diào)(RAFT),提升領(lǐng)域RAG效果的新方法-AI.x社區(qū)

官方也提供了相應(yīng)的訓(xùn)練指導(dǎo)[2],包含了生成數(shù)據(jù)集,微調(diào),評估的全過程,llamaindex也實(shí)現(xiàn)了數(shù)據(jù)集生成的工具包[3],可方便對接llamaindex流程。


參考:

【1】https://arxiv.org/abs/2403.10131

【2】https://github.com/ShishirPatil/gorilla/tree/main/raft

【3】https://github.com/run-llama/llama_index/tree/main/llama-index-packs/llama-index-packs-raft-dataset

本文轉(zhuǎn)載自***,作者:

標(biāo)簽
收藏
回復(fù)
舉報(bào)
回復(fù)
相關(guān)推薦