Make sure AI model outputs are consistent
Project description
consisTent is a full blows testing framework for prompts. The goal of consisTent is to create reproducible tests for LLM based applications regardless of the FM used.
Installation
pip install consistent
Concepts
consisTent comes with 2 types of validators (testers)
syntactic validators
This type of validators is used to do static assertions of the LLM output. for example validating if the output is in a certain JSON format and assert the schema. You can also use syntactic validators to assert something is a valid piece of code (JS or Python are supported at the moment)
Syntactic validators are used to assert the FORM of the response
example
consisTent.JsValidator().validate('console.log("Im a JS program!")')
consisTent.PyValidator().validate('print("Im a python program!")')
consisTent.JsonValidator().validate('"question": {"is this a valid JSON?"}')
syntactic validators
This type of validators is used to assert the quality of the response with more "soft" parameters for example, check if something is factually correct, check for hallucinations, check for labels like "funny"/"interesting" etc... another type of semantic validator is the semantic consistency validator where you provide a seed of validated input and a threshold, and the test will assert the semantic distance of the new output from the seed cluster.
Semantic validators are used to assert the CONTENT of the response
example
import consisTent
seed = [
"the cat sat on the mat",
"the feline layed on the carpet",
]
consisTent.ConsistencyValidator(
seed_size=2,
consistency_threshold=0.5,
).validate(
seed=seed,
model_output="the dog sat on the mat",
)
Label Test
OPENAI_KEY = "XXXXXXXXXXXXXXX"
consisTent.LabelsValidator(openai_key=OPENAI_KEY).validate(
labels=[
"funny",
"short",
"about rabbits",
],
model_output="What do you call a rabbit that tells jokes? A funny bunny!",
)
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
Built Distribution
File details
Details for the file consistent-0.0.7.tar.gz
.
File metadata
- Download URL: consistent-0.0.7.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 071454bcbd82b7be1535225a684f57466e9a324cb43f290b42df9ac7951bd3ac |
|
MD5 | 9e9239e41b542fed16ac468851a17b33 |
|
BLAKE2b-256 | 601e40385f41419467def4db454240f4daebe9011a2fc6cb1d3b814726b715e2 |
File details
Details for the file consistent-0.0.7-py3-none-any.whl
.
File metadata
- Download URL: consistent-0.0.7-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8dd1118db20e310d563e50e0f64c286b67e0b8184f66ac574bd4947f77b9081f |
|
MD5 | bb5de14c924c46e24590e21fb4070304 |
|
BLAKE2b-256 | 1a697b5f17371b8ef2eab9c4920d8ea70c55c01ef334007b23a03f88f4bbd31c |