mindformers.pipeline.TranslationPipeline¶
- class mindformers.pipeline.TranslationPipeline(model: Union[str, BaseModel, Model], tokenizer: Optional[BaseTokenizer] = None, **kwargs)[源代码]¶
Pipeline for Translation
- Args:
- model (Union[str, BaseModel]): The model used to perform task,
the input could be a supported model name, or a model instance inherited from BaseModel.
- tokenizer (Optional[BaseTokenizer]): A tokenizer (None or Tokenizer)
for text processing.
- Raises:
TypeError: If input model and tokenizer’s types are not corrected. ValueError: if the input model is not in support list.
- Examples:
>>> from mindformers.pipeline import TranslationPipeline >>> translator = TranslationPipeline("t5_small") >>> output = translator("abc")
- forward(model_inputs: dict, **forward_params)[源代码]¶
The Forward Process of Model
- Args:
inputs (dict): The output of preprocess. forward_params (dict): The parameter dict for model forward.