Changelog#
Releases before the entries below are listed, with their notes, on the GitHub releases page.
Unreleased#
Changes against 2026.11.1.
Breaking#
EPRClassifieris nowEPRandWEPRClassifieris nowWEPR. The 2026.11.1EPRandWEPR, which took responses,PoolingDetector,BaseDetectorandBaseEntropyClassifierare removed.EPRandWEPRtake logprob arrays. Passing responses raises aTypeErrornamingis_logprob_array: parse first withLogProbParser(k=15).transform(responses), or usemake_detector(k=15).A
Poolingsubclass must be a@dataclasses.dataclass(frozen=True)with its parameters as fields; an undecorated subclass raisesTypeErrorwhen instantiated. An array field is declareddataclasses.field(compare=False). A pooling cannot be mutated after construction.FunctionPoolingtakes noname=: it is named after the function, and a lambda or apartialis namedpooling. Define a named function to name it.EntropyTransformerhas nok: it reads the width from the data, and a fitted one refuses another width.WEPRhas nok, andWEPR.from_pretrained(repo)takes none.EPR(k)pins the input width. An array of another width is refused withtrained on 15 candidates per token, got 10: use LogProbParser(k=15), for a loaded or clonedEPRtoo.EPR.from_pretrained(repo, k=15)still requiresk.scripts/train_detector.py --poolingtakeseprorwepronly.
Added#
make_detector(*, k, classifier=None)returns aDetectorPipeline(LogProbParser(k=k)thenclassifier,WEPR()by default): aPipelinewithpredict_token_proba, from responses to scores.token_proba(steps, X): per-token probabilities through a list of pipeline steps. Each step runstransform_tokenswhen it has one, elsetransform, and the last step’spredict_probascores each token, withNaNat padding.DetectorPipelineuses it forpredict_token_proba.TokenProbaMixin:predict_token_probafor a classifier that builds a fittedpipeline_, throughtoken_proba.EPR,WEPRand a detector of your own use it.The runtime-checkable protocols
TokenTransformerandTokenClassifier.make_detectorrefuses aclassifierwithoutpredict_token_proba, andDetectorPipelinerefuses atfita layout with no per-token step, with aTypeError.kis searchable through the parser:{"logprobparser__k": [5, 10, 15]}.The scikit-learn guide shows how to write your own detector and the advanced
make_pipelinerecipes (end to end on responses,GridSearchCV,FeatureUnion).
Changed#
from_pretrainedreturns a detector backed by aFrozenEstimator. It predicts, also afterclone, and afitkeeps the loaded weights.check_estimatorruns onEPR,WEPR,EntropyTransformerand a custom detector with no expected failure.EntropyTransformer.transform_tokenscalls the pooling on real tokens only, and returnsNaNrows at padding tokens, so a pooling built onnp.nanmedianornp.nanmeanno longer warns about all-NaNpadding windows.The docs and the example notebooks use
EPR,WEPRandmake_detectorfor basic usage, andmake_pipelineonly in the advanced section.
Fixed#
LogProbParservalidateskatfitwith scikit-learn’sInvalidParameterError.
2026.11.0#
Breaking#
predict_token_proba,EntropyTransformer.transformandtransform_tokensname their inputXinstead ofx, as scikit-learn does. Positional calls are unaffected; a call that passesx=must passX=.fitraisesValueErrorwhen the entropy step’s pooling differs from the one the class fixes, for instanceEPRClassifier(k=15).set_params(entropy__pooling=WEPRPooling()). UseWEPRClassifierinstead.EPRandWEPRtake responses only. A numeric table raisesTypeErrornamingEPRClassifierandWEPRClassifier.artefactual.preprocessing.openai_parseris removed: calltop_logprobs()andsampled_logprobs()onChatCompletionorResponsesPayload.Estimator persistence is split into
PretrainedMixin(from_pretrained, with the public override pointscached_fileandload_file) andSavePretrainedMixin(save_pretrained), importable fromartefactual.utils.ioonly. Renamed:EstimatorPersistenceMixintoPretrainedMixinandSavePretrainedMixin;save_estimatortosave_pretrained;resolve_estimatorandlocal_estimatortocached_file;read_estimatortoload_file;_from_estimatortofrom_estimator.load_estimatoris removed: callfrom_pretrained.EntropyTransformer(reduction=...)is nowEntropyTransformer(pooling=...), and the entropy step’s parameter isentropy__pooling. A pooling is aPoolinginstance (EPRPooling(),WEPRPooling(), or a subclass ofPoolingof your own) or a plain functionf(x, axis); a string is refused with aTypeError. There is no name registry: nothing is selected by name, and no global state holds a pooling.STRATEGIESandartefactual.utils.io.Reductionare removed, and so isBaseDetector.trainable: constructEPR,WEPRorPoolingDetector(pooling). The class attributereductionof the estimators is nowpooling, aPoolinginstance, andEntropyTransformer.reduction_fnis gone: calltransformer.applied_pooling().scripts/train_detector.py --reductionis now--pooling:epr,wepr, or an import pathpackage.module:Attrto aPoolingsubclass, aPoolinginstance or a function.EntropyTransformer(pooling)andPoolingDetector.from_pretrained(path, pooling=...)require the pooling: nothing defaults toEPRPooling()andpooling=Noneis refused.EPR,WEPRand their classifiers still fix theirs.khas no default.EPR,WEPR,EPRClassifier,WEPRClassifier,PoolingDetectorandEntropyTransformerrequire it,artefactual.scoring.base_detector.DEFAULT_Kis removed, andscripts/train_detector.pyrequires--k.EntropyTransformer(pooling, k=None)still keeps every rank. Pass thekthe weights were trained at, which is 15 for the published detectors.get_feature_names_outof a custom pooling function returns names (its own name, orname_0, …) instead of raisingValueError.A fitted
EntropyTransformerrefuses attransforma cube whose last dimension differs from the width it was fitted on, with aValueError, instead of scoring it silently. Fit and transform on the same width.Pooling.__call__takesX, as the estimator methods do, where it tookx: an override that renames the argument still works when it is called positionally, whichEntropyTransformerdoes.
Added#
Pooling,EPRPooling,WEPRPoolingandFunctionPooling: subclassPooling, implement__call__(X, axis), and pass an instance toEntropyTransformerorPoolingDetector. Overridename,width(k),constant_widthandfeature_names(ranks)to name the features or declare the width; otherwise the width is probed and a one-feature pooling is named after the class. A bare function works too and is named after itself.PoolingDetector(pooling, k, estimator)is the detector over any pooling; its file holds the classifier alone, soPoolingDetector.from_pretrainedtakespooling=.BaseDetectorandBaseEntropyClassifierare importable from the package root.EPRClassifierandWEPRClassifierscore logprob arrays you already hold: a(n_sequences, n_tokens, width)array, or a numeric 2-D table read as one token per row. Targets must be binary. They pass scikit-learn’scheck_estimator, with one declared expected failure (check_estimators_overwrite_params, which scikit-learn lists forPipelineitself);EntropyTransformerpasses it too, and the checks that need no data are run by hand onLogProbParser.EPRandWEPRare the same estimators with aLogProbParserin front, so they take responses and are not run throughparametrize_with_checks. See scikit-learn compatibility.BaseEntropyClassifier, the pipeline the four estimators share, and the class-levelpooling.EntropyTransformerkeeps the firstkranks of input that is wider, which are the most likely candidates, so aGridSearchCVoverkworks on one wide array. Input narrower thankis used as it is.Feature names:
get_feature_names_outworks through the pipeline, and scikit-learn’sset_output("pandas"or"polars") gives named DataFrames on slices such asdetector[:-1].EntropyTransformertakes an optionalk, which the estimators set on it. Rank columns arerank0..rank{k-1};EPRandEPRClassifierhave one feature,epr;WEPRandWEPRClassifierhavewepr_mean_rank*thenwepr_max_rank*. A classifier fitted on a table with column names uses them in place ofrank*.from_pretrainedtakes keyword-onlyrevision,tokenandcache_dir, forwarded to the Hugging Face download, so a published detector can be pinned to a commit.EntropyTransformervalidates itspoolingandkatfit, and a detector validateskandestimator, with scikit-learn’sInvalidParameterError(aValueError).from artefactual import EPR, WEPR, EPRClassifier, WEPRClassifier: the four estimators are exported from the package root.numpydoc docstrings on the estimators, documenting the fitted attributes (
classes_,n_features_in_,named_steps,steps,estimator).Guide pages: Installation, scikit-learn compatibility, this changelog, and a curated API reference reference.
CITATION.cffat the repository root.Judgment, the schema of a judge’s reply (judgment,explanation), usable as a structured-outputresponse_format.Judgment.from_text,from_completionandfrom_batchread a reply, a completion or a whole batch of verdicts, keeping the explanation;read_judgmentkeeps working and returns the same verdicts.ChatCompletion.top_logprobs()andsampled_logprobs(), and the same two on the Responses payload model, share one implementation throughLogprobsMixin. A class that implements the mixin is registered as a format, so a new format is one class.LogprobsMixin.parsevalidates a completion, a Responses payload or a batch line into the model it is;ChatCompletion.parseandResponsesPayload.parseaccept their own format only.BatchRequestOutput.payload()returns the body of a successful line.TokenLogprobs.candidates()gives a token’s candidates, highest first.parse_top_logprobs,parse_sampled_token_logprobsandLogProbParserreturn the same results and raise the same errors as before.epr_reductionandwepr_reduction, the two reductions behind the detectors, andEntropyTransformer.validate, its input check, are public. Together withEPR,WEPR,EPRClassifier,WEPRClassifier,EntropyTransformer,LogProbParser,Judgment,ChatCompletion,ResponsesPayload,BatchRequestOutputandread_batch, they import fromartefactualdirectly.LogprobsMixinstays inartefactual.preprocessing.response_models.
Changed#
EntropyTransformernamesmin(k, n_features_in_)features once fitted, which is the width it hands on when the input is narrower thank.predict_token_probaon an empty batch returns an array of shape(0, 0, 1), and on a batch whose tokens are all padding returnsNaN, instead of raising.predictafter the pooling was swapped on a fitted detector raises aValueErrorasking for a refit, instead of scoring with coefficients fitted for the old pooling.predict_probacolumns followclasses_. With0/1labels column 1 is the hallucination class; with other labels uselist(detector.classes_).index(label).get_paramsreportsestimator=Nonewhile the final step is the untouched default, soclonerebuilds an equal detector.The estimator tags declare a binary classifier. The classifiers declare 2-D input, and
EntropyTransformer’s tags declare both 2-D and 3-D input.
Fixed#
detector[::2]raisesValueError, asPipelinedoes, instead of returning a pipeline of an arbitrary subset of steps.EntropyTransformer.transformandtransform_tokensaccept a nested list and raiseValueErroron infinite logprobs, rather than abeartypeerror or an infinite feature.from_pretrainedrefuses an estimator that is not a fitted two-class classifier, with aValueErrornaming the file.A repository that cannot be found, a missing revision and a malformed repository id raise
ValueError; connection and authentication errors now propagate as thehuggingface_huberror they are, instead of being wrapped.Judgment.from_textandread_judgmentreturnNonefor a reply that is not JSON and carries both"judgment": trueand"judgment": false, instead of reading it as correct.A chat choice whose
logprobs.contentis null is read as a sequence without tokens, as one whoselogprobsis null is, instead of raising aValidationError.The
adaptersextra requireslangfuse<5: 5.0 removed the trace callsHallucinationEvaluatorreads with.