Git Product home page Git Product logo

quality-prompts's Introduction

Write Quality Prompts

Use and evaluate prompting techniques quickly.

QualityPrompts implements 58 prompting techniques explained in this survey from OpenAI, Microsoft, et al.

1. Install Quality Prompts:

pip install quality-prompts

2. Write the components of your prompt

from quality_prompts.prompt import QualityPrompt

directive = "You are given a document and your task..."
additional_information = "In the knowledge graph, ..."
output_formatting = "You will respond with a knowledge graph in..."

prompt = QualityPrompt(
                        directive,
                        additional_information,
                        output_formatting,
                        exemplar_store
                       )

3. QualityPrompts searches and uses only the few-shot examples that are relevant to the user's query

input_text = "list the disorders included in cvd"
prompt.few_shot(input_text=input_text, n_shots=1)

4. Simply call one of several prompting techniques to your prompt

System2Attention

Helps clarify the given context as an additinoal step before it's used to answer the question

prompt.system2attention(input_text)
print(prompt.compile())
>> You are given a document and your task is to create a knowledge graph from it.
        
In the knowledge graph, entities such as people, places, objects, institutions, topics, ideas, etc. are represented as nodes.
Whereas the relationships and actions between them are represented as edges.

Example input: Cardiovascular disease (CVD) encompasses a spectrum of...
Example output: [{'entity': 'cardiovascular disease (cvd)', 'connections': ...

You will respond with a knowledge graph in the given JSON format:

[
    {"entity" : "Entity_name", "connections" : [
        {"entity" : "Connected_entity_1", "relationship" : "Relationship_with_connected_entity_1},
        {"entity" : "Connected_entity_2", "relationship" : "Relationship_with_connected_entity_2},
        ]
    },
]

Tabular Chain of Thought Prompting

Prompts the LLM to think step by step and write the step, process and result of each step in a markdown table. Significantly boosts accuracy in solving math problems.

prompt.tabular_chain_of_thought_prompting(input_text=input_text)
print(prompt.compile())
Solve the given math problem.
Think through the problem step by step to solve it.
At each step, you have to figure out:
- the step number,
- the sub-question to be answered in that step,
- the thought process of solving that step, and
- the result of solving that step.
Respond in the following markdown table format for each step:
|step|subquestion|process|result|    

6. Upcoming: Easily evaluate different prompting techniques

Star History

Star History Chart

To stay updated on the latest features and prompting techniques added to the library, you can star this repo.

quality-prompts's People

Contributors

sarthakrastogi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.