PromptCoder
1.0.0
由於語言模型(LMS)用於日益複雜的任務,因此製作提示變得充滿挑戰和麻煩,尤其是當任務涉及復雜的準則或多LM系統時。
pystcoder( procoder )是一個python軟件包,旨在簡化LM提示的創建。此用戶友好的軟件包允許編碼模塊化的LM提示,就像使用Python編程一樣,可以輕鬆地創建複雜而復雜的提示系統。
此軟件包的關鍵功能包括:
通過使用procoder軟件包,我們開發並維護了一個提示系統,該系統在TooleMu項目中總共具有超過20K令牌,這是一個基於LM的工具仿真框架,用於評估LM代理的風險。
請注意,該軟件包仍處於早期階段,並且正在積極發展。
git clone https://github.com/dhh1995/PromptCoder
cd PromptCoder
pip install -e . 下面的示例顯示瞭如何使用Inkstcoder代碼提示。該示例使用procoder.prompt軟件包中實現的模塊。輸出提示顯示在代碼下方。
from procoder . functional import format_prompt , replaced_submodule
from procoder . prompt import *
requirements = NamedBlock (
"Requirements" ,
Collection (
NamedVariable (
refname = "input_req" ,
name = "Input Requirement" ,
content = "The input should be two numbers." ,
),
NamedVariable (
refname = "output_req" ,
name = "Output Requirement" ,
content = Single (
"The output should be the sum of the two numbers."
). set_refname ( "output_req_content" ),
),
),
)
instruction = NamedBlock (
"Instruction" ,
"Write a function in {language} that satisfies the {input_req} and {output_req}." ,
)
prompt = (
Collection ( requirements , instruction )
. set_sep ( " n n " )
. set_indexing_method ( sharp2_indexing )
)
another_prompt = replaced_submodule (
prompt ,
"output_req_content" ,
Single ( "The output should be the multiplication of the two numbers." ),
)
inputs = { "language" : "python" }
print ( "First prompt:" )
print ( format_prompt ( prompt , inputs ))
print ( "" )
print ( "Second prompt:" )
print ( format_prompt ( another_prompt , inputs ))第一個提示的輸出是:
## Requirements
1 . Input Requirement: The input should be two numbers.
2 . Output Requirement: The output should be the sum of the two numbers.
## Instruction
Write a function in python that satisfies the [ Input Requirement ] and [ Output Requirement ] .第二個提示的輸出是:
## Requirements
1 . Input Requirement: The input should be two numbers.
2 . Output Requirement: The output should be the multiplication of the two numbers.
## Instruction
Write a function in python that satisfies the [ Input Requirement ] and [ Output Requirement ] .有關更多示例,請參閱使用procoder軟件包開發的工具提示。