API reference#
The public surface of artefactual, grouped by role: estimators, transformers, parsing and
utilities. A detector is
artefactual.EPR or artefactual.WEPR, which score the logprob arrays artefactual.LogProbParser
turns responses into; artefactual.make_detector(k=15) chains the two. The other sections are the parts they are made of and the helpers around them.
Estimators#
Scores logprob arrays with one pooled feature, the Entropy Production Rate. |
|
Scores logprob arrays with a mean and a max per rank, the Weighted EPR. |
|
A scikit-learn Pipeline from completion responses to scores, with per-token scores. |
Transformers#
Reduce per-candidate entropy contributions to the features a calibration was fit on. |
Entropy Production Rate: the truncated entropy, averaged over tokens. |
|
Weighted EPR features: the per-rank mean over tokens, then the per-rank max. |
Pools the token axis of NaN-padded entropy contributions; the last axis is ranks. |
|
The Entropy Production Rate: one feature, epr_reduction. |
|
The Weighted EPR: a mean and a max per rank, wepr_reduction. |
|
A plain function f(x, axis) as a Pooling, named after the function. |
Subclass scoring.Pooling for a pooling of your own, or pass a plain function f(x, axis); either goes to scoring.EntropyTransformer.
Parsing#
LogProbParser, readers and validated models for the response shapes it accepts.
First pipeline step: completion responses in, a dense logprob array out. |
The rows that carry a completion, keyed by the id every stage joins on. |
|
Extract the logprob of each sampled token, ignoring the alternatives. |
|
Extract each token's top-k logprobs, one entry per sampled sequence. |
|
Every line of a Batch output file, in file order. |
|
Whether the judge said the answer was CORRECT, or None if its reply cannot be read. |
|
What the model said, or None if the payload carries no text. |
One line of an OpenAI Batch output file. |
|
The response envelope of one Batch output line. |
|
One sampled sequence of a chat completion. |
|
client.chat.completions.create(...) — one choice per sampled sequence. |
|
The assistant message a chat choice carries. |
|
What a judge said about an answer: the verdict, and why. |
|
client.responses.create(...) — one output item per sampled sequence. |
Utilities#
Protocols, the per-token score walk and mixins to build on, and the Langfuse integration.
A step that also maps its input to one feature row per token. |
|
A classifier that scores each token of a sequence itself. |
|
predict_token_proba for a classifier that builds a fitted pipeline_. |
|
Provides entropy_contributions to the transformers that reduce it. |
Per-token probabilities of class 1 through fitted (name, estimator) steps. |
Integrations#
Needs the adapters extra: pip install "artefactual[adapters]".
Scores a Langfuse trace's output and writes the result back as a trace score. |
Exceptions and warnings#
Base for all artefactual errors, so callers can catch the family. |
|
Base for all artefactual warnings (subclass of UserWarning → shown by default, filterable). |
|
A sequence had no tokens; scored at the classifier baseline. |