Bugs: One typed detect interface for the detectors package

Đang mở
#192 0 bình luận 0 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@hslev đang làm issue này rồi.

Từ ngày 10/11/2026.

Đánh giá

Issue này chưa được đánh giá.

Mô tả

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.
Ngôn ngữ chính
Python
Star
615
Fork
60
Merge trung bình
2 ngày 18 giờ
Pull request đã merge (30 ngày)
12

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của KRLabsOrg/LettuceDetect

Tất cả issue của KRLabsOrg/LettuceDetect

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.