Skip to main content

No project description provided

Project description

Write Quality Prompts

Use and evaluate prompting techniques surveyed by Openai and Microsoft quickly.

1. Install Quality Prompts:

pip install quality-prompts

2. Write down few-shot examples:

from quality_prompts.prompt import QualityPrompt
from quality_prompts.exemplars import ExemplarStore, Exemplar
from quality_prompts.utils.llm import get_embedding

exemplars = [Exemplar(input="Cardiovascular disease (CVD) encompasses..."
                      label="[{"entity": "cardiovascular disease (cvd)..."
                      input_embedding=[-0.008424, 0.097374, ...]
                     ),
                     ...
            ]
exemplar_store = ExemplarStore(exemplars=exemplars)

3. Write the components of your prompt

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

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

4. Effortlessly add few-shot examples to your prompt and compile it.

input_text = "list the disorders included in cvd"
prompt.few_shot(input_text=input_text, n_shots=2)
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': ...

Example input: The epidemiological burden of cardiovascular disease underscores ...
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},
        ]
    },
]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

quality-prompts-0.0.1.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

quality_prompts-0.0.1-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file quality-prompts-0.0.1.tar.gz.

File metadata

  • Download URL: quality-prompts-0.0.1.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.9

File hashes

Hashes for quality-prompts-0.0.1.tar.gz
Algorithm Hash digest
SHA256 f337dd82f55bcadbb9543a619437aa97d828e1d1426efdfa48aae61fa5dedd95
MD5 bd341d0b2c953bab7c65edb17b28cc48
BLAKE2b-256 6cc523002070069cf771567f3cd53238984a1204988820914045e186e7952b93

See more details on using hashes here.

File details

Details for the file quality_prompts-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for quality_prompts-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5ddfeb968ac7c0f9e1183604a32a592698807dc0d76dc15f8f7a2545cf6478f9
MD5 f52ed500713112e6feb6310265254bdf
BLAKE2b-256 3628dbd86c5bb1a568d7b9456ec5acc202abf4fae05c5d89e137af5eefc0e43b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page