diff --git a/CHANGELOG.md b/CHANGELOG.md index 1250746..26e66bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,8 +25,10 @@ All notable changes to LettuceDetect are documented here. - `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` +- LFM2.5-Encoder span tagger scripts: `scripts/train_lfm_span_detector.py` loads weights saved with a wrapper prefix, and `scripts/evaluate_lfm_span_model.py` reports results per source (#97) ### Changed +- `TransformerDetector.predict_prompt_batch` used to score one sample at a time; it now pads and scores `batch_size` pairs (default 16) in one forward pass, in input order (#23, thanks @c71qu3) - `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__.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`) @@ -51,6 +53,11 @@ All notable changes to LettuceDetect are documented here. - 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 +### Fixed +- Claude Code Stop hook: `--min-confidence` above `0.0` no longer drops every span in `--llm-model` mode. Unscored spans are kept, matching `BaseDetector._filter_spans_by_confidence` (#117, thanks @Clannad47) +- A batch call with different numbers of prompts and answers used to drop the extra items silently in some detectors; every detector now raises (#113, #122, thanks @c71qu3 and @YassinNouh21) +- The generic LLM judge is now asked to list spans in answer order, with one item per occurrence of a repeated text, so repeated span texts map to the right occurrences (#85, thanks @kocaemre) + ### 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. @@ -68,11 +75,6 @@ Each name below is deprecated since 0.3.0 and carries a `.. deprecated::` note i - 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 -- Claude Code Stop hook: `--min-confidence` above `0.0` no longer drops every span in `--llm-model` mode. Unscored spans are kept, matching `BaseDetector._filter_spans_by_confidence` (#117) - ## [0.2.3] - 2026-08-14 ### Added diff --git a/PUBLIC_ROADMAP.md b/PUBLIC_ROADMAP.md index b43b986..7af2867 100644 --- a/PUBLIC_ROADMAP.md +++ b/PUBLIC_ROADMAP.md @@ -2,31 +2,28 @@ LettuceDetect is maintained and evidence-driven. This roadmap separates near-term release work from research directions, and it intentionally has no delivery dates. Every item links to a GitHub issue where the discussion happens; milestones group them. -## Now: [v0.2.4 — Faster, lighter, consistent inference](https://github.com/KRLabsOrg/LettuceDetect/milestone/1) +## Now: [0.3.0 — One typed detect interface for the detectors](https://github.com/KRLabsOrg/LettuceDetect/milestone/5) -The next PyPI release is about making the existing detectors more reliable, cheaper to install, and faster to run—not about adding new detection methods. - -Open: +Release 0.3.0 gives the detectors package one typed interface: `detect`, `adetect`, `detect_batch` and `adetect_batch` take a typed request and return a typed result with spans, scores, usage and warnings. The existing API keeps working through adapters that are deprecated in 0.3.0 and removed in 0.5.0. The [changelog](CHANGELOG.md) lists every deprecated name and every behavior that changes through the existing API. -- [Real batched inference](https://github.com/KRLabsOrg/LettuceDetect/issues/23): `predict_prompt_batch` currently loops one sample at a time; the plan is padded-batch tokenization with a single forward pass. -- [Lighter installs](https://github.com/KRLabsOrg/LettuceDetect/issues/69): lazy top-level imports so the LLM detector never touches torch. How to slim the default install without breaking existing users is an open design question; input welcome on the issue. -- [Define evidence aggregation for chunked inference](https://github.com/KRLabsOrg/LettuceDetect/issues/74): benchmark whether evidence in any chunk or every chunk is required before changing the current conservative behavior. -- [Dataset-level hallucination-rate evaluation and reporting](https://github.com/KRLabsOrg/LettuceDetect/issues/56): ships with 0.2.4. +The release also carries what was merged since 0.2.3: [real batched inference](https://github.com/KRLabsOrg/LettuceDetect/issues/23) for the encoder models, one length check for batch calls on every detector, and a [fix to the Claude Code Stop hook](https://github.com/KRLabsOrg/LettuceDetect/issues/117). The work is merged; [the release issue](https://github.com/KRLabsOrg/LettuceDetect/issues/100) tracks what is left. -Shipped in this milestone so far: the network-free unit suite as a merge gate ([#73](https://github.com/KRLabsOrg/LettuceDetect/issues/73)), the `lettucedetect` CLI ([#47](https://github.com/KRLabsOrg/LettuceDetect/issues/47)), the detector latency/throughput benchmark ([#58](https://github.com/KRLabsOrg/LettuceDetect/issues/58)), token output from the LLM detector ([#65](https://github.com/KRLabsOrg/LettuceDetect/issues/65)), the `min_confidence` documentation ([#64](https://github.com/KRLabsOrg/LettuceDetect/issues/64)), and deterministic localization of repeated LLM spans ([#85](https://github.com/KRLabsOrg/LettuceDetect/issues/85)). +## Next: [Lighter installs, consistent inference, API follow-ups](https://github.com/KRLabsOrg/LettuceDetect/milestone/1) -## Next: [0.3.0 — One typed detect interface for the detectors](https://github.com/KRLabsOrg/LettuceDetect/issues/126) +Making the detectors cheaper to install and more consistent to run: -Release 0.3.0 gives the detectors package one typed interface: `detect`, `adetect`, `detect_batch` and `adetect_batch` take a typed request and return a typed result with spans, scores, usage and warnings. The existing API keeps working through adapters that are deprecated in 0.3.0 and removed in 0.5.0. The [changelog](CHANGELOG.md) lists every deprecated name and every behavior that changes through the existing API. +- [Lighter installs](https://github.com/KRLabsOrg/LettuceDetect/issues/69): lazy top-level imports so the LLM detector never touches torch. How to slim the default install without breaking existing users is an open design question; input welcome on the issue. +- [Define evidence aggregation for chunked inference](https://github.com/KRLabsOrg/LettuceDetect/issues/74): benchmark whether evidence in any chunk or every chunk is required before changing the current conservative behavior. +- [Dataset-level hallucination-rate evaluation and reporting](https://github.com/KRLabsOrg/LettuceDetect/issues/56) -Follow-ups, outside this release: +Follow-ups of the typed interface: -- Facade migration: move the `HallucinationDetector` facade, the CLI, the integrations, the evaluator and `lettucedetect_api/` off the deprecated names, then remove the rule that keeps calls from inside the package silent. -- The HTTP contract: a typed detect route in `lettucedetect_api/` and deprecation of the old routes, related to [the stable HTTP contract](https://github.com/KRLabsOrg/LettuceDetect/issues/75). -- Shared types: where `Chunk`, `Span`, `Usage` and the error classes live, and whether source ids must be unique. In 0.3.0 they are defined in `lettucedetect.detectors`, and source ids are not checked. -- The LLM-call layer that replaces `LLMClient`, so that `usage` can report provider model names and token counts. -- Native async LLM calls, the first follow-up after the LLM-call layer decision. The change adds to the signatures and results and removes nothing. The thread path stays as the default, because Bedrock, the fact checker and the encoder have no native async path. The caller owns the async client, as it owns the sync one. Two behaviors change and go in that release's changelog: cancelling `adetect` really cancels the call, and the OpenAI path stops using worker threads. -- Documentation site: a migration page and pages for the new API. Re-exporting the new names from the `lettucedetect` root is also open. +- [Facade migration](https://github.com/KRLabsOrg/LettuceDetect/issues/206): move the `HallucinationDetector` facade, the CLI, the integrations, the evaluator and `lettucedetect_api/` off the deprecated names, then remove the rule that keeps calls from inside the package silent. +- The HTTP contract: a typed detect route in `lettucedetect_api/` and deprecation of the old routes, part of [the stable HTTP contract](https://github.com/KRLabsOrg/LettuceDetect/issues/75). +- [Shared types](https://github.com/KRLabsOrg/LettuceDetect/issues/207): where `Chunk`, `Span`, `Usage` and the error classes live, and whether source ids must be unique. In 0.3.0 they are defined in `lettucedetect.detectors`, and source ids are not checked. +- [The LLM-call layer](https://github.com/KRLabsOrg/LettuceDetect/issues/208) that replaces `LLMClient`, so that `usage` can report provider model names and token counts. +- [Native async LLM calls](https://github.com/KRLabsOrg/LettuceDetect/issues/209), the first follow-up after the LLM-call layer decision. The change adds to the signatures and results and removes nothing. The thread path stays as the default, because Bedrock, the fact checker and the encoder have no native async path. The caller owns the async client, as it owns the sync one. Two behaviors change and go in that release's changelog: cancelling `adetect` really cancels the call, and the OpenAI path stops using worker threads. +- [Documentation site](https://github.com/KRLabsOrg/LettuceDetect/issues/210): a migration page and pages for the new API. Re-exporting the new names from the `lettucedetect` root is also open. ## Next: [Validation — Typed-span workflows](https://github.com/KRLabsOrg/LettuceDetect/milestone/3) diff --git a/docs/TINYLETTUCE.md b/docs/TINYLETTUCE.md index 5c38613..516dcc7 100644 --- a/docs/TINYLETTUCE.md +++ b/docs/TINYLETTUCE.md @@ -50,7 +50,7 @@ from lettucedetect.models.inference import HallucinationDetector # Load tiny but powerful model detector = HallucinationDetector( method="transformer", - model_path="KRLabsOrg/tinylettuce-ettin-17m-en-v1" + model_path="KRLabsOrg/tinylettuce-ettin-17m-en" ) # Detect hallucinations in medical context diff --git a/pyproject.toml b/pyproject.toml index e9112a9..0ee06d4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -45,6 +45,7 @@ dev = [ "pytest-asyncio>=0.25", "ruff>=0.0.270", "httpx>=0.28", + "boto3>=1.34", ] api = [ "fastapi[standard]>=0.115",