Make TaxonomyTyper take loaded objects and add from_pretrained

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

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

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
74/100
issue の種類
リファクタリング
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python, pytorch

調査の方向性

Start with lettucedetect/detectors/taxonomy_head.py and the construction site in transformer.py:69-82; run uv run --extra dev pytest tests/test_custom_taxonomy_pytest.py -q first. Keep resolve_taxonomy and type_spans behavior intact while separating construction from loading. Done when the stub construction avoids downloads, from_pretrained records the specified version and logs model_loaded, and the existing test passes unchanged.

索引モデルが issue の本文から書いたものです。

説明

ready-for-agent

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

Problem

TaxonomyTyper loads its own encoder and tokenizer from a name inside its constructor, so it cannot be built from objects a service already loaded and downloads on construction.

Current behavior

  • lettucedetect/detectors/taxonomy_head.py:49-82 constructor loads the encoder and tokenizer from a name.
  • taxonomy_head.py:21 resolve_taxonomy turns True, a list, a flat dict or the nested dict into (categories, subcategories).
  • taxonomy_head.py:96 type_spans(answer, context, spans) types spans.

Steps

  1. Change the constructor to TaxonomyTyper(encoder, tokenizer, *, categories=None, subcategories=None, max_length=1024, model_id=None, model_version=None); no download.
  2. Add TaxonomyTyper.from_pretrained(model_id, *, device=None, categories=None, subcategories=None, model_version=None, **loader_kwargs); logs model_loaded. Version is the resolved commit for a hub id and the caller's model_version for a local path.
  3. Keep resolve_taxonomy and all four taxonomy forms with today's meaning.
  4. Update the one place that constructs it (transformer.py:69-82) to use from_pretrained.

Acceptance criteria

  • Constructing with stub encoder/tokenizer downloads nothing.
  • from_pretrained with fakes records version as described and logs model_loaded.
  • type_spans output unchanged; tests/test_custom_taxonomy_pytest.py passes unchanged.
  • Follows CONTRIBUTING "Errors and logging".

Start here

uv run --extra dev pytest tests/test_custom_taxonomy_pytest.py -q
主要言語
Python
スター
615
フォーク
60
平均マージ
1日 8時間
マージ済み PR(30日)
10

環境構築

はじめの一歩

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

KRLabsOrg/LettuceDetect のほかの issue

KRLabsOrg/LettuceDetect の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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