promptslab/提示

AIGC开源项目8个月前发布 admin
3 00

提示

提示工程,用 LLM 解决 NLP 问题,并使用 Promptify 为流行的生成模型(如 GPT、PaLM 等)轻松生成不同的 NLP 任务提示

promptslab/提示

promptslab/提示

promptslab/提示

promptslab/提示

promptslab/提示

    

promptslab/提示

安装

用点子

该存储库在 Python 3.7+、openai 0.25+ 上进行了测试。

您应该使用 Pip 命令安装 Promptify

pip3 install promptify

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

快速浏览

为了立即将 LLM 模型用于您的 NLP 任务,我们提供了 API。Pipeline

from promptify import Prompter,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(api_key) # or `HubModel()` for Huggingface-based inference or 'Azure' etc
prompter     = Prompter('ner.jinja') # select a template or provide custom template
pipe         = Pipeline(prompter , model)


result = pipe.fit(sentence, domain="medical", labels=None)


### Output

[
    {"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"},
]
 

promptslab/提示

promptslab/提示

promptslab/提示

GPT-3 Example with NER, MultiLabel, Question Generation Task

Features 🎮

  • Perform NLP tasks (such as NER and classification) in just 2 lines of code, with no training data required
  • Easily add one shot, two shot, or few shot examples to the prompt
  • Handling out-of-bounds prediction from LLMS (GPT, t5, etc.)
  • Output always provided as a Python object (e.g. list, dictionary) for easy parsing and filtering. This is a major advantage over LLMs generated output, whose unstructured and raw output makes it difficult to use in business or other applications.
  • Custom examples and samples can be easily added to the prompt
  • 🤗 Run inference on any model stored on the Huggingface Hub (see notebook guide).
  • Optimized prompts to reduce OpenAI token costs (coming soon)

Supporting wide-range of Prompt-Based NLP tasks :

任务名称Colab 笔记本地位
命名实体识别GPT-3 的 NER 示例
多标签文本分类GPT-3 的分类示例
多类文本分类GPT-3 的分类示例
二进制文本分类GPT-3 的分类示例
问答GPT-3 的 QA 任务示例
问答生成GPT-3 的 QA 任务示例
关系提取使用 GPT-3 的关系提取示例
综述使用 GPT-3 的总结任务示例
解释使用 GPT-3 的解释任务示例
SQL 编写器使用 GPT-3 的 SQL 编写器示例
表格数据
图像数据
更多提示

文档

提示文档

社区

如果你对Prompt-Engineering、LLMs、ChatGPT等最新研究讨论感兴趣,请考虑加入PromptsLab

promptslab/提示


@misc{Promptify2022,
  title = {Promptify: Structured Output from LLMs},
  author = {Pal, Ankit},
  year = {2022},
  howpublished = {\url{https://github.com/promptslab/Promptify}},
  note = {Prompt-Engineering components for NLP tasks in Python}
}

© 版权声明

Warning: Trying to access array offset on value of type bool in /www/wwwroot/ainvp.com/wp-content/themes/onenav/inc/clipimage.php on line 34

Warning: Trying to access array offset on value of type bool in /www/wwwroot/ainvp.com/wp-content/themes/onenav/inc/clipimage.php on line 34

相关文章