Como los modelos de lenguaje (LMS) se utilizan para tareas cada vez más complejas, elaborar sus indicaciones se está volviendo desafiante y engorroso, especialmente cuando las tareas involucran pautas complejas o sistemas multi-LM.
PromptCoder ( procoder ) es un paquete de Python diseñado para optimizar la creación de indicaciones LM. Este paquete fácil de usar permite codificar las indicaciones de LM modularizadas al igual que la programación con Python, lo que permite la creación de sistemas de inmediato complejos e intrincados con facilidad.
Las características clave de este paquete incluyen:
Al usar el paquete procoder , desarrollamos y mantuvimos un sistema de indicaciones que tienen en total más de 20k tokens en el proyecto ToolEmu, que es un marco de emulación de herramientas basado en LM para evaluar los riesgos de los agentes de LM.
Tenga en cuenta que el paquete todavía se encuentra en sus primeras etapas y en desarrollo activo.
git clone https://github.com/dhh1995/PromptCoder
cd PromptCoder
pip install -e . El siguiente ejemplo muestra cómo usar el momento de la hora para codificar un aviso. El ejemplo usa los módulos implementados en el paquete procoder.prompt . La solicitud de salida se muestra debajo del código.
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 ))La salida del primer mensaje es:
## 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 ] .La salida del segundo mensaje es:
## 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 ] . Para obtener más ejemplos, consulte las indicaciones de herramientas que se desarrollaron utilizando el paquete procoder .