Vald8 is a minimalist, developer-first SDK for testing LLM-powered Python functions using structured JSONL datasets.
This project has been archived.
The maintainers of this project have marked this project as archived. No new releases are expected.
Project description
๐งช Vald8 โ Lightweight Evaluation Framework for LLM Reliability
Vald8 is a minimalist, developer-first SDK for testing LLM-powered Python functions using structured JSONL datasets.
It provides a simple way to validate:
- Schema correctness
- Instruction adherence
- Reference accuracy
- Keyword / regex expectations
With optional support for LLM-as-Judge scoring.
Focus: Make LLM evaluation as easy as pytest. Nothing more. Nothing less.
Why Vald8?
If you're building with LLMs, you need a way to verify that your AI functions:
- produce valid JSON
- follow instructions consistently
- don't regress when prompts or models change
- behave consistently across environments
- meet quality thresholds before deployment
Vald8 gives you this with:
- โ One decorator
- โ One JSONL file
- โ One evaluation call
No configuration. No complexity. No over-engineering.
Install
pip install vald8
Core Concept
You decorate any LLM function:
from vald8 import vald8
@vald8(dataset="tests.jsonl")
def generate(prompt: str) -> dict:
...
Vald8 loads your dataset, runs the function against each example, and scores the results.
Running Examples
Vald8 comes with a realistic example script that demonstrates how to evaluate functions using real LLM APIs (OpenAI, Anthropic, Gemini).
Prerequisites
-
Install SDKs:
pip install openai anthropic google-generativeai
-
Set API Keys:
export OPENAI_API_KEY="your-key-here" export ANTHROPIC_API_KEY="your-key-here" export GEMINI_API_KEY="your-key-here"
Alternatively, use a
.envfile:- Copy
.env.exampleto.env:cp .env.example .env
- Edit
.envand add your API keys.
- Copy
Run the Examples
We provide specific examples for different testing scenarios:
1. Reference (Exact Match)
python examples/example_reference_openai.py
2. Summarization (Content Check)
python examples/example_summary_openai.py
3. Extraction (Schema Validation)
python examples/example_extraction_openai.py
4. Regex (Pattern Matching)
python examples/example_regex_openai.py
5. Safety (Refusal Check)
python examples/example_safety_openai.py
6. Judge (LLM Evaluation)
python examples/example_judge_openai.py
These scripts will:
- Load the evaluation dataset from
examples/eval_dataset.jsonl. - Run evaluations on the respective models.
- Output pass/fail results and success rates.
๐ JSONL Test Dataset Example
Save as tests.jsonl:
{"id": "math1", "input": "What is 2+2?", "expected": {"reference": "4"}}
{"id": "json1", "input": "Return JSON with name and age", "expected": {"schema": {"type": "object", "properties": {"name": {"type": "string"}, "age": {"type": "number"}}, "required": ["name", "age"]}}}
{"id": "hello1", "input": "Greet politely", "expected": {"contains": ["hello", "please"]}}
{"id": "regex1", "input": "Give a date", "expected": {"regex": "\d{4}-\d{2}-\d{2}" }}
Supported expectations:
1. Reference (Exact Match)
Checks if the output matches a reference string exactly (ignoring whitespace).
"expected": {"reference": "42"}
2. Contains (Keywords)
Checks if the output contains all specified keywords (case-insensitive).
"expected": {"contains": ["hello", "world"]}
3. Regex (Pattern Matching)
Checks if the output matches a regular expression.
"expected": {"regex": "^\\d{4}-\\d{2}-\\d{2}$"}
4. Schema (JSON Validation)
Validates that the output is valid JSON and conforms to a JSON Schema.
"expected": {
"schema": {
"type": "object",
"properties": {
"name": {"type": "string"},
"age": {"type": "integer"}
},
"required": ["name", "age"]
}
}
5. Safety (Harmful Content)
Checks for harmful content using a keyword list. Can be inverted.
"expected": {"safe": true}
6. Judge (LLM-as-a-Judge)
Uses an LLM to evaluate the output based on a custom prompt. Requires judge_provider to be configured.
"expected": {
"judge": {
"prompt": "Is this response polite and professional?"
}
}
โ๏ธ Configuration
Vald8 supports configuration through decorator parameters and environment variables.
Decorator Parameters
@vald8(
dataset="path/to/dataset.jsonl", # Required: Path to JSONL dataset
tests=["accuracy", "schema_fidelity"], # Optional: Metrics to evaluate (default: [])
thresholds={"accuracy": 0.9}, # Optional: Pass/fail thresholds (default: 0.8)
judge_provider="openai", # Optional: LLM judge provider
judge_model="gpt-5.1", # Optional: Judge model name
sample_size=10, # Optional: Number of examples to sample
shuffle=True, # Optional: Shuffle before sampling (default: False)
cache=True, # Optional: Cache results (default: True)
cache_dir=".vald8_cache", # Optional: Cache directory
results_dir="runs", # Optional: Results directory
fail_fast=False, # Optional: Stop on first failure (default: False)
timeout=60, # Optional: Function timeout in seconds
save_results=True, # Optional: Save detailed results (default: True)
parallel=False # Optional: Parallel execution (future)
)
Environment Variables
All configuration parameters can be set via environment variables with the VALD8_ prefix:
| Variable | Type | Description | Default |
|---|---|---|---|
VALD8_TESTS |
List | Comma-separated metrics (e.g., "accuracy,safety") |
[] |
VALD8_THRESHOLD |
Float | Global threshold for all metrics | 0.8 |
VALD8_THRESHOLD_ACCURACY |
Float | Threshold for accuracy metric | 0.8 |
VALD8_THRESHOLD_SAFETY |
Float | Threshold for safety metric | 1.0 |
VALD8_SAMPLE_SIZE |
Int | Number of examples to sample | All |
VALD8_SHUFFLE |
Bool | Shuffle examples (true/false) |
false |
VALD8_CACHE |
Bool | Enable caching | true |
VALD8_CACHE_DIR |
String | Cache directory path | .vald8_cache |
VALD8_RESULTS_DIR |
String | Results directory path | runs |
VALD8_FAIL_FAST |
Bool | Stop on first failure | false |
VALD8_TIMEOUT |
Int | Function timeout (seconds) | 60 |
Judge Configuration
For LLM-as-judge metrics (instruction_adherence, safety, custom_judge):
| Variable | Description | Default |
|---|---|---|
VALD8_JUDGE_MODEL |
Judge model name | Provider-specific |
VALD8_JUDGE_API_KEY |
Judge API key | From provider env var |
VALD8_JUDGE_BASE_URL |
Custom API base URL | Provider default |
VALD8_JUDGE_TIMEOUT |
Judge request timeout | 30 |
VALD8_JUDGE_MAX_RETRIES |
Max retry attempts | 3 |
VALD8_JUDGE_TEMPERATURE |
Judge temperature | 0.0 |
Provider API Keys:
- OpenAI:
OPENAI_API_KEY - Anthropic:
ANTHROPIC_API_KEY - Bedrock:
AWS_ACCESS_KEY_ID
๐งช Decorating an LLM Function
from vald8 import vald8
import openai
@vald8(dataset="tests.jsonl")
def generate(prompt: str) -> dict:
response = openai.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": prompt}],
response_format={"type": "json_object"}
)
return {"response": response.choices[0].message.content}
๐ Running Evaluations
results = generate.run_eval()
print("Passed:", results["passed"])
print("Success Rate:", results["summary"]["success_rate"])
print("Details saved to:", results["run_dir"])
Example output:
โ math1
โ json1
โ hello1 โ missing: please
โ regex1
Overall: 3/4 passed (75%)
๐งฑ Optional: LLM-as-Judge Scoring
Useful for long-form or fuzzy outputs.
@vald8(
dataset="tests.jsonl",
judge_provider="openai" # or "anthropic", "local"
)
def summarize(text: str) -> str:
return llm_summarize(text)
Most tests require no API calls.
CI/CD Integration
- name: Run Vald8 Tests
run: |
python -c "
from my_llm import generate
assert generate.run_eval()['passed']
"
Results Format
Each run produces:
runs/
โโโ 2025-11-21_12-01-44/
โโโ results.jsonl
โโโ summary.json
โโโ metadata.json
Configuration Options
@vald8(
dataset="tests.jsonl",
tests=["schema", "contains", "reference"],
thresholds={"success_rate": 0.9},
sample_size=None,
cache=False,
judge_provider=None,
)
All parameters are optional.
๐ Results Folder Structure
Vald8 automatically saves evaluation results in a session-based hierarchy:
runs/
โโโ 2025-11-23_a1b2c3d4/ # Session folder (date + session_id)
โโโ extract_correct/ # Function-specific results
โ โโโ results.jsonl # Detailed test results (one per line)
โ โโโ summary.json # Aggregated statistics
โ โโโ metadata.json # Run configuration and info
โ โโโ report.txt # Human-readable report
โโโ extract_incorrect/
โ โโโ ...
โโโ judge_correct/
โโโ ...
Session Grouping: All functions evaluated in the same script run share a session ID and are grouped under one master folder.
Files:
results.jsonl: Line-delimited JSON with each test resultsummary.json: Success rate, metrics, timing statsmetadata.json: Function name, config, timestampreport.txt: Formatted report with failed tests
Contributing
PRs welcome.
License
MIT License โ free and open source.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vald8-0.1.3.tar.gz.
File metadata
- Download URL: vald8-0.1.3.tar.gz
- Upload date:
- Size: 39.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1a6445f8c451d4626dfb2220e422feec6201c05bf42615ee8b54259d0bfbdd25
|
|
| MD5 |
0df602b218f8744cfc03d24700578281
|
|
| BLAKE2b-256 |
bb3404f5fbaace70da7a9c3181360ef19597ea4afeb8ef86a0f3251ed133ae34
|
File details
Details for the file vald8-0.1.3-py3-none-any.whl.
File metadata
- Download URL: vald8-0.1.3-py3-none-any.whl
- Upload date:
- Size: 36.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7374f94b6bc787ec356ef902755d6f8adf0c7148089f3a95441626c0cc86c953
|
|
| MD5 |
f1c5a7fdfe408ba2bbedfb24676e8f3b
|
|
| BLAKE2b-256 |
3575584f7a2179aa822ed14b8d28b49b509a6deb14d439ce5b37aefa03151c2e
|