Bugs: One typed detect interface for the detectors package

オープン
#192 コメント 0 件 リアクション 0 件 担当者 1 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@hslev がすでに取り組んでいます。

2026年11月10日 から。

評価

この issue はまだ評価されていません。

説明

A bug issue created from @adaamko's comment

  1. EncoderDetector(model, tokenizer, typer): typer is positional. EncoderDetector(model, tok, EncoderConfig(max_length=512)) constructs fine with the config taken as the typer and max_length left at 4096. It fails only at the first span, with AttributeError: 'EncoderConfig' object has no attribute 'type_spans' (encoder.py:240-249). Making everything after tokenizer keyword-only fixes it.
  2. A TransformerDetector subclass that overrides predict is bypassed by detect(). With a subclass whose predict post-filters spans, predict() returns ['short'] and detect() returns ['word', 'short']. Nothing visible breaks today, but once predict_prompt_batch and HallucinationDetector route through detect, such subclasses silently change behaviour. BaseDetector already bridges detect-less subclasses through predict; the same bridge could apply when predict or predict_prompt is overridden.
  3. make_cache_key(kind=...) rejects every kind except judge, native and verify (response_cache.py:29-30). It is public, but the fact-checker (#169) and third-party detectors can't use it with their own kind.
  4. Detection.tokens includes the trailing [SEP] as a flagged token. For a 30-character answer the last entry is TokenScore(token='[SEP]', start=30, end=30, score=0.99, flagged=True) (encoder.py:521-522). The deprecated predict path has to keep this for the golden fixtures, but the new output should drop zero-width tokens. TokenScore also accepts end < start, while Span rejects it.
  5. detect() with a dict request raises AttributeError ('dict' object has no attribute 'answer') instead of InvalidInputError.
  6. A detect-only detector inherits a predict() whose default fails. The default output_format="tokens" raises tokens_not_supported for any detector without token support.
  7. Two doc mismatches. CONTRIBUTING points to tests/test_deprecation.py, but the file is tests/test_deprecation_pytest.py. The EncoderConfig.batch_size docstring describes padded batches, which detect doesn't do until #175.
主要言語
Python
スター
615
フォーク
60
平均マージ
2日 18時間
マージ済み PR(30日)
12

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

KRLabsOrg/LettuceDetect のほかの issue

KRLabsOrg/LettuceDetect の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。