xlm_roberta_xl
mindnlp.transformers.models.xlm_roberta_xl.configuration_xlm_roberta_xl
¶
XLM_ROBERTa_XL configuration
mindnlp.transformers.models.xlm_roberta_xl.configuration_xlm_roberta_xl.XLMRobertaXLConfig
¶
Bases: PretrainedConfig
This is the configuration class to store the configuration of a [XLMRobertaXLModel
] or a [TFXLMRobertaXLModel
].
It is used to instantiate a XLM_ROBERTA_XL 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
XLM_ROBERTA_XL facebook/xlm-roberta-xl architecture.
Configuration objects inherit from [PretrainedConfig
] and can be used to control the model outputs. Read the
documentation from [PretrainedConfig
] for more information.
PARAMETER | DESCRIPTION |
---|---|
vocab_size |
Vocabulary size of the XLM_ROBERTA_XL model. Defines the number of different tokens that can be represented
by the
TYPE:
|
hidden_size |
Dimensionality of the encoder layers and the pooler layer.
TYPE:
|
num_hidden_layers |
Number of hidden layers in the Transformer encoder.
TYPE:
|
num_attention_heads |
Number of attention heads for each attention layer in the Transformer encoder.
TYPE:
|
intermediate_size |
Dimensionality of the "intermediate" (often named feed-forward) layer in the Transformer encoder.
TYPE:
|
hidden_act |
The non-linear activation function (function or string) in the encoder and pooler. If string,
TYPE:
|
hidden_dropout_prob |
The dropout probability for all fully connected layers in the embeddings, encoder, and pooler.
TYPE:
|
attention_probs_dropout_prob |
The dropout ratio for the attention probabilities.
TYPE:
|
max_position_embeddings |
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).
TYPE:
|
type_vocab_size |
The vocabulary size of the
TYPE:
|
initializer_range |
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
TYPE:
|
layer_norm_eps |
The epsilon used by the layer normalization layers.
TYPE:
|
position_embedding_type |
Type of position embedding. Choose one of
TYPE:
|
use_cache |
Whether or not the model should return the last key/values attentions (not used by all models). Only
relevant if
TYPE:
|
classifier_dropout |
The dropout ratio for the classification head.
TYPE:
|
Example
>>> from transformers import XLMRobertaXLConfig, XLMRobertaXLModel
...
>>> # Initializing a XLM_ROBERTA_XL google-bert/bert-base-uncased style configuration
>>> configuration = XLMRobertaXLConfig()
...
>>> # Initializing a model (with random weights) from the google-bert/bert-base-uncased style configuration
>>> model = XLMRobertaXLModel(configuration)
...
>>> # Accessing the model configuration
>>> configuration = model.config
Source code in mindnlp/transformers/models/xlm_roberta_xl/configuration_xlm_roberta_xl.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
|
mindnlp.transformers.models.xlm_roberta_xl.modeling_xlm_roberta_xl
¶
PyTorch XLM RoBERTa xl,xxl model.
mindnlp.transformers.models.xlm_roberta_xl.modeling_xlm_roberta_xl.XLMRobertaXLClassificationHead
¶
Bases: Module
Head for sentence-level classification tasks.
Source code in mindnlp/transformers/models/xlm_roberta_xl/modeling_xlm_roberta_xl.py
1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 |
|
mindnlp.transformers.models.xlm_roberta_xl.modeling_xlm_roberta_xl.XLMRobertaXLEmbeddings
¶
Bases: Module
Same as BertEmbeddings with a tiny tweak for positional embeddings indexing.
Source code in mindnlp/transformers/models/xlm_roberta_xl/modeling_xlm_roberta_xl.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
|
mindnlp.transformers.models.xlm_roberta_xl.modeling_xlm_roberta_xl.XLMRobertaXLEmbeddings.__init__(config)
¶
init
Initializes a new instance of the XLMRobertaEmbeddings class.
PARAMETER | DESCRIPTION |
---|---|
self |
The instance of the XLMRobertaEmbeddings class.
|
config |
An object containing configuration parameters for the XLMRoberta model. It includes the following attributes:
|
RETURNS | DESCRIPTION |
---|---|
None. |
Source code in mindnlp/transformers/models/xlm_roberta_xl/modeling_xlm_roberta_xl.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
|
mindnlp.transformers.models.xlm_roberta_xl.modeling_xlm_roberta_xl.XLMRobertaXLEmbeddings.create_position_ids_from_inputs_embeds(inputs_embeds)
¶
We are provided embeddings directly. We cannot infer which are padded so just generate sequential position ids.
PARAMETER | DESCRIPTION |
---|---|
inputs_embeds |
mindspore.Tensor
|
RETURNS | DESCRIPTION |
---|---|
mindspore.Tensor |
Source code in mindnlp/transformers/models/xlm_roberta_xl/modeling_xlm_roberta_xl.py
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
|
mindnlp.transformers.models.xlm_roberta_xl.modeling_xlm_roberta_xl.XLMRobertaXLEmbeddings.forward(input_ids=None, token_type_ids=None, position_ids=None, inputs_embeds=None, past_key_values_length=0)
¶
Method: forward
This method forwards the embeddings for the XLM-Roberta model.
PARAMETER | DESCRIPTION |
---|---|
self |
(object) The instance of the class.
|
input_ids |
(Tensor, optional) The input tensor containing the token ids. Default is None.
DEFAULT:
|
token_type_ids |
(Tensor, optional) The input tensor containing the token type ids. Default is None.
DEFAULT:
|
position_ids |
(Tensor, optional) The input tensor containing the position ids. Default is None.
DEFAULT:
|
inputs_embeds |
(Tensor, optional) The input embeddings tensor. Default is None.
DEFAULT:
|
past_key_values_length |
(int) The length of the past key values. Default is 0.
DEFAULT:
|
RETURNS | DESCRIPTION |
---|---|
embeddings
|
(Tensor) The forwarded embeddings for the XLM-Roberta model. |
RAISES | DESCRIPTION |
---|---|
ValueError
|
If both input_ids and inputs_embeds are None, or if an unsupported position_embedding_type is provided. |
IndexError
|
If input_ids or inputs_embeds do not have the expected shape. |
AttributeError
|
If the 'token_type_ids' attribute is missing in the class. |
Source code in mindnlp/transformers/models/xlm_roberta_xl/modeling_xlm_roberta_xl.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
|
mindnlp.transformers.models.xlm_roberta_xl.modeling_xlm_roberta_xl.XLMRobertaXLForCausalLM
¶
Bases: XLMRobertaXLPreTrainedModel
Source code in mindnlp/transformers/models/xlm_roberta_xl/modeling_xlm_roberta_xl.py
807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 |
|
mindnlp.transformers.models.xlm_roberta_xl.modeling_xlm_roberta_xl.XLMRobertaXLForCausalLM.__init__(config)
¶
Initializes an instance of the XLMRobertaForCausalLM class.
PARAMETER | DESCRIPTION |
---|---|
self |
The instance of the class.
|
config |
An object representing the configuration for the XLMRobertaForCausalLM model.
|
RETURNS | DESCRIPTION |
---|---|
None. |
Source code in mindnlp/transformers/models/xlm_roberta_xl/modeling_xlm_roberta_xl.py
810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 |
|
mindnlp.transformers.models.xlm_roberta_xl.modeling_xlm_roberta_xl.XLMRobertaXLForCausalLM.forward(input_ids=None, attention_mask=None, token_type_ids=None, position_ids=None, head_mask=None, inputs_embeds=None, encoder_hidden_states=None, encoder_attention_mask=None, labels=None, past_key_values=None, use_cache=None, output_attentions=None, output_hidden_states=None, return_dict=None)
¶
PARAMETER | DESCRIPTION |
---|---|
encoder_hidden_states |
Sequence of hidden-states at the output of the last layer of the encoder. Used in the cross-attention if the model is configured as a decoder.
TYPE:
|
encoder_attention_mask |
Mask to avoid performing attention on the padding token indices of the encoder input. This mask is used in
the cross-attention if the model is configured as a decoder. Mask values selected in
TYPE:
|
labels |
Labels for computing the left-to-right language modeling loss (next word prediction). Indices should be in
TYPE:
|
use_cache |
If set to
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Union[Tuple[Tensor], CausalLMOutputWithCrossAttentions]
|
|
Example
>>> from transformers import AutoTokenizer, XLMRobertaForCausalLM, AutoConfig
...
>>> tokenizer = AutoTokenizer.from_pretrained("roberta-base")
>>> config = AutoConfig.from_pretrained("roberta-base")
>>> config.is_decoder = True
>>> model = XLMRobertaForCausalLM.from_pretrained("roberta-base", config=config)
...
>>> inputs = tokenizer("Hello, my dog is cute", return_tensors="pt")
>>> outputs = model(**inputs)
...
>>> prediction_logits = outputs.logits
Source code in mindnlp/transformers/models/xlm_roberta_xl/modeling_xlm_roberta_xl.py
879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 |
|
mindnlp.transformers.models.xlm_roberta_xl.modeling_xlm_roberta_xl.XLMRobertaXLForCausalLM.get_output_embeddings()
¶
Method to retrieve the output embeddings from XLMRobertaForCausalLM model.
PARAMETER | DESCRIPTION |
---|---|
self |
The instance of the XLMRobertaForCausalLM class. It is used to access the decoder of the model to get the output embeddings.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None
|
This method does not return any value but directly provides access to the output embeddings through the decoder. |
Source code in mindnlp/transformers/models/xlm_roberta_xl/modeling_xlm_roberta_xl.py
834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 |
|
mindnlp.transformers.models.xlm_roberta_xl.modeling_xlm_roberta_xl.XLMRobertaXLForCausalLM.set_output_embeddings(new_embeddings)
¶
Sets the output embeddings for the XLMRobertaForCausalLM model.
PARAMETER | DESCRIPTION |
---|---|
self |
The instance of the XLMRobertaForCausalLM class.
TYPE:
|
new_embeddings |
The new embeddings to be set as the output embeddings for the model.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None. |
Note
The output embeddings are used in the decoder layer of the XLMRobertaForCausalLM model. By setting new embeddings, users can customize the output layer of the model according to their specific requirements.
Example
>>> model = XLMRobertaForCausalLM.from_pretrained('xlm-roberta-base')
>>> new_embeddings = torch.nn.Embedding(10, 768)
>>> model.set_output_embeddings(new_embeddings)
Source code in mindnlp/transformers/models/xlm_roberta_xl/modeling_xlm_roberta_xl.py
851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 |
|
mindnlp.transformers.models.xlm_roberta_xl.modeling_xlm_roberta_xl.XLMRobertaXLForMaskedLM
¶
Bases: XLMRobertaXLPreTrainedModel
XLMRobertaForMaskedLM
Source code in mindnlp/transformers/models/xlm_roberta_xl/modeling_xlm_roberta_xl.py
1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 |
|
mindnlp.transformers.models.xlm_roberta_xl.modeling_xlm_roberta_xl.XLMRobertaXLForMaskedLM.__init__(config)
¶
Initializes an instance of XLMRobertaForMaskedLM.
PARAMETER | DESCRIPTION |
---|---|
self |
The instance of the class.
|
config |
The configuration object containing the settings for the model. It should have attributes like 'is_decoder' to control the behavior of the model. If 'is_decoder' is set to True, a warning message will be logged. Ensure that 'is_decoder' is set to False for bi-directional self-attention.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None. |
Source code in mindnlp/transformers/models/xlm_roberta_xl/modeling_xlm_roberta_xl.py
1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 |
|
mindnlp.transformers.models.xlm_roberta_xl.modeling_xlm_roberta_xl.XLMRobertaXLForMaskedLM.forward(input_ids=None, attention_mask=None, token_type_ids=None, position_ids=None, head_mask=None, inputs_embeds=None, encoder_hidden_states=None, encoder_attention_mask=None, labels=None, output_attentions=None, output_hidden_states=None, return_dict=None)
¶
PARAMETER | DESCRIPTION |
---|---|
labels |
Labels for computing the masked language modeling loss. Indices should be in
TYPE:
|
kwargs |
Used to hide legacy arguments that have been deprecated.
TYPE:
|
Source code in mindnlp/transformers/models/xlm_roberta_xl/modeling_xlm_roberta_xl.py
1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 |
|
mindnlp.transformers.models.xlm_roberta_xl.modeling_xlm_roberta_xl.XLMRobertaXLForMaskedLM.get_output_embeddings()
¶
Get the output embeddings for the XLM-Roberta model.
PARAMETER | DESCRIPTION |
---|---|
self |
The instance of the XLMRobertaForMaskedLM class.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None. |
Source code in mindnlp/transformers/models/xlm_roberta_xl/modeling_xlm_roberta_xl.py
1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 |
|
mindnlp.transformers.models.xlm_roberta_xl.modeling_xlm_roberta_xl.XLMRobertaXLForMaskedLM.set_output_embeddings(new_embeddings)
¶
This method sets the output embeddings for the XLMRobertaForMaskedLM model.
PARAMETER | DESCRIPTION |
---|---|
self |
The instance of the XLMRobertaForMaskedLM class.
TYPE:
|
new_embeddings |
The new embeddings to be set as the output embeddings for the model. It should be an instance of torch.nn.Module representing the new embeddings.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None. |
RAISES | DESCRIPTION |
---|---|
TypeError
|
If the new_embeddings parameter is not an instance of torch.nn.Module. |
AttributeError
|
If the lm_head.decoder attribute does not exist or is not accessible within the XLMRobertaForMaskedLM instance. |
Source code in mindnlp/transformers/models/xlm_roberta_xl/modeling_xlm_roberta_xl.py
1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 |
|
mindnlp.transformers.models.xlm_roberta_xl.modeling_xlm_roberta_xl.XLMRobertaXLForMultipleChoice
¶
Bases: XLMRobertaXLPreTrainedModel
XLMRobertaForMultipleChoice
Source code in mindnlp/transformers/models/xlm_roberta_xl/modeling_xlm_roberta_xl.py
1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 |
|
mindnlp.transformers.models.xlm_roberta_xl.modeling_xlm_roberta_xl.XLMRobertaXLForMultipleChoice.__init__(config)
¶
init
Initialize the XLMRobertaForMultipleChoice model.
PARAMETER | DESCRIPTION |
---|---|
self |
The instance of the class.
|
config |
An instance of the configuration class containing the model configuration. It is used to initialize the XLMRobertaModel, dropout, and classifier. It should be of type XLMRobertaConfig.
|
RETURNS | DESCRIPTION |
---|---|
None. |
Source code in mindnlp/transformers/models/xlm_roberta_xl/modeling_xlm_roberta_xl.py
1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 |
|
mindnlp.transformers.models.xlm_roberta_xl.modeling_xlm_roberta_xl.XLMRobertaXLForMultipleChoice.forward(input_ids=None, token_type_ids=None, attention_mask=None, labels=None, position_ids=None, head_mask=None, inputs_embeds=None, output_attentions=None, output_hidden_states=None, return_dict=None)
¶
PARAMETER | DESCRIPTION |
---|---|
labels |
Labels for computing the multiple choice classification loss. Indices should be in
TYPE:
|
Source code in mindnlp/transformers/models/xlm_roberta_xl/modeling_xlm_roberta_xl.py
1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 |
|
mindnlp.transformers.models.xlm_roberta_xl.modeling_xlm_roberta_xl.XLMRobertaXLForQuestionAnswering
¶
Bases: XLMRobertaXLPreTrainedModel
XLMRobertaForQuestionAnswering
Source code in mindnlp/transformers/models/xlm_roberta_xl/modeling_xlm_roberta_xl.py
1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 |
|
mindnlp.transformers.models.xlm_roberta_xl.modeling_xlm_roberta_xl.XLMRobertaXLForQuestionAnswering.__init__(config)
¶
Initializes the XLMRobertaForQuestionAnswering class.
PARAMETER | DESCRIPTION |
---|---|
self |
The instance of the XLMRobertaForQuestionAnswering class.
TYPE:
|
config |
The configuration object for the XLM-RoBERTa model. It contains various parameters for model initialization, such as num_labels, hidden_size, and more.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None. |
RAISES | DESCRIPTION |
---|---|
TypeError
|
If the provided config is not of type XLMRobertaConfig. |
ValueError
|
If the number of labels in the config is not a positive integer. |
Source code in mindnlp/transformers/models/xlm_roberta_xl/modeling_xlm_roberta_xl.py
1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 |
|
mindnlp.transformers.models.xlm_roberta_xl.modeling_xlm_roberta_xl.XLMRobertaXLForQuestionAnswering.forward(input_ids=None, attention_mask=None, token_type_ids=None, position_ids=None, head_mask=None, inputs_embeds=None, start_positions=None, end_positions=None, output_attentions=None, output_hidden_states=None, return_dict=None)
¶
PARAMETER | DESCRIPTION |
---|---|
start_positions |
Labels for position (index) of the start of the labelled span for computing the token classification loss.
Positions are clamped to the length of the sequence (
TYPE:
|
end_positions |
Labels for position (index) of the end of the labelled span for computing the token classification loss.
Positions are clamped to the length of the sequence (
TYPE:
|
Source code in mindnlp/transformers/models/xlm_roberta_xl/modeling_xlm_roberta_xl.py
1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 |
|
mindnlp.transformers.models.xlm_roberta_xl.modeling_xlm_roberta_xl.XLMRobertaXLForSequenceClassification
¶
Bases: XLMRobertaXLPreTrainedModel
Source code in mindnlp/transformers/models/xlm_roberta_xl/modeling_xlm_roberta_xl.py
1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 |
|
mindnlp.transformers.models.xlm_roberta_xl.modeling_xlm_roberta_xl.XLMRobertaXLForSequenceClassification.__init__(config)
¶
PARAMETER | DESCRIPTION |
---|---|
self |
The instance of the class.
TYPE:
|
config |
The configuration object containing the model hyperparameters and settings.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None. |
Source code in mindnlp/transformers/models/xlm_roberta_xl/modeling_xlm_roberta_xl.py
1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 |
|
mindnlp.transformers.models.xlm_roberta_xl.modeling_xlm_roberta_xl.XLMRobertaXLForSequenceClassification.forward(input_ids=None, attention_mask=None, token_type_ids=None, position_ids=None, head_mask=None, inputs_embeds=None, labels=None, output_attentions=None, output_hidden_states=None, return_dict=None)
¶
PARAMETER | DESCRIPTION |
---|---|
labels |
Labels for computing the sequence classification/regression loss. Indices should be in
TYPE:
|
Source code in mindnlp/transformers/models/xlm_roberta_xl/modeling_xlm_roberta_xl.py
1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 |
|
mindnlp.transformers.models.xlm_roberta_xl.modeling_xlm_roberta_xl.XLMRobertaXLForTokenClassification
¶
Bases: XLMRobertaXLPreTrainedModel
XLMRobertaForTokenClassification
Source code in mindnlp/transformers/models/xlm_roberta_xl/modeling_xlm_roberta_xl.py
1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 |
|
mindnlp.transformers.models.xlm_roberta_xl.modeling_xlm_roberta_xl.XLMRobertaXLForTokenClassification.__init__(config)
¶
Initializes the XLMRobertaForTokenClassification model.
PARAMETER | DESCRIPTION |
---|---|
self |
The instance of the XLMRobertaForTokenClassification class.
|
config |
An object containing configuration settings for the model. It must provide the following attributes:
|
RETURNS | DESCRIPTION |
---|---|
None. |
RAISES | DESCRIPTION |
---|---|
TypeError
|
If config is not provided or is not an instance of the expected configuration object. |
ValueError
|
If the required attributes (num_labels, hidden_dropout_prob, hidden_size) are missing from the config. |
Source code in mindnlp/transformers/models/xlm_roberta_xl/modeling_xlm_roberta_xl.py
1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 |
|
mindnlp.transformers.models.xlm_roberta_xl.modeling_xlm_roberta_xl.XLMRobertaXLForTokenClassification.forward(input_ids=None, attention_mask=None, token_type_ids=None, position_ids=None, head_mask=None, inputs_embeds=None, labels=None, output_attentions=None, output_hidden_states=None, return_dict=None)
¶
PARAMETER | DESCRIPTION |
---|---|
labels |
Labels for computing the token classification loss. Indices should be in
TYPE:
|
Source code in mindnlp/transformers/models/xlm_roberta_xl/modeling_xlm_roberta_xl.py
1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 |
|
mindnlp.transformers.models.xlm_roberta_xl.modeling_xlm_roberta_xl.XLMRobertaXLModel
¶
Bases: XLMRobertaXLPreTrainedModel
The model can behave as an encoder (with only self-attention) as well as a decoder, in which case a layer of
cross-attention is added between the self-attention layers, following the architecture described in Attention is
all you need*_ by Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Lukasz
Kaiser and Illia Polosukhin. To behave as an decoder the model needs to be initialized with the is_decoder
argument of the configuration set to True
. To be used in a Seq2Seq model, the model needs to initialized with
both is_decoder
argument and add_cross_attention
set to True
; an encoder_hidden_states
is then expected as
an input to the forward pass. .. _*Attention is all you need: https://arxiv.org/abs/1706.03762
Source code in mindnlp/transformers/models/xlm_roberta_xl/modeling_xlm_roberta_xl.py
639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 |
|
mindnlp.transformers.models.xlm_roberta_xl.modeling_xlm_roberta_xl.XLMRobertaXLModel.forward(input_ids=None, attention_mask=None, token_type_ids=None, position_ids=None, head_mask=None, inputs_embeds=None, encoder_hidden_states=None, encoder_attention_mask=None, past_key_values=None, use_cache=None, output_attentions=None, output_hidden_states=None, return_dict=None)
¶
PARAMETER | DESCRIPTION |
---|---|
encoder_hidden_states |
Sequence of hidden-states at the output of the last layer of the encoder. Used in the cross-attention if the model is configured as a decoder.
TYPE:
|
encoder_attention_mask |
Mask to avoid performing attention on the padding token indices of the encoder input. This mask is used in
the cross-attention if the model is configured as a decoder. Mask values selected in
TYPE:
|
use_cache |
If set to
TYPE:
|
Source code in mindnlp/transformers/models/xlm_roberta_xl/modeling_xlm_roberta_xl.py
677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 |
|
mindnlp.transformers.models.xlm_roberta_xl.modeling_xlm_roberta_xl.XLMRobertaXLPreTrainedModel
¶
Bases: PreTrainedModel
An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained models.
Source code in mindnlp/transformers/models/xlm_roberta_xl/modeling_xlm_roberta_xl.py
611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 |
|
mindnlp.transformers.models.xlm_roberta_xl.modeling_xlm_roberta_xl.XLMRobertaXLSelfAttention
¶
Bases: Module
Source code in mindnlp/transformers/models/xlm_roberta_xl/modeling_xlm_roberta_xl.py
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 |
|
mindnlp.transformers.models.xlm_roberta_xl.modeling_xlm_roberta_xl.XLMRobertaXLSelfAttention.forward(hidden_states, attention_mask=None, head_mask=None, encoder_hidden_states=None, encoder_attention_mask=None, past_key_value=None, output_attentions=False)
¶
Constructs the self-attention mechanism for the XLMRoberta model.
PARAMETER | DESCRIPTION |
---|---|
self |
An instance of the XLMRobertaSelfAttention class.
|
hidden_states |
The input hidden states. Shape (batch_size, seq_length, hidden_size).
TYPE:
|
attention_mask |
The attention mask tensor. Shape (batch_size, seq_length, seq_length). Defaults to None.
TYPE:
|
head_mask |
The head mask tensor. Shape (num_attention_heads, seq_length, seq_length). Defaults to None.
TYPE:
|
encoder_hidden_states |
The hidden states from the encoder. Shape (batch_size, seq_length, hidden_size). Defaults to None.
TYPE:
|
encoder_attention_mask |
The attention mask for the encoder hidden states. Shape (batch_size, seq_length, seq_length). Defaults to None.
TYPE:
|
past_key_value |
The past key-value pairs for each layer in the encoder. Defaults to None.
TYPE:
|
output_attentions |
Whether to output attention probabilities. Defaults to False.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Tuple[Tensor]
|
Tuple[mindspore.Tensor]: A tuple containing the context layer tensor. Shape (batch_size, seq_length, hidden_size).
|
Source code in mindnlp/transformers/models/xlm_roberta_xl/modeling_xlm_roberta_xl.py
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 |
|
mindnlp.transformers.models.xlm_roberta_xl.modeling_xlm_roberta_xl.XLMRobertaXLSelfAttention.transpose_for_scores(x)
¶
transpose_for_scores
Source code in mindnlp/transformers/models/xlm_roberta_xl/modeling_xlm_roberta_xl.py
207 208 209 210 211 |
|
mindnlp.transformers.models.xlm_roberta_xl.modeling_xlm_roberta_xl.create_position_ids_from_input_ids(input_ids, padding_idx, past_key_values_length=0)
¶
Replace non-padding symbols with their position numbers. Position numbers begin at padding_idx+1. Padding symbols
are ignored. This is modified from fairseq's utils.make_positions
.
PARAMETER | DESCRIPTION |
---|---|
x |
mindspore.Tensor x:
|
RETURNS | DESCRIPTION |
---|---|
mindspore.Tensor |
Source code in mindnlp/transformers/models/xlm_roberta_xl/modeling_xlm_roberta_xl.py
1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 |
|