•✅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等)。
from promptify importPrompter,OpenAI,Pipelinesentence ="""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"}]👉 整理干净的结构化输出,准确分类,还能归属到临床科室。节省大量人工标注时间。
from promptify importOpenAI,Promptersentence ="""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'}]👉 非常适合做医疗知识图谱、自动病例标签系统等。
from promptify importOpenAI,Promptersentence ="""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做到了这几点:
✅ 节省脑力:告别 prompt 拼命调试
✅ 模板灵活:支持自定义任务模版
✅ 多模型兼容:OpenAI、Hugging Face 都能跑
✅ 任务多样:从医学到创意写作都能驾驭
✅ 快速上手:几行代码就能跑结果
Promptify 是所有在 NLP 路上摸索的开发者的贴心助手。无论你做的是实体提取、文本分类、还是生成问题,它都能一站式搞定。
推荐给:
•数据科学家•医疗 NLP 工程师•教育/创作者•AI 初学者
小伙伴们,可以尝试下,按照你工作、生活中所使用的提示词,把这些都管理起来,作为自己的资源。
| 欢迎光临 链载Ai (https://www.lianzai.com/) | Powered by Discuz! X3.5 |