Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
5d8e157
test: pin today's TransformerDetector output with golden fixtures (#128)
hslev Nov 5, 2026
f06fa7c
test: pin today's LLMDetector output with golden fixtures (#129)
hslev Nov 5, 2026
305ab25
test: pin today's RAGFactCheckerDetector output with golden fixtures …
hslev Nov 5, 2026
8361657
test: pin make_detector, HallucinationDetector and CacheManager behav…
hslev Nov 5, 2026
52bad80
Merge pull request #182 from KRLabsOrg/127-record-golden-fixtures-for…
hslev Nov 5, 2026
21ed8f3
Revert "test: record golden fixtures for today's detector API (#127)"
hslev Nov 5, 2026
2bda4cb
Merge pull request #183 from KRLabsOrg/revert-182-127-record-golden-f…
hslev Nov 5, 2026
b3199c4
test: pin today's TransformerDetector output with golden fixtures (#128)
hslev Nov 5, 2026
f4eb78a
test: pin today's LLMDetector output with golden fixtures (#129)
hslev Nov 5, 2026
9e72c66
test: pin today's RAGFactCheckerDetector output with golden fixtures …
hslev Nov 5, 2026
ca5c2a6
test: pin make_detector, HallucinationDetector and CacheManager behav…
hslev Nov 5, 2026
d3cf892
docs: state the error handling and logging rules
hslev Nov 5, 2026
7bb7382
chore: add LettuceDetectDeprecationWarning and a deprecation helper (…
hslev Nov 6, 2026
b7b3940
test: turn LettuceDetectDeprecationWarning into a test error (#136)
hslev Nov 6, 2026
8bb64be
chore: add LettuceDetectError, its three subclasses and the result wa…
hslev Nov 6, 2026
e211ea7
chore: add the detect request and result types
hslev Nov 6, 2026
6fb7551
Merge remote-tracking branch 'origin/132-read-the-errors-and-logging-…
hslev Nov 6, 2026
8950bb6
Merge remote-tracking branch 'origin/134-see-one-consistent-warning-f…
hslev Nov 6, 2026
3f21997
Merge branch '137-build-detect-requests-and-read-typed-results-and-er…
hslev Nov 6, 2026
fef39aa
feat: add BaseDetector.detect and adetect with min_score and support …
hslev Nov 6, 2026
92c5dc2
Merge pull request #184 from KRLabsOrg/127-golden-fixtures-v2
hslev Nov 6, 2026
6cae1ed
Merge pull request #185 from KRLabsOrg/132-read-the-errors-and-loggin…
hslev Nov 6, 2026
d3c6dcc
Merge pull request #186 from KRLabsOrg/134-see-one-consistent-warning…
hslev Nov 6, 2026
144cffa
Merge branch 'stateless_core' into 137-build-detect-requests-and-read…
hslev Nov 6, 2026
5c0ca43
Merge pull request #187 from KRLabsOrg/137-build-detect-requests-and-…
hslev Nov 6, 2026
bef046d
feat: bridge old and new BaseDetector interfaces (#142)
hslev Nov 6, 2026
396a6cf
test: add the reusable detector contract suite (#143)
hslev Nov 6, 2026
7ff3929
chore: format with ruff
hslev Nov 6, 2026
0938efe
Merge branch 'stateless_core' into 140-implement-a-detector-against-d…
hslev Nov 6, 2026
2b21986
Merge pull request #188 from KRLabsOrg/140-implement-a-detector-again…
hslev Nov 6, 2026
65f4bf3
feat: add ResponseCache protocol, make_cache_key, SyncCacheBase and I…
hslev Nov 9, 2026
2917422
feat: add FileCache with atomic writes and TTL (#146)
hslev Nov 9, 2026
7d4d46a
refactor: make CacheManager a deprecated subclass of FileCache (#147)
hslev Nov 9, 2026
dc9263e
feat: log cache steps at DEBUG on the module loggers (#146, #145)
hslev Nov 9, 2026
2302d1c
Merge pull request #189 from KRLabsOrg/144-pass-a-responsecache-to-a-…
hslev Nov 9, 2026
8879fbb
feat: add EncoderDetector and EncoderConfig with detect spans (#149)
hslev Nov 9, 2026
97b7873
feat: add token scores, input_truncated and usage to EncoderDetector …
hslev Nov 9, 2026
afb876f
feat: add EncoderDetector.from_pretrained with model_version (#151)
hslev Nov 9, 2026
be63d29
feat: make TransformerDetector a deprecated subclass of EncoderDetect…
hslev Nov 9, 2026
15ebc32
Merge pull request #190 from KRLabsOrg/148-load-an-encoderdetector-ex…
hslev Nov 9, 2026
8d198e5
feat: make TaxonomyTyper take loaded objects and add from_pretrained …
hslev Nov 9, 2026
2529b51
feat: type spans in EncoderDetector.detect and meter the typer (#155)
hslev Nov 9, 2026
d0a7d5c
Merge pull request #191 from KRLabsOrg/153-get-typed-spans-from-the-e…
hslev Nov 9, 2026
580b2d8
fix: detect interface bugs from #192 and run the tests on stateless_c…
adaamko Nov 16, 2026
7c71908
feat: add VelaDetector and VelaConfig for in-process Vela 2.0 models …
FurkanAtass Nov 18, 2026
15fd151
feat: add VelaDetector HTTP mode and when-to-choose-Vela docs (#118) …
FurkanAtass Nov 19, 2026
7ded6d1
feat: get triplets and fact-check results from RAGFactCheckerDetector…
FurkanAtass Nov 22, 2026
647ef06
feat: raise typed errors from OpenAIClient and BedrockClient (#157)
adaamko Nov 22, 2026
66a1e79
feat: add LLMJudgeDetector with LLMJudgeConfig and visible failures (…
adaamko Nov 22, 2026
8b9ee48
feat: add caching and usage to LLMJudgeDetector (#159)
adaamko Nov 22, 2026
d4f3452
feat: add the verify pass to LLMJudgeDetector with verification_skipp…
adaamko Nov 22, 2026
5657b9f
refactor: delegate the LLMDetector judge path to LLMJudgeDetector (#161)
adaamko Nov 22, 2026
f0e9eda
feat: add GenerativeDetector with GenerativeConfig and typed spans (#…
adaamko Nov 22, 2026
ab56545
feat: add caching, usage and the verify pass to GenerativeDetector (#…
adaamko Nov 22, 2026
7b443b7
refactor: delegate the LLMDetector native path to GenerativeDetector …
adaamko Nov 22, 2026
1a79e99
feat: warn on deprecated LLMDetector use and stop writing a default c…
adaamko Nov 22, 2026
e963429
Merge pull request #197 from KRLabsOrg/156-llm-judge-detector
adaamko Nov 22, 2026
669a49e
feat: raise typed errors from LLMDetector predict methods and forward…
adaamko Nov 22, 2026
326af43
Merge pull request #198 from KRLabsOrg/162-generative-detector
adaamko Nov 22, 2026
047c3fc
Merge remote-tracking branch 'origin/stateless_core' into 166-llmdete…
adaamko Nov 22, 2026
ed2762e
Merge pull request #199 from KRLabsOrg/166-llmdetector-adapter
adaamko Nov 22, 2026
e3f7d00
feat: add the model registry and load_detector (#173)
adaamko Nov 22, 2026
c588a96
feat: deprecate make_detector in favour of load_detector (#174)
adaamko Nov 22, 2026
e055046
Merge pull request #200 from KRLabsOrg/172-load-detector
adaamko Nov 22, 2026
78661c9
fix: route detect through an overridden predict (#192)
adaamko Nov 22, 2026
892389d
feat: add detect_batch and adetect_batch with concurrent execution (#…
adaamko Nov 22, 2026
c4b414b
feat: score EncoderDetector batches in padded groups (#177)
adaamko Nov 22, 2026
9359ca5
refactor: route predict_prompt_batch through detect_batch (#178)
adaamko Nov 22, 2026
f38f679
Merge remote-tracking branch 'origin/stateless_core' into 175-detect-…
adaamko Nov 22, 2026
60117d3
Merge pull request #201 from KRLabsOrg/175-detect-batch
adaamko Nov 22, 2026
2490077
docs: add the 0.3.0 changelog and roadmap entries and bump the versio…
adaamko Nov 22, 2026
b409a6b
docs: describe the detector interface in CONTRIBUTING and test the ch…
adaamko Nov 22, 2026
04c4999
feat: warn when the deprecated predict methods are called from outsid…
adaamko Nov 22, 2026
24b0e3d
fix: keep TaxonomyTyper(model_path, ...) working as a deprecated call…
adaamko Nov 22, 2026
55b2307
docs: list the predict warnings and the TaxonomyTyper call as depreca…
adaamko Nov 22, 2026
446d074
Merge pull request #202 from KRLabsOrg/179-changelog
adaamko Nov 22, 2026
803f635
Merge main into stateless_core
adaamko Nov 22, 2026
0921212
Merge pull request #203 from KRLabsOrg/sync-main-into-stateless-core
adaamko Nov 22, 2026
64276e1
fix(registry): register every published encoder id and default lang t…
adaamko Nov 30, 2026
907ccca
fix(rag_fact_checker): raise typed errors for a failing fact checker …
adaamko Nov 30, 2026
af2b8b6
fix(file_cache): parse the file only when it changed and keep its per…
adaamko Nov 30, 2026
1716026
fix(vela_client): validate the base URL scheme, translate every httpx…
adaamko Nov 30, 2026
5af8084
fix: isolate encoder request failures and harden encoder and typer lo…
adaamko Nov 30, 2026
da5b6b1
fix(llm): translate provider errors, clamp confidences, read fenced j…
adaamko Nov 30, 2026
038f02f
Merge branches '204-fix-a', '204-fix-b', '204-fix-c' and '204-fix-d' …
adaamko Nov 30, 2026
c9b89c6
docs: changelog for the error isolation and loader fixes; one registr…
adaamko Nov 30, 2026
740cdc7
Merge pull request #205 from KRLabsOrg/204-review-fixes
adaamko Nov 30, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches: [main]
pull_request:
branches: [main]
branches: [main, stateless_core]

jobs:
lint:
Expand Down
66 changes: 66 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,72 @@

All notable changes to LettuceDetect are documented here.

## [0.3.0] - Unreleased

### Added
- `detect(request, *, min_score=0.0, include_tokens=False, include_detail=False)` on every detector. It takes a `SourcesInput` or a `PromptInput` and returns one `Detection` with `spans`, optional `tokens`, optional `detail`, `usage` and `warnings`. Every span has a numeric `score`, and `min_score` drops the spans below it (#126)
- `adetect`: the async version of `detect`. It runs `detect` in a worker thread on the event loop's default executor. That executor is shared with the rest of the service, DNS lookups included, so size it for many concurrent calls. Cancelling `adetect` stops the wait, not the thread. There is no `executor` argument
- `detect_batch`: runs many requests and returns a `list[BatchResult]`, one per request in input order. A `BatchResult` holds the `detection` or the typed `error` of its request, with `ok` and `get_or_raise()`, so one failed request does not discard the others. At most `max_concurrency` requests run at once
- `adetect_batch`: the async version of `detect_batch`. It runs on the same default executor as `adetect` and the same notes apply: size the executor, cancelling stops the wait and not the batch, and there is no `executor` argument
- `EncoderDetector` with `EncoderConfig`: the encoder models on the typed interface. The constructor takes a loaded model and tokenizer and downloads nothing; `EncoderDetector.from_pretrained` loads them and records the resolved Hugging Face commit as `model_version`. `include_tokens=True` returns `TokenScore` items without zero-width special tokens, a `typer` adds `category` and `subcategory` to every span, an input over `max_length` adds the `input_truncated` warning, an answer that does not fit in `max_length` raises `InvalidInputError` (`input_too_long`), model output that cannot form a valid result (NaN scores, invalid offsets) raises `UpstreamError` (`invalid_model_output`), and `detect_batch` scores requests in padded groups of `batch_size`. A used detector can be pickled and deep-copied
- `LLMJudgeDetector` with `LLMJudgeConfig`: the zero-shot and few-shot LLM judge with reasoning, taxonomy and the verify pass. It takes the LLM client as an argument, reads no environment variable and writes no file. Dropped items are reported with the `span_not_found` and `item_malformed` warnings, a skipped verify pass with `verification_skipped`
- `GenerativeDetector` with `GenerativeConfig`: the fine-tuned generative models with their frozen prompt, typed spans and the custom taxonomy forms, on a client the caller passes
- `VelaDetector` with `VelaConfig`: a detector for Vela 2.0 models. `VelaDetector.from_pretrained` loads a model in process (install the new `vela` extra), and `VelaDetector.from_server` calls a SystemOne server through `SystemOneClient`, which closes only an HTTP client it built itself (#118)
- `RAGFactCheckerDetector.detect` and `adetect`. `include_detail=True` returns a `DetailedResult` with the triplets and fact-check results. Two new keywords: `fact_checker` takes a ready fact checker, so nothing is built and the environment is not read (`usage.model_id` is then the `model` attribute of the fact checker, or `None`), and `max_concurrency` (default 30) bounds the fact-check calls running at once on one instance
- `TaxonomyTyper.from_pretrained`: loads the typing head and records its commit as `model_version`. It accepts `max_length`. A typer and an `EncoderDetector` built on the same tokenizer object share one lock, so typing and scoring run one at a time
- `load_detector(model_id, ...)`: builds the detector of a registered KR Labs model id. It knows every published encoder model, and `lang` defaults to the language of the model (for example German for `lettucedect-210m-eurobert-de-v1`); a `lang` the caller passes is kept. An unknown id raises `InvalidInputError` (`unknown_model_id`) that lists the known ids, and a generative id without `client` raises `ConfigurationError` (`client_required`)
- Reply caching that the caller controls: the `ResponseCache` protocol, the `SyncCacheBase` base class, `FileCache` (one JSON file, atomic writes that keep the permissions of the file, optional TTL, parses the file again only when it changed on disk, reads files written by `CacheManager`) and `InMemoryCache`. The LLM-backed detectors cache only when a `cache` is passed
- `make_cache_key`: builds the cache key of a model call. With a `model_version` the key includes it, so a redeployed model does not read the replies of the old one; without one the key equals the key `LLMDetector` has always built, so existing cache files keep hitting
- Request and result types: `Chunk`, `SourcesInput`, `PromptInput`, `DetectRequest`, `Detection`, `Span`, `DetectedSpan`, `TokenScore`, `DetailedResult`, `Usage`, `ResultWarning` and `BatchResult`. They are frozen pydantic models and their validation errors never contain the input text
- Error types: `LettuceDetectError` and its subclasses `InvalidInputError` (an argument of a call), `ConfigurationError` (a constructor argument, a setting or a missing package) and `UpstreamError` (a failed or missing reply from a service). Each carries a stable `code`
- `usage` on every `Detection`: one entry per model that ran, with `model_id`, `model_version` and counts such as `input_tokens`, `llm_calls` and `cache_hits`
- The `synthetic_score` warning on a `Detection` whose scores are constants and not model outputs
- `BaseDetector` bridges both interfaces: a subclass that implements `_detect` gets the `predict*` methods, and a subclass that implements only `predict` gets `detect`, which also goes through a `predict` overridden below the class that implements `_detect`. A subclass that implements neither raises `TypeError` when it is defined
- `LettuceDetectDeprecationWarning`, the warning class of every deprecation in the library
- `--method vela` and `--revision` in `scripts/evaluate_span_model.py`

### Changed
- `LLMDetector` spans that had no `confidence` key (the judge without `include_reasoning`, the generative models) now carry `confidence: 1.0`
- `LLMDetector` used to cache every reply in `cache_<model>_<lang>.json` inside the installed package; it now caches, and writes a file, only when `cache_file` is passed
- A reply that can't be parsed (not JSON, or without `hallucination_list` for the judge or `hallucinated_spans` for the generative models) used to return no spans; it now raises `UpstreamError` (`unparseable_response`)
- A generative-model reply used to be cached before it was parsed, so a bad reply was replayed; a reply is now cached only after it parses, and a cached entry that doesn't parse is deleted
- A generative-model reply item that is a bare string used to be skipped; it is now returned as a span without a category
- `BedrockClient` used to return an empty string for a reply without a tool call, which read as "no spans"; it now raises `UpstreamError` (`empty_response`)
- `BedrockClient` used to let botocore's own exceptions through; missing or rejected AWS credentials now raise `ConfigurationError` (`authentication_failed`), throttling, timeouts, connection errors and server errors raise a retryable `UpstreamError` (`upstream_unavailable`), and any other rejected request raises `UpstreamError` (`request_rejected`)
- `OpenAIClient` used to let OpenAI's own exceptions through; authentication and quota errors now raise `ConfigurationError` (`authentication_failed`, `quota_exceeded`), timeouts, connection errors, rate limits and server errors raise a retryable `UpstreamError` (`upstream_unavailable`, with `retry_after` from the `retry-after` header of a rate-limit reply), any other rejected request, such as a prompt over the context window, raises `UpstreamError` (`request_rejected`), and a reply without content raises `UpstreamError` (`empty_response`). The original error is the `__cause__`
- With `verify=True`, a verify call that failed in the provider used to raise; it now keeps the first-pass spans when the failure is an `UpstreamError`, as an unparseable verify reply already did
- `LLMDetector` constructor errors are now `ConfigurationError`, which is not a `ValueError`: an unknown `lang` (`invalid_language`, was `ValueError`), `native` with `zero_shot`, `fewshot_path` or `prompt_path` (`native_options_conflict`, was `ValueError`), a missing `prompt_path` (`invalid_config`, was `FileNotFoundError`) and any other invalid option (`invalid_config`)
- A `fewshot_path` that doesn't exist used to log a warning and run without examples; it now raises `ConfigurationError` (`fewshot_not_found`)
- The `predict*` methods of `LLMDetector` and `RAGFactCheckerDetector` used to raise a plain `ValueError` for an unsupported `output_format`, a `min_confidence` outside `[0, 1]` or lists of different lengths; they now raise `InvalidInputError` (`unsupported_output_format`, `invalid_min_score`, `length_mismatch`), which is still a `ValueError`
- A merged `RAGFactCheckerDetector` span used to keep the text of its first part; its `text` is now the answer between its offsets
- `RAGFactCheckerDetector.predict_prompt_batch` used to make one `detect_hallucinations_batch` call; it now makes concurrent `detect_hallucinations` calls, and all `predict*` calls on one instance share the `max_concurrency` bound
- A fact checker result that doesn't have the expected types used to be passed through; `RAGFactCheckerDetector` now raises `UpstreamError` (`invalid_model_output`)
- An error raised by the fact checker inside `RAGFactCheckerDetector.detect` is now an `UpstreamError` (`upstream_error`) with the original error as `__cause__`
- A `RAGFactCheckerDetector` span matched case-insensitively used to get wrong offsets when the answer holds a character whose lowercase form is longer, such as `İ`; the offsets are now taken from the answer itself
- An LLM judge `confidence` outside `[0, 1]` used to be replaced by `1.0`; it is now clamped into the range, and only a missing or non-numeric confidence becomes `1.0`
- A judge reply wrapped in a code fence used to be unparseable; it is now parsed, as a generative-model reply already was
- `LLMDetector` used to log malformed items, dropped span texts and the raw reply on its module logger; module loggers now record counts only, and the raw reply is logged at DEBUG on the `lettucedetect.content` logger
- `CacheManager` used to create its directory and read the file in the constructor; the constructor now touches no disk, the first write creates the directory, writes are atomic, and an invalid file raises `ConfigurationError` (`cache_file_invalid`) on first use
- Concurrent `predict*` calls on one `TransformerDetector` used to run unsynchronised on the shared tokenizer; they now run one at a time
- `pydantic`, `httpx`, `packaging` and `typing_extensions` are now required dependencies

### Deprecated
Each name below is deprecated since 0.3.0 and carries a `.. deprecated::` note in its docstring. Using one from outside the `lettucedetect` package warns with `LettuceDetectDeprecationWarning`; calls made inside the package are silent, so `HallucinationDetector`, which is not deprecated, does not warn. The `predict*` methods warn on every detector, once per call, and that warning covers their `min_confidence` and `output_format` arguments, which have no warning of their own. A `BaseDetector` subclass that implements only the `predict*` methods keeps working through `detect` and warns once per class; implement `_detect` instead.
- `TransformerDetector`: use `EncoderDetector.from_pretrained`. Removed in 0.5.0.
- `LLMDetector`: use `LLMJudgeDetector` or `GenerativeDetector`. Removed in 0.5.0.
- The `provider`, `client_kwargs` and `cache_file` arguments of `LLMDetector`, and leaving out `client`: use `LLMJudgeDetector` or `GenerativeDetector`. Removed in 0.5.0. Build the client yourself (`OpenAIClient` or `BedrockClient`) and pass `cache=FileCache(path)` for a cache file.
- `make_detector`: use `load_detector`. Removed in 0.5.0. For a model that is not a registered KR Labs model id, build the detector class directly.
- `CacheManager`: use `FileCache`. Removed in 0.5.0.
- `TaxonomyTyper(model_path, ...)`: use `TaxonomyTyper.from_pretrained`. Removed in 0.5.0. The constructor now takes a loaded encoder and tokenizer; a call with a model name or path as the first argument still loads the typing head itself.
- `predict` and `predict_prompt`: use `detect`. Removed in 0.5.0.
- `predict_prompt_batch`: use `detect_batch`. Removed in 0.5.0.
- The `min_confidence` argument of the three methods above: use `min_score`. Removed in 0.5.0.
- The `output_format` argument of the three methods above: use `include_tokens`. Removed in 0.5.0. Token scores come from `EncoderDetector` only; the token output of `LLMDetector` and `RAGFactCheckerDetector` has no replacement, and `"detailed"` becomes `include_detail=True`.

### Documentation
- Errors and logging convention in `CONTRIBUTING.md`
- "Vela 2.0" section in the detection methods guide, with the reproduced Vela 2.0 0.3B results

## [Unreleased]

### Fixed
Expand Down
Loading
Loading