Add EncoderDetector.from_pretrained with model_version

Abierto
#151 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
1-2 días
Aptitud para principiantes
48/100
Tipo de issue
Nueva funcionalidad
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
huggingface, python, pytorch

Línea de trabajo

The issue points to lettucedetect/detectors/transformer.py:62-82 and tests/test_inference_pytest.py. First read those sections and the CONTRIBUTING guidance on errors and logging, then run uv run --extra dev pytest tests/test_inference_pytest.py -q. Done means the factory loads tokenizer and model, passes the device, resolves the hub commit or preserves the local version, and logs model_loaded once at INFO; the issue is blocked by #149.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

ready-for-agent

Parent: #148 · Epic: #126 · Blocked by: #149
Branch from stateless_core; open the PR against it.

Problem

A service needs one explicit place where a model name becomes a model, and a record of the exact weights that ran. Today the download happens inside the constructor and nothing records the revision.

Current behavior

  • lettucedetect/detectors/transformer.py:62-63 loads tokenizer and model with **tok_kwargs in the constructor; :66-67 device handling.
  • No model_loaded log, no commit or version.

Steps

  1. Add EncoderDetector.from_pretrained(model_id, *, device=None, taxonomy_head=None, include_taxonomy=True, model_version=None, config=None, **loader_kwargs) loading tokenizer and model and constructing the detector.
  2. model_version is the resolved Hugging Face commit for a hub id; for a local path it is the caller's model_version, or None.
  3. Log model_loaded at INFO (model id, version, device — no customer text).
  4. Accept taxonomy_head and include_taxonomy and keep today's loading for them (transformer.py:69-82); typed spans are #154/#155.

Acceptance criteria

  • With AutoTokenizer/AutoModelForTokenClassification replaced by fakes (no network), from_pretrained builds a working detector and passes device through.
  • Hub id → model_version is the resolved commit; local path → the caller's value or None.
  • model_loaded is logged exactly once at INFO.
  • Existing tests pass; follows CONTRIBUTING "Errors and logging".

Start here

uv run --extra dev pytest tests/test_inference_pytest.py -q
Lenguaje dominante
Python
Estrellas
615
Forks
60
Merge medio
1 d 8 h
PR fusionados (30 d)
10

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.