Langchain创始人新项目Auto-Prompt Builder一键优化你的Prompt,再也不担心写不好Prompt了

增长营销数据中台云原生可观测

picture.image

大模型Prompt的重要性越来越受到重视,有关prompt engineering相关的技术一箩筐,在前面的文章里《 一文探秘LLM应用开发(21)-Prompt(编写技巧) 》有提到过OpenAI 官方推荐的最佳编写方法,也有大家经过实践总结的编写技巧。然而,这些理论对于prompt编写实操来讲,还是有些太重,做不到及时和灵活应用。

有没有这样一款工具,能够把用户的prompt进行优化改写以便达到最佳效果呢?曾经,笔者推荐过jinaAI开发的一款产品PromptPefect,它就能达到这样的目的,但是 它是一款完整的产品,覆盖了prompt编写到应用服务的全过程,但对于开发者来讲,不太利于集成。现介绍另一款新的工具供大家参考,它是langchain创始人 Harrison Chase最新 开发的一个能力纯粹的开源项目 auto-openai-prompte r,其核心思路 是将OpenAI的Prompt优化原则提交给GPT,然后让GPT-4帮助你优化prompt,可谓是用魔法打败魔法。

picture.image

项目地址:https://github.com/hwchase17/auto-openai-prompter

整个实现非常简洁巧妙,他这样的编程思路相较于这一项目本身来讲更值得学习,如何改变编程惯性,用好大模型,是AI 2.0时代程序员脱颖而出的关键。

这是其中一段源码:


          
Prompt engineering
          
This guide shares strategies and tactics for getting better results from large language models (sometimes referred to as GPT models) like GPT-4. The methods described here can sometimes be deployed in combination for greater effect. We encourage experimentation to find the methods that work best for you.
          

          
Some of the examples demonstrated here currently work only with our most capable model, gpt-4. In general, if you find that a model fails at a task and a more capable model is available, it's often worth trying again with the more capable model.
          

          
You can also explore example prompts which showcase what our models are capable of:
          

          
Prompt examples
          
Explore prompt examples to learn what GPT models can do
          
Six strategies for getting better results
          
Write clear instructions
          
These models can’t read your mind. If outputs are too long, ask for brief replies. If outputs are too simple, ask for expert-level writing. If you dislike the format, demonstrate the format you’d like to see. The less the model has to guess at what you want, the more likely you’ll get it.
          

          
Tactics:
          

          
Include details in your query to get more relevant answers
          
Ask the model to adopt a persona
          
Use delimiters to clearly indicate distinct parts of the input
          
Specify the steps required to complete a task
          
Provide examples
          
Specify the desired length of the output
          
Provide reference text
          
Language models can confidently invent fake answers, especially when asked about esoteric topics or for citations and URLs. In the same way that a sheet of notes can help a student do better on a test, providing reference text to these models can help in answering with fewer fabrications.
          
...
      

          
template = """Based on the following instrutions, help me write a good prompt TEMPLATE for the following task:
          

          
{task}
          

          
Notably, this prompt TEMPLATE expects that additional information will be provided by the end user of the prompt you are writing. For the piece(s) of information that they are expected to provide, please write the prompt in a format where they can be formatted into as if a Python f-string.
          

          
When you have enough information to create a good prompt, return the prompt in the following format:\n\n```prompt\n\n...\n\n```
          

          
Instructions for a good prompt:
          

          
{instructions}
          
"""
      

Harr ison Chase还专门录制了视频,给大家介绍这款工具。

笔者简单测试:

picture.image

感兴趣的读者可以直接点此尝试:https://openai-prompting-helper-e924c62387f55170bc7836f9f-ffoprvkqsa-uc.a.run.app/auto-prompter/playground/

0
0
0
0
关于作者
关于作者

文章

0

获赞

0

收藏

0

相关资源
vivo 容器化平台架构与核心能力建设实践
为了实现规模化降本提效的目标,vivo 确定了基于云原生理念构建容器化生态的目标。在容器化生态发展过程中,平台架构不断演进,并针对业务的痛点和诉求,持续完善容器化能力矩阵。本次演讲将会介绍 vivo 容器化平台及主要子系统的架构设计,并分享重点建设的容器化核心能力。
相关产品
评论
未登录
看完啦,登录分享一下感受吧~
暂无评论