π Generic Single TurnΒΆ
metrics.llm_as_judge.rating.llama_3_70b_instruct.generic_single_turn
LLMAsJudge(
inference_model=CrossProviderInferenceEngine(
model="llama-3-70b-instruct",
max_tokens=252,
),
template="templates.response_assessment.rating.generic_single_turn",
task="rating.single_turn",
format="formats.chat_api",
main_score="llama_3_70b_instruct_template_generic_single_turn",
prediction_type="str",
)
[source]from unitxt.inference import CrossProviderInferenceEngine
Explanation about LLMAsJudgeΒΆ
LLM-as-judge-based metric class for evaluating correctness of generated predictions.
This class uses the source prompt given to the generator and the generatorβs predictions to evaluate correctness using one of three supported tasks (rating.single_turn, rating.single_turn_with_reference, pairwise_comparative_rating.single_turn).
- Attributes:
main_score (str): The main score label used for evaluation.
task (Literal[βrating.single_turnβ,βrating.single_turn_with_referenceβ, βpairwise_comparative_rating.single_turnβ]): The type of task the llm as judge runs. This defines the output and input format of the judge model.
template (Template): The template used when generating inputs for the judge llm.
format (Format): The format used when generating inputs for judge llm.
system_prompt (SystemPrompt): The system prompt used when generating inputs for judge llm.
strip_system_prompt_and_format_from_inputs (bool): Whether to strip the system prompt and formatting from the inputs that the models that is being judges received, when they are inserted to the llm-as-judge prompt.
inference_model (InferenceEngine): The module that creates the inference of the judge llm.
reduction_map (dict): A dictionary specifying the reduction method for the metric.
batch_size (int): The size of the bulk.
Explanation about CrossProviderInferenceEngineΒΆ
Inference engine capable of dynamically switching between multiple providers APIs.
This class extends the InferenceEngine and OpenAiInferenceEngineParamsMixin to enable seamless integration with various API providers. The supported APIs are specified in
_supported_apis, allowing users to interact with multiple models from different sources. Theprovider_model_mapdictionary maps each API to specific model identifiers, enabling automatic configuration based on user requests.Current _supported_apis = [βwatsonxβ, βtogether-aiβ, βopen-aiβ, βawsβ, βollamaβ, βbamβ, βwatsonx-sdkβ, βritsβ, βvertex-aiβ]
- Args:
- provider (Optional):
Specifies the current API in use. Must be one of the literals in _supported_apis.
- provider_model_map (Dict[_supported_apis, Dict[str, str]]):
mapping each supported API to a corresponding model identifier string. This mapping allows consistent access to models across different API backends.
- provider_specific_args:
(Optional[Dict[str, Dict[str,str]]]) Args specific to a provider for example provider_specific_args={βwatsonxβ: {βmax_requests_per_secondβ: 4}}
References: templates.response_assessment.rating.generic_single_turn, formats.chat_api
Read more about catalog usage here.