Repository navigation
fix: detect interface bugs from #192 and run the tests on stateless_core PRs - #195
Merged
Merged
Conversation
…ore PRs - EncoderDetector takes typer, config, model_id and model_version by keyword only, so a config passed third is no longer taken as the typer. - Detectors built on one tokenizer share one scoring lock. A fast tokenizer fails with 'Already borrowed' when two threads use it at once, also through two detectors. - Detection.tokens leaves out zero-width special tokens such as the trailing [SEP], and TokenScore rejects an end that is not after its start. - detect() raises InvalidInputError (invalid_request) for a request that is not a SourcesInput or a PromptInput. - make_cache_key accepts a kind of the caller's own. - predict() on a detector without token scores names output_format="spans" in its error. - CONTRIBUTING names the right deprecation test file, and the EncoderConfig.batch_size docstring says what detect does today. - The test workflow also runs on pull requests against stateless_core. Signed-off-by: Kovács Ádám <adaam.ko@gmail.com>
11 of 13 tasks
This was referenced Nov 16, 2026
1 task done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes six of the seven bugs listed in #192 on the typed detector interface, one concurrency bug in
EncoderDetector, and makes the test workflow run on pull requests againststateless_core.EncoderDetector(model, tokenizer, typer): everything aftertokenizeris keyword-only.EncoderDetector(model, tok, EncoderConfig(...))now raisesTypeErrorinstead of taking the config as the typer.RuntimeError: Already borrowed. The contract testtest_concurrent_adetect_returns_results_in_call_orderbuilds three such detectors and failed this way for me with transformers 5.1.0.Detection.tokensleaves out zero-width special tokens such as the trailing[SEP].TokenScorerejects anendthat is not afterstart, asSpandoes. The deprecatedTransformerDetector.predicthas its own path and still returns[SEP], so the golden fixtures are unchanged.detect()raisesInvalidInputErrorwith the codeinvalid_requestfor a request that is not aSourcesInputor aPromptInput, instead ofAttributeError.make_cache_key(kind=...)accepts a kind of the caller's own. A kind must be a non-blank string without=, which is reserved for themodel_versionpart of the key. The keys ofjudge,nativeandverifyare unchanged.predict()on a detector without token scores raisestokens_not_supportedwithparam="output_format"and a message that namesoutput_format="spans". The default stays"tokens".tests/test_deprecation_pytest.py, and theEncoderConfig.batch_sizedocstring says thatdetectscores one request at a time.python-tests.ymlalso runs on pull requests againststateless_core. Until now those pull requests only got the rights check.Not in this pull request: bug 2 of #192 (a
TransformerDetectorsubclass that overridespredictis bypassed bydetect()). It needs a decision on which method wins, so it stays open in the issue.Related issue
Relates to #192. It targets
stateless_core, so GitHub will not close the issue; bug 2 keeps it open anyway.Type of change
Testing
ruff format --check lettucedetect/ lettucedetect_api/ tests/ruff check lettucedetect/ lettucedetect_api/ tests/ --extend-exclude lettucedetect/integrations/python -m pytestResults: 701 passed, 1 failed locally. The failure,
test_importing_the_module_has_no_import_cycle_or_warning, starts a subprocess that imported another installed copy of the package on my machine; it fails the same way onstateless_core.Checklist
Rights & sign-off (required)
distributed under the repository's MIT license
(see CONTRIBUTING).