Convert Figma logo to code with AI

promptslab logoPromptify

Prompt Engineering | Prompt Versioning | Use GPT or other prompt based models to get structured output. Join our discord for Prompt-Engineering, LLMs and other latest research

3,189
235
3,189
60

Top Related Projects

🤗 Transformers: State-of-the-art Machine Learning for Pytorch, TensorFlow, and JAX.

34,658

DeepSpeed is a deep learning optimization library that makes distributed training and inference easy, efficient, and effective.

11,750

An open-source NLP research library, built on PyTorch.

30,331

Facebook AI Research Sequence-to-Sequence Toolkit written in Python.

37,810

TensorFlow code and pre-trained models for BERT

29,635

💫 Industrial-strength Natural Language Processing (NLP) in Python

Quick Overview

Promptify is an open-source Python library designed to streamline prompt engineering workflows. It offers a range of tools for creating, managing, and optimizing prompts for large language models, making it easier for developers to work with AI-powered applications.

Pros

  • Simplifies prompt engineering with a user-friendly API
  • Supports multiple language models, including OpenAI's GPT models
  • Offers various prompt templates and techniques for different use cases
  • Includes tools for prompt versioning and management

Cons

  • Limited documentation and examples for some advanced features
  • May require additional setup for certain language models
  • Still in active development, so some features might be unstable
  • Learning curve for users new to prompt engineering concepts

Code Examples

  1. Basic prompt generation:
from promptify import Promptify

prompter = Promptify()
prompt = prompter.text_to_prompt("Summarize this article about climate change.")
print(prompt)
  1. Using a specific prompt template:
from promptify import Promptify, PromptTemplate

template = PromptTemplate("Translate the following text to {language}: {text}")
prompter = Promptify()
prompt = prompter.from_template(template, language="French", text="Hello, world!")
print(prompt)
  1. Generating a response using OpenAI's GPT-3:
from promptify import Promptify, OpenAILanguageModel

model = OpenAILanguageModel(api_key="your_api_key")
prompter = Promptify(model=model)
response = prompter.generate("What is the capital of France?")
print(response)

Getting Started

To get started with Promptify, follow these steps:

  1. Install the library:
pip install promptify
  1. Import and initialize Promptify:
from promptify import Promptify

prompter = Promptify()
  1. Generate a simple prompt:
prompt = prompter.text_to_prompt("Write a short story about a robot.")
print(prompt)

For more advanced usage, refer to the Promptify documentation and examples in the GitHub repository.

Competitor Comparisons

🤗 Transformers: State-of-the-art Machine Learning for Pytorch, TensorFlow, and JAX.

Pros of transformers

  • Extensive library with support for a wide range of NLP tasks and models
  • Well-documented and actively maintained by a large community
  • Seamless integration with PyTorch and TensorFlow

Cons of transformers

  • Steeper learning curve due to its comprehensive nature
  • Can be resource-intensive for smaller projects or limited hardware
  • May include unnecessary features for simple prompt engineering tasks

Code Comparison

transformers:

from transformers import pipeline

classifier = pipeline("sentiment-analysis")
result = classifier("I love this product!")[0]
print(f"Label: {result['label']}, Score: {result['score']:.4f}")

Promptify:

from promptify import Promptify

prompter = Promptify()
result = prompter.classify("I love this product!", ["positive", "negative"])
print(f"Label: {result['label']}, Score: {result['score']:.4f}")

Summary

While transformers offers a comprehensive suite of NLP tools and models, Promptify focuses specifically on prompt engineering and management. transformers is better suited for complex NLP tasks and research, while Promptify may be more appropriate for projects centered around prompt-based AI interactions. The choice between the two depends on the specific requirements of your project and the level of complexity you're willing to manage.

34,658

DeepSpeed is a deep learning optimization library that makes distributed training and inference easy, efficient, and effective.

Pros of DeepSpeed

  • Highly optimized for large-scale model training and inference
  • Supports a wide range of deep learning models and architectures
  • Offers advanced features like ZeRO optimizer and pipeline parallelism

Cons of DeepSpeed

  • Steeper learning curve due to its complexity and advanced features
  • Primarily focused on performance optimization rather than prompt engineering
  • May require more setup and configuration for smaller projects

Code Comparison

DeepSpeed:

import deepspeed
model_engine, optimizer, _, _ = deepspeed.initialize(args=args,
                                                     model=model,
                                                     model_parameters=params)

Promptify:

from promptify import Prompter
prompter = Prompter()
result = prompter.fit(prompt="Translate to French: {text}", text="Hello world")

DeepSpeed focuses on distributed training and optimization, while Promptify specializes in prompt engineering and management for language models. DeepSpeed is better suited for large-scale projects requiring high performance, whereas Promptify offers a more straightforward approach for working with prompts in natural language processing tasks.

11,750

An open-source NLP research library, built on PyTorch.

Pros of AllenNLP

  • Comprehensive NLP toolkit with a wide range of pre-built models and components
  • Extensive documentation and tutorials for ease of use
  • Strong community support and regular updates

Cons of AllenNLP

  • Steeper learning curve for beginners
  • Primarily focused on research-oriented tasks
  • Requires more setup and configuration for basic tasks

Code Comparison

AllenNLP:

from allennlp.predictors.predictor import Predictor

predictor = Predictor.from_path("https://storage.googleapis.com/allennlp-public-models/bert-base-srl-2020.03.24.tar.gz")
result = predictor.predict(sentence="Did Uriah honestly think he could beat the game in under three hours?")

