speechbrain.lobes.models.huggingface_transformers.labse module
This lobe enables the integration of huggingface pretrained LaBSE models. Reference: https://arxiv.org/abs/2007.01852
Transformer from HuggingFace needs to be installed: https://huggingface.co/transformers/installation.html
- Authors
Ha Nguyen 2023
Summary
Classes:
This lobe enables the integration of HuggingFace and SpeechBrain pretrained LaBSE models. |
Reference
- class speechbrain.lobes.models.huggingface_transformers.labse.LaBSE(source, save_path, freeze=True, output_norm=True)[source]
Bases:
HFTransformersInterface
This lobe enables the integration of HuggingFace and SpeechBrain pretrained LaBSE models.
Source paper LaBSE: https://arxiv.org/abs/2007.01852 Transformer from HuggingFace needs to be installed: https://huggingface.co/transformers/installation.html
The model can be used as a fixed text-based sentence-level embeddings generator or can be finetuned. It will download automatically the model from HuggingFace or use a local path.
- Parameters:
source (str) – HuggingFace hub name: e.g “setu4993/LaBSE”
save_path (str) – Path (dir) of the downloaded model.
freeze (bool (default: True)) – If True, the model is frozen. If False, the model will be trained alongside with the rest of the pipeline.
output_norm (bool (default: True)) – If True, normalize the output.
Example
>>> inputs = ["La vie est belle"] >>> model_hub = "setu4993/smaller-LaBSE" >>> save_path = "savedir" >>> model = LaBSE(model_hub, save_path) >>> outputs = model(inputs)