source
stringclasses
470 values
url
stringlengths
49
167
file_type
stringclasses
1 value
chunk
stringlengths
1
512
chunk_id
stringlengths
5
9
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/xlm-prophetnet.md
https://huggingface.co/docs/transformers/en/model_doc/xlm-prophetnet/#overview
.md
The XLM-ProphetNet model was proposed in [ProphetNet: Predicting Future N-gram for Sequence-to-Sequence Pre-training,](https://arxiv.org/abs/2001.04063) by Yu Yan, Weizhen Qi, Yeyun Gong, Dayiheng Liu, Nan Duan, Jiusheng Chen, Ruofei Zhang, Ming Zhou on 13 Jan, 2020. XLM-ProphetNet is an encoder-decoder model and can predict n-future tokens for "ngram" language modeling instead of just the next token. Its architecture is identical to ProhpetNet, but the model was trained on the multi-lingual
209_2_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/xlm-prophetnet.md
https://huggingface.co/docs/transformers/en/model_doc/xlm-prophetnet/#overview
.md
just the next token. Its architecture is identical to ProhpetNet, but the model was trained on the multi-lingual "wiki100" Wikipedia dump. XLM-ProphetNet's model architecture and pretraining objective is same as ProphetNet, but XLM-ProphetNet was pre-trained on the cross-lingual dataset XGLUE. The abstract from the paper is the following: *In this paper, we present a new sequence-to-sequence pretraining model called ProphetNet, which introduces a novel
209_2_1
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/xlm-prophetnet.md
https://huggingface.co/docs/transformers/en/model_doc/xlm-prophetnet/#overview
.md
*In this paper, we present a new sequence-to-sequence pretraining model called ProphetNet, which introduces a novel self-supervised objective named future n-gram prediction and the proposed n-stream self-attention mechanism. Instead of the optimization of one-step ahead prediction in traditional sequence-to-sequence model, the ProphetNet is optimized by n-step ahead prediction which predicts the next n tokens simultaneously based on previous context tokens at each time
209_2_2
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/xlm-prophetnet.md
https://huggingface.co/docs/transformers/en/model_doc/xlm-prophetnet/#overview
.md
n-step ahead prediction which predicts the next n tokens simultaneously based on previous context tokens at each time step. The future n-gram prediction explicitly encourages the model to plan for the future tokens and prevent overfitting on strong local correlations. We pre-train ProphetNet using a base scale dataset (16GB) and a large scale dataset (160GB) respectively. Then we conduct experiments on CNN/DailyMail, Gigaword, and SQuAD 1.1 benchmarks for
209_2_3
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/xlm-prophetnet.md
https://huggingface.co/docs/transformers/en/model_doc/xlm-prophetnet/#overview
.md
dataset (160GB) respectively. Then we conduct experiments on CNN/DailyMail, Gigaword, and SQuAD 1.1 benchmarks for abstractive summarization and question generation tasks. Experimental results show that ProphetNet achieves new state-of-the-art results on all these datasets compared to the models using the same scale pretraining corpus.* The Authors' code can be found [here](https://github.com/microsoft/ProphetNet).
209_2_4
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/xlm-prophetnet.md
https://huggingface.co/docs/transformers/en/model_doc/xlm-prophetnet/#resources
.md
- [Causal language modeling task guide](../tasks/language_modeling) - [Translation task guide](../tasks/translation) - [Summarization task guide](../tasks/summarization)
209_3_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/xlm-prophetnet.md
https://huggingface.co/docs/transformers/en/model_doc/xlm-prophetnet/#xlmprophetnetconfig
.md
This is the configuration class to store the configuration of a [`XLMProphetNetModel`]. It is used to instantiate a XLMProphetNet model according to the specified arguments, defining the model architecture. Instantiating a configuration with the defaults will yield a similar configuration to that of the XLMProphetNet [microsoft/xprophetnet-large-wiki100-cased](https://huggingface.co/microsoft/xprophetnet-large-wiki100-cased) architecture.
209_4_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/xlm-prophetnet.md
https://huggingface.co/docs/transformers/en/model_doc/xlm-prophetnet/#xlmprophetnetconfig
.md
[microsoft/xprophetnet-large-wiki100-cased](https://huggingface.co/microsoft/xprophetnet-large-wiki100-cased) architecture. Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the documentation from [`PretrainedConfig`] for more information. Args: activation_dropout (`float`, *optional*, defaults to 0.1): The dropout ratio for activations inside the fully connected layer. activation_function (`str` or `function`, *optional*, defaults to `"gelu"`):
209_4_1
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/xlm-prophetnet.md
https://huggingface.co/docs/transformers/en/model_doc/xlm-prophetnet/#xlmprophetnetconfig
.md
activation_function (`str` or `function`, *optional*, defaults to `"gelu"`): The non-linear activation function (function or string) in the encoder and pooler. If string, `"gelu"`, `"relu"`, `"silu"` and `"gelu_new"` are supported. vocab_size (`int`, *optional*, defaults to 30522): Vocabulary size of the ProphetNET model. Defines the number of different tokens that can be represented by the `inputs_ids` passed when calling [`XLMProphetNetModel`]. hidden_size (`int`, *optional*, defaults to 1024):
209_4_2
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/xlm-prophetnet.md
https://huggingface.co/docs/transformers/en/model_doc/xlm-prophetnet/#xlmprophetnetconfig
.md
the `inputs_ids` passed when calling [`XLMProphetNetModel`]. hidden_size (`int`, *optional*, defaults to 1024): Dimensionality of the layers and the pooler layer. encoder_ffn_dim (`int`, *optional*, defaults to 4096): Dimensionality of the "intermediate" (often named feed-forward) layer in decoder. num_encoder_layers (`int`, *optional*, defaults to 12): Number of encoder layers. num_encoder_attention_heads (`int`, *optional*, defaults to 16):
209_4_3
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/xlm-prophetnet.md
https://huggingface.co/docs/transformers/en/model_doc/xlm-prophetnet/#xlmprophetnetconfig
.md
Number of encoder layers. num_encoder_attention_heads (`int`, *optional*, defaults to 16): Number of attention heads for each attention layer in the Transformer encoder. decoder_ffn_dim (`int`, *optional*, defaults to 4096): Dimensionality of the `intermediate` (often named feed-forward) layer in decoder. num_decoder_layers (`int`, *optional*, defaults to 12): Number of decoder layers. num_decoder_attention_heads (`int`, *optional*, defaults to 16):
209_4_4
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/xlm-prophetnet.md
https://huggingface.co/docs/transformers/en/model_doc/xlm-prophetnet/#xlmprophetnetconfig
.md
Number of decoder layers. num_decoder_attention_heads (`int`, *optional*, defaults to 16): Number of attention heads for each attention layer in the Transformer decoder. attention_dropout (`float`, *optional*, defaults to 0.1): The dropout ratio for the attention probabilities. dropout (`float`, *optional*, defaults to 0.1): The dropout probability for all fully connected layers in the embeddings, encoder, and pooler. max_position_embeddings (`int`, *optional*, defaults to 512):
209_4_5
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/xlm-prophetnet.md
https://huggingface.co/docs/transformers/en/model_doc/xlm-prophetnet/#xlmprophetnetconfig
.md
max_position_embeddings (`int`, *optional*, defaults to 512): The maximum sequence length that this model might ever be used with. Typically set this to something large just in case (e.g., 512 or 1024 or 2048). init_std (`float`, *optional*, defaults to 0.02): The standard deviation of the truncated_normal_initializer for initializing all weight matrices. add_cross_attention (`bool`, *optional*, defaults to `True`): Whether cross-attention layers should be added to the model.
209_4_6
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/xlm-prophetnet.md
https://huggingface.co/docs/transformers/en/model_doc/xlm-prophetnet/#xlmprophetnetconfig
.md
add_cross_attention (`bool`, *optional*, defaults to `True`): Whether cross-attention layers should be added to the model. is_encoder_decoder (`bool`, *optional*, defaults to `True`): Whether this is an encoder/decoder model. pad_token_id (`int`, *optional*, defaults to 1) Padding token id. bos_token_id (`int`, *optional*, defaults to 0) Beginning of stream token id. eos_token_id (`int`, *optional*, defaults to 2) End of stream token id. ngram (`int`, *optional*, defaults to 2)
209_4_7
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/xlm-prophetnet.md
https://huggingface.co/docs/transformers/en/model_doc/xlm-prophetnet/#xlmprophetnetconfig
.md
eos_token_id (`int`, *optional*, defaults to 2) End of stream token id. ngram (`int`, *optional*, defaults to 2) Number of future tokens to predict. Set to 1 to be same as traditional Language model to predict next first token. num_buckets (`int`, *optional*, defaults to 32) The number of buckets to use for each attention layer. This is for relative position calculation. See the [T5 paper](see https://arxiv.org/abs/1910.10683) for more details. relative_max_distance (`int`, *optional*, defaults to 128)
209_4_8
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/xlm-prophetnet.md
https://huggingface.co/docs/transformers/en/model_doc/xlm-prophetnet/#xlmprophetnetconfig
.md
[T5 paper](see https://arxiv.org/abs/1910.10683) for more details. relative_max_distance (`int`, *optional*, defaults to 128) Relative distances greater than this number will be put into the last same bucket. This is for relative position calculation. See the [T5 paper](see https://arxiv.org/abs/1910.10683) for more details. disable_ngram_loss (`bool`, *optional*, defaults to `False`): Whether be trained predicting only the next first token. eps (`float`, *optional*, defaults to 0.0):
209_4_9
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/xlm-prophetnet.md
https://huggingface.co/docs/transformers/en/model_doc/xlm-prophetnet/#xlmprophetnetconfig
.md
Whether be trained predicting only the next first token. eps (`float`, *optional*, defaults to 0.0): Controls the `epsilon` parameter value for label smoothing in the loss calculation. If set to 0, no label smoothing is performed. use_cache (`bool`, *optional*, defaults to `True`): Whether or not the model should return the last key/values attentions (not used by all models).
209_4_10
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/xlm-prophetnet.md
https://huggingface.co/docs/transformers/en/model_doc/xlm-prophetnet/#xlmprophetnettokenizer
.md
Adapted from [`RobertaTokenizer`] and [`XLNetTokenizer`]. Based on [SentencePiece](https://github.com/google/sentencepiece). This tokenizer inherits from [`PreTrainedTokenizer`] which contains most of the main methods. Users should refer to this superclass for more information regarding those methods. Args: vocab_file (`str`): Path to the vocabulary file. bos_token (`str`, *optional*, defaults to `"[SEP]"`):
209_5_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/xlm-prophetnet.md
https://huggingface.co/docs/transformers/en/model_doc/xlm-prophetnet/#xlmprophetnettokenizer
.md
Args: vocab_file (`str`): Path to the vocabulary file. bos_token (`str`, *optional*, defaults to `"[SEP]"`): The beginning of sequence token that was used during pretraining. Can be used a sequence classifier token. <Tip> When building a sequence using special tokens, this is not the token that is used for the beginning of sequence. The token used is the `cls_token`. </Tip> eos_token (`str`, *optional*, defaults to `"[SEP]"`): The end of sequence token. <Tip>
209_5_1
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/xlm-prophetnet.md
https://huggingface.co/docs/transformers/en/model_doc/xlm-prophetnet/#xlmprophetnettokenizer
.md
</Tip> eos_token (`str`, *optional*, defaults to `"[SEP]"`): The end of sequence token. <Tip> When building a sequence using special tokens, this is not the token that is used for the end of sequence. The token used is the `sep_token`. </Tip> sep_token (`str`, *optional*, defaults to `"[SEP]"`): The separator token, which is used when building a sequence from multiple sequences, e.g. two sequences for
209_5_2
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/xlm-prophetnet.md
https://huggingface.co/docs/transformers/en/model_doc/xlm-prophetnet/#xlmprophetnettokenizer
.md
The separator token, which is used when building a sequence from multiple sequences, e.g. two sequences for sequence classification or for a text and a question for question answering. It is also used as the last token of a sequence built with special tokens. unk_token (`str`, *optional*, defaults to `"[UNK]"`): The unknown token. A token that is not in the vocabulary cannot be converted to an ID and is set to be this token instead. pad_token (`str`, *optional*, defaults to `"[PAD]"`):
209_5_3
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/xlm-prophetnet.md
https://huggingface.co/docs/transformers/en/model_doc/xlm-prophetnet/#xlmprophetnettokenizer
.md
token instead. pad_token (`str`, *optional*, defaults to `"[PAD]"`): The token used for padding, for example when batching sequences of different lengths. cls_token (`str`, *optional*, defaults to `"[CLS]"`): The classifier token which is used when doing sequence classification (classification of the whole sequence instead of per-token classification). It is the first token of the sequence when built with special tokens. mask_token (`str`, *optional*, defaults to `"[MASK]"`):
209_5_4
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/xlm-prophetnet.md
https://huggingface.co/docs/transformers/en/model_doc/xlm-prophetnet/#xlmprophetnettokenizer
.md
mask_token (`str`, *optional*, defaults to `"[MASK]"`): The token used for masking values. This is the token used when training this model with masked language modeling. This is the token which the model will try to predict. sp_model_kwargs (`dict`, *optional*): Will be passed to the `SentencePieceProcessor.__init__()` method. The [Python wrapper for SentencePiece](https://github.com/google/sentencepiece/tree/master/python) can be used, among other things, to set:
209_5_5
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/xlm-prophetnet.md
https://huggingface.co/docs/transformers/en/model_doc/xlm-prophetnet/#xlmprophetnettokenizer
.md
SentencePiece](https://github.com/google/sentencepiece/tree/master/python) can be used, among other things, to set: - `enable_sampling`: Enable subword regularization. - `nbest_size`: Sampling parameters for unigram. Invalid for BPE-Dropout. - `nbest_size = {0,1}`: No sampling is performed. - `nbest_size > 1`: samples from the nbest_size results. - `nbest_size < 0`: assuming that nbest_size is infinite and samples from the all hypothesis (lattice)
209_5_6
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/xlm-prophetnet.md
https://huggingface.co/docs/transformers/en/model_doc/xlm-prophetnet/#xlmprophetnettokenizer
.md
- `nbest_size < 0`: assuming that nbest_size is infinite and samples from the all hypothesis (lattice) using forward-filtering-and-backward-sampling algorithm. - `alpha`: Smoothing parameter for unigram sampling, and dropout probability of merge operations for BPE-dropout. Attributes: sp_model (`SentencePieceProcessor`): The *SentencePiece* processor that is used for every conversion (string, tokens and IDs).
209_5_7
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/xlm-prophetnet.md
https://huggingface.co/docs/transformers/en/model_doc/xlm-prophetnet/#xlmprophetnetmodel
.md
The bare XLMProphetNet Model outputting raw hidden-states without any specific head on top. This model inherits from [`PreTrainedModel`]. Check the superclass documentation for the generic methods the library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads etc.) Original ProphetNet code can be found [here](https://github.com/microsoft/ProphetNet). Checkpoints were converted
209_6_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/xlm-prophetnet.md
https://huggingface.co/docs/transformers/en/model_doc/xlm-prophetnet/#xlmprophetnetmodel
.md
etc.) Original ProphetNet code can be found [here](https://github.com/microsoft/ProphetNet). Checkpoints were converted from original Fairseq checkpoints. For more information on the checkpoint conversion, please take a look at the file `convert_prophetnet_original_pytorch_checkpoint_to_pytorch.py`. This model is a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) sub-class. Use
209_6_1
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/xlm-prophetnet.md
https://huggingface.co/docs/transformers/en/model_doc/xlm-prophetnet/#xlmprophetnetmodel
.md
This model is a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) sub-class. Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matters related to general usage and behavior. Parameters: config ([`XLMProphetNetConfig`]): Model configuration class with all the parameters of the model. Initializing with a config file does not load the weights associated with the model, only the
209_6_2
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/xlm-prophetnet.md
https://huggingface.co/docs/transformers/en/model_doc/xlm-prophetnet/#xlmprophetnetmodel
.md
Initializing with a config file does not load the weights associated with the model, only the configuration. Check out the [`~PreTrainedModel.from_pretrained`] method to load the model weights.
209_6_3
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/xlm-prophetnet.md
https://huggingface.co/docs/transformers/en/model_doc/xlm-prophetnet/#xlmprophetnetencoder
.md
The standalone encoder part of the XLMProphetNetModel. This model inherits from [`PreTrainedModel`]. Check the superclass documentation for the generic methods the library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads etc.) Original ProphetNet code can be found [here](https://github.com/microsoft/ProphetNet). Checkpoints were converted from original Fairseq checkpoints. For more information on the checkpoint conversion, please take a look at the
209_7_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/xlm-prophetnet.md
https://huggingface.co/docs/transformers/en/model_doc/xlm-prophetnet/#xlmprophetnetencoder
.md
from original Fairseq checkpoints. For more information on the checkpoint conversion, please take a look at the file `convert_prophetnet_original_pytorch_checkpoint_to_pytorch.py`. This model is a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) sub-class. Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matters related to general usage and behavior. Parameters:
209_7_1
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/xlm-prophetnet.md
https://huggingface.co/docs/transformers/en/model_doc/xlm-prophetnet/#xlmprophetnetencoder
.md
behavior. Parameters: config ([`XLMProphetNetConfig`]): Model configuration class with all the parameters of the model. Initializing with a config file does not load the weights associated with the model, only the configuration. Check out the [`~PreTrainedModel.from_pretrained`] method to load the model weights. word_embeddings (`torch.nn.Embeddings` of shape `(config.vocab_size, config.hidden_size)`, *optional*):
209_7_2
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/xlm-prophetnet.md
https://huggingface.co/docs/transformers/en/model_doc/xlm-prophetnet/#xlmprophetnetencoder
.md
word_embeddings (`torch.nn.Embeddings` of shape `(config.vocab_size, config.hidden_size)`, *optional*): The word embedding parameters. This can be used to initialize [`XLMProphetNetEncoder`] with pre-defined word embeddings instead of randomly initialized word embeddings.
209_7_3
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/xlm-prophetnet.md
https://huggingface.co/docs/transformers/en/model_doc/xlm-prophetnet/#xlmprophetnetdecoder
.md
The standalone decoder part of the XLMProphetNetModel. This model inherits from [`PreTrainedModel`]. Check the superclass documentation for the generic methods the library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads etc.) Original ProphetNet code can be found [here](https://github.com/microsoft/ProphetNet). Checkpoints were converted from original Fairseq checkpoints. For more information on the checkpoint conversion, please take a look at the
209_8_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/xlm-prophetnet.md
https://huggingface.co/docs/transformers/en/model_doc/xlm-prophetnet/#xlmprophetnetdecoder
.md
from original Fairseq checkpoints. For more information on the checkpoint conversion, please take a look at the file `convert_prophetnet_original_pytorch_checkpoint_to_pytorch.py`. This model is a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) sub-class. Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matters related to general usage and behavior. Parameters:
209_8_1
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/xlm-prophetnet.md
https://huggingface.co/docs/transformers/en/model_doc/xlm-prophetnet/#xlmprophetnetdecoder
.md
behavior. Parameters: config ([`XLMProphetNetConfig`]): Model configuration class with all the parameters of the model. Initializing with a config file does not load the weights associated with the model, only the configuration. Check out the [`~PreTrainedModel.from_pretrained`] method to load the model weights. word_embeddings (`torch.nn.Embeddings` of shape `(config.vocab_size, config.hidden_size)`, *optional*):
209_8_2
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/xlm-prophetnet.md
https://huggingface.co/docs/transformers/en/model_doc/xlm-prophetnet/#xlmprophetnetdecoder
.md
word_embeddings (`torch.nn.Embeddings` of shape `(config.vocab_size, config.hidden_size)`, *optional*): The word embedding parameters. This can be used to initialize [`XLMProphetNetEncoder`] with pre-defined word embeddings instead of randomly initialized word embeddings.
209_8_3
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/xlm-prophetnet.md
https://huggingface.co/docs/transformers/en/model_doc/xlm-prophetnet/#xlmprophetnetforconditionalgeneration
.md
The XLMProphetNet Model with a language modeling head. Can be used for sequence generation tasks. This model inherits from [`PreTrainedModel`]. Check the superclass documentation for the generic methods the library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads etc.) Original ProphetNet code can be found [here](https://github.com/microsoft/ProphetNet). Checkpoints were converted
209_9_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/xlm-prophetnet.md
https://huggingface.co/docs/transformers/en/model_doc/xlm-prophetnet/#xlmprophetnetforconditionalgeneration
.md
etc.) Original ProphetNet code can be found [here](https://github.com/microsoft/ProphetNet). Checkpoints were converted from original Fairseq checkpoints. For more information on the checkpoint conversion, please take a look at the file `convert_prophetnet_original_pytorch_checkpoint_to_pytorch.py`. This model is a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) sub-class. Use
209_9_1
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/xlm-prophetnet.md
https://huggingface.co/docs/transformers/en/model_doc/xlm-prophetnet/#xlmprophetnetforconditionalgeneration
.md
This model is a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) sub-class. Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matters related to general usage and behavior. Parameters: config ([`XLMProphetNetConfig`]): Model configuration class with all the parameters of the model. Initializing with a config file does not load the weights associated with the model, only the
209_9_2
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/xlm-prophetnet.md
https://huggingface.co/docs/transformers/en/model_doc/xlm-prophetnet/#xlmprophetnetforconditionalgeneration
.md
Initializing with a config file does not load the weights associated with the model, only the configuration. Check out the [`~PreTrainedModel.from_pretrained`] method to load the model weights.
209_9_3
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/xlm-prophetnet.md
https://huggingface.co/docs/transformers/en/model_doc/xlm-prophetnet/#xlmprophetnetforcausallm
.md
The standalone decoder part of the XLMProphetNetModel with a lm head on top. The model can be used for causal language modeling. This model inherits from [`PreTrainedModel`]. Check the superclass documentation for the generic methods the library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads etc.) Original ProphetNet code can be found [here](https://github.com/microsoft/ProphetNet). Checkpoints were converted
209_10_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/xlm-prophetnet.md
https://huggingface.co/docs/transformers/en/model_doc/xlm-prophetnet/#xlmprophetnetforcausallm
.md
etc.) Original ProphetNet code can be found [here](https://github.com/microsoft/ProphetNet). Checkpoints were converted from original Fairseq checkpoints. For more information on the checkpoint conversion, please take a look at the file `convert_prophetnet_original_pytorch_checkpoint_to_pytorch.py`. This model is a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) sub-class. Use
209_10_1
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/xlm-prophetnet.md
https://huggingface.co/docs/transformers/en/model_doc/xlm-prophetnet/#xlmprophetnetforcausallm
.md
This model is a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) sub-class. Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matters related to general usage and behavior. Parameters: config ([`XLMProphetNetConfig`]): Model configuration class with all the parameters of the model. Initializing with a config file does not load the weights associated with the model, only the
209_10_2
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/xlm-prophetnet.md
https://huggingface.co/docs/transformers/en/model_doc/xlm-prophetnet/#xlmprophetnetforcausallm
.md
Initializing with a config file does not load the weights associated with the model, only the configuration. Check out the [`~PreTrainedModel.from_pretrained`] method to load the model weights.
209_10_3
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/open-llama.md
https://huggingface.co/docs/transformers/en/model_doc/open-llama/
.md
<!--Copyright 2023 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
210_0_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/open-llama.md
https://huggingface.co/docs/transformers/en/model_doc/open-llama/
.md
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be rendered properly in your Markdown viewer. -->
210_0_1
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/open-llama.md
https://huggingface.co/docs/transformers/en/model_doc/open-llama/#open-llama
.md
<Tip warning={true}> This model is in maintenance mode only, we don't accept any new PRs changing its code. If you run into any issues running this model, please reinstall the last version that supported this model: v4.31.0. You can do so by running the following command: `pip install -U transformers==4.31.0`. </Tip> <Tip warning={true}>
210_1_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/open-llama.md
https://huggingface.co/docs/transformers/en/model_doc/open-llama/#open-llama
.md
You can do so by running the following command: `pip install -U transformers==4.31.0`. </Tip> <Tip warning={true}> This model differs from the [OpenLLaMA models](https://huggingface.co/models?search=openllama) on the Hugging Face Hub, which primarily use the [LLaMA](llama) architecture. </Tip>
210_1_1
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/open-llama.md
https://huggingface.co/docs/transformers/en/model_doc/open-llama/#overview
.md
The Open-Llama model was proposed in the open source Open-Llama project by community developer s-JoL. The model is mainly based on LLaMA with some modifications, incorporating memory-efficient attention from Xformers, stable embedding from Bloom, and shared input-output embedding from PaLM. And the model is pre-trained on both Chinese and English, which gives it better performance on Chinese language tasks. This model was contributed by [s-JoL](https://huggingface.co/s-JoL).
210_2_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/open-llama.md
https://huggingface.co/docs/transformers/en/model_doc/open-llama/#overview
.md
This model was contributed by [s-JoL](https://huggingface.co/s-JoL). The original code was released on GitHub by [s-JoL](https://github.com/s-JoL), but is now removed.
210_2_1
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/open-llama.md
https://huggingface.co/docs/transformers/en/model_doc/open-llama/#openllamaconfig
.md
This is the configuration class to store the configuration of a [`OpenLlamaModel`]. It is used to instantiate an Open-Llama model according to the specified arguments, defining the model architecture. Instantiating a configuration with the defaults will yield a similar configuration to that of the [s-JoL/Open-Llama-V1](https://huggingface.co/s-JoL/Open-Llama-V1). Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
210_3_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/open-llama.md
https://huggingface.co/docs/transformers/en/model_doc/open-llama/#openllamaconfig
.md
Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the documentation from [`PretrainedConfig`] for more information. Args: vocab_size (`int`, *optional*, defaults to 32000): Vocabulary size of the Open-Llama model. Defines the number of different tokens that can be represented by the `inputs_ids` passed when calling [`OpenLlamaModel`] hidden_size (`int`, *optional*, defaults to 4096): Dimension of the hidden representations.
210_3_1
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/open-llama.md
https://huggingface.co/docs/transformers/en/model_doc/open-llama/#openllamaconfig
.md
hidden_size (`int`, *optional*, defaults to 4096): Dimension of the hidden representations. intermediate_size (`int`, *optional*, defaults to 11008): Dimension of the MLP representations. num_hidden_layers (`int`, *optional*, defaults to 32): Number of hidden layers in the Transformer encoder. num_attention_heads (`int`, *optional*, defaults to 32): Number of attention heads for each attention layer in the Transformer encoder. hidden_act (`str` or `function`, *optional*, defaults to `"silu"`):
210_3_2
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/open-llama.md
https://huggingface.co/docs/transformers/en/model_doc/open-llama/#openllamaconfig
.md
hidden_act (`str` or `function`, *optional*, defaults to `"silu"`): The non-linear activation function (function or string) in the decoder. max_position_embeddings (`int`, *optional*, defaults to 2048): The maximum sequence length that this model might ever be used with. Typically set this to something large just in case (e.g., 512 or 1024 or 2048). initializer_range (`float`, *optional*, defaults to 0.02): The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
210_3_3
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/open-llama.md
https://huggingface.co/docs/transformers/en/model_doc/open-llama/#openllamaconfig
.md
The standard deviation of the truncated_normal_initializer for initializing all weight matrices. rms_norm_eps (`float`, *optional*, defaults to 1e-12): The epsilon used by the rms normalization layers. use_cache (`bool`, *optional*, defaults to `True`): Whether or not the model should return the last key/values attentions (not used by all models). Only relevant if `config.is_decoder=True`. tie_word_embeddings(`bool`, *optional*, defaults to `False`): Whether to tie weight embeddings
210_3_4
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/open-llama.md
https://huggingface.co/docs/transformers/en/model_doc/open-llama/#openllamaconfig
.md
tie_word_embeddings(`bool`, *optional*, defaults to `False`): Whether to tie weight embeddings rope_theta (`float`, *optional*, defaults to 10000.0): The base period of the RoPE embeddings. rope_scaling (`Dict`, *optional*): Dictionary containing the scaling configuration for the RoPE embeddings. Currently supports two scaling strategies: linear and dynamic. Their scaling factor must be a float greater than 1. The expected format is
210_3_5
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/open-llama.md
https://huggingface.co/docs/transformers/en/model_doc/open-llama/#openllamaconfig
.md
strategies: linear and dynamic. Their scaling factor must be a float greater than 1. The expected format is `{"type": strategy name, "factor": scaling factor}`. When using this flag, don't update `max_position_embeddings` to the expected new maximum. See the following thread for more information on how these scaling strategies behave: https://www.reddit.com/r/LocalLLaMA/comments/14mrgpr/dynamically_scaled_rope_further_increases/. This is an
210_3_6
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/open-llama.md
https://huggingface.co/docs/transformers/en/model_doc/open-llama/#openllamaconfig
.md
https://www.reddit.com/r/LocalLLaMA/comments/14mrgpr/dynamically_scaled_rope_further_increases/. This is an experimental feature, subject to breaking API changes in future versions. Example: ```python >>> from transformers import OpenLlamaModel, OpenLlamaConfig
210_3_7
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/open-llama.md
https://huggingface.co/docs/transformers/en/model_doc/open-llama/#openllamaconfig
.md
>>> # Initializing a Open-Llama open_llama-7b style configuration >>> configuration = OpenLlamaConfig() >>> # Initializing a model from the open_llama-7b style configuration >>> model = OpenLlamaModel(configuration) >>> # Accessing the model configuration >>> configuration = model.config ```
210_3_8
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/open-llama.md
https://huggingface.co/docs/transformers/en/model_doc/open-llama/#openllamamodel
.md
The bare Open-Llama Model outputting raw hidden-states without any specific head on top. This model inherits from [`PreTrainedModel`]. Check the superclass documentation for the generic methods the library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads etc.) This model is also a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) subclass.
210_4_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/open-llama.md
https://huggingface.co/docs/transformers/en/model_doc/open-llama/#openllamamodel
.md
etc.) This model is also a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) subclass. Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and behavior. Parameters: config ([`OpenLlamaConfig`]): Model configuration class with all the parameters of the model. Initializing with a config file does not load the weights associated with the model, only the configuration. Check out the
210_4_1
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/open-llama.md
https://huggingface.co/docs/transformers/en/model_doc/open-llama/#openllamamodel
.md
load the weights associated with the model, only the configuration. Check out the [`~PreTrainedModel.from_pretrained`] method to load the model weights. Transformer decoder consisting of *config.num_hidden_layers* layers. Each layer is a [`OpenLlamaDecoderLayer`] Args: config: OpenLlamaConfig Methods: forward
210_4_2
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/open-llama.md
https://huggingface.co/docs/transformers/en/model_doc/open-llama/#openllamaforcausallm
.md
No docstring available for OpenLlamaForCausalLM Methods: forward
210_5_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/open-llama.md
https://huggingface.co/docs/transformers/en/model_doc/open-llama/#openllamaforsequenceclassification
.md
The LLaMa Model transformer with a sequence classification head on top (linear layer). [`OpenLlamaForSequenceClassification`] uses the last token in order to do the classification, as other causal models (e.g. GPT-2) do. Since it does classification on the last token, it requires to know the position of the last token. If a `pad_token_id` is defined in the configuration, it finds the last token that is not a padding token in each row. If
210_6_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/open-llama.md
https://huggingface.co/docs/transformers/en/model_doc/open-llama/#openllamaforsequenceclassification
.md
`pad_token_id` is defined in the configuration, it finds the last token that is not a padding token in each row. If no `pad_token_id` is defined, it simply takes the last value in each row of the batch. Since it cannot guess the padding tokens when `inputs_embeds` are passed instead of `input_ids`, it does the same (take the last value in each row of the batch). This model inherits from [`PreTrainedModel`]. Check the superclass documentation for the generic methods the
210_6_1
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/open-llama.md
https://huggingface.co/docs/transformers/en/model_doc/open-llama/#openllamaforsequenceclassification
.md
This model inherits from [`PreTrainedModel`]. Check the superclass documentation for the generic methods the library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads etc.) This model is also a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) subclass. Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and behavior. Parameters:
210_6_2
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/open-llama.md
https://huggingface.co/docs/transformers/en/model_doc/open-llama/#openllamaforsequenceclassification
.md
and behavior. Parameters: config ([`OpenLlamaConfig`]): Model configuration class with all the parameters of the model. Initializing with a config file does not load the weights associated with the model, only the configuration. Check out the [`~PreTrainedModel.from_pretrained`] method to load the model weights. Methods: forward
210_6_3
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/phi.md
https://huggingface.co/docs/transformers/en/model_doc/phi/
.md
<!--Copyright 2023 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
211_0_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/phi.md
https://huggingface.co/docs/transformers/en/model_doc/phi/
.md
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be rendered properly in your Markdown viewer. -->
211_0_1
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/phi.md
https://huggingface.co/docs/transformers/en/model_doc/phi/#overview
.md
The Phi-1 model was proposed in [Textbooks Are All You Need](https://arxiv.org/abs/2306.11644) by Suriya Gunasekar, Yi Zhang, Jyoti Aneja, Caio César Teodoro Mendes, Allie Del Giorno, Sivakanth Gopi, Mojan Javaheripi, Piero Kauffmann, Gustavo de Rosa, Olli Saarikivi, Adil Salim, Shital Shah, Harkirat Singh Behl, Xin Wang, Sébastien Bubeck, Ronen Eldan, Adam Tauman Kalai, Yin Tat Lee and Yuanzhi Li.
211_1_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/phi.md
https://huggingface.co/docs/transformers/en/model_doc/phi/#overview
.md
The Phi-1.5 model was proposed in [Textbooks Are All You Need II: phi-1.5 technical report](https://arxiv.org/abs/2309.05463) by Yuanzhi Li, Sébastien Bubeck, Ronen Eldan, Allie Del Giorno, Suriya Gunasekar and Yin Tat Lee.
211_1_1
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/phi.md
https://huggingface.co/docs/transformers/en/model_doc/phi/#summary
.md
In Phi-1 and Phi-1.5 papers, the authors showed how important the quality of the data is in training relative to the model size. They selected high quality "textbook" data alongside with synthetically generated data for training their small sized Transformer based model Phi-1 with 1.3B parameters. Despite this small scale, phi-1 attains pass@1 accuracy 50.6% on HumanEval and 55.5% on MBPP.
211_2_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/phi.md
https://huggingface.co/docs/transformers/en/model_doc/phi/#summary
.md
They follow the same strategy for Phi-1.5 and created another 1.3B parameter model with performance on natural language tasks comparable to models 5x larger, and surpassing most non-frontier LLMs. Phi-1.5 exhibits many of the traits of much larger LLMs such as the ability to “think step by step” or perform some rudimentary in-context learning. With these two experiments the authors successfully showed the huge impact of quality of training data when training machine learning models.
211_2_1
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/phi.md
https://huggingface.co/docs/transformers/en/model_doc/phi/#summary
.md
The abstract from the Phi-1 paper is the following: *We introduce phi-1, a new large language model for code, with significantly smaller size than competing models: phi-1 is a Transformer-based model with 1.3B parameters, trained for 4 days on 8 A100s, using a selection of “textbook quality” data from the web (6B tokens) and synthetically generated textbooks and exercises with GPT-3.5 (1B tokens). Despite this small scale, phi-1 attains
211_2_2
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/phi.md
https://huggingface.co/docs/transformers/en/model_doc/phi/#summary
.md
generated textbooks and exercises with GPT-3.5 (1B tokens). Despite this small scale, phi-1 attains pass@1 accuracy 50.6% on HumanEval and 55.5% on MBPP. It also displays surprising emergent properties compared to phi-1-base, our model before our finetuning stage on a dataset of coding exercises, and phi-1-small, a smaller model with 350M parameters trained with the same pipeline as phi-1 that still achieves 45% on HumanEval.* The abstract from the Phi-1.5 paper is the following:
211_2_3
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/phi.md
https://huggingface.co/docs/transformers/en/model_doc/phi/#summary
.md
phi-1 that still achieves 45% on HumanEval.* The abstract from the Phi-1.5 paper is the following: *We continue the investigation into the power of smaller Transformer-based language models as initiated by TinyStories – a 10 million parameter model that can produce coherent English – and the follow-up work on phi-1, a 1.3 billion parameter model with Python coding performance close to the state-of-the-art. The latter work proposed to use existing Large Language Models (LLMs) to
211_2_4
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/phi.md
https://huggingface.co/docs/transformers/en/model_doc/phi/#summary
.md
to the state-of-the-art. The latter work proposed to use existing Large Language Models (LLMs) to generate “textbook quality” data as a way to enhance the learning process compared to traditional web data. We follow the “Textbooks Are All You Need” approach, focusing this time on common sense reasoning in natural language, and create a new 1.3 billion parameter model named phi-1.5, with performance on natural language tasks comparable to models 5x larger, and surpassing most
211_2_5
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/phi.md
https://huggingface.co/docs/transformers/en/model_doc/phi/#summary
.md
with performance on natural language tasks comparable to models 5x larger, and surpassing most non-frontier LLMs on more complex reasoning tasks such as grade-school mathematics and basic coding. More generally, phi-1.5 exhibits many of the traits of much larger LLMs, both good –such as the ability to “think step by step” or perform some rudimentary in-context learning– and bad, including hallucinations and the potential for toxic and biased generations –encouragingly though, we
211_2_6
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/phi.md
https://huggingface.co/docs/transformers/en/model_doc/phi/#summary
.md
including hallucinations and the potential for toxic and biased generations –encouragingly though, we are seeing improvement on that front thanks to the absence of web data. We open-source phi-1.5 to promote further research on these urgent topics.* This model was contributed by [Susnato Dhar](https://huggingface.co/susnato).
211_2_7
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/phi.md
https://huggingface.co/docs/transformers/en/model_doc/phi/#summary
.md
This model was contributed by [Susnato Dhar](https://huggingface.co/susnato). The original code for Phi-1, Phi-1.5 and Phi-2 can be found [here](https://huggingface.co/microsoft/phi-1), [here](https://huggingface.co/microsoft/phi-1_5) and [here](https://huggingface.co/microsoft/phi-2), respectively.
211_2_8
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/phi.md
https://huggingface.co/docs/transformers/en/model_doc/phi/#usage-tips
.md
- This model is quite similar to `Llama` with the main difference in [`PhiDecoderLayer`], where they used [`PhiAttention`] and [`PhiMLP`] layers in parallel configuration. - The tokenizer used for this model is identical to the [`CodeGenTokenizer`].
211_3_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/phi.md
https://huggingface.co/docs/transformers/en/model_doc/phi/#how-to-use-phi-2
.md
<Tip warning={true}> Phi-2 has been integrated in the development version (4.37.0.dev) of `transformers`. Until the official version is released through `pip`, ensure that you are doing one of the following: * When loading the model, ensure that `trust_remote_code=True` is passed as an argument of the `from_pretrained()` function.
211_4_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/phi.md
https://huggingface.co/docs/transformers/en/model_doc/phi/#how-to-use-phi-2
.md
* When loading the model, ensure that `trust_remote_code=True` is passed as an argument of the `from_pretrained()` function. * Update your local `transformers` to the development version: `pip uninstall -y transformers && pip install git+https://github.com/huggingface/transformers`. The previous command is an alternative to cloning and installing from the source. </Tip> ```python >>> from transformers import AutoModelForCausalLM, AutoTokenizer
211_4_1
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/phi.md
https://huggingface.co/docs/transformers/en/model_doc/phi/#how-to-use-phi-2
.md
>>> model = AutoModelForCausalLM.from_pretrained("microsoft/phi-2") >>> tokenizer = AutoTokenizer.from_pretrained("microsoft/phi-2") >>> inputs = tokenizer('Can you help me write a formal email to a potential business partner proposing a joint venture?', return_tensors="pt", return_attention_mask=False)
211_4_2
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/phi.md
https://huggingface.co/docs/transformers/en/model_doc/phi/#how-to-use-phi-2
.md
>>> outputs = model.generate(**inputs, max_length=30) >>> text = tokenizer.batch_decode(outputs)[0] >>> print(text) Can you help me write a formal email to a potential business partner proposing a joint venture? Input: Company A: ABC Inc. Company B ```
211_4_3
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/phi.md
https://huggingface.co/docs/transformers/en/model_doc/phi/#example-
.md
```python >>> from transformers import PhiForCausalLM, AutoTokenizer >>> # define the model and tokenizer. >>> model = PhiForCausalLM.from_pretrained("microsoft/phi-1_5") >>> tokenizer = AutoTokenizer.from_pretrained("microsoft/phi-1_5") >>> # feel free to change the prompt to your liking. >>> prompt = "If I were an AI that had just achieved" >>> # apply the tokenizer. >>> tokens = tokenizer(prompt, return_tensors="pt")
211_5_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/phi.md
https://huggingface.co/docs/transformers/en/model_doc/phi/#example-
.md
>>> # apply the tokenizer. >>> tokens = tokenizer(prompt, return_tensors="pt") >>> # use the model to generate new tokens. >>> generated_output = model.generate(**tokens, use_cache=True, max_new_tokens=10) >>> tokenizer.batch_decode(generated_output)[0] 'If I were an AI that had just achieved a breakthrough in machine learning, I would be thrilled' ```
211_5_1
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/phi.md
https://huggingface.co/docs/transformers/en/model_doc/phi/#combining-phi-and-flash-attention-2
.md
First, make sure to install the latest version of Flash Attention 2 to include the sliding window attention feature. ```bash pip install -U flash-attn --no-build-isolation ``` Make also sure that you have a hardware that is compatible with Flash-Attention 2. Read more about it in the official documentation of flash-attn repository. Make also sure to load your model in half-precision (e.g. `torch.float16``) To load and run a model using Flash Attention 2, refer to the snippet below: ```python
211_6_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/phi.md
https://huggingface.co/docs/transformers/en/model_doc/phi/#combining-phi-and-flash-attention-2
.md
To load and run a model using Flash Attention 2, refer to the snippet below: ```python >>> import torch >>> from transformers import PhiForCausalLM, AutoTokenizer
211_6_1
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/phi.md
https://huggingface.co/docs/transformers/en/model_doc/phi/#combining-phi-and-flash-attention-2
.md
>>> # define the model and tokenizer and push the model and tokens to the GPU. >>> model = PhiForCausalLM.from_pretrained("microsoft/phi-1_5", torch_dtype=torch.float16, attn_implementation="flash_attention_2").to("cuda") # doctest: +SKIP >>> tokenizer = AutoTokenizer.from_pretrained("microsoft/phi-1_5") >>> # feel free to change the prompt to your liking. >>> prompt = "If I were an AI that had just achieved" >>> # apply the tokenizer. >>> tokens = tokenizer(prompt, return_tensors="pt").to("cuda")
211_6_2
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/phi.md
https://huggingface.co/docs/transformers/en/model_doc/phi/#combining-phi-and-flash-attention-2
.md
>>> # apply the tokenizer. >>> tokens = tokenizer(prompt, return_tensors="pt").to("cuda") >>> # use the model to generate new tokens. >>> generated_output = model.generate(**tokens, use_cache=True, max_new_tokens=10) # doctest: +SKIP >>> tokenizer.batch_decode(generated_output)[0] # doctest: +SKIP 'If I were an AI that had just achieved a breakthrough in machine learning, I would be thrilled' ```
211_6_3
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/phi.md
https://huggingface.co/docs/transformers/en/model_doc/phi/#expected-speedups
.md
Below is an expected speedup diagram that compares pure inference time between the native implementation in transformers using `microsoft/phi-1` checkpoint and the Flash Attention 2 version of the model using a sequence length of 2048. <div style="text-align: center"> <img src="https://huggingface.co/datasets/ybelkada/documentation-images/resolve/main/phi_1_speedup_plot.jpg"> </div>
211_7_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/phi.md
https://huggingface.co/docs/transformers/en/model_doc/phi/#phiconfig
.md
This is the configuration class to store the configuration of a [`PhiModel`]. It is used to instantiate an Phi model according to the specified arguments, defining the model architecture. Instantiating a configuration with the defaults will yield a similar configuration to that of the Phi [microsoft/phi-1](https://huggingface.co/microsoft/phi-1). Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
211_8_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/phi.md
https://huggingface.co/docs/transformers/en/model_doc/phi/#phiconfig
.md
Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the documentation from [`PretrainedConfig`] for more information. Args: vocab_size (`int`, *optional*, defaults to 51200): Vocabulary size of the Phi model. Defines the number of different tokens that can be represented by the `inputs_ids` passed when calling [`PhiModel`]. hidden_size (`int`, *optional*, defaults to 2048): Dimension of the hidden representations.
211_8_1
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/phi.md
https://huggingface.co/docs/transformers/en/model_doc/phi/#phiconfig
.md
hidden_size (`int`, *optional*, defaults to 2048): Dimension of the hidden representations. intermediate_size (`int`, *optional*, defaults to 8192): Dimension of the MLP representations. num_hidden_layers (`int`, *optional*, defaults to 24): Number of hidden layers in the Transformer decoder. num_attention_heads (`int`, *optional*, defaults to 32): Number of attention heads for each attention layer in the Transformer decoder. num_key_value_heads (`int`, *optional*):
211_8_2
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/phi.md
https://huggingface.co/docs/transformers/en/model_doc/phi/#phiconfig
.md
Number of attention heads for each attention layer in the Transformer decoder. num_key_value_heads (`int`, *optional*): This is the number of key_value heads that should be used to implement Grouped Query Attention. If `num_key_value_heads=num_attention_heads`, the model will use Multi Head Attention (MHA), if `num_key_value_heads=1` the model will use Multi Query Attention (MQA) otherwise GQA is used. When
211_8_3
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/phi.md
https://huggingface.co/docs/transformers/en/model_doc/phi/#phiconfig
.md
`num_key_value_heads=1` the model will use Multi Query Attention (MQA) otherwise GQA is used. When converting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructed by meanpooling all the original heads within that group. For more details checkout [this paper](https://arxiv.org/pdf/2305.13245.pdf). If it is not specified, will default to `num_attention_heads`. resid_pdrop (`float`, *optional*, defaults to 0.0): Dropout probability for mlp outputs.
211_8_4
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/phi.md
https://huggingface.co/docs/transformers/en/model_doc/phi/#phiconfig
.md
`num_attention_heads`. resid_pdrop (`float`, *optional*, defaults to 0.0): Dropout probability for mlp outputs. embd_pdrop (`int`, *optional*, defaults to 0.0): The dropout ratio for the embeddings. attention_dropout (`float`, *optional*, defaults to 0.0): The dropout ratio after computing the attention scores. hidden_act (`str` or `function`, *optional*, defaults to `"gelu_new"`): The non-linear activation function (function or string) in the decoder.
211_8_5
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/phi.md
https://huggingface.co/docs/transformers/en/model_doc/phi/#phiconfig
.md
The non-linear activation function (function or string) in the decoder. max_position_embeddings (`int`, *optional*, defaults to 2048): The maximum sequence length that this model might ever be used with. Phi-1 and Phi-1.5 supports up to 2048 tokens. initializer_range (`float`, *optional*, defaults to 0.02): The standard deviation of the truncated_normal_initializer for initializing all weight matrices. layer_norm_eps (`float`, *optional*, defaults to 1e-05):
211_8_6