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.
input_text = "list the disorders included in cvd"
prompt.few_shot(input_text=input_text, n_shots=2)
5. Simply call a prompting technique to your prompt
prompt.system2attention(input_text)
6. Compile your prompt to use it
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.2.tar.gz
(5.3 kB
view details)
Built Distribution
File details
Details for the file quality-prompts-0.0.2.tar.gz
.
File metadata
- Download URL: quality-prompts-0.0.2.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 06e21eb346aef579775a48461bd36592187c6be2545512b64139da209a1c0de6 |
|
MD5 | 2e36b728fb2b23307a1addab2fb2c7ff |
|
BLAKE2b-256 | 2e3e700d7b4480f96a14dcb40d3312e548149db3820d32e38e6c1bac6d3d796b |
File details
Details for the file quality_prompts-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: quality_prompts-0.0.2-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d08db9169c5542470bbb803d030bfa1d34c365e59d01a3d2f681d9cd31bbebbc |
|
MD5 | 1e3c72e3bdd1e1026495e1d7ffb0ff79 |
|
BLAKE2b-256 | 180be2afb24f13284b224695644edc8980cc12ff3cce48864e0af5329becfb68 |