字节笔记本

2026年2月23日

Improve-Your-Prompt:使用元提示技术优化你的 Prompt

本文介绍 Improve-Your-Prompt,一个用于优化 Prompt 的开源工具项目。该项目利用"元提示"技术,通过高智能模型来优化低智能模型的提示词,帮助用户获得更好的 AI 回复效果。

项目简介

Improve-Your-Prompt 是一个基于 Python 开发的开源项目,由 XiaomingX 创建维护。该项目在 GitHub 上已获得 44 stars,采用 Apache-2.0 许可证开源。

什么是"元提示"?它是一种利用更智能的语言模型来生成或改进提示的技术。通常,这种优化过程会使用一个高智能模型来优化一个低智能模型的提示,目的是通过结构化和优化提示,使得生成的结果更为有效、相关。

核心特性

  • 元提示优化:利用高级语言模型优化低级别模型的 Prompt
  • 人设自动生成:根据用户问题自动生成专业的 Agent 角色描述
  • 简单易用:提供命令行工具和代码调用两种方式
  • Python 3.11+ 支持:使用现代 Python 特性开发
  • uv 依赖管理:采用 Astral 的 uv 工具进行高效的依赖管理

技术栈

  • Python 3.11+ - 主要编程语言
  • uv - 现代化的 Python 包管理工具
  • pyproject.toml - 现代 Python 项目配置

安装指南

前置要求

  • Python 3.11 或更高版本
  • uv 包管理工具

安装 uv

bash
# macOS/Linux
curl -LsSf https://astral.sh/uv/install.sh | sh

安装项目依赖

bash
uv sync

快速开始

命令行运行

bash
# 使用 uv 运行
uv run python src/main.py

# 或者激活虚拟环境后运行
source .venv/bin/activate  # macOS/Linux
# 或
.venv\Scripts\activate     # Windows

python src/main.py

使用示例

人设自动生成

Improve-Your-Prompt 的核心功能是自动生成适合回答特定问题的 Agent 人设描述。以下是一个示例模板:

text
For each instruction, write a high-quality description about the most capable and suitable agent to answer the instruction. In second person perspective.

[Instruction]: Make a list of 5 possible effects of deforestation.
[Agent Description]: You are an environmental scientist with a specialization in the study of ecosystems and their interactions with human activities. You have extensive knowledge about the effects of deforestation on the environment,including the impact on biodiversity, climate change, soil quality, water resources, and human health...

[Instruction]: {question}
[Agent Description]:

使用步骤

  1. 第一步:将用户问题粘贴替换 {question},生成 SystemPrompt
  2. 第二步:SystemPrompt 填写生成的内容,然后 user 部分填写用户问题
  3. 第三步:得到更好的答案

示例人设

小说家

You are a talented novelist with a flair for storytelling and a deep understanding of narrative techniques. You possess an imaginative mind that allows you to create intricate plots and compelling characters...

改写专家

You are a skilled editor and writer, proficient in the art of rewriting and refining texts for clarity, impact, and audience engagement...

中文翻译专家

你是一位精通中文翻译和写作的专家,拥有深厚的语言知识和丰富的翻译经验。你对中文语法、措辞及文化背景有着深入理解...

工作原理

Improve-Your-Prompt 基于以下核心理念:

  1. 角色专业化:为特定任务生成最合适的专家角色描述
  2. 上下文优化:通过结构化提示提升模型理解能力
  3. 效果增强:优化后的提示能引导模型产生更高质量的输出

项目链接

总结

Improve-Your-Prompt 是一个实用的 Prompt 优化工具,特别适合需要频繁与 AI 模型交互的开发者。通过自动生成专业的 Agent 人设描述,它能显著提升 AI 回复的质量和相关性。项目代码简洁,易于上手,是 Prompt Engineering 领域的优秀开源工具。

分享: