langtest.modelhandler.llm_modelhandler.PretrainedModelForFactuality#

class PretrainedModelForFactuality(hub: str, model: Any, *args, **kwargs)#

Bases: PretrainedModelForQA, ModelAPI

A class representing a pretrained model for factuality detection.

Inherits:

PretrainedModelForQA: The base class for pretrained models.

__init__(hub: str, model: Any, *args, **kwargs)#

Constructor class

Parameters:
  • hub (str) – The hub name for the model.

  • model (str) – The model name or path.

  • *args – Additional positional arguments.

  • **kwargs – Additional keyword arguments.

Methods

__init__(hub, model, *args, **kwargs)

Constructor class

load_model(hub, path, *args, **kwargs)

Load the pretrained model.

predict(text, prompt, *args, **kwargs)

Perform prediction using the pretrained model.

predict_raw(text, prompt, *args, **kwargs)

Perform raw prediction using the pretrained model.

Attributes

HUB_PARAM_MAPPING

model_registry

classmethod load_model(hub: str, path: str, *args, **kwargs) PretrainedModelForQA#

Load the pretrained model.

Parameters:
  • hub (str) – The hub name for the model.

  • path (str) – The model path.

  • *args – Additional positional arguments.

  • **kwargs – Additional keyword arguments.

Returns:

The loaded pretrained model.

Return type:

PretrainedModelForQA

Raises:
  • ValueError – If the model is not found online or locally.

  • ConfigError – If there is an error in the model configuration.

predict(text: str | dict, prompt: dict, *args, **kwargs)#

Perform prediction using the pretrained model.

Parameters:
  • text (Union[str, dict]) – The input text or dictionary.

  • prompt (dict) – The prompt configuration.

  • *args – Additional positional arguments.

  • **kwargs – Additional keyword arguments.

Returns:

The prediction result.

predict_raw(text: str | dict, prompt: dict, *args, **kwargs)#

Perform raw prediction using the pretrained model.

Parameters:
  • text (Union[str, dict]) – The input text or dictionary.

  • prompt (dict) – The prompt configuration.

  • *args – Additional positional arguments.

  • **kwargs – Additional keyword arguments.

Returns:

The prediction result.