.. include:: /Includes.rst.txt .. _developer-quality-evaluation: ================== Quality evaluation ================== nr_llm can measure the quality of the answers a model produces against **golden prompt sets** and detect regressions between runs. Evaluation is an explicitly triggered, out-of-request operation — it never runs in the request pipeline and, with the default grader, spends no tokens. See :ref:`ADR-060 ` for the design rationale. A golden set is a collection of prompts, each with the expectations it should satisfy. A run executes the set against a model, grades every response, aggregates the results to a pass rate and mean score, stores the run, and compares it against the previous run for the same set and model. .. _developer-quality-evaluation-declaring: Declaring a golden set in your extension ======================================== Implement :php:`GoldenPromptSetProviderInterface`. The ``nr_llm.golden_prompt_set`` DI tag is applied automatically when your extension's :file:`Services.yaml` has ``autoconfigure: true`` (the TYPO3 default): .. code-block:: php selectByQuality( ['capabilities' => ['chat']], minQuality: 0.7, ); ``selectByQuality()`` takes the candidates :php:`ModelSelectionService` would return for the criteria and re-ranks them by measured quality score (latest run per set, averaged). Candidates without evaluation data keep their base order behind the scored ones; with ``minQuality`` set, candidates below it (or without data) are excluded. Making quality a first-class sort key inside :php:`ModelSelectionService` is a planned follow-up (see :ref:`ADR-060 `).