提示Source是用於創建,共享和使用自然語言提示的工具包。
最近的工作表明,大型語言模型具有對新任務進行合理的零彈性概括的能力。例如,GPT-3證明了大語言模型具有強大的零和少數能力。弗蘭(Flan)和T0隨後證明,以大量多任務時尚的方式微調的預訓練的語言模型甚至更強的零擊性能。這些作品中的共同點是使用提示,該提示引起了NLP研究人員和工程師的興趣。這強調了需要創建,共享和使用自然語言提示的新工具的必要性。
提示是將示例從數據集繪製到自然語言輸入和目標輸出的示例的功能。提示庫包含越來越多的提示(我們稱為P3 : P ROMPTS的P 3)。截至2022年1月20日,P3中有170多個英語數據集的英文提示約為2'000。

提示提供了創建和共享自然語言提示的工具(請參閱如何創建提示,然後通過簡單的API使用數千個現有和新創建的提示(請參閱如何使用提示)。提示保存在獨立的結構化文件中,並以簡單的模板語言編寫,稱為Jinja。
{{premise}}
Question: Does this imply that "{{hypothesis}}"? Yes, no, or maybe? ||| {{answer_choices[labe l] }}您可以瀏覽託管版提示版中的現有提示。
如果您不打算創建新提示,則可以簡單地運行:
pip install promptsource否則,您需要在本地安裝回購:
pip install -e .要安裝promptsource模塊注意:出於穩定原因,您目前需要一個Python 3.7環境才能運行最後一步。但是,如果您只打算使用這些提示,而不是通過接口創建新提示,則可以在setup.py中刪除此約束並在本地安裝軟件包。
您可以將提示應用到來自擁抱面部數據集庫數據集的示例。
# Load an example from the datasets ag_news
> >> from datasets import load_dataset
> >> dataset = load_dataset ( "ag_news" , split = "train" )
> >> example = dataset [ 1 ]
# Load prompts for this dataset
> >> from promptsource . templates import DatasetTemplates
> >> ag_news_prompts = DatasetTemplates ( 'ag_news' )
# Print all the prompts available for this dataset. The keys of the dict are the UUIDs the uniquely identify each of the prompt, and the values are instances of `Template` which wraps prompts
> >> print ( ag_news_prompts . templates )
{ '24e44a81-a18a-42dd-a71c-5b31b2d2cb39' : < promptsource . templates . Template object at 0x7fa7aeb20350 > , '8fdc1056-1029-41a1-9c67-354fc2b8ceaf' : < promptsource . templates . Template object at 0x7fa7aeb17c10 > , '918267e0-af68-4117-892d-2dbe66a58ce9' : < promptsource . templates . Template object at 0x7fa7ac7a2310 > , '9345df33-4f23-4944-a33c-eef94e626862' : < promptsource . templates . Template object at 0x7fa7ac7a2050 > , '98534347-fff7-4c39-a795-4e69a44791f7' : < promptsource . templates . Template object at 0x7fa7ac7a1310 > , 'b401b0ee-6ffe-4a91-8e15-77ee073cd858' : < promptsource . templates . Template object at 0x7fa7ac7a12d0 > , 'cb355f33-7e8c-4455-a72b-48d315bd4f60' : < promptsource . templates . Template object at 0x7fa7ac7a1110 > }
# Select a prompt by its name
>> > prompt = ag_news_prompts [ "classify_question_first" ]
# Apply the prompt to the example
>> > result = prompt . apply ( example )
>> > print ( "INPUT: " , result [ 0 ])
INPUT : What label best describes this news article ?
Carlyle Looks Toward Commercial Aerospace ( Reuters ) Reuters - Private investment firm Carlyle Group , which has a reputation for making well - timed and occasionally controversial plays in the defense industry , has quietly placed its bets on another part of the market .
> >> print ( "TARGET: " , result [ 1 ])
TARGET : Business如果您正在尋找可用於數據集特定子集的提示,則應使用以下語法:
dataset_name , subset_name = "super_glue" , "rte"
dataset = load_dataset ( f" { dataset_name } / { subset_name } " , split = "train" )
example = dataset [ 0 ]
prompts = DatasetTemplates ( f" { dataset_name } / { subset_name } " )您還可以為其關聯數據集收集所有可用的提示:
> >> from promptsource . templates import TemplateCollection
# Get all the prompts available in PromptSource
> >> collection = TemplateCollection ()
# Print a dict where the key is the pair (dataset name, subset name)
# and the value is an instance of DatasetTemplates
> >> print ( collection . datasets_templates )
{( 'poem_sentiment' , None ): < promptsource . templates . DatasetTemplates object at 0x7fa7ac7939d0 > , ( 'common_gen' , None ): < promptsource . templates . DatasetTemplates object at 0x7fa7ac795410 > , ( 'anli' , None ): < promptsource . templates . DatasetTemplates object at 0x7fa7ac794590 > , ( 'cc_news' , None ): < promptsource . templates . DatasetTemplates object at 0x7fa7ac798a90 > , ( 'craigslist_bargains' , None ): < promptsource . templates . DatasetTemplates object at 0x7fa7ac7a2c10 > ,...}您可以了解有關提示的API的更多信息,以存儲,操縱和使用文檔中的提示。
提示Source提供了基於Web的GUI,使開發人員能夠以模板語言編寫提示,並在不同示例中立即查看其輸出。
應用中有3種模式:

要在本地啟動該應用程序,請首先確保您遵循設置的步驟,從倉庫的根目錄中運行:
streamlit run promptsource/app.py您也可以在提示索的託管版本上瀏覽現有提示。請注意,託管版本禁用採購模式( streamlit run promptsource/app.py -- --read-only )。
在創建新提示之前,您應該閱讀貢獻指南,該指南逐步描述如何為提示的收集貢獻。
某些數據集不是由datasets自動處理的,並且要求用戶手動下載數據集(例如, story_cloze )。
為了處理這些數據集,我們要求用戶下載數據集並將其放入~/.cache/promptsource中。這是包含所有手動下載數據集的根目錄。
您可以使用PROMPTSOURCE_MANUAL_DATASET_DIR環境變量覆蓋此默認路徑。這應該指向根目錄。
提示和P3最初是作為開放研究的Bigscience項目的一部分而開發的,這是針對大型模型和數據集研究的為期一年的計劃。該項目的目的是在大型技術公司以外的公共環境中研究語言模型。該項目擁有來自50個國家 /地區的600名研究人員和250多家機構。
特別是,提示庫和P3是紙張多任務提示培訓的第一步,可以使零擊任務概括。
您會在此處找到官方存儲庫來重現本文的結果:https://github.com/bigscience-workshop/t-zerero。我們還發布了T0*(發音為“ T Zero”),這是一系列在P3上訓練並在論文中呈現的模型。檢查點可在此處找到。
OS X上有關Darwin的警告或錯誤:嘗試將Pyarrow降級至3.0.0。
ConnectionRefusedError:[ERRNO 61]連接拒絕:偶爾發生。嘗試重新啟動應用程序。
如果您發現P3或提示有用,請引用以下參考:
@misc { bach2022promptsource ,
title = { PromptSource: An Integrated Development Environment and Repository for Natural Language Prompts } ,
author = { Stephen H. Bach and Victor Sanh and Zheng-Xin Yong and Albert Webson and Colin Raffel and Nihal V. Nayak and Abheesht Sharma and Taewoon Kim and M Saiful Bari and Thibault Fevry and Zaid Alyafeai and Manan Dey and Andrea Santilli and Zhiqing Sun and Srulik Ben-David and Canwen Xu and Gunjan Chhablani and Han Wang and Jason Alan Fries and Maged S. Al-shaibani and Shanya Sharma and Urmish Thakker and Khalid Almubarak and Xiangru Tang and Xiangru Tang and Mike Tian-Jian Jiang and Alexander M. Rush } ,
year = { 2022 } ,
eprint = { 2202.01279 } ,
archivePrefix = { arXiv } ,
primaryClass = { cs.LG }
}