langtest.modelhandler.llm_modelhandler.PretrainedModelForSensitivity#

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

Bases: PretrainedModelForQA, ModelAPI

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

Initialize the PretrainedModelForSensitivity.

Parameters:
  • hub (str) – The hub name associated with the pretrained model.

  • model (Any) – The pretrained model to be used.

  • *args – Additional positional arguments.

  • **kwargs – Additional keyword arguments.

Methods

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

Initialize the PretrainedModelForSensitivity.

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, *args, **kwargs)#

Perform prediction using the pretrained model.

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

  • *args – Additional positional arguments.

  • **kwargs – Additional keyword arguments.

Returns:

A dictionary containing the prediction result.
  • ’result’: The prediction result.

Return type:

dict

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.