SafeLLM4SE
SafeLLM4SE is a Python toolkit for statistically principled evaluation of LLM-based software engineering systems. It treats each LLM execution as a sample from a stochastic process, then reports quality, stability, uncertainty, resource usage, and statistical comparisons instead of relying on a single run.
The project exposes three command-line programs:
safellm4se-sample: runs adaptive sampling with a user-selected evaluator.safellm4se-report: summarizes one sampled task into a SafeLLM4SE report CSV.safellm4se-compare: compares two sampled tasks with the SafeLLM4SE comparison protocol.
Install
SafeLLM4SE is available on PyPI as safellm4se, so you only need to run:
python -m pip install safellm4se
If you want to install SafeLLM4SE from its source code, check the installation details.
Quick Start
SafeLLM4SE collects repeated observations with safellm4se-sample.
Then, it can be used to report or visualize one sample of observations with safellm4se-report,
or compare task samples with safellm4se-compare.
Sampling
First, you need to generate a sample of repeated observations.
For this purpose, safellm4se-sample loads an evaluator class and repeatedly calls it until a stopping condition is met
(maximum number of tokens consumed or the confidence interval width is below a threshold).
You commonly implement the process being measured as an evaluator,
but we provide several example evaluators, including default implementations for Ollama,
Gemini, and Groq APIs.
For this example, we perform adaptive sampling on a random evaluator:
safellm4se-sample --evaluator safellm4se.sampling.myevaluators.random_normal_evaluator
Reporting
If you have already created a sample of repeated observations with the task identifier task-id-1,
stored in output/measurements.csv,
you can create reports and visualizations with safellm4se-report.
The report includes the sample size, token usage, central tendency, variability, and confidence interval information.
The supported visualizations are boxplot, violin plot, empirical cumulative distribution function (ECDF), raincloud plot, and kernel density estimate (KDE).
safellm4se-report --input output/measurements.csv --output output/report-demo.csv --task-id task-id-1 --boxplot output/demo-boxplot.svg
Example CSV report generated with safellm4se-report:
task_id,model_name,model_id,N,total_tokens,theta_mean,sd,ci_method,ci_low,ci_high,ci_width
task-id-54,qwen-coder,qwen2.5-coder:7b,30,1178530,0.8272357723577236,0.019436705668000667,t,0.8199779871829312,0.834493557532516,0.014515570349584728
Comparing
You can also compare two samples of repeated observations with safellm4se-compare.
The report will tell you the estimated difference, confidence interval, statistical test,
p-value, and effect size.
It also generates figures comparing the two samples, including the visualizations mentioned in
reporting.
safellm4se-compare --input output/measurements.csv --output output/comparing-demo.csv --task-id-1 task-a --task-id-2 task-b --test-type paired --raincloud output/comparing-demo-raincloud.svg
Example plot generated with safellm4se-compare:
The following CSV comparison report has also been generated:
task_id_1,task_id_2,test_type,estimated_difference,ci_low,ci_high,statistical_test,p_value,effect_size_name,effect_size,effect_size_magnitude
task-id-54,task-id-56,independent,0.20833333333333337,0.19369410569105683,0.2223628048780488,Mann-Whitney U,2.8591961948613224e-11,Cliff's delta,1.0,large
Documentation
License
See LICENSE.
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 safellm4se-0.1.0.tar.gz.
File metadata
- Download URL: safellm4se-0.1.0.tar.gz
- Upload date:
- Size: 74.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ef127704f069e6bb23547f96fbc72126ec9953c014ccb128738c39d26646d33b
|
|
| MD5 |
399391046fdb12b3788781caf3371497
|
|
| BLAKE2b-256 |
b2a98c3c8b26fbeda0e52ac12ac98dfa55d720ec8e255b49aa1c532d0934d154
|
Provenance
The following attestation bundles were made for safellm4se-0.1.0.tar.gz:
Publisher:
release.yml on francisco-ortin/SafeLLM4SE
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
safellm4se-0.1.0.tar.gz -
Subject digest:
ef127704f069e6bb23547f96fbc72126ec9953c014ccb128738c39d26646d33b - Sigstore transparency entry: 2702108923
- Sigstore integration time:
-
Permalink:
francisco-ortin/SafeLLM4SE@4337a1922880dbcbce850469d9458544e98c7a9d -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/francisco-ortin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4337a1922880dbcbce850469d9458544e98c7a9d -
Trigger Event:
release
-
Statement type:
File details
Details for the file safellm4se-0.1.0-py3-none-any.whl.
File metadata
- Download URL: safellm4se-0.1.0-py3-none-any.whl
- Upload date:
- Size: 91.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a261e8ef6eb6e868e2049f44ae614b334f0f461d8e5f8b56f624edf2ab8e7963
|
|
| MD5 |
32e0e9af76abcfeb284c06d574a8515b
|
|
| BLAKE2b-256 |
e2b416ab428a4957e30a86a9b266b27e5db8f9aa26ca205c8b033b2e16256da5
|
Provenance
The following attestation bundles were made for safellm4se-0.1.0-py3-none-any.whl:
Publisher:
release.yml on francisco-ortin/SafeLLM4SE
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
safellm4se-0.1.0-py3-none-any.whl -
Subject digest:
a261e8ef6eb6e868e2049f44ae614b334f0f461d8e5f8b56f624edf2ab8e7963 - Sigstore transparency entry: 2702109265
- Sigstore integration time:
-
Permalink:
francisco-ortin/SafeLLM4SE@4337a1922880dbcbce850469d9458544e98c7a9d -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/francisco-ortin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4337a1922880dbcbce850469d9458544e98c7a9d -
Trigger Event:
release
-
Statement type: