Bugs: One typed detect interface for the detectors package

Abierto
#192 0 comentarios 0 reacciones 1 asignado Ver en GitHub

Los mantenedores suelen responder en 1 día

@hslev ya está trabajando en esto.

Desde el 10/11/2026.

Evaluación

Este issue todavía no se ha evaluado.

Descripción

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.
Lenguaje dominante
Python
Estrellas
615
Forks
60
Merge medio
2 d 18 h
PR fusionados (30 d)
12

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de KRLabsOrg/LettuceDetect

Todos los issues de KRLabsOrg/LettuceDetect

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.