deeppavlov / deeppavlov/AutoIntent

Extract `BaseAPIDescriptionScorer` shared by `LLMDescriptionScorer` and `TypeSafeDescriptionScorer`

Open
#357 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Python
Stars
54
Forks
16
PR merge metrics
No merged PRs in 30d

Description

After #350, LLMDescriptionScorer (llm_encoder.py, 319 lines) and TypeSafeDescriptionScorer (typesafe.py, 416 lines) carry the same machinery side by side:

concern LLMDescriptionScorer TypeSafeDescriptionScorer
max_concurrent / max_per_second params, sync client when max_concurrent is None :111-136 :160-209
_init_event_loop + run_until_complete(aiometer.run_all(...)) fan-out :247-252, :282-291 :331-340, :259-270
per-utterance sync/async ask with failure → uniform row :202-224, :264-268 :342-362, :303-307
clear_cache dropping clients + loop :274-280 :384-388
dump / load with exclude=[asyncio.BaseEventLoop, dict] and a JSON sidecar for the config :293-318 :390-416

They differ only in what one request is (an OpenAI structured-output prompt vs a TypeSafe Choice/Noul question), how its answer maps to a similarity row, and the cache key.

Proposed

BaseAPIDescriptionScorer(DescriptionScorer) owning the shared part: the request fan-out (_ask_many), the event-loop helper, cache-first lookup, the fatal/transient error policy, clear_cache, dump/load. Subclasses implement _ask_one_async(utterance) -> row, _cache_key(utterance), client construction, and the similarity mapping. description_bi / description_cross stay on DescriptionScorer as they are.

Deliberately left out of #350 to keep it reviewable. Best done after the three behavioural fixes so each policy is written once, in the base: #351 (error policy), #353 (event loop), #354 (cache before limiter).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read src/autointent/modules/scoring/_description/llm_encoder.py and typesafe.py, comparing the listed shared concerns and the existing DescriptionScorer. Review #351, #353, and #354 first to understand the intended error, event-loop, and cache policies. Done means both scorers use a shared BaseAPIDescriptionScorer while retaining their distinct request, cache-key, and similarity behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.