langtest.modelhandler.jsl_modelhandler.PretrainedModelForTranslation#

class PretrainedModelForTranslation(model: NLUPipeline | PretrainedPipeline | LightPipeline | PipelineModel)#

Bases: PretrainedJSLModel, ModelAPI

Pretrained model for translations tasks

__init__(model: NLUPipeline | PretrainedPipeline | LightPipeline | PipelineModel)#

Constructor class

Parameters:

model (LightPipeline) – Loaded SparkNLP LightPipeline for inference.

Methods

__init__(model)

Constructor class

is_translator(model_instance)

Check translator model instance is supported by langtest

load_model(path)

Load the NER model into the model attribute.

predict(text, *args, **kwargs)

Perform predictions with SparkNLP LightPipeline on the input text.

predict_raw(text)

Perform predictions on the input text.

Attributes

hub

model_registry

task

static is_translator(model_instance) bool#

Check translator model instance is supported by langtest

classmethod load_model(path) NLUPipeline#

Load the NER model into the model attribute.

Parameters:

path (str) – Path to pretrained local or NLP Models Hub SparkNLP model

predict(text: str, *args, **kwargs) TranslationOutput#

Perform predictions with SparkNLP LightPipeline on the input text.

Parameters:

text (str) – Input text to perform translation on.

Returns:

Translation output from SparkNLP LightPipeline.

Return type:

TranslationOutput

predict_raw(text: str) List[str]#

Perform predictions on the input text.

Parameters:

text (str) – Input text to perform translation on.

Returns:

Predictions as a list of strings.

Return type:

List[str]