支持私有化部署
AI知识库

53AI知识库

学习大模型的前沿技术与行业应用场景


提示词管理神器:Promptify

发布日期:2025-06-25 08:39:02 浏览次数: 1543
作者:AI大模型观察站

微信搜一搜,关注“AI大模型观察站”

推荐语

告别繁琐的prompt调试,Promptify让你用几行代码轻松驾驭大语言模型!

核心内容:
1. Promptify三大核心组件:Prompter、LLM接口和Pipeline
2. 安装方法与API密钥配置指南
3. 医学实体识别等实际应用案例演示

杨芳贤
53AI创始人/腾讯云(TVP)最具价值专家

Promptify 是一个Python库这款 Python 库通过 prompter、LLM 集成与 pipeline,把原本要反复调试 prompt 的过程简化成几行代码。

Github地址:https://github.com/promptslab/Promptify

本文将通过简单示例,带你了解 Promptify 为什么能成为 NLP 工具链中的“呼吸一口新鲜空气”。

欢迎大家关注公众号:AI大模型观察站,谢谢啦~~~~~



Promptify 是什么?

假设你有一段文本,比如一份小说片段,想提取关键词、进行分类、生成问题。

通常你得构造复杂的 prompt,反复尝试才能让 LLM 给出合适结果。

Promptify 彻底改变了这一流程。

它是一个 Python 库,核心由三部分组成:

✅ Prompter:用于构建 prompt(支持内置或自定义模板)✅ LLM 接口:支持 OpenAI、PaLM、Hugging Face 等多种模型✅ Pipeline:自动将文本输入 → prompt → LLM → 输出打通

无论是关键词提取、还是生成读书问题,Promptify 都能轻松搞定。


安装方式

使用 pip 安装:

pip3 install promptify

或安装最新 GitHub 版本:

pip3 install git+https://github.com/promptslab/Promptify.git

使用前需要准备 LLM 的 API Key(如 OpenAI、DeepSeek等)。


使用示例

✅ 示例 1:提取医学实体(NER)

from promptify importPrompter,OpenAI,Pipeline
sentence ="""The patient is a 93-year-old female with a medical history of chronic right hip pain, osteoporosis, hypertension, depression, and chronic atrial fibrillation admitted for evaluation and management of severe nausea and vomiting and urinary tract infection"""
model =OpenAI("your_api_key_here")prompter =Prompter('ner.jinja')pipe =Pipeline(prompter, model)result = pipe.fit(sentence, domain="medical", labels=None)
print(result)

输出结果如下:

[{"E":"93-year-old","T":"Age"},{"E":"chronic right hip pain","T":"Medical Condition"},{"E":"osteoporosis","T":"Medical Condition"},{"E":"hypertension","T":"Medical Condition"},{"E":"depression","T":"Medical Condition"},{"E":"chronic atrial fibrillation","T":"Medical Condition"},{"E":"severe nausea and vomiting","T":"Symptom"},{"E":"urinary tract infection","T":"Medical Condition"},{"Branch":"Internal Medicine","Group":"Geriatrics"}]

👉 整理干净的结构化输出,准确分类,还能归属到临床科室。节省大量人工标注时间。


✅ 示例 2:多标签医学分类

from promptify importOpenAI,Prompter
sentence ="""The patient is a 93-year-old female with a medical history of chronic right hip pain, osteoporosis, hypertension, depression, and chronic atrial fibrillation admitted for evaluation and management of severe nausea and vomiting and urinary tract infection"""
model =OpenAI("your_api_key_here")nlp_prompter =Prompter(model)result = nlp_prompter.fit('multilabel_classification.jinja', domain='medical', text_input=sentence)
print(result)

输出如下:

[{'1':'Medicine','2':'Osteoporosis','3':'Hypertension','4':'Depression','5':'Atrial fibrillation','6':'Nausea and vomiting','7':'Urinary tract infection','branch':'Health','group':'Clinical medicine','main class':'Health'}]

👉 非常适合做医疗知识图谱、自动病例标签系统等。


✅ 示例 3:生成阅读理解题目

from promptify importOpenAI,Prompter
sentence ="""The rabbit-hole went straight on like a tunnel for some way, and then dipped suddenly down, so suddenly that Alice had not a moment to think about stopping herself before she found herself falling down a very deep well."""
model =OpenAI("your_api_key_here")nlp_prompter =Prompter(model)result = nlp_prompter.fit('qa_gen.jinja', domain='story_writing', text_input=sentence)
print(result)

输出结果:

[{'A':'Alice found herself falling down a very deep well.','Q':'What happened when Alice went down the rabbit-hole?'},{'A':'Very deep.','Q':'How deep was the well?'},{'A':'No, she did not have a moment to think.','Q':'Did Alice have time to think about stopping herself?'},{'A':'It went straight on like a tunnel.','Q':'What direction did the rabbit-hole go?'},{'A':'No, she did not expect it.','Q':'Did Alice expect to fall down a well?'}]

👉 这些问答题可以直接拿去做英文阅读理解测验,省心又省力!


为什么我推荐 Promptify?

作为一个在资深程序员(已经写了十多年的代码),我对工具的要求是“节省脑细胞 + 效果可控”。

Promptify 做到了这几点:

✅ 节省脑力:告别 prompt 拼命调试 

✅ 模板灵活:支持自定义任务模版 

✅ 多模型兼容:OpenAI、Hugging Face 都能跑

 ✅ 任务多样:从医学到创意写作都能驾驭 

✅ 快速上手:几行代码就能跑结果


结语

Promptify 是所有在 NLP 路上摸索的开发者的贴心助手。无论你做的是实体提取、文本分类、还是生成问题,它都能一站式搞定。

推荐给:

数据科学家医疗 NLP 工程师教育/创作者AI 初学者


小伙伴们,可以尝试下,按照你工作、生活中所使用的提示词,把这些都管理起来,作为自己的资源。

53AI,企业落地大模型首选服务商

产品:场景落地咨询+大模型应用平台+行业解决方案

承诺:免费场景POC验证,效果验证后签署服务协议。零风险落地应用大模型,已交付160+中大型企业

联系我们

售前咨询
186 6662 7370
预约演示
185 8882 0121

微信扫码

添加专属顾问

回到顶部

加载中...

扫码咨询