返回顶部
热门问答 更多热门问答
技术文章 更多技术文章

提示词管理神器:Promptify

[复制链接]
链载Ai 显示全部楼层 发表于 昨天 18:46 |阅读模式 打印 上一主题 下一主题

ingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-size: 15px;letter-spacing: 0.1em;">Promptify是一个Python库这款 Python 库通过 prompter、LLM 集成与 pipeline,把原本要反复调试 prompt 的过程简化成几行代码。

ingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-size: 15px;letter-spacing: 0.1em;">Github地址:https://github.com/promptslab/Promptify

ingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-size: 15px;letter-spacing: 0.1em;">本文将通过简单示例,带你了解Promptify为什么能成为 NLP 工具链中的“呼吸一口新鲜空气”。

ingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-size: 15px;letter-spacing: 0.1em;">欢迎大家关注公众号:AI大模型观察站,谢谢啦~~~~~

ingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-size: 15px;letter-spacing: 0.1em;">


ingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-size: 1.2em;display: table;border-bottom: 1px solid rgb(248, 57, 41);">Promptify 是什么?

ingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-size: 15px;letter-spacing: 0.1em;">假设你有一段文本,比如一份小说片段,想提取关键词、进行分类、生成问题。

ingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-size: 15px;letter-spacing: 0.1em;">通常你得构造复杂的 prompt,反复尝试才能让 LLM 给出合适结果。

ingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-size: 15px;letter-spacing: 0.1em;">Promptify彻底改变了这一流程。

ingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-size: 15px;letter-spacing: 0.1em;">它是一个 Python 库,核心由三部分组成:

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

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


安装方式

使用 pip 安装:

pip3installpromptify

或安装最新 GitHub 版本:

pip3installgit+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":"chronicrighthippain","T":"MedicalCondition"},{"E":"osteoporosis","T":"MedicalCondition"},{"E":"hypertension","T":"MedicalCondition"},{"E":"depression","T":"MedicalCondition"},{"E":"chronicatrialfibrillation","T":"MedicalCondition"},{"E":"severenauseaandvomiting","T":"Symptom"},{"E":"urinarytractinfection","T":"MedicalCondition"},{"Branch":"InternalMedicine","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':'Atrialfibrillation','6':'Nauseaandvomiting','7':'Urinarytractinfection','branch':'Health','group':'Clinicalmedicine','mainclass':'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':'Alicefoundherselffallingdownaverydeepwell.','Q':'WhathappenedwhenAlicewentdowntherabbit-hole?'},{'A':'Verydeep.','Q':'Howdeepwasthewell?'},{'A':'No,shedidnothaveamomenttothink.','Q':'DidAlicehavetimetothinkaboutstoppingherself?'},{'A':'Itwentstraightonlikeatunnel.','Q':'Whatdirectiondidtherabbit-holego?'},{'A':'No,shedidnotexpectit.','Q':'DidAliceexpecttofalldownawell?'}]

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


为什么我推荐 Promptify?

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

Promptify做到了这几点:

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

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

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

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

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


结语

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

推荐给:

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


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

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

链载AI是专业的生成式人工智能教程平台。提供Stable Diffusion、Midjourney AI绘画教程,Suno AI音乐生成指南,以及Runway、Pika等AI视频制作与动画生成实战案例。从提示词编写到参数调整,手把手助您从入门到精通。
  • 官方手机版

  • 微信公众号

  • 商务合作

  • Powered by Discuz! X3.5 | Copyright © 2025-2025. | 链载Ai
  • 桂ICP备2024021734号 | 营业执照 | |广西笔趣文化传媒有限公司|| QQ