Keep LLMDetector working as a warning adapter

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

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

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

評価

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

調査の方向性

Read the parent issue #126, blockers #156 and #162, and the Errors and logging section of CONTRIBUTING.md; branch from stateless_core. Locate LLMDetector, LLMJudgeDetector, GenerativeDetector, HallucinationDetector, and the golden fixtures and existing tests. Compare current behavior with the acceptance criteria, then verify the old outputs, typed errors, warning behavior, and cache behavior against those tests.

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

説明

ready-for-agent

Parent

#126

Branch

Branch from stateless_core and open the pull request against it, not main. Close this ticket by hand once its pull request merges there: GitHub only closes issues automatically on merges into main.

What to build

Everyone who builds LLMDetector today keeps working and learns what to change. LLMDetector becomes a thin adapter: it chooses LLMJudgeDetector or GenerativeDetector by today's name rule or by native=, builds the client and the cache the old way when the caller passes none, and warns for each deprecated use, naming the replacement. The default cache file inside the installed package directory is gone: a file is written only when the caller passes cache_file.

The old predict* output, including the token output of the LLM detector, stays as today's golden fixtures record it.

Acceptance criteria

  • Constructing LLMDetector from outside the package warns LettuceDetectDeprecationWarning naming LLMJudgeDetector and GenerativeDetector; constructing it from inside the package does not warn.
  • LLMDetector picks GenerativeDetector for a model name that matches today's rule, and LLMJudgeDetector for any other. native=True or native=False overrides the rule.
  • native=True (or a name that matches the rule) together with zero_shot, fewshot_path or prompt_path raises ConfigurationError (native_options_conflict, with param), as today's ValueError case does.
  • Without client, LLMDetector builds one from provider and **client_kwargs as today and warns that the client should be passed; passing provider or client_kwargs warns as a deprecated argument.
  • cache_file builds a FileCache and warns as a deprecated argument naming cache=. With no cache_file the detector has no cache and no file is written anywhere.
  • predict, predict_prompt and predict_prompt_batch convert the new detector's Detection into today's dicts, with confidence taken from score and each key present exactly as today (golden fixtures), apart from spans that had no confidence now carrying 1.0.
  • predict(output_format="tokens") still returns one token, pred and prob dict per whitespace token, with prob the overlapping span's confidence when there is one, else 0.9 for a flagged token and 0.1 for the others, as in the golden fixtures.
  • The old methods raise InvalidInputError (unsupported_output_format, length_mismatch, invalid_min_score) and surface the typed errors of the new detector.
  • predict_prompt_batch is unchanged apart from the above until the batch task.
  • LLMDetector also exposes detect and adetect, forwarding to the chosen delegate: the result equals the delegate's, model_id is the delegate's, and no warning is added beyond the one at construction.
  • LLMDetector has the docstring note from the deprecation mechanism, and HallucinationDetector(method="llm", ...) returns today's output without a warning.
  • The existing tests pass unchanged.
  • The changed code follows the Errors and logging section of CONTRIBUTING.md, and no customer text is logged outside lettucedetect.content.

Blocked by

#156, #162

User stories covered

40, 44, 45, 46, 47, 48, 57

主要言語
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 を短くまとめたダイジェスト。