Add LLMJudgeDetector with LLMJudgeConfig and visible failures
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 38/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Ambito
- backend, machine-learning
Direzione di ricerca
Start with lettucedetect/detectors/llm.py and the existing tests tests/test_llm_detector_pytest.py and tests/test_golden_llm_pytest.py; run the command in “Start here” to see current behavior. Read the referenced BaseDetector, judge fixtures from #129, and the contributing guidance on errors and logging before tracing prompt building, parsing, locating, and concurrency behavior. Done means the new detector passes its contract and async, error, and concurrency acceptance cases, with updated fixtures and no answer text in messages or non-content logs.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Parent: #156 · Epic: #126 · Blocked by: #129, #143, #157
Branch from stateless_core; open the PR against it.
Problem
LLMDetector builds clients and caches from names, decides judge vs generative by substring, checks 14 keyword conflicts at runtime, and swallows failures: an unparseable reply returns no spans, an unlocated item is dropped with a debug line, and a missing fewshot_path only warns.
Current behavior
- Constructor:
lettucedetect/detectors/llm.py:63-194(ValueErrorat:109,:123; missing few-shot only logs at:164). _predict:395(parse failure →logger.errorat:424, no spans),_to_spans:297(malformed item WARNING with item text at:315; unlocated item DEBUG with span text at:329),_parse_response:377.- Spans have no
confidenceunlessinclude_reasoningis set.
Steps
- Add
LLMJudgeConfig(frozen pydantic,extra="forbid"):temperature=0.0,lang="en",zero_shot=False,fewshot_path=None,prompt_path=None,include_reasoning=False,include_taxonomy=False(bool, list, flat dict, nested dict),min_score=0.0,verify=False,max_concurrency=30. Errors:invalid_config,invalid_language,fewshot_not_found(paramconfig.fewshot_path).max_concurrencybelow 1 →invalid_config(paramconfig.max_concurrency). - Add
LLMJudgeDetector(client, model, *, config=None, cache=None, model_version=None)— builds no client, reads no environment, writes no file.model_id = model. _detectfor both request kinds. Reuse the prompt-building and item-locating code (first unused verbatim match, no overlaps). Score: the model'sconfidencewithinclude_reasoning=True, else 1.0 plus onesynthetic_scorewarning.- Unlocated item → drop +
span_not_found; item that is neither a string nor an object withtext→ drop +item_malformed; model-rejected item (is_hallucinationfalse) → drop silently. Log counts and codes only; raw reply and span text only onlettucedetect.contentat DEBUG. - Reply that is not JSON, lacks
hallucination_list, or has it as a non-list →UpstreamError(unparseable_response). adetectis inherited fromBaseDetector(#141) and not overridden: the synchronousLLMClientcall, the reply parsing and the locating all run inside the one worker thread._detectkeeps no per-call state on the detector, so concurrentadetectcalls on one instance don't interfere.LLMJudgeConfig.min_scoreapplies before (later) verify; the call'smin_scoreto the final spans.- Concurrency bound: the constructor creates one
threading.BoundedSemaphore(config.max_concurrency)per instance._detecttakes it only aroundclient.complete(released in afinally), never around cache access, parsing or the wholedetect, so every entry point shares it and a batch pool can't deadlock on it. The verify call (#160) takes the same semaphore. - Implementation note, not an acceptance criterion: write
_detectas thin orchestration. Prompt building, reply parsing, item locating and verify-merging are pure functions with no client, cache or thread in their signature, shared withGenerativeDetector(#163). The only I/O is three points: the cache read, the client call (under the semaphore) and the cache write or delete. A later native async driver (epic, Out of Scope) can then reuse the pure steps. They are tested throughdetectandadetectonly, as the epic's Testing Decisions require, not directly.
Acceptance criteria
- Output equals the #129 judge fixtures except spans without
confidencenow carry 1.0 (update those fixtures as an intended change, called out in the PR). - All error/warning cases above have tests with a fake client; no answer text appears in any message or non-content logger.
-
await adetect(...)equalsdetectfor aSourcesInputand aPromptInput, with and withoutinclude_reasoning, and the client call runs off the event loop's thread while the loop stays free (fake client that sleeps and records its thread). - Every error and warning case above also holds through
adetect:UpstreamError(unparseable_response) andConfigurationErrorcome out of theawaitwith the same class andcode, and a caller's own client error propagates unwrapped;span_not_found/item_malformedwarnings are in the result. -
asyncio.gatherover severaladetectcalls on one detector returns each call's own result in call order (fake client replies keyed by prompt). - With
max_concurrency=2and many concurrentdetectandadetectcalls on one detector (more than 2, started from threads and fromasyncio.gather), a counting fake client never sees more than 2 calls in flight and every call gets its own result.max_concurrency=0raisesConfigurationError(invalid_config, paramconfig.max_concurrency). -
LLMJudgeDetectorpasses the contract suite. - Existing tests pass; follows CONTRIBUTING "Errors and logging".
Start here
uv run --extra dev pytest tests/test_llm_detector_pytest.py tests/test_golden_llm_pytest.py -q
- Lingua principale
- Python
- Stelle
- 615
- Fork
- 60
- Merge medio
- 1g 8h
- PR unite (30g)
- 10
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di KRLabsOrg/LettuceDetect
-
Stop-hook --min-confidence drops every --llm-model span (missing confidence treated as 0.0), reporting hallucinated answers as cleanForse già presa @Clannad47 l’ha presa 18 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
KRLabsOrg/LettuceDetect#117 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
KRLabsOrg/LettuceDetect#108 ·
I maintainer di solito rispondono entro 1 giorno
-
documentation
Difficoltà 2/5 Mezza giornata Idoneità per principianti 70/100
KRLabsOrg/LettuceDetect#104 ·
I maintainer di solito rispondono entro 1 giorno
-
ready-for-agent
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
KRLabsOrg/LettuceDetect#181 ·
I maintainer di solito rispondono entro 1 giorno
-
ready-for-agent
Difficoltà 5/5 Più di una settimana Idoneità per principianti 22/100
KRLabsOrg/LettuceDetect#180 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di KRLabsOrg/LettuceDetect
Issue simili
-
LLVM versionsAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
I maintainer di solito rispondono entro 1 giorno
-
Translate docs/ to SpanishApertadocumentation good first issue language
Difficoltà 2/5 1-3 ore Idoneità per principianti 91/100
-
good first issue help wanted translation
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
I maintainer di solito rispondono entro 1 giorno
-
Fix duplicated word in speculative decoding docsForse già presa @ddlw l’ha presa oggi. Apertacommunity-request
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 89/100
NVIDIA/Megatron-LM#9118 ·
I maintainer di solito rispondono entro 2 giorni