Promptify:

from promptify import Promptify

prompt = Promptify()
result = prompt.ask("Summarize the following text: {text}", text="Your input text here")

AllenNLP provides a more structured approach for specific NLP tasks, while Promptify offers a simpler interface for prompt-based operations. AllenNLP requires more setup but offers greater flexibility for complex NLP tasks, whereas Promptify focuses on ease of use for prompt engineering and language model interactions.

30,331

Facebook AI Research Sequence-to-Sequence Toolkit written in Python.

Pros of fairseq

  • Comprehensive toolkit for sequence modeling tasks
  • Supports a wide range of architectures and models
  • Highly optimized for performance and scalability

Cons of fairseq

  • Steeper learning curve due to its complexity
  • Requires more setup and configuration
  • May be overkill for simpler NLP tasks

Code Comparison

fairseq:

from fairseq.models.transformer import TransformerModel
en2de = TransformerModel.from_pretrained(
    '/path/to/checkpoints',
    checkpoint_file='checkpoint_best.pt',
    data_name_or_path='data-bin/wmt16_en_de_bpe32k'
)
en2de.translate('Hello world!')

Promptify:

from promptify import Promptify
p = Promptify()
prompt = "Translate the following English text to French: 'Hello world!'"
response = p.generate(prompt)
print(response)

Summary

fairseq is a powerful and versatile toolkit for sequence modeling, offering a wide range of features and optimizations. However, it comes with a steeper learning curve and more complex setup. Promptify, on the other hand, provides a simpler interface for prompt-based tasks, making it easier to use for basic NLP operations but potentially lacking the advanced capabilities of fairseq.

37,810

TensorFlow code and pre-trained models for BERT

Pros of BERT

  • Widely adopted and well-established pre-trained language model
  • Extensive documentation and community support
  • Proven performance on various NLP tasks

Cons of BERT

  • Requires more computational resources for fine-tuning
  • Less flexible for prompt engineering tasks
  • Steeper learning curve for implementation

Code Comparison

BERT:

from transformers import BertTokenizer, BertModel
tokenizer = BertTokenizer.from_pretrained('bert-base-uncased')
model = BertModel.from_pretrained('bert-base-uncased')
inputs = tokenizer("Hello, my dog is cute", return_tensors="pt")
outputs = model(**inputs)

Promptify:

from promptify import Promptify
p = Promptify()
prompt = "Summarize the following text: {text}"
result = p.fit(prompt, text="Your input text here")

BERT focuses on tokenization and model loading for general NLP tasks, while Promptify simplifies prompt engineering with a more straightforward API. BERT requires more setup but offers greater flexibility, whereas Promptify provides a more user-friendly approach for specific prompt-based tasks.

29,635

💫 Industrial-strength Natural Language Processing (NLP) in Python

Pros of spaCy

  • Mature, well-established library with extensive documentation and community support
  • Offers a wide range of NLP functionalities beyond text processing
  • Highly optimized for performance, suitable for large-scale production environments

Cons of spaCy

  • Steeper learning curve due to its comprehensive feature set
  • Requires more system resources and has a larger footprint
  • Less focused on prompt engineering and LLM-specific tasks

Code Comparison

spaCy:

import spacy

nlp = spacy.load("en_core_web_sm")
doc = nlp("Apple is looking at buying U.K. startup for $1 billion")

for ent in doc.ents:
    print(ent.text, ent.label_)

Promptify:

from promptify import Promptify

p = Promptify()
text = "Apple is looking at buying U.K. startup for $1 billion"
result = p.ner(text, "en")

print(result)

Key Differences

  • spaCy is a comprehensive NLP library, while Promptify focuses on prompt engineering and LLM interactions
  • Promptify offers a simpler API for quick implementation of NLP tasks
  • spaCy provides more granular control over NLP pipelines and models
  • Promptify is designed to work seamlessly with various LLMs and prompt-based tasks

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Promptify

Prompt Engineering, Solve NLP Problems with LLM's & Easily generate different NLP Task prompts for popular generative models like GPT, PaLM, and more with Promptify

Promptify is released under the Apache 2.0 license. PyPI version http://makeapullrequest.com Community colab

Installation

With pip

This repository is tested on Python 3.7+, openai 0.25+.

You should install Promptify using Pip command

pip3 install promptify

or

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

Quick tour

To immediately use a LLM model for your NLP task, we provide the Pipeline API.

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

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 :

Task NameColab NotebookStatus
Named Entity RecognitionNER Examples with GPT-3✅
Multi-Label Text ClassificationClassification Examples with GPT-3✅
Multi-Class Text ClassificationClassification Examples with GPT-3✅
Binary Text ClassificationClassification Examples with GPT-3✅
Question-AnsweringQA Task Examples with GPT-3✅
Question-Answer GenerationQA Task Examples with GPT-3✅
Relation-ExtractionRelation-Extraction Examples with GPT-3✅
SummarizationSummarization Task Examples with GPT-3✅
ExplanationExplanation Task Examples with GPT-3✅
SQL WriterSQL Writer Example with GPT-3✅
Tabular Data
Image Data
More Prompts

Docs

Promptify Docs

Community

If you are interested in Prompt-Engineering, LLMs, ChatGPT and other latest research discussions, please consider joining PromptsLab
Join us on Discord

@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}
}

💁 Contributing

We welcome any contributions to our open source project, including new features, improvements to infrastructure, and more comprehensive documentation. Please see the contributing guidelines