Karena model bahasa (LM) digunakan untuk tugas yang semakin kompleks, membuat petunjuknya menjadi menantang dan rumit, terutama ketika tugas-tugas tersebut melibatkan pedoman yang rumit atau sistem multi-LM.
PromptCoder ( procoder ) adalah paket Python yang dirancang untuk merampingkan pembuatan prompt LM. Paket yang ramah pengguna ini memungkinkan pengkodean permintaan LM modularisasi seperti pemrograman dengan Python, memungkinkan pembuatan sistem prompt yang kompleks dan rumit dengan mudah.
Fitur utama dari paket ini meliputi:
Dengan menggunakan paket procoder , kami mengembangkan dan memelihara sistem petunjuk yang memiliki total lebih dari 20k token dalam proyek ToolEMU, yang merupakan kerangka kerja emulasi alat berbasis LM untuk menilai risiko agen LM.
Perhatikan bahwa paket masih dalam tahap awal dan di bawah pengembangan aktif.
git clone https://github.com/dhh1995/PromptCoder
cd PromptCoder
pip install -e . Contoh berikut menunjukkan cara menggunakan promptCoder untuk mengkode prompt. Contoh ini menggunakan modul yang diimplementasikan dalam paket procoder.prompt . Prompt output ditampilkan di bawah kode.
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 ))Output dari prompt pertama adalah:
## 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 ] .Output dari prompt kedua adalah:
## 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 ] . Untuk contoh lebih lanjut, silakan merujuk ke prompt ToolEMU yang dikembangkan menggunakan paket procoder .