Add EncoderDetector.from_pretrained with model_version

Aperta
#151 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
1-2 giorni
Idoneità per principianti
48/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
huggingface, python, pytorch

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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
Lingua principale
Python
Stelle
615
Fork
60
Merge medio
1g 8h
PR unite (30g)
10

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di KRLabsOrg/LettuceDetect

Tutte le issue di KRLabsOrg/LettuceDetect

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.