code stringlengths 66 870k | docstring stringlengths 19 26.7k | func_name stringlengths 1 138 | language stringclasses 1
value | repo stringlengths 7 68 | path stringlengths 5 324 | url stringlengths 46 389 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
def forward(
self,
input_ids: Optional[torch.LongTensor] = None,
attention_mask: Optional[torch.FloatTensor] = None,
token_type_ids: Optional[torch.LongTensor] = None,
pixel_values: Optional[torch.FloatTensor] = None,
pixel_mask: Optional[torch.LongTensor] = None,
... |
labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
Labels are currently not supported.
Returns:
Examples:
```python
>>> from transformers import ViltProcessor, ViltForImageAndTextRetrieval
>>> import requests
>>> from PIL import Imag... | forward | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/vilt/modeling_vilt.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/vilt/modeling_vilt.py | Apache-2.0 |
def forward(
self,
input_ids: Optional[torch.LongTensor] = None,
attention_mask: Optional[torch.FloatTensor] = None,
token_type_ids: Optional[torch.LongTensor] = None,
pixel_values: Optional[torch.FloatTensor] = None,
pixel_mask: Optional[torch.LongTensor] = None,
... |
labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
Binary classification labels.
Returns:
Examples:
```python
>>> from transformers import ViltProcessor, ViltForImagesAndTextClassification
>>> import requests
>>> from PIL import Imag... | forward | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/vilt/modeling_vilt.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/vilt/modeling_vilt.py | Apache-2.0 |
def forward(
self,
input_ids: Optional[torch.LongTensor] = None,
attention_mask: Optional[torch.FloatTensor] = None,
token_type_ids: Optional[torch.LongTensor] = None,
pixel_values: Optional[torch.FloatTensor] = None,
pixel_mask: Optional[torch.LongTensor] = None,
... |
labels (`torch.LongTensor` of shape `(batch_size, text_sequence_length)`, *optional*):
Labels for computing the token classification loss. Indices should be in `[0, ..., config.num_labels - 1]`.
Returns:
| forward | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/vilt/modeling_vilt.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/vilt/modeling_vilt.py | Apache-2.0 |
def __call__(
self,
images,
text: Union[TextInput, PreTokenizedInput, List[TextInput], List[PreTokenizedInput]] = None,
add_special_tokens: bool = True,
padding: Union[bool, str, PaddingStrategy] = False,
truncation: Union[bool, str, TruncationStrategy] = None,
ma... |
This method uses [`ViltFeatureExtractor.__call__`] method to prepare image(s) for the model, and
[`BertTokenizerFast.__call__`] to prepare text for the model.
Please refer to the docstring of the above two methods for more information.
| __call__ | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/vilt/processing_vilt.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/vilt/processing_vilt.py | Apache-2.0 |
def from_encoder_decoder_configs(
cls, encoder_config: PretrainedConfig, decoder_config: PretrainedConfig, **kwargs
) -> PretrainedConfig:
r"""
Instantiate a [`VisionEncoderDecoderConfig`] (or a derived class) from a pre-trained encoder model
configuration and decoder model configura... |
Instantiate a [`VisionEncoderDecoderConfig`] (or a derived class) from a pre-trained encoder model
configuration and decoder model configuration.
Returns:
[`VisionEncoderDecoderConfig`]: An instance of a configuration object
| from_encoder_decoder_configs | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/vision_encoder_decoder/configuration_vision_encoder_decoder.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/vision_encoder_decoder/configuration_vision_encoder_decoder.py | Apache-2.0 |
def get_decoder_config(
self, encoder_config: PretrainedConfig, decoder_config: PretrainedConfig, feature: str = "default"
) -> OnnxConfig:
r"""
Returns ONNX decoder config for `VisionEncoderDecoder` model.
Args:
encoder_config (`PretrainedConfig`):
The e... |
Returns ONNX decoder config for `VisionEncoderDecoder` model.
Args:
encoder_config (`PretrainedConfig`):
The encoder model's configuration to use when exporting to ONNX.
decoder_config (`PretrainedConfig`):
The decoder model's configuration to us... | get_decoder_config | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/vision_encoder_decoder/configuration_vision_encoder_decoder.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/vision_encoder_decoder/configuration_vision_encoder_decoder.py | Apache-2.0 |
def encode(
self,
pixel_values: jnp.ndarray,
output_attentions: Optional[bool] = None,
output_hidden_states: Optional[bool] = None,
return_dict: Optional[bool] = None,
train: bool = False,
params: dict = None,
dropout_rng: PRNGKey = None,
):
r"... |
Returns:
Example:
```python
>>> from transformers import ViTFeatureExtractor, FlaxVisionEncoderDecoderModel
>>> from PIL import Image
>>> import requests
>>> url = "http://images.cocodataset.org/val2017/000000039769.jpg"
>>> image = Image.open(requests... | encode | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/vision_encoder_decoder/modeling_flax_vision_encoder_decoder.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/vision_encoder_decoder/modeling_flax_vision_encoder_decoder.py | Apache-2.0 |
def decode(
self,
decoder_input_ids,
encoder_outputs,
decoder_attention_mask: Optional[jnp.ndarray] = None,
decoder_position_ids: Optional[jnp.ndarray] = None,
past_key_values: dict = None,
output_attentions: Optional[bool] = None,
output_hidden_states: Op... |
Returns:
Example:
```python
>>> from transformers import ViTFeatureExtractor, FlaxVisionEncoderDecoderModel
>>> import jax.numpy as jnp
>>> from PIL import Image
>>> import requests
>>> url = "http://images.cocodataset.org/val2017/000000039769.jpg"
... | decode | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/vision_encoder_decoder/modeling_flax_vision_encoder_decoder.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/vision_encoder_decoder/modeling_flax_vision_encoder_decoder.py | Apache-2.0 |
def __call__(
self,
pixel_values: jnp.ndarray,
decoder_input_ids: Optional[jnp.ndarray] = None,
decoder_attention_mask: Optional[jnp.ndarray] = None,
decoder_position_ids: Optional[jnp.ndarray] = None,
output_attentions: Optional[bool] = None,
output_hidden_states... |
Returns:
Examples:
```python
>>> from transformers import FlaxVisionEncoderDecoderModel, ViTFeatureExtractor, GPT2Tokenizer
>>> from PIL import Image
>>> import requests
>>> url = "http://images.cocodataset.org/val2017/000000039769.jpg"
>>> image = Ima... | __call__ | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/vision_encoder_decoder/modeling_flax_vision_encoder_decoder.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/vision_encoder_decoder/modeling_flax_vision_encoder_decoder.py | Apache-2.0 |
def from_encoder_decoder_pretrained(
cls,
encoder_pretrained_model_name_or_path: Optional[Union[str, os.PathLike]] = None,
decoder_pretrained_model_name_or_path: Optional[Union[str, os.PathLike]] = None,
*model_args,
**kwargs
) -> FlaxPreTrainedModel:
r"""
Ins... |
Instantiate an encoder and a decoder from one or two base classes of the library from pretrained model
checkpoints.
Params:
encoder_pretrained_model_name_or_path (`Union[str, os.PathLike]`, *optional*):
Information necessary to initiate the encoder. Can be either:
... | from_encoder_decoder_pretrained | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/vision_encoder_decoder/modeling_flax_vision_encoder_decoder.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/vision_encoder_decoder/modeling_flax_vision_encoder_decoder.py | Apache-2.0 |
def from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs):
r"""
Example:
```python
>>> from transformers import TFVisionEncoderDecoderModel, ViTFeatureExtractor, GPT2Tokenizer
>>> from PIL import Image
>>> import requests
>>> feature_extract... |
Example:
```python
>>> from transformers import TFVisionEncoderDecoderModel, ViTFeatureExtractor, GPT2Tokenizer
>>> from PIL import Image
>>> import requests
>>> feature_extractor = ViTFeatureExtractor.from_pretrained("ydshieh/vit-gpt2-coco-en")
>>> decoder_tok... | from_pretrained | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/vision_encoder_decoder/modeling_tf_vision_encoder_decoder.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/vision_encoder_decoder/modeling_tf_vision_encoder_decoder.py | Apache-2.0 |
def from_encoder_decoder_pretrained(
cls,
encoder_pretrained_model_name_or_path: str = None,
decoder_pretrained_model_name_or_path: str = None,
*model_args,
**kwargs
) -> TFPreTrainedModel:
r"""
Instantiate an encoder and a decoder from one or two base classes... |
Instantiate an encoder and a decoder from one or two base classes of the library from pretrained model
checkpoints.
Params:
encoder_pretrained_model_name_or_path (`str`, *optional*):
Information necessary to initiate the encoder. Can be either:
... | from_encoder_decoder_pretrained | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/vision_encoder_decoder/modeling_tf_vision_encoder_decoder.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/vision_encoder_decoder/modeling_tf_vision_encoder_decoder.py | Apache-2.0 |
def call(
self,
pixel_values=None,
decoder_input_ids=None,
decoder_attention_mask=None,
encoder_outputs=None,
past_key_values=None,
decoder_inputs_embeds=None,
labels=None,
use_cache=None,
output_attentions=None,
output_hidden_state... |
Returns:
Examples:
```python
>>> from transformers import AutoFeatureExtractor, AutoTokenizer, TFVisionEncoderDecoderModel
>>> from PIL import Image
>>> import requests
>>> feature_extractor = AutoFeatureExtractor.from_pretrained("google/vit-base-patch16-224-i... | call | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/vision_encoder_decoder/modeling_tf_vision_encoder_decoder.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/vision_encoder_decoder/modeling_tf_vision_encoder_decoder.py | Apache-2.0 |
def from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs):
r"""
Example:
```python
>>> from transformers import VisionEncoderDecoderModel, ViTFeatureExtractor, GPT2Tokenizer
>>> from PIL import Image
>>> import requests
>>> feature_extractor... |
Example:
```python
>>> from transformers import VisionEncoderDecoderModel, ViTFeatureExtractor, GPT2Tokenizer
>>> from PIL import Image
>>> import requests
>>> feature_extractor = ViTFeatureExtractor.from_pretrained("ydshieh/vit-gpt2-coco-en")
>>> decoder_token... | from_pretrained | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/vision_encoder_decoder/modeling_vision_encoder_decoder.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/vision_encoder_decoder/modeling_vision_encoder_decoder.py | Apache-2.0 |
def from_encoder_decoder_pretrained(
cls,
encoder_pretrained_model_name_or_path: str = None,
decoder_pretrained_model_name_or_path: str = None,
*model_args,
**kwargs
) -> PreTrainedModel:
r"""
Instantiate an encoder and a decoder from one or two base classes o... |
Instantiate an encoder and a decoder from one or two base classes of the library from pretrained model
checkpoints.
The model is set in evaluation mode by default using `model.eval()` (Dropout modules are deactivated). To train
the model, you need to first set it back in training mode... | from_encoder_decoder_pretrained | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/vision_encoder_decoder/modeling_vision_encoder_decoder.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/vision_encoder_decoder/modeling_vision_encoder_decoder.py | Apache-2.0 |
def forward(
self,
pixel_values=None,
decoder_input_ids=None,
decoder_attention_mask=None,
encoder_outputs=None,
past_key_values=None,
decoder_inputs_embeds=None,
labels=None,
use_cache=None,
output_attentions=None,
output_hidden_st... |
Returns:
Examples:
```python
>>> from transformers import TrOCRProcessor, VisionEncoderDecoderModel
>>> import requests
>>> from PIL import Image
>>> import torch
>>> processor = TrOCRProcessor.from_pretrained("microsoft/trocr-base-handwritten")
... | forward | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/vision_encoder_decoder/modeling_vision_encoder_decoder.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/vision_encoder_decoder/modeling_vision_encoder_decoder.py | Apache-2.0 |
def get_text_features(
self,
input_ids,
attention_mask=None,
position_ids=None,
token_type_ids=None,
params: dict = None,
dropout_rng: jax.random.PRNGKey = None,
train=False,
):
r"""
Args:
input_ids (`numpy.ndarray` of shape... |
Args:
input_ids (`numpy.ndarray` of shape `(batch_size, sequence_length)`):
Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you
provide it.
Indices can be obtained using [`PreTrainedTokenizer`]. See [`Pre... | get_text_features | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/vision_text_dual_encoder/modeling_flax_vision_text_dual_encoder.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/vision_text_dual_encoder/modeling_flax_vision_text_dual_encoder.py | Apache-2.0 |
def get_image_features(
self, pixel_values, params: dict = None, dropout_rng: jax.random.PRNGKey = None, train=False
):
r"""
Args:
pixel_values (`numpy.ndarray` of shape `(batch_size, num_channels, height, width)`):
Pixel values. Padding will be ignored by default... |
Args:
pixel_values (`numpy.ndarray` of shape `(batch_size, num_channels, height, width)`):
Pixel values. Padding will be ignored by default should you provide it. Pixel values can be obtained
using [`ImageFeatureExtractionMixin`]. See [`ImageFeatureExtractionMixin.__... | get_image_features | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/vision_text_dual_encoder/modeling_flax_vision_text_dual_encoder.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/vision_text_dual_encoder/modeling_flax_vision_text_dual_encoder.py | Apache-2.0 |
def from_vision_text_pretrained(
cls,
vision_model_name_or_path: str = None,
text_model_name_or_path: str = None,
*model_args,
**kwargs,
) -> FlaxPreTrainedModel:
"""
Params:
vision_model_name_or_path (`str`, *optional*, defaults to `None`):
... |
Params:
vision_model_name_or_path (`str`, *optional*, defaults to `None`):
Information necessary to initiate the vision model. Can be either:
- A string, the *model id* of a pretrained model hosted inside a model repo on huggingface.co.
Val... | from_vision_text_pretrained | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/vision_text_dual_encoder/modeling_flax_vision_text_dual_encoder.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/vision_text_dual_encoder/modeling_flax_vision_text_dual_encoder.py | Apache-2.0 |
def get_text_features(
self,
input_ids=None,
attention_mask=None,
position_ids=None,
token_type_ids=None,
output_attentions=None,
output_hidden_states=None,
return_dict=None,
):
r"""
Returns:
text_features (`torch.FloatTenso... |
Returns:
text_features (`torch.FloatTensor` of shape `(batch_size, output_dim`): The text embeddings obtained by
applying the projection layer to the pooled output of [`CLIPTextModel`].
Examples:
```python
>>> from transformers import VisionTextDualEncoderModel... | get_text_features | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/vision_text_dual_encoder/modeling_vision_text_dual_encoder.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/vision_text_dual_encoder/modeling_vision_text_dual_encoder.py | Apache-2.0 |
def get_image_features(
self,
pixel_values=None,
output_attentions=None,
output_hidden_states=None,
return_dict=None,
):
r"""
Returns:
image_features (`torch.FloatTensor` of shape `(batch_size, output_dim`): The image embeddings obtained by
... |
Returns:
image_features (`torch.FloatTensor` of shape `(batch_size, output_dim`): The image embeddings obtained by
applying the projection layer to the pooled output of [`CLIPVisionModel`].
Examples:
```python
>>> from PIL import Image
>>> import reques... | get_image_features | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/vision_text_dual_encoder/modeling_vision_text_dual_encoder.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/vision_text_dual_encoder/modeling_vision_text_dual_encoder.py | Apache-2.0 |
def forward(
self,
input_ids=None,
pixel_values=None,
attention_mask=None,
position_ids=None,
return_loss=None,
token_type_ids=None,
output_attentions=None,
output_hidden_states=None,
return_dict=None,
):
r"""
Returns:
... |
Returns:
Examples:
```python
>>> from PIL import Image
>>> import requests
>>> from transformers import (
... VisionTextDualEncoderModel,
... VisionTextDualEncoderProcessor,
... ViTFeatureExtractor,
... BertTokenizer,
... | forward | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/vision_text_dual_encoder/modeling_vision_text_dual_encoder.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/vision_text_dual_encoder/modeling_vision_text_dual_encoder.py | Apache-2.0 |
def from_vision_text_pretrained(
cls,
vision_model_name_or_path: str = None,
text_model_name_or_path: str = None,
*model_args,
**kwargs,
) -> PreTrainedModel:
"""
Params:
vision_model_name_or_path (`str`, *optional*, defaults to `None`):
... |
Params:
vision_model_name_or_path (`str`, *optional*, defaults to `None`):
Information necessary to initiate the vision model. Can be either:
- A string, the *model id* of a pretrained model hosted inside a model repo on huggingface.co.
Val... | from_vision_text_pretrained | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/vision_text_dual_encoder/modeling_vision_text_dual_encoder.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/vision_text_dual_encoder/modeling_vision_text_dual_encoder.py | Apache-2.0 |
def __call__(self, text=None, images=None, return_tensors=None, **kwargs):
"""
Main method to prepare for the model one or several sequences(s) and image(s). This method forwards the `text`
and `kwargs` arguments to VisionTextDualEncoderTokenizer's [`~PreTrainedTokenizer.__call__`] if `text` is ... |
Main method to prepare for the model one or several sequences(s) and image(s). This method forwards the `text`
and `kwargs` arguments to VisionTextDualEncoderTokenizer's [`~PreTrainedTokenizer.__call__`] if `text` is not
`None` to encode the text. To prepare the image(s), this method forwards t... | __call__ | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/vision_text_dual_encoder/processing_vision_text_dual_encoder.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/vision_text_dual_encoder/processing_vision_text_dual_encoder.py | Apache-2.0 |
def convert_visual_bert_checkpoint(checkpoint_path, pytorch_dump_folder_path):
"""
Copy/paste/tweak model's weights to our VisualBERT structure.
"""
assert (
checkpoint_path.split("/")[-1] in ACCEPTABLE_CHECKPOINTS
), f"The checkpoint provided must be in {ACCEPTABLE_CHECKPOINTS}."
# Ge... |
Copy/paste/tweak model's weights to our VisualBERT structure.
| convert_visual_bert_checkpoint | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/visual_bert/convert_visual_bert_original_pytorch_checkpoint_to_pytorch.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/visual_bert/convert_visual_bert_original_pytorch_checkpoint_to_pytorch.py | Apache-2.0 |
def forward(
self,
input_ids: Optional[torch.LongTensor] = None,
attention_mask: Optional[torch.LongTensor] = None,
token_type_ids: Optional[torch.LongTensor] = None,
position_ids: Optional[torch.LongTensor] = None,
head_mask: Optional[torch.LongTensor] = None,
in... |
Returns:
Example:
```python
# Assumption: *get_visual_embeddings(image)* gets the visual embeddings of the image.
from transformers import BertTokenizer, VisualBertModel
import torch
tokenizer = BertTokenizer.from_pretrained("bert-base-uncased")
model... | forward | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/visual_bert/modeling_visual_bert.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/visual_bert/modeling_visual_bert.py | Apache-2.0 |
def forward(
self,
input_ids: Optional[torch.LongTensor] = None,
attention_mask: Optional[torch.LongTensor] = None,
token_type_ids: Optional[torch.LongTensor] = None,
position_ids: Optional[torch.LongTensor] = None,
head_mask: Optional[torch.LongTensor] = None,
in... |
labels (`torch.LongTensor` of shape `(batch_size, total_sequence_length)`, *optional*):
Labels for computing the masked language modeling loss. Indices should be in `[-100, 0, ...,
config.vocab_size]` (see `input_ids` docstring) Tokens with indices set to `-100` are ignored (masked), th... | forward | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/visual_bert/modeling_visual_bert.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/visual_bert/modeling_visual_bert.py | Apache-2.0 |
def forward(
self,
input_ids: Optional[torch.LongTensor] = None,
attention_mask: Optional[torch.LongTensor] = None,
token_type_ids: Optional[torch.LongTensor] = None,
position_ids: Optional[torch.LongTensor] = None,
head_mask: Optional[torch.LongTensor] = None,
in... |
labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
Labels for computing the multiple choice classification loss. Indices should be in `[0, ...,
num_choices-1]` where `num_choices` is the size of the second dimension of the input tensors. (See
`input_ids` above... | forward | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/visual_bert/modeling_visual_bert.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/visual_bert/modeling_visual_bert.py | Apache-2.0 |
def forward(
self,
input_ids: Optional[torch.LongTensor] = None,
attention_mask: Optional[torch.LongTensor] = None,
token_type_ids: Optional[torch.LongTensor] = None,
position_ids: Optional[torch.LongTensor] = None,
head_mask: Optional[torch.LongTensor] = None,
in... |
labels (`torch.LongTensor` of shape `(batch_size, total_sequence_length)`, *optional*):
Labels for computing the sequence classification/regression loss. Indices should be in `[0, ...,
config.num_labels - 1]`. A KLDivLoss is computed between the labels and the returned logits.
... | forward | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/visual_bert/modeling_visual_bert.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/visual_bert/modeling_visual_bert.py | Apache-2.0 |
def forward(
self,
input_ids: Optional[torch.LongTensor] = None,
attention_mask: Optional[torch.LongTensor] = None,
token_type_ids: Optional[torch.LongTensor] = None,
position_ids: Optional[torch.LongTensor] = None,
head_mask: Optional[torch.LongTensor] = None,
in... |
labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
Labels for computing the sequence classification/regression loss. Indices should be in `[0, ...,
config.num_labels - 1]`. A classification loss is computed (Cross-Entropy) against these labels.
Returns:
... | forward | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/visual_bert/modeling_visual_bert.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/visual_bert/modeling_visual_bert.py | Apache-2.0 |
def forward(
self,
input_ids: Optional[torch.LongTensor] = None,
attention_mask: Optional[torch.LongTensor] = None,
token_type_ids: Optional[torch.LongTensor] = None,
position_ids: Optional[torch.LongTensor] = None,
head_mask: Optional[torch.LongTensor] = None,
in... |
region_to_phrase_position (`torch.LongTensor` of shape `(batch_size, total_sequence_length)`, *optional*):
The positions depicting the position of the image embedding corresponding to the textual tokens.
labels (`torch.LongTensor` of shape `(batch_size, total_sequence_length, visual_sequen... | forward | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/visual_bert/modeling_visual_bert.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/visual_bert/modeling_visual_bert.py | Apache-2.0 |
def convert_vit_checkpoint(model_name, pytorch_dump_folder_path, base_model=True):
"""
Copy/paste/tweak model's weights to our ViT structure.
"""
# define default ViT configuration
config = ViTConfig()
# patch_size
if model_name[-1] == "8":
config.patch_size = 8
# set labels if ... |
Copy/paste/tweak model's weights to our ViT structure.
| convert_vit_checkpoint | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/vit/convert_dino_to_pytorch.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/vit/convert_dino_to_pytorch.py | Apache-2.0 |
def forward(
self,
pixel_values: Optional[torch.Tensor] = None,
bool_masked_pos: Optional[torch.BoolTensor] = None,
head_mask: Optional[torch.Tensor] = None,
output_attentions: Optional[bool] = None,
output_hidden_states: Optional[bool] = None,
interpolate_pos_enc... |
bool_masked_pos (`torch.BoolTensor` of shape `(batch_size, num_patches)`):
Boolean masked positions. Indicates which patches are masked (1) and which aren't (0).
Returns:
Examples:
```python
>>> from transformers import ViTFeatureExtractor, ViTForMaskedImageModelin... | forward | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/vit/modeling_vit.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/vit/modeling_vit.py | Apache-2.0 |
def get_2d_sincos_pos_embed(embed_dim, grid_size, add_cls_token=False):
"""
Create 2D sin/cos positional embeddings.
Args:
embed_dim (`int`):
Embedding dimension.
grid_size (`int`):
The grid height and width.
add_cls_token (`bool`, *optional*, defaults to `Fa... |
Create 2D sin/cos positional embeddings.
Args:
embed_dim (`int`):
Embedding dimension.
grid_size (`int`):
The grid height and width.
add_cls_token (`bool`, *optional*, defaults to `False`):
Whether or not to add a classification (CLS) token.
Ret... | get_2d_sincos_pos_embed | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/vit_mae/modeling_tf_vit_mae.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/vit_mae/modeling_tf_vit_mae.py | Apache-2.0 |
def get_1d_sincos_pos_embed_from_grid(embed_dim, pos):
"""
embed_dim: output dimension for each position pos: a list of positions to be encoded: size (M,) out: (M, D)
"""
if embed_dim % 2 != 0:
raise ValueError("embed_dim must be even")
omega = tf.range(embed_dim // 2, dtype="float32")
... |
embed_dim: output dimension for each position pos: a list of positions to be encoded: size (M,) out: (M, D)
| get_1d_sincos_pos_embed_from_grid | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/vit_mae/modeling_tf_vit_mae.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/vit_mae/modeling_tf_vit_mae.py | Apache-2.0 |
def random_masking(self, sequence: tf.Tensor, noise: Optional[tf.Tensor] = None):
"""
Perform per-sample random masking by per-sample shuffling. Per-sample shuffling is done by argsort random
noise.
Args:
sequence (`tf.Tensor` of shape `(batch_size, sequence_length, dim)`)
... |
Perform per-sample random masking by per-sample shuffling. Per-sample shuffling is done by argsort random
noise.
Args:
sequence (`tf.Tensor` of shape `(batch_size, sequence_length, dim)`)
noise (`tf.Tensor` of shape `(batch_size, sequence_length)`, *optional*) which is
... | random_masking | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/vit_mae/modeling_tf_vit_mae.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/vit_mae/modeling_tf_vit_mae.py | Apache-2.0 |
def call(
self,
pixel_values: Optional[TFModelInputType] = None,
noise: tf.Tensor = None,
head_mask: Optional[Union[np.ndarray, tf.Tensor]] = None,
output_attentions: Optional[bool] = None,
output_hidden_states: Optional[bool] = None,
return_dict: Optional[bool] =... |
Returns:
Examples:
```python
>>> from transformers import AutoFeatureExtractor, TFViTMAEModel
>>> from PIL import Image
>>> import requests
>>> url = "http://images.cocodataset.org/val2017/000000039769.jpg"
>>> image = Image.open(requests.get(url, stre... | call | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/vit_mae/modeling_tf_vit_mae.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/vit_mae/modeling_tf_vit_mae.py | Apache-2.0 |
def patchify(self, pixel_values):
"""
Args:
pixel_values (`tf.Tensor` of shape `(batch_size, height, width, num_channels)` or `(batch_size, num_channels, height, width)`):
Pixel values.
Returns:
`tf.Tensor` of shape `(batch_size, num_patches, patch_size**... |
Args:
pixel_values (`tf.Tensor` of shape `(batch_size, height, width, num_channels)` or `(batch_size, num_channels, height, width)`):
Pixel values.
Returns:
`tf.Tensor` of shape `(batch_size, num_patches, patch_size**2 * num_channels)`:
Patchifie... | patchify | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/vit_mae/modeling_tf_vit_mae.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/vit_mae/modeling_tf_vit_mae.py | Apache-2.0 |
def unpatchify(self, patchified_pixel_values):
"""
Args:
patchified_pixel_values (`tf.Tensor` of shape `(batch_size, num_patches, patch_size**2 * num_channels)`:
Patchified pixel values.
Returns:
`tf.Tensor` of shape `(batch_size, height, width, num_chann... |
Args:
patchified_pixel_values (`tf.Tensor` of shape `(batch_size, num_patches, patch_size**2 * num_channels)`:
Patchified pixel values.
Returns:
`tf.Tensor` of shape `(batch_size, height, width, num_channels)`:
Pixel values.
| unpatchify | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/vit_mae/modeling_tf_vit_mae.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/vit_mae/modeling_tf_vit_mae.py | Apache-2.0 |
def forward_loss(self, pixel_values, pred, mask):
"""
Args:
pixel_values (`tf.Tensor` of shape `(batch_size, height, width, num_channels)`):
Pixel values.
pred (`tf.Tensor` of shape `(batch_size, num_patches, patch_size**2 * num_channels)`:
Predict... |
Args:
pixel_values (`tf.Tensor` of shape `(batch_size, height, width, num_channels)`):
Pixel values.
pred (`tf.Tensor` of shape `(batch_size, num_patches, patch_size**2 * num_channels)`:
Predicted pixel values.
mask (`tf.Tensor` of shape `(bat... | forward_loss | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/vit_mae/modeling_tf_vit_mae.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/vit_mae/modeling_tf_vit_mae.py | Apache-2.0 |
def call(
self,
pixel_values: Optional[TFModelInputType] = None,
noise: tf.Tensor = None,
head_mask: Optional[Union[np.ndarray, tf.Tensor]] = None,
output_attentions: Optional[bool] = None,
output_hidden_states: Optional[bool] = None,
return_dict: Optional[bool] =... |
Returns:
Examples:
```python
>>> from transformers import AutoFeatureExtractor, TFViTMAEForPreTraining
>>> from PIL import Image
>>> import requests
>>> url = "http://images.cocodataset.org/val2017/000000039769.jpg"
>>> image = Image.open(requests.get(... | call | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/vit_mae/modeling_tf_vit_mae.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/vit_mae/modeling_tf_vit_mae.py | Apache-2.0 |
def get_2d_sincos_pos_embed(embed_dim, grid_size, add_cls_token=False):
"""
Create 2D sin/cos positional embeddings.
Args:
embed_dim (`int`):
Embedding dimension.
grid_size (`int`):
The grid height and width.
add_cls_token (`bool`, *optional*, defaults to `Fa... |
Create 2D sin/cos positional embeddings.
Args:
embed_dim (`int`):
Embedding dimension.
grid_size (`int`):
The grid height and width.
add_cls_token (`bool`, *optional*, defaults to `False`):
Whether or not to add a classification (CLS) token.
Ret... | get_2d_sincos_pos_embed | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/vit_mae/modeling_vit_mae.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/vit_mae/modeling_vit_mae.py | Apache-2.0 |
def random_masking(self, sequence, noise=None):
"""
Perform per-sample random masking by per-sample shuffling. Per-sample shuffling is done by argsort random
noise.
Args:
sequence (`torch.LongTensor` of shape `(batch_size, sequence_length, dim)`)
noise (`torch.Fl... |
Perform per-sample random masking by per-sample shuffling. Per-sample shuffling is done by argsort random
noise.
Args:
sequence (`torch.LongTensor` of shape `(batch_size, sequence_length, dim)`)
noise (`torch.FloatTensor` of shape `(batch_size, sequence_length)`, *optio... | random_masking | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/vit_mae/modeling_vit_mae.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/vit_mae/modeling_vit_mae.py | Apache-2.0 |
def forward(
self,
pixel_values: Optional[torch.FloatTensor] = None,
noise: Optional[torch.FloatTensor] = None,
head_mask: Optional[torch.FloatTensor] = None,
output_attentions: Optional[bool] = None,
output_hidden_states: Optional[bool] = None,
return_dict: Optio... |
Returns:
Examples:
```python
>>> from transformers import AutoFeatureExtractor, ViTMAEModel
>>> from PIL import Image
>>> import requests
>>> url = "http://images.cocodataset.org/val2017/000000039769.jpg"
>>> image = Image.open(requests.get(url, stream... | forward | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/vit_mae/modeling_vit_mae.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/vit_mae/modeling_vit_mae.py | Apache-2.0 |
def patchify(self, pixel_values):
"""
Args:
pixel_values (`torch.FloatTensor` of shape `(batch_size, num_channels, height, width)`):
Pixel values.
Returns:
`torch.FloatTensor` of shape `(batch_size, num_patches, patch_size**2 * num_channels)`:
... |
Args:
pixel_values (`torch.FloatTensor` of shape `(batch_size, num_channels, height, width)`):
Pixel values.
Returns:
`torch.FloatTensor` of shape `(batch_size, num_patches, patch_size**2 * num_channels)`:
Patchified pixel values.
| patchify | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/vit_mae/modeling_vit_mae.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/vit_mae/modeling_vit_mae.py | Apache-2.0 |
def unpatchify(self, patchified_pixel_values):
"""
Args:
patchified_pixel_values (`torch.FloatTensor` of shape `(batch_size, num_patches, patch_size**2 * num_channels)`:
Patchified pixel values.
Returns:
`torch.FloatTensor` of shape `(batch_size, num_chan... |
Args:
patchified_pixel_values (`torch.FloatTensor` of shape `(batch_size, num_patches, patch_size**2 * num_channels)`:
Patchified pixel values.
Returns:
`torch.FloatTensor` of shape `(batch_size, num_channels, height, width)`:
Pixel values.
... | unpatchify | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/vit_mae/modeling_vit_mae.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/vit_mae/modeling_vit_mae.py | Apache-2.0 |
def forward_loss(self, pixel_values, pred, mask):
"""
Args:
pixel_values (`torch.FloatTensor` of shape `(batch_size, num_channels, height, width)`):
Pixel values.
pred (`torch.FloatTensor` of shape `(batch_size, num_patches, patch_size**2 * num_channels)`:
... |
Args:
pixel_values (`torch.FloatTensor` of shape `(batch_size, num_channels, height, width)`):
Pixel values.
pred (`torch.FloatTensor` of shape `(batch_size, num_patches, patch_size**2 * num_channels)`:
Predicted pixel values.
mask (`torch.Flo... | forward_loss | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/vit_mae/modeling_vit_mae.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/vit_mae/modeling_vit_mae.py | Apache-2.0 |
def forward(
self,
pixel_values: Optional[torch.FloatTensor] = None,
noise: Optional[torch.FloatTensor] = None,
head_mask: Optional[torch.FloatTensor] = None,
output_attentions: Optional[bool] = None,
output_hidden_states: Optional[bool] = None,
return_dict: Optio... |
Returns:
Examples:
```python
>>> from transformers import AutoFeatureExtractor, ViTMAEForPreTraining
>>> from PIL import Image
>>> import requests
>>> url = "http://images.cocodataset.org/val2017/000000039769.jpg"
>>> image = Image.open(requests.get(ur... | forward | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/vit_mae/modeling_vit_mae.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/vit_mae/modeling_vit_mae.py | Apache-2.0 |
def forward(
self,
pixel_values: Optional[torch.Tensor] = None,
bool_masked_pos: Optional[torch.BoolTensor] = None,
head_mask: Optional[torch.Tensor] = None,
output_attentions: Optional[bool] = None,
output_hidden_states: Optional[bool] = None,
interpolate_pos_enc... |
Returns:
Examples:
```python
>>> from transformers import AutoFeatureExtractor, ViTMSNModel
>>> import torch
>>> from PIL import Image
>>> import requests
>>> url = "http://images.cocodataset.org/val2017/000000039769.jpg"
>>> image = Image.open... | forward | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/vit_msn/modeling_vit_msn.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/vit_msn/modeling_vit_msn.py | Apache-2.0 |
def forward(
self,
pixel_values: Optional[torch.Tensor] = None,
head_mask: Optional[torch.Tensor] = None,
labels: Optional[torch.Tensor] = None,
output_attentions: Optional[bool] = None,
output_hidden_states: Optional[bool] = None,
interpolate_pos_encoding: Option... |
Returns:
Examples:
```python
>>> from transformers import AutoFeatureExtractor, ViTMSNForImageClassification
>>> import torch
>>> from PIL import Image
>>> import requests
>>> torch.manual_seed(2) # doctest: +IGNORE_RESULT
>>> url = "http://i... | forward | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/vit_msn/modeling_vit_msn.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/vit_msn/modeling_vit_msn.py | Apache-2.0 |
def zero_mean_unit_var_norm(
input_values: List[np.ndarray], attention_mask: List[np.ndarray], padding_value: float = 0.0
) -> List[np.ndarray]:
"""
Every array in the list is normalized to have zero mean and unit variance
"""
if attention_mask is not None:
attent... |
Every array in the list is normalized to have zero mean and unit variance
| zero_mean_unit_var_norm | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/wav2vec2/feature_extraction_wav2vec2.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/wav2vec2/feature_extraction_wav2vec2.py | Apache-2.0 |
def __call__(
self,
raw_speech: Union[np.ndarray, List[float], List[np.ndarray], List[List[float]]],
padding: Union[bool, str, PaddingStrategy] = False,
max_length: Optional[int] = None,
truncation: bool = False,
pad_to_multiple_of: Optional[int] = None,
return_at... |
Main method to featurize and prepare for the model one or several sequence(s).
Args:
raw_speech (`np.ndarray`, `List[float]`, `List[np.ndarray]`, `List[List[float]]`):
The sequence or batch of sequences to be padded. Each sequence can be a numpy array, a list of float
... | __call__ | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/wav2vec2/feature_extraction_wav2vec2.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/wav2vec2/feature_extraction_wav2vec2.py | Apache-2.0 |
def _compute_mask_indices(
shape: Tuple[int, int],
mask_prob: float,
mask_length: int,
attention_mask: Optional[np.ndarray] = None,
min_masks: int = 0,
) -> np.ndarray:
"""
Computes random mask spans for a given shape. Used to implement [SpecAugment: A Simple Data Augmentation Method for
... |
Computes random mask spans for a given shape. Used to implement [SpecAugment: A Simple Data Augmentation Method for
ASR](https://arxiv.org/abs/1904.08779). Note that this method is not optimized to run on TPU and should be run on
CPU as part of the preprocessing during training.
Args:
shape: t... | _compute_mask_indices | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/wav2vec2/modeling_flax_wav2vec2.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/wav2vec2/modeling_flax_wav2vec2.py | Apache-2.0 |
def call(
self,
input_values: tf.Tensor,
attention_mask: Optional[tf.Tensor] = None,
token_type_ids: Optional[tf.Tensor] = None,
position_ids: Optional[tf.Tensor] = None,
head_mask: Optional[tf.Tensor] = None,
inputs_embeds: Optional[tf.Tensor] = None,
out... |
Returns:
Example:
```python
>>> from transformers import Wav2Vec2Processor, TFWav2Vec2Model
>>> from datasets import load_dataset
>>> import soundfile as sf
>>> processor = Wav2Vec2Processor.from_pretrained("facebook/wav2vec2-base-960h")
>>> model = T... | call | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/wav2vec2/modeling_tf_wav2vec2.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/wav2vec2/modeling_tf_wav2vec2.py | Apache-2.0 |
def call(
self,
input_values: tf.Tensor,
attention_mask: Optional[tf.Tensor] = None,
token_type_ids: Optional[tf.Tensor] = None,
position_ids: Optional[tf.Tensor] = None,
head_mask: Optional[tf.Tensor] = None,
inputs_embeds: Optional[tf.Tensor] = None,
out... |
labels (`tf.Tensor` or `np.ndarray` of shape `(batch_size, sequence_length)`, *optional*):
Labels for computing the masked language modeling loss. Indices should be in `[-100, 0, ...,
config.vocab_size]` (see `input_values` docstring) Tokens with indices set to `-100` are ignored (maske... | call | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/wav2vec2/modeling_tf_wav2vec2.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/wav2vec2/modeling_tf_wav2vec2.py | Apache-2.0 |
def forward(
self,
input_values: Optional[torch.Tensor],
attention_mask: Optional[torch.Tensor] = None,
mask_time_indices: Optional[torch.BoolTensor] = None,
sampled_negative_indices: Optional[torch.BoolTensor] = None,
output_attentions: Optional[bool] = None,
out... |
mask_time_indices (`torch.BoolTensor` of shape `(batch_size, sequence_length)`, *optional*):
Indices to mask extracted features for contrastive loss. When in training mode, model learns to predict
masked extracted features in *config.proj_codevector_dim* space.
sampled_negative_... | forward | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/wav2vec2/modeling_wav2vec2.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/wav2vec2/modeling_wav2vec2.py | Apache-2.0 |
def __call__(self, *args, **kwargs):
"""
When used in normal mode, this method forwards all its arguments to Wav2Vec2FeatureExtractor's
[`~Wav2Vec2FeatureExtractor.__call__`] and returns its output. If used in the context
[`~Wav2Vec2Processor.as_target_processor`] this method forwards al... |
When used in normal mode, this method forwards all its arguments to Wav2Vec2FeatureExtractor's
[`~Wav2Vec2FeatureExtractor.__call__`] and returns its output. If used in the context
[`~Wav2Vec2Processor.as_target_processor`] this method forwards all its arguments to PreTrainedTokenizer's
... | __call__ | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/wav2vec2/processing_wav2vec2.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/wav2vec2/processing_wav2vec2.py | Apache-2.0 |
def pad(self, *args, **kwargs):
"""
When used in normal mode, this method forwards all its arguments to Wav2Vec2FeatureExtractor's
[`~Wav2Vec2FeatureExtractor.pad`] and returns its output. If used in the context
[`~Wav2Vec2Processor.as_target_processor`] this method forwards all its argu... |
When used in normal mode, this method forwards all its arguments to Wav2Vec2FeatureExtractor's
[`~Wav2Vec2FeatureExtractor.pad`] and returns its output. If used in the context
[`~Wav2Vec2Processor.as_target_processor`] this method forwards all its arguments to PreTrainedTokenizer's
[`~P... | pad | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/wav2vec2/processing_wav2vec2.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/wav2vec2/processing_wav2vec2.py | Apache-2.0 |
def as_target_processor(self):
"""
Temporarily sets the tokenizer for processing the input. Useful for encoding the labels when fine-tuning
Wav2Vec2.
"""
warnings.warn(
"`as_target_processor` is deprecated and will be removed in v5 of Transformers. You can process you... |
Temporarily sets the tokenizer for processing the input. Useful for encoding the labels when fine-tuning
Wav2Vec2.
| as_target_processor | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/wav2vec2/processing_wav2vec2.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/wav2vec2/processing_wav2vec2.py | Apache-2.0 |
def _tokenize(self, text, **kwargs):
"""
Converts a string in a sequence of tokens (string), using the tokenizer.
"""
if self.do_lower_case:
text = text.upper()
return list(text.replace(" ", self.word_delimiter_token)) |
Converts a string in a sequence of tokens (string), using the tokenizer.
| _tokenize | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/wav2vec2/tokenization_wav2vec2.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/wav2vec2/tokenization_wav2vec2.py | Apache-2.0 |
def convert_tokens_to_string(
self,
tokens: List[str],
group_tokens: bool = True,
spaces_between_special_tokens: bool = False,
output_char_offsets: bool = False,
output_word_offsets: bool = False,
) -> Dict[str, Union[str, float]]:
"""
Converts a conne... |
Converts a connectionist-temporal-classification (CTC) output tokens into a single string.
| convert_tokens_to_string | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/wav2vec2/tokenization_wav2vec2.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/wav2vec2/tokenization_wav2vec2.py | Apache-2.0 |
def _decode(
self,
token_ids: List[int],
skip_special_tokens: bool = False,
clean_up_tokenization_spaces: bool = True,
group_tokens: bool = True,
spaces_between_special_tokens: bool = False,
output_word_offsets: Optional[bool] = False,
output_char_offsets:... |
special _decode function is needed for Wav2Vec2Tokenizer because added tokens should be treated exactly the
same as tokens of the base vocabulary and therefore the function `convert_tokens_to_string` has to be called on
the whole token list and not individually on added tokens
| _decode | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/wav2vec2/tokenization_wav2vec2.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/wav2vec2/tokenization_wav2vec2.py | Apache-2.0 |
def batch_decode(
self,
sequences: Union[List[int], List[List[int]], "np.ndarray", "torch.Tensor", "tf.Tensor"],
skip_special_tokens: bool = False,
clean_up_tokenization_spaces: bool = True,
output_char_offsets: bool = False,
output_word_offsets: bool = False,
**k... |
Convert a list of lists of token ids into a list of strings by calling decode.
Args:
sequences (`Union[List[int], List[List[int]], np.ndarray, torch.Tensor, tf.Tensor]`):
List of tokenized input ids. Can be obtained using the `__call__` method.
skip_special_toke... | batch_decode | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/wav2vec2/tokenization_wav2vec2.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/wav2vec2/tokenization_wav2vec2.py | Apache-2.0 |
def decode(
self,
token_ids: Union[int, List[int], "np.ndarray", "torch.Tensor", "tf.Tensor"],
skip_special_tokens: bool = False,
clean_up_tokenization_spaces: bool = True,
output_char_offsets: bool = False,
output_word_offsets: bool = False,
**kwargs
) -> str... |
Converts a sequence of ids in a string, using the tokenizer and vocabulary with options to remove special
tokens and clean up tokenization spaces.
Similar to doing `self.convert_tokens_to_string(self.convert_ids_to_tokens(token_ids))`.
Args:
token_ids (`Union[int, List[int... | decode | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/wav2vec2/tokenization_wav2vec2.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/wav2vec2/tokenization_wav2vec2.py | Apache-2.0 |
def _add_tokens(self, new_tokens: Union[List[str], List[AddedToken]], special_tokens: bool = False) -> int:
"""
Add a list of new tokens to the tokenizer class. If the new tokens are not in the vocabulary, they are added to
it with indices starting from length of the current vocabulary.
... |
Add a list of new tokens to the tokenizer class. If the new tokens are not in the vocabulary, they are added to
it with indices starting from length of the current vocabulary.
Args:
new_tokens (`List[str]`or `List[tokenizers.AddedToken]`):
Token(s) to add in vocabul... | _add_tokens | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/wav2vec2/tokenization_wav2vec2.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/wav2vec2/tokenization_wav2vec2.py | Apache-2.0 |
def __call__(
self,
raw_speech: Union[np.ndarray, List[float], List[np.ndarray], List[List[float]]],
padding: Union[bool, str, PaddingStrategy] = False,
max_length: Optional[int] = None,
pad_to_multiple_of: Optional[int] = None,
return_tensors: Optional[Union[str, TensorT... |
Main method to tokenize and prepare for the model one or several sequence(s) or one or several pair(s) of
sequences.
Args:
raw_speech (`np.ndarray`, `List[float]`, `List[np.ndarray]`, `List[List[float]]`):
The sequence or batch of sequences to be padded. Each sequen... | __call__ | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/wav2vec2/tokenization_wav2vec2.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/wav2vec2/tokenization_wav2vec2.py | Apache-2.0 |
def forward(
self,
input_values: Optional[torch.Tensor],
attention_mask: Optional[torch.Tensor] = None,
mask_time_indices: Optional[torch.BoolTensor] = None,
sampled_negative_indices: Optional[torch.BoolTensor] = None,
output_attentions: Optional[bool] = None,
out... |
mask_time_indices (`torch.BoolTensor` of shape `(batch_size, sequence_length)`, *optional*):
Indices to mask extracted features for contrastive loss. When in training mode, model learns to predict
masked extracted features in *config.proj_codevector_dim* space.
sampled_negative_... | forward | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/wav2vec2_conformer/modeling_wav2vec2_conformer.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/wav2vec2_conformer/modeling_wav2vec2_conformer.py | Apache-2.0 |
def init_backend(self, phonemizer_lang: str):
"""
Initializes the backend.
Args:
phonemizer_lang (`str`): The language to be used.
"""
requires_backends(self, "phonemizer")
from phonemizer.backend import BACKENDS
self.backend = BACKENDS[self.phonemiz... |
Initializes the backend.
Args:
phonemizer_lang (`str`): The language to be used.
| init_backend | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/wav2vec2_phoneme/tokenization_wav2vec2_phoneme.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/wav2vec2_phoneme/tokenization_wav2vec2_phoneme.py | Apache-2.0 |
def prepare_for_tokenization(
self,
text: str,
is_split_into_words: bool = False,
phonemizer_lang: Optional[str] = None,
do_phonemize: Optional[bool] = None,
) -> Tuple[str, Dict[str, Any]]:
"""
Performs any necessary transformations before tokenization.
... |
Performs any necessary transformations before tokenization.
This method should pop the arguments from kwargs and return the remaining `kwargs` as well. We test the
`kwargs` at the end of the encoding process to be sure all the arguments have been used.
Args:
text (`str`):
... | prepare_for_tokenization | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/wav2vec2_phoneme/tokenization_wav2vec2_phoneme.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/wav2vec2_phoneme/tokenization_wav2vec2_phoneme.py | Apache-2.0 |
def _decode(
self,
token_ids: List[int],
skip_special_tokens: bool = False,
clean_up_tokenization_spaces: bool = True,
group_tokens: bool = True,
filter_word_delimiter_token: bool = True,
spaces_between_special_tokens: bool = False,
output_char_offsets: bo... |
special _decode function is needed for Wav2Vec2PhonemeTokenizer because added tokens should be treated exactly
the same as tokens of the base vocabulary and therefore the function `convert_tokens_to_string` has to be
called on the whole token list and not individually on added tokens
| _decode | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/wav2vec2_phoneme/tokenization_wav2vec2_phoneme.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/wav2vec2_phoneme/tokenization_wav2vec2_phoneme.py | Apache-2.0 |
def decode(
self,
token_ids: Union[int, List[int], "np.ndarray", "torch.Tensor", "tf.Tensor"],
skip_special_tokens: bool = False,
clean_up_tokenization_spaces: bool = True,
output_char_offsets: bool = False,
**kwargs
) -> str:
"""
Converts a sequence o... |
Converts a sequence of ids in a string, using the tokenizer and vocabulary with options to remove special
tokens and clean up tokenization spaces.
Similar to doing `self.convert_tokens_to_string(self.convert_ids_to_tokens(token_ids))`.
Args:
token_ids (`Union[int, List[int... | decode | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/wav2vec2_phoneme/tokenization_wav2vec2_phoneme.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/wav2vec2_phoneme/tokenization_wav2vec2_phoneme.py | Apache-2.0 |
def batch_decode(
self,
sequences: Union[List[int], List[List[int]], "np.ndarray", "torch.Tensor", "tf.Tensor"],
skip_special_tokens: bool = False,
clean_up_tokenization_spaces: bool = True,
output_char_offsets: bool = False,
**kwargs
) -> List[str]:
"""
... |
Convert a list of lists of token ids into a list of strings by calling decode.
Args:
sequences (`Union[List[int], List[List[int]], np.ndarray, torch.Tensor, tf.Tensor]`):
List of tokenized input ids. Can be obtained using the `__call__` method.
skip_special_toke... | batch_decode | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/wav2vec2_phoneme/tokenization_wav2vec2_phoneme.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/wav2vec2_phoneme/tokenization_wav2vec2_phoneme.py | Apache-2.0 |
def _add_tokens(self, new_tokens: Union[List[str], List[AddedToken]], special_tokens: bool = False) -> int:
"""
Add a list of new tokens to the tokenizer class. If the new tokens are not in the vocabulary, they are added to
it with indices starting from length of the current vocabulary.
... |
Add a list of new tokens to the tokenizer class. If the new tokens are not in the vocabulary, they are added to
it with indices starting from length of the current vocabulary.
Args:
new_tokens (`List[str]`or `List[tokenizers.AddedToken]`):
Token(s) to add in vocabul... | _add_tokens | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/wav2vec2_phoneme/tokenization_wav2vec2_phoneme.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/wav2vec2_phoneme/tokenization_wav2vec2_phoneme.py | Apache-2.0 |
def from_pretrained(cls, pretrained_model_name_or_path, **kwargs):
r"""
Instantiate a [`Wav2Vec2ProcessorWithLM`] from a pretrained Wav2Vec2 processor.
<Tip>
This class method is simply calling Wav2Vec2FeatureExtractor's
[`~feature_extraction_utils.FeatureExtractionMixin.from_p... |
Instantiate a [`Wav2Vec2ProcessorWithLM`] from a pretrained Wav2Vec2 processor.
<Tip>
This class method is simply calling Wav2Vec2FeatureExtractor's
[`~feature_extraction_utils.FeatureExtractionMixin.from_pretrained`], Wav2Vec2CTCTokenizer's
[`~tokenization_utils_base.PreTrain... | from_pretrained | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/wav2vec2_with_lm/processing_wav2vec2_with_lm.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/wav2vec2_with_lm/processing_wav2vec2_with_lm.py | Apache-2.0 |
def __call__(self, *args, **kwargs):
"""
When used in normal mode, this method forwards all its arguments to Wav2Vec2FeatureExtractor's
[`~Wav2Vec2FeatureExtractor.__call__`] and returns its output. If used in the context
[`~Wav2Vec2ProcessorWithLM.as_target_processor`] this method forwa... |
When used in normal mode, this method forwards all its arguments to Wav2Vec2FeatureExtractor's
[`~Wav2Vec2FeatureExtractor.__call__`] and returns its output. If used in the context
[`~Wav2Vec2ProcessorWithLM.as_target_processor`] this method forwards all its arguments to
Wav2Vec2CTCToke... | __call__ | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/wav2vec2_with_lm/processing_wav2vec2_with_lm.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/wav2vec2_with_lm/processing_wav2vec2_with_lm.py | Apache-2.0 |
def pad(self, *args, **kwargs):
"""
When used in normal mode, this method forwards all its arguments to Wav2Vec2FeatureExtractor's
[`~Wav2Vec2FeatureExtractor.pad`] and returns its output. If used in the context
[`~Wav2Vec2ProcessorWithLM.as_target_processor`] this method forwards all it... |
When used in normal mode, this method forwards all its arguments to Wav2Vec2FeatureExtractor's
[`~Wav2Vec2FeatureExtractor.pad`] and returns its output. If used in the context
[`~Wav2Vec2ProcessorWithLM.as_target_processor`] this method forwards all its arguments to
Wav2Vec2CTCTokenizer... | pad | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/wav2vec2_with_lm/processing_wav2vec2_with_lm.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/wav2vec2_with_lm/processing_wav2vec2_with_lm.py | Apache-2.0 |
def batch_decode(
self,
logits: np.ndarray,
pool: Optional[Pool] = None,
num_processes: Optional[int] = None,
beam_width: Optional[int] = None,
beam_prune_logp: Optional[float] = None,
token_min_logp: Optional[float] = None,
hotwords: Optional[Iterable[str... |
Batch decode output logits to audio transcription with language model support.
<Tip>
This function makes use of Python's multiprocessing. Currently, multiprocessing is available only on Unix
systems (see this [issue](https://github.com/kensho-technologies/pyctcdecode/issues/65)).
... | batch_decode | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/wav2vec2_with_lm/processing_wav2vec2_with_lm.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/wav2vec2_with_lm/processing_wav2vec2_with_lm.py | Apache-2.0 |
def decode(
self,
logits: np.ndarray,
beam_width: Optional[int] = None,
beam_prune_logp: Optional[float] = None,
token_min_logp: Optional[float] = None,
hotwords: Optional[Iterable[str]] = None,
hotword_weight: Optional[float] = None,
alpha: Optional[float... |
Decode output logits to audio transcription with language model support.
Args:
logits (`np.ndarray`):
The logits output vector of the model representing the log probabilities for each token.
beam_width (`int`, *optional*):
Maximum number of beams... | decode | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/wav2vec2_with_lm/processing_wav2vec2_with_lm.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/wav2vec2_with_lm/processing_wav2vec2_with_lm.py | Apache-2.0 |
def as_target_processor(self):
"""
Temporarily sets the processor for processing the target. Useful for encoding the labels when fine-tuning
Wav2Vec2.
"""
warnings.warn(
"`as_target_processor` is deprecated and will be removed in v5 of Transformers. You can process yo... |
Temporarily sets the processor for processing the target. Useful for encoding the labels when fine-tuning
Wav2Vec2.
| as_target_processor | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/wav2vec2_with_lm/processing_wav2vec2_with_lm.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/wav2vec2_with_lm/processing_wav2vec2_with_lm.py | Apache-2.0 |
def remove_symbols_and_diacritics(s: str, keep=""):
"""
Replace any other markers, symbols, and punctuations with a space, and drop any diacritics (category 'Mn' and some
manual mappings)
"""
def replace_character(char):
if char in keep:
return char
elif char in ADDITION... |
Replace any other markers, symbols, and punctuations with a space, and drop any diacritics (category 'Mn' and some
manual mappings)
| remove_symbols_and_diacritics | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/whisper/english_normalizer.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/whisper/english_normalizer.py | Apache-2.0 |
def fram_wave(self, waveform, center=True):
"""
Transform a raw waveform into a list of smaller waveforms. The window length defines how much of the signal is
contain in each frame (smalle waveform), while the hope length defines the step between the beginning of each
new frame.
... |
Transform a raw waveform into a list of smaller waveforms. The window length defines how much of the signal is
contain in each frame (smalle waveform), while the hope length defines the step between the beginning of each
new frame.
Centering is done by reflecting the waveform which is ... | fram_wave | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/whisper/feature_extraction_whisper.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/whisper/feature_extraction_whisper.py | Apache-2.0 |
def stft(self, frames, window):
"""
Calculates the complex Short-Time Fourier Transform (STFT) of the given framed signal. Should give the same
results as `torch.stft`.
"""
frame_size = frames.shape[1]
fft_size = self.n_fft
if fft_size is None:
fft_si... |
Calculates the complex Short-Time Fourier Transform (STFT) of the given framed signal. Should give the same
results as `torch.stft`.
| stft | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/whisper/feature_extraction_whisper.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/whisper/feature_extraction_whisper.py | Apache-2.0 |
def _np_extract_fbank_features(self, waveform: np.array) -> np.ndarray:
"""
Compute the log-Mel spectrogram of the provided audio, gives similar results whisper's original torch
implementation with 1e-5 tolerance.
"""
window = np.hanning(self.n_fft + 1)[:-1]
frames = sel... |
Compute the log-Mel spectrogram of the provided audio, gives similar results whisper's original torch
implementation with 1e-5 tolerance.
| _np_extract_fbank_features | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/whisper/feature_extraction_whisper.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/whisper/feature_extraction_whisper.py | Apache-2.0 |
def __call__(
self,
raw_speech: Union[np.ndarray, List[float], List[np.ndarray], List[List[float]]],
truncation: bool = True,
pad_to_multiple_of: Optional[int] = None,
return_tensors: Optional[Union[str, TensorType]] = None,
return_attention_mask: Optional[bool] = None,
... |
Main method to featurize and prepare for the model one or several sequence(s).
Args:
raw_speech (`np.ndarray`, `List[float]`, `List[np.ndarray]`, `List[List[float]]`):
The sequence or batch of sequences to be padded. Each sequence can be a numpy array, a list of float
... | __call__ | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/whisper/feature_extraction_whisper.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/whisper/feature_extraction_whisper.py | Apache-2.0 |
def call(
self,
input_features=None,
head_mask=None,
output_attentions=None,
output_hidden_states=None,
return_dict=None,
training=False,
):
r"""
Args:
input_features (`tf.Tensor` of shape `(batch_size, feature_size, sequence_length... |
Args:
input_features (`tf.Tensor` of shape `(batch_size, feature_size, sequence_length)`):
Float values of fbank features extracted from the raw speech waveform. Raw speech waveform can be
obtained by loading a `.flac` or `.wav` audio file into an array of type `List... | call | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/whisper/modeling_tf_whisper.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/whisper/modeling_tf_whisper.py | Apache-2.0 |
def call(
self,
input_ids=None,
attention_mask=None,
position_ids=None,
encoder_hidden_states=None,
head_mask=None,
cross_attn_head_mask=None,
past_key_values=None,
inputs_embeds=None,
use_cache=None,
output_attentions=None,
... |
Args:
input_ids (`tf.Tensor` of shape `(batch_size, sequence_length)`):
Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you
provide it.
Indices can be obtained using [`WhisperTokenizer`]. See [`PreTrained... | call | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/whisper/modeling_tf_whisper.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/whisper/modeling_tf_whisper.py | Apache-2.0 |
def call(
self,
input_features=None,
decoder_input_ids=None,
decoder_attention_mask=None,
decoder_position_ids=None,
head_mask=None,
decoder_head_mask=None,
cross_attn_head_mask=None,
encoder_outputs=None,
past_key_values=None,
deco... |
Returns:
Example:
```python
>>> import tensorflow as tf
>>> from transformers import TFWhisperModel, WhisperFeatureExtractor
>>> from datasets import load_dataset
>>> model = TFWhisperModel.from_pretrained("openai/whisper-base")
>>> feature_extra... | call | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/whisper/modeling_tf_whisper.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/whisper/modeling_tf_whisper.py | Apache-2.0 |
def call(
self,
input_features=None,
decoder_input_ids=None,
decoder_attention_mask=None,
decoder_position_ids=None,
head_mask=None,
decoder_head_mask=None,
cross_attn_head_mask=None,
encoder_outputs=None,
past_key_values=None,
deco... |
labels (`tf.Tensor` of shape `(batch_size, sequence_length)`, *optional*):
Labels for computing the language modeling loss. Indices should either be in `[0, ..., config.vocab_size]`
or -100 (see `input_ids` docstring). Tokens with indices set to `-100` are ignored (masked), the loss is
... | call | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/whisper/modeling_tf_whisper.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/whisper/modeling_tf_whisper.py | Apache-2.0 |
def forward(
self,
input_features,
head_mask=None,
output_attentions=None,
output_hidden_states=None,
return_dict=None,
):
r"""
Args:
input_features (`torch.LongTensor` of shape `(batch_size, feature_size, sequence_length)`):
... |
Args:
input_features (`torch.LongTensor` of shape `(batch_size, feature_size, sequence_length)`):
Float values of mel features extracted from the raw speech waveform. Raw speech waveform can be
obtained by loading a `.flac` or `.wav` audio file into an array of type ... | forward | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/whisper/modeling_whisper.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/whisper/modeling_whisper.py | Apache-2.0 |
def forward(
self,
input_ids=None,
attention_mask=None,
encoder_hidden_states=None,
head_mask=None,
cross_attn_head_mask=None,
past_key_values=None,
inputs_embeds=None,
use_cache=None,
output_attentions=None,
output_hidden_states=No... |
Args:
input_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`):
Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you
provide it.
Indices can be obtained using [`WhisperTokenizer`]. See [`Pre... | forward | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/whisper/modeling_whisper.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/whisper/modeling_whisper.py | Apache-2.0 |
def forward(
self,
input_features=None,
decoder_input_ids=None,
decoder_attention_mask=None,
head_mask=None,
decoder_head_mask=None,
cross_attn_head_mask=None,
encoder_outputs=None,
past_key_values=None,
decoder_inputs_embeds=None,
... |
Returns:
Example:
```python
>>> import torch
>>> from transformers import WhisperFeatureExtractor, WhisperModel
>>> from datasets import load_dataset
>>> model = WhisperModel.from_pretrained("openai/whisper-base")
>>> feature_extractor = WhisperFe... | forward | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/whisper/modeling_whisper.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/whisper/modeling_whisper.py | Apache-2.0 |
def forward(
self,
input_features=None,
decoder_input_ids=None,
decoder_attention_mask=None,
head_mask=None,
decoder_head_mask=None,
cross_attn_head_mask=None,
encoder_outputs=None,
past_key_values=None,
decoder_inputs_embeds=None,
... |
labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
Labels for computing the language modeling loss. Indices should either be in `[0, ..., config.vocab_size]`
or -100 (see `input_ids` docstring). Tokens with indices set to `-100` are ignored (masked), the l... | forward | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/whisper/modeling_whisper.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/whisper/modeling_whisper.py | Apache-2.0 |
def __call__(self, *args, **kwargs):
"""
Forwards the `audio` argument to WhisperFeatureExtractor's [`~WhisperFeatureExtractor.__call__`] and the `text`
argument to [`~WhisperTokenizer.__call__`]. Please refer to the doctsring of the above two methods for more
information.
"""
... |
Forwards the `audio` argument to WhisperFeatureExtractor's [`~WhisperFeatureExtractor.__call__`] and the `text`
argument to [`~WhisperTokenizer.__call__`]. Please refer to the doctsring of the above two methods for more
information.
| __call__ | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/whisper/processing_whisper.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/whisper/processing_whisper.py | Apache-2.0 |
def _create_position_ids_from_inputs_embeds(
inputs_embeds: tf.Tensor, past_key_values_length: int, padding_idx: Optional[int]
) -> tf.Tensor:
"""
Args:
We are provided embeddings directly. We cannot infer which are padded so just generate sequential position ids.
inputs_embeds: tf.Tensor
Re... |
Args:
We are provided embeddings directly. We cannot infer which are padded so just generate sequential position ids.
inputs_embeds: tf.Tensor
Returns: tf.Tensor
| _create_position_ids_from_inputs_embeds | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/xglm/modeling_tf_xglm.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/xglm/modeling_tf_xglm.py | Apache-2.0 |
def forward(
self,
input_ids: Optional[torch.Tensor] = None,
attention_mask: Optional[torch.Tensor] = None,
encoder_hidden_states: Optional[torch.Tensor] = None,
encoder_attention_mask: Optional[torch.Tensor] = None,
head_mask: Optional[torch.Tensor] = None,
cross... |
Args:
input_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`):
Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you
provide it.
Indices can be obtained using [`~XGLMTokenizer`]. See [`PreTr... | forward | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/xglm/modeling_xglm.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/xglm/modeling_xglm.py | Apache-2.0 |
def forward(
self,
input_ids: Optional[torch.Tensor] = None,
attention_mask: Optional[torch.Tensor] = None,
encoder_hidden_states: Optional[torch.Tensor] = None,
encoder_attention_mask: Optional[torch.Tensor] = None,
head_mask: Optional[torch.Tensor] = None,
cross... |
labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
Labels for computing the masked language modeling loss. Indices should either be in `[0, ...,
config.vocab_size]` or -100 (see `input_ids` docstring). Tokens with indices set to `-100` are ignored
... | forward | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/xglm/modeling_xglm.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/xglm/modeling_xglm.py | Apache-2.0 |
def lowercase_and_remove_accent(text):
"""
Lowercase and strips accents from a piece of text based on
https://github.com/facebookresearch/XLM/blob/master/tools/lowercase_and_remove_accent.py
"""
text = " ".join(text)
text = text.lower()
text = unicodedata.normalize("NFD", text)
output = ... |
Lowercase and strips accents from a piece of text based on
https://github.com/facebookresearch/XLM/blob/master/tools/lowercase_and_remove_accent.py
| lowercase_and_remove_accent | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/xlm/tokenization_xlm.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/xlm/tokenization_xlm.py | Apache-2.0 |
def romanian_preprocessing(text):
"""Sennrich's WMT16 scripts for Romanian preprocessing, used by model `xlm-mlm-enro-1024`"""
# https://github.com/rsennrich/wmt16-scripts/blob/master/preprocess/normalise-romanian.py
text = text.replace("\u015e", "\u0218").replace("\u015f", "\u0219")
text = text.replace... | Sennrich's WMT16 scripts for Romanian preprocessing, used by model `xlm-mlm-enro-1024` | romanian_preprocessing | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/xlm/tokenization_xlm.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/xlm/tokenization_xlm.py | Apache-2.0 |
def _tokenize(self, text, lang="en", bypass_tokenizer=False):
"""
Tokenize a string given language code. For Chinese, Japanese and Thai, we use a language specific tokenizer.
Otherwise, we use Moses.
Details of tokenization:
- [sacremoses](https://github.com/alvations/sacre... |
Tokenize a string given language code. For Chinese, Japanese and Thai, we use a language specific tokenizer.
Otherwise, we use Moses.
Details of tokenization:
- [sacremoses](https://github.com/alvations/sacremoses): port of Moses
- Install with `pip install sacremoses`... | _tokenize | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/xlm/tokenization_xlm.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/xlm/tokenization_xlm.py | Apache-2.0 |
def forward(
self,
input_ids: Optional[torch.Tensor] = None,
attention_mask: Optional[torch.Tensor] = None,
head_mask: Optional[torch.Tensor] = None,
inputs_embeds: Optional[torch.Tensor] = None,
output_attentions: Optional[bool] = None,
output_hidden_states: Opti... |
Returns:
Example:
```python
>>> from transformers import XLMProphetNetTokenizer, XLMProphetNetEncoder
>>> import torch
>>> tokenizer = XLMProphetNetTokenizer.from_pretrained("patrickvonplaten/xprophetnet-large-uncased-standalone")
>>> model = XLMProphetNetEnco... | forward | python | FMInference/FlexLLMGen | benchmark/third_party/transformers/src/transformers/models/xlm_prophetnet/modeling_xlm_prophetnet.py | https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/xlm_prophetnet/modeling_xlm_prophetnet.py | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.