langtest.modelhandler.lmstudio_modelhandler.PretrainedModelForNER#
- class PretrainedModelForNER(model: Any, output_parser: Callable | None = None, **kwargs)#
Bases:
PretrainedModel
,ModelAPI
A class representing a pretrained model for named entity recognition.
- Inherits:
PretrainedModel: The base class for pretrained models.
- predict(text: str, \*args, \*\*kwargs)#
Predicts the answer to a given question based on the pre-trained model.
- Raises:
Exception – If an error occurs during prediction.
- __init__(model: Any, output_parser: Callable | None = None, **kwargs) None #
Initialize the PretrainedModel.
- Parameters:
model (Any) – The pretrained model to be used.
**kwargs – Additional keyword arguments.
Methods
__init__
(model[, output_parser])Initialize the PretrainedModel.
load_model
(path, *args, **kwargs)Load the pretrained model.
predict
(text, *args, **kwargs)Perform prediction using the pretrained model.
predict_raw
(text, prompt, server_prompt, ...)Predicts the output for the given input text without caching.
Attributes
model_registry
- classmethod load_model(path: str, *args, **kwargs) Any #
Load the pretrained model.
- Parameters:
path (str) – The path to the pretrained model.
*args – Additional positional arguments.
**kwargs – Additional keyword arguments.
- Returns:
The loaded pretrained model.
- Return type:
Any
- predict_raw(text: str | dict, prompt: dict, server_prompt: str, *args, **kwargs)#
Predicts the output for the given input text without caching.
- Parameters:
text (Union[str, dict]) – The input text or dictionary.
prompt (dict) – The prompt for the prediction.
server_prompt (str) – The server prompt for the chat.
*args – Additional positional arguments.
**kwargs – Additional keyword arguments.
- Returns:
The predicted output.
- Return type:
str