promptimal
1.0.0
CLI快速改善您的AI提示。无需数据集。
只需提交您的提示,并描述您想要改进的内容即可。然后,提示将使用遗传算法对迭代提示进行改进,直到它比原始提示更好。 LLM评估了修改后的提示以指导该过程,但您也可以定义自己的评估功能。

> pipx install promptimal安装后,请确保将OpenAI API密钥添加到环境中:
> export OPENAI_API_KEY= " ... " 从您的终端打开工具:
> promptimal您会被要求输入您的初始提示以及要改进的内容。另外,您可以将这些输入指定为命令行参数:
> promptimal
--prompt " You will be provided with a piece of code, and your task is to explain it in a concise way. "
--improve " Summaries need to include less code references and be more high-level. "完成后,UI将在您的终端打开以监视优化过程:

您可以通过传递其他命令行参数来控制优化参数:
> promptimal --num_iters=10 --num_samples=20 --threshold=0.7num_iters :运行优化循环的迭代次数。相当于进化算法中的“世代”数量。num_samples :在每次迭代中生成的候选提示数。相当于进化算法中的“人口规模”。threshold :循环的终止阈值。如果候选提示的得分高于此阈值,则优化循环将停止。默认值为1.0。默认情况下,Pomprimal使用LLM-AS-Gudge方法(具有自一致性)来评估及时的候选人。但是为了提高性能,您可能需要根据数据集评估提示或使用其他一些评估技术。为此,首先创建一个称为evaluator.py的python文件。然后将下面的代码复制到该文件中,并定义您自己的评估功能:
import argparse
def evaluator ( prompt : str ) -> float :
# Your code goes here
# Must return value between 0 and 1
def main ():
parser = argparse . ArgumentParser ()
parser . add_argument ( "--prompt" , required = True , type = str )
args = parser . parse_args ()
score = evaluator ( args . prompt )
print ( score )
if __name__ == "__main__" :
main ()完成后,在运行Remplymal时指定evaluator.py的路径:
> promptimal --evaluator= " path/to/evaluator.py "该文件将有效地用作评估提示的脚本。