luke
mindnlp.transformers.models.luke.luke
¶
MindNlp LUKE model
mindnlp.transformers.models.luke.luke.EntityPredictionHead
¶
Bases: Module
EntityPredictionHead
Source code in mindnlp/transformers/models/luke/luke.py
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 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 |
|
mindnlp.transformers.models.luke.luke.EntityPredictionHead.__init__(config)
¶
Initialize the EntityPredictionHead instance.
PARAMETER | DESCRIPTION |
---|---|
self |
The EntityPredictionHead instance.
TYPE:
|
config |
The configuration object containing parameters for entity prediction head. This object should have attributes required for initializing the EntityPredictionHead instance. It must be provided as an argument during initialization.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None. |
RAISES | DESCRIPTION |
---|---|
TypeError
|
If the config parameter is not provided or is of an incorrect type. |
ValueError
|
If the config object does not contain the required attributes for initialization. |
RuntimeError
|
If there is an issue with initializing any component within the EntityPredictionHead instance. |
Source code in mindnlp/transformers/models/luke/luke.py
1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 |
|
mindnlp.transformers.models.luke.luke.EntityPredictionHead.construct(hidden_states)
¶
Method to construct the entity prediction head using the given hidden states.
PARAMETER | DESCRIPTION |
---|---|
self |
An instance of the EntityPredictionHead class.
TYPE:
|
hidden_states |
The hidden states to be used for constructing the entity prediction head. Should be a tensor representing the hidden states of the input data.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None
|
This method does not return any value. The entity prediction head is constructed and updated within the class instance. |
RAISES | DESCRIPTION |
---|---|
TypeError
|
If the input hidden_states is not of type tensor. |
ValueError
|
If the hidden_states tensor is empty or has invalid dimensions. |
Source code in mindnlp/transformers/models/luke/luke.py
1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 |
|
mindnlp.transformers.models.luke.luke.EntityPredictionHeadTransform
¶
Bases: Module
EntityPredictionHeadTransform
Source code in mindnlp/transformers/models/luke/luke.py
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 |
|
mindnlp.transformers.models.luke.luke.EntityPredictionHeadTransform.__init__(config)
¶
Initializes the EntityPredictionHeadTransform class.
PARAMETER | DESCRIPTION |
---|---|
self |
The instance of the EntityPredictionHeadTransform class.
|
config |
An object containing configuration parameters for the EntityPredictionHeadTransform class.
|
RETURNS | DESCRIPTION |
---|---|
None. |
RAISES | DESCRIPTION |
---|---|
TypeError
|
If the config.hidden_act parameter is not a string or a valid activation function. |
ValueError
|
If the config.entity_emb_size is invalid or the config.layer_norm_eps is not within the valid range. |
Source code in mindnlp/transformers/models/luke/luke.py
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 |
|
mindnlp.transformers.models.luke.luke.EntityPredictionHeadTransform.construct(hidden_states)
¶
Method to construct the entity prediction head transformation.
PARAMETER | DESCRIPTION |
---|---|
self |
An instance of the EntityPredictionHeadTransform class. |
hidden_states |
The input hidden states to be transformed. It should be a tensor representing the hidden states of the model.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
tensor
|
The transformed hidden states after passing through the dense layer, activation function, and layer normalization. It retains the same shape and structure as the input hidden states. |
Source code in mindnlp/transformers/models/luke/luke.py
972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 |
|
mindnlp.transformers.models.luke.luke.LukeAttention
¶
Bases: Module
LukeAttention
Source code in mindnlp/transformers/models/luke/luke.py
453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 |
|
mindnlp.transformers.models.luke.luke.LukeAttention.__init__(config)
¶
Initializes a new instance of the LukeAttention class.
PARAMETER | DESCRIPTION |
---|---|
self |
The current instance of the LukeAttention class.
TYPE:
|
config |
The configuration object for the attention mechanism.
|
RETURNS | DESCRIPTION |
---|---|
None. |
Source code in mindnlp/transformers/models/luke/luke.py
457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 |
|
mindnlp.transformers.models.luke.luke.LukeAttention.construct(word_hidden_states, entity_hidden_states, attention_mask=None, head_mask=None, output_attentions=False)
¶
Constructs the attention mechanism in the LukeAttention class.
PARAMETER | DESCRIPTION |
---|---|
self |
The instance of the LukeAttention class.
TYPE:
|
word_hidden_states |
The hidden states of words. Shape: (batch_size, word_seq_len, hidden_size).
TYPE:
|
entity_hidden_states |
The hidden states of entities. Shape: (batch_size, entity_seq_len, hidden_size).
TYPE:
|
attention_mask |
Mask to avoid performing attention on padding tokens. Shape: (batch_size, 1, word_seq_len, entity_seq_len).
TYPE:
|
head_mask |
Mask to exclude certain attention heads. Shape: (num_attention_heads,).
TYPE:
|
output_attentions |
Whether to output attentions. Default is False.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
tuple
|
A tuple containing word_attention_output and entity_attention_output if entity_hidden_states is not None, else None.
|
RAISES | DESCRIPTION |
---|---|
ValueError
|
If the shapes of word_hidden_states and entity_hidden_states are incompatible. |
RuntimeError
|
If an error occurs during the attention computation. |
IndexError
|
If the attention indices are out of bounds. |
Source code in mindnlp/transformers/models/luke/luke.py
482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 |
|
mindnlp.transformers.models.luke.luke.LukeAttention.prune_heads(heads)
¶
NotImplementedError
Source code in mindnlp/transformers/models/luke/luke.py
476 477 478 479 480 |
|
mindnlp.transformers.models.luke.luke.LukeEmbeddings
¶
Bases: Module
LukeEmbeddings
Source code in mindnlp/transformers/models/luke/luke.py
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 131 132 133 134 135 |
|
mindnlp.transformers.models.luke.luke.LukeEmbeddings.__init__(config)
¶
Initializes an instance of the LukeEmbeddings class.
PARAMETER | DESCRIPTION |
---|---|
self |
The instance of the class itself.
|
config |
An object of the LukeConfig class containing configuration parameters.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None |
Source code in mindnlp/transformers/models/luke/luke.py
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 |
|
mindnlp.transformers.models.luke.luke.LukeEmbeddings.construct(input_ids=None, token_type_ids=None, position_ids=None, inputs_embeds=None)
¶
PARAMETER | DESCRIPTION |
---|---|
self |
The instance of the LukeEmbeddings class.
TYPE:
|
input_ids |
A 2-D tensor containing the input token IDs. Defaults to None.
TYPE:
|
token_type_ids |
A 2-D tensor containing the token type IDs. Defaults to None.
TYPE:
|
position_ids |
A 2-D tensor containing the position IDs. Defaults to None.
TYPE:
|
inputs_embeds |
A 3-D tensor containing the input embeddings. Defaults to None.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None. |
RAISES | DESCRIPTION |
---|---|
ValueError
|
If both input_ids and inputs_embeds are None. |
ValueError
|
If input_ids and inputs_embeds have mismatched shapes. |
TypeError
|
If the data type of token_type_ids is not int64. |
Source code in mindnlp/transformers/models/luke/luke.py
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 |
|
mindnlp.transformers.models.luke.luke.LukeEmbeddings.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.
Source code in mindnlp/transformers/models/luke/luke.py
125 126 127 128 129 130 131 132 133 134 135 |
|
mindnlp.transformers.models.luke.luke.LukeEncoder
¶
Bases: Module
LukeEncoder
Source code in mindnlp/transformers/models/luke/luke.py
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 805 806 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 |
|
mindnlp.transformers.models.luke.luke.LukeEncoder.__init__(config)
¶
Initialize a LukeEncoder object.
PARAMETER | DESCRIPTION |
---|---|
self |
The LukeEncoder instance.
TYPE:
|
config |
A dictionary containing configuration parameters for the encoder.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None. |
Source code in mindnlp/transformers/models/luke/luke.py
773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 |
|
mindnlp.transformers.models.luke.luke.LukeEncoder.construct(word_hidden_states, entity_hidden_states, attention_mask=None, head_mask=None, output_attentions=False, output_hidden_states=False, return_dict=True)
¶
This method constructs the hidden states and attentions for a LukeEncoder model.
PARAMETER | DESCRIPTION |
---|---|
self |
The instance of the LukeEncoder class.
|
word_hidden_states |
The hidden states of words, of shape (batch_size, sequence_length, hidden_size).
|
entity_hidden_states |
The hidden states of entities, of shape (batch_size, num_entities, hidden_size).
|
attention_mask |
An optional tensor of shape (batch_size, sequence_length) containing attention mask values.
DEFAULT:
|
head_mask |
An optional tensor of shape (num_layers, num_attention_heads) providing a mask for attention heads.
DEFAULT:
|
output_attentions |
A boolean flag indicating whether to output attention weights.
DEFAULT:
|
output_hidden_states |
A boolean flag indicating whether to output hidden states.
DEFAULT:
|
return_dict |
A boolean flag indicating whether to return the output as a dictionary.
DEFAULT:
|
RETURNS | DESCRIPTION |
---|---|
None |
RAISES | DESCRIPTION |
---|---|
ValueError
|
If the dimensions of input tensors are not valid. |
TypeError
|
If the input parameters are not of the expected types. |
IndexError
|
If the head mask dimensions do not match the expected shape. |
Source code in mindnlp/transformers/models/luke/luke.py
791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 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 |
|
mindnlp.transformers.models.luke.luke.LukeEntityEmbeddings
¶
Bases: Module
LukeEntityEmbeddings
Source code in mindnlp/transformers/models/luke/luke.py
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 178 179 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 |
|
mindnlp.transformers.models.luke.luke.LukeEntityEmbeddings.__init__(config)
¶
Initializes the LukeEntityEmbeddings class.
PARAMETER | DESCRIPTION |
---|---|
self |
The instance of the class.
|
config |
An instance of LukeConfig containing the configuration parameters for the entity embeddings. It specifies the entity vocabulary size, entity embedding size, hidden size, maximum position embeddings, type vocabulary size, and layer normalization epsilon. It is used to configure the entity embeddings, position embeddings, token type embeddings, layer normalization, and dropout.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None. |
Source code in mindnlp/transformers/models/luke/luke.py
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 |
|
mindnlp.transformers.models.luke.luke.LukeEntityEmbeddings.construct(entity_ids, position_ids, token_type_ids=None)
¶
This method constructs entity embeddings by combining entity, position, and token type embeddings.
PARAMETER | DESCRIPTION |
---|---|
self |
The instance of the LukeEntityEmbeddings class.
|
entity_ids |
A tensor containing the entity IDs for which embeddings need to be constructed.
TYPE:
|
position_ids |
A tensor containing the position IDs representing the position of each entity.
TYPE:
|
token_type_ids |
A tensor containing the token type IDs. Defaults to None. If not provided, it is initialized as zeros_like(entity_ids).
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
embeddings
|
The combined embeddings of entities, positions, and token types after normalization and dropout.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
ValueError
|
If the dimensions of entity_embeddings and hidden_size do not match. |
TypeError
|
If entity_ids, position_ids, or token_type_ids are not of type Tensor. |
ValueError
|
If the position_ids contain values less than -1. |
RuntimeError
|
If any runtime error occurs during the computation process. |
Source code in mindnlp/transformers/models/luke/luke.py
173 174 175 176 177 178 179 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 |
|
mindnlp.transformers.models.luke.luke.LukeForEntityClassification
¶
Bases: LukePreTrainedModel
LukeForEntityClassification
Source code in mindnlp/transformers/models/luke/luke.py
1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 |
|
mindnlp.transformers.models.luke.luke.LukeForEntityClassification.__init__(config)
¶
Initializes a new instance of the LukeForEntityClassification class.
PARAMETER | DESCRIPTION |
---|---|
self |
The instance of the class.
|
config |
A configuration object containing the settings for the LukeForEntityClassification model.
|
RETURNS | DESCRIPTION |
---|---|
None. |
RAISES | DESCRIPTION |
---|---|
TypeError
|
If the config parameter is not of the expected type. |
ValueError
|
If the config parameter does not contain the required settings. |
RuntimeError
|
If there is an issue with the initialization process. |
Source code in mindnlp/transformers/models/luke/luke.py
1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 |
|
mindnlp.transformers.models.luke.luke.LukeForEntityClassification.construct(input_ids=None, attention_mask=None, token_type_ids=None, position_ids=None, entity_ids=None, entity_attention_mask=None, entity_token_type_ids=None, entity_position_ids=None, head_mask=None, inputs_embeds=None, labels=None, output_attentions=None, output_hidden_states=None, return_dict=None)
¶
Constructs the LukeForEntityClassification model.
PARAMETER | DESCRIPTION |
---|---|
self |
The instance of the LukeForEntityClassification class. |
input_ids |
The input tensor containing the indices of input sequence tokens in the vocabulary.
TYPE:
|
attention_mask |
The optional mask tensor, usually used to ignore padding tokens.
TYPE:
|
token_type_ids |
The optional tensor containing the type ids of input sequence tokens.
TYPE:
|
position_ids |
The optional tensor containing the positions ids of input sequence tokens.
TYPE:
|
entity_ids |
The optional tensor containing the indices of entity tokens in the vocabulary.
TYPE:
|
entity_attention_mask |
The optional mask tensor for entity tokens.
TYPE:
|
entity_token_type_ids |
The optional tensor containing the type ids of entity sequence tokens.
TYPE:
|
entity_position_ids |
The optional tensor containing the positions ids of entity sequence tokens.
TYPE:
|
head_mask |
The optional mask tensor for attention heads.
TYPE:
|
inputs_embeds |
The optional tensor containing the embeddings of input sequence tokens.
TYPE:
|
labels |
The optional tensor containing the labels of the entity classification task.
TYPE:
|
output_attentions |
Whether to return the attentions weights of the model.
TYPE:
|
output_hidden_states |
Whether to return the hidden states of the model.
TYPE:
|
return_dict |
Whether to return a dictionary instead of a tuple.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Tuple[Optional[Tensor], Optional[Tensor], Optional[Tensor], Optional[Tensor], Optional[Tensor]]: A tuple containing the loss, logits, hidden states, entity hidden states, and attentions weights (if available) respectively. |
Source code in mindnlp/transformers/models/luke/luke.py
1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 |
|
mindnlp.transformers.models.luke.luke.LukeForEntityPairClassification
¶
Bases: LukePreTrainedModel
LukeForEntityPairClassification
Source code in mindnlp/transformers/models/luke/luke.py
1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 |
|
mindnlp.transformers.models.luke.luke.LukeForEntityPairClassification.__init__(config)
¶
Initializes a new instance of LukeForEntityPairClassification.
PARAMETER | DESCRIPTION |
---|---|
self |
The object instance itself.
|
config |
The configuration object containing various parameters.
|
RETURNS | DESCRIPTION |
---|---|
None. |
Source code in mindnlp/transformers/models/luke/luke.py
1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 |
|
mindnlp.transformers.models.luke.luke.LukeForEntityPairClassification.construct(input_ids=None, attention_mask=None, token_type_ids=None, position_ids=None, entity_ids=None, entity_attention_mask=None, entity_token_type_ids=None, entity_position_ids=None, head_mask=None, inputs_embeds=None, labels=None, output_attentions=None, output_hidden_states=None, return_dict=None)
¶
This method 'construct' in the class 'LukeForEntityPairClassification' is responsible for constructing the model and performing entity pair classification.
PARAMETER | DESCRIPTION |
---|---|
self |
The instance of the class.
|
input_ids |
Input tensor containing token indices. Default is None.
TYPE:
|
attention_mask |
Mask tensor for the input, indicating which tokens should be attended to. Default is None.
TYPE:
|
token_type_ids |
Tensor specifying the type of token (e.g., segment A or B). Default is None.
TYPE:
|
position_ids |
Tensor specifying the position of tokens. Default is None.
TYPE:
|
entity_ids |
Tensor containing entity indices.
TYPE:
|
entity_attention_mask |
Mask tensor for entity inputs. Default is None.
TYPE:
|
entity_token_type_ids |
Tensor specifying the type of entity token. Default is None.
TYPE:
|
entity_position_ids |
Tensor specifying the position of entity tokens. Default is None.
TYPE:
|
head_mask |
Mask tensor for attention heads. Default is None.
TYPE:
|
inputs_embeds |
Additional embeddings to be added to the model input embeddings. Default is None.
TYPE:
|
labels |
Tensor containing the classification labels. Default is None.
TYPE:
|
output_attentions |
Whether to output attentions. Default is None.
TYPE:
|
output_hidden_states |
Whether to output hidden states. Default is None.
TYPE:
|
return_dict |
Whether to return a dictionary as output. Default is None.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Tuple
|
A tuple containing elements that are not None among loss (if labels provided), logits, hidden states, entity hidden states, and attentions. Returns None if all elements are None. |
RAISES | DESCRIPTION |
---|---|
ValueError
|
If labels are provided but have an incorrect shape for cross-entropy computation. |
TypeError
|
If the input types are not as expected by the method. |
RuntimeError
|
If there are runtime issues during the execution of the method. |
Source code in mindnlp/transformers/models/luke/luke.py
1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 |
|
mindnlp.transformers.models.luke.luke.LukeForEntitySpanClassification
¶
Bases: LukePreTrainedModel
LukeForEntitySpanClassification
Source code in mindnlp/transformers/models/luke/luke.py
1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 |
|
mindnlp.transformers.models.luke.luke.LukeForEntitySpanClassification.__init__(config)
¶
Initializes an instance of the LukeForEntitySpanClassification class.
PARAMETER | DESCRIPTION |
---|---|
self |
The instance of the class.
|
config |
The configuration object containing various settings and parameters for the model. It should be an instance of the configuration class specific to LukeForEntitySpanClassification.
|
RETURNS | DESCRIPTION |
---|---|
None. |
RAISES | DESCRIPTION |
---|---|
TypeError
|
If the config parameter is not of the expected type. |
ValueError
|
If the configuration provided is invalid or missing required parameters. |
RuntimeError
|
If there is an issue with the initialization process. |
Source code in mindnlp/transformers/models/luke/luke.py
1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 |
|
mindnlp.transformers.models.luke.luke.LukeForEntitySpanClassification.construct(input_ids=None, attention_mask=None, token_type_ids=None, position_ids=None, entity_ids=None, entity_attention_mask=None, entity_token_type_ids=None, entity_position_ids=None, entity_start_positions=None, entity_end_positions=None, head_mask=None, inputs_embeds=None, labels=None, output_attentions=None, output_hidden_states=None, return_dict=None)
¶
Constructs the forward pass of LukeForEntitySpanClassification model.
PARAMETER | DESCRIPTION |
---|---|
self |
The instance of the LukeForEntitySpanClassification class. |
input_ids |
The input tensor of shape (batch_size, sequence_length) containing the input tokens indices.
TYPE:
|
attention_mask |
The attention mask tensor of shape (batch_size, sequence_length) containing the attention mask values.
TYPE:
|
token_type_ids |
The tensor of shape (batch_size, sequence_length) containing the token type ids.
TYPE:
|
position_ids |
The tensor of shape (batch_size, sequence_length) containing the position ids.
TYPE:
|
entity_ids |
The tensor of shape (batch_size, sequence_length) containing the entity ids.
TYPE:
|
entity_attention_mask |
The tensor of shape (batch_size, sequence_length) containing the entity attention mask values.
TYPE:
|
entity_token_type_ids |
The tensor of shape (batch_size, sequence_length) containing the entity token type ids.
TYPE:
|
entity_position_ids |
The tensor of shape (batch_size, sequence_length) containing the entity position ids.
TYPE:
|
entity_start_positions |
The tensor of shape (batch_size, sequence_length) containing the start positions of the entities.
TYPE:
|
entity_end_positions |
The tensor of shape (batch_size, sequence_length) containing the end positions of the entities.
TYPE:
|
head_mask |
The tensor of shape (batch_size, num_heads) containing the head mask values.
TYPE:
|
inputs_embeds |
The tensor of shape (batch_size, sequence_length, hidden_size) containing the input embeddings.
TYPE:
|
labels |
The tensor of shape (batch_size, sequence_length) containing the labels.
TYPE:
|
output_attentions |
Whether to output the attentions.
TYPE:
|
output_hidden_states |
Whether to output the hidden states.
TYPE:
|
return_dict |
Whether to return a dictionary instead of a tuple.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
tuple
|
Tuple of values containing the loss (Tensor), logits (Tensor), hidden states (Tensor), entity hidden states (Tensor), and attentions (Tensor) if not None. |
Source code in mindnlp/transformers/models/luke/luke.py
1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 |
|
mindnlp.transformers.models.luke.luke.LukeForMaskedLM
¶
Bases: LukePreTrainedModel
LukeForMaskedLM
Source code in mindnlp/transformers/models/luke/luke.py
1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 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 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 |
|
mindnlp.transformers.models.luke.luke.LukeForMaskedLM.__init__(config)
¶
Initializes an instance of the 'LukeForMaskedLM' class.
PARAMETER | DESCRIPTION |
---|---|
self |
The current instance of the 'LukeForMaskedLM' class.
|
config |
An object of type 'ConfigBase' containing the configuration parameters for the model.
|
RETURNS | DESCRIPTION |
---|---|
None. |
Source code in mindnlp/transformers/models/luke/luke.py
1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 |
|
mindnlp.transformers.models.luke.luke.LukeForMaskedLM.construct(input_ids=None, attention_mask=None, token_type_ids=None, position_ids=None, entity_ids=None, entity_attention_mask=None, entity_token_type_ids=None, entity_position_ids=None, labels=None, entity_labels=None, head_mask=None, inputs_embeds=None, output_attentions=None, output_hidden_states=None, return_dict=None)
¶
Constructs the outputs for the LukeForMaskedLM model.
PARAMETER | DESCRIPTION |
---|---|
self |
The instance of the LukeForMaskedLM class.
TYPE:
|
input_ids |
The input token IDs. Default: None.
TYPE:
|
attention_mask |
The attention mask. Default: None.
TYPE:
|
token_type_ids |
The token type IDs. Default: None.
TYPE:
|
position_ids |
The position IDs. Default: None.
TYPE:
|
entity_ids |
The entity IDs. Default: None.
TYPE:
|
entity_attention_mask |
The entity attention mask. Default: None.
TYPE:
|
entity_token_type_ids |
The entity token type IDs. Default: None.
TYPE:
|
entity_position_ids |
The entity position IDs. Default: None.
TYPE:
|
labels |
The labels for masked language modeling. Default: None.
TYPE:
|
entity_labels |
The labels for entity prediction. Default: None.
TYPE:
|
head_mask |
The head mask. Default: None.
TYPE:
|
inputs_embeds |
The input embeddings. Default: None.
TYPE:
|
output_attentions |
Whether to output attentions. Default: None.
TYPE:
|
output_hidden_states |
Whether to output hidden states. Default: None.
TYPE:
|
return_dict |
Whether to return a dictionary output. Default: None.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Tuple of (loss, mlm_loss, mep_loss, logits, entity_logits, hidden_states, entity_hidden_states, attentions):
|
Source code in mindnlp/transformers/models/luke/luke.py
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 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 |
|
mindnlp.transformers.models.luke.luke.LukeForMaskedLM.get_output_embeddings()
¶
get_output_embeddings
Source code in mindnlp/transformers/models/luke/luke.py
1518 1519 1520 |
|
mindnlp.transformers.models.luke.luke.LukeForMaskedLM.set_output_embeddings(new_embeddings)
¶
set_output_embeddings
Source code in mindnlp/transformers/models/luke/luke.py
1522 1523 1524 |
|
mindnlp.transformers.models.luke.luke.LukeForMaskedLM.tie_weights()
¶
tie_weight
Source code in mindnlp/transformers/models/luke/luke.py
1513 1514 1515 1516 |
|
mindnlp.transformers.models.luke.luke.LukeForMultipleChoice
¶
Bases: LukePreTrainedModel
LukeForMultipleChoice
Source code in mindnlp/transformers/models/luke/luke.py
2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 |
|
mindnlp.transformers.models.luke.luke.LukeForMultipleChoice.__init__(config)
¶
Initializes an instance of the LukeForMultipleChoice class.
PARAMETER | DESCRIPTION |
---|---|
self |
The instance of the class.
|
config |
An object containing the configuration settings for the model (type:
|
RETURNS | DESCRIPTION |
---|---|
None. |
Source code in mindnlp/transformers/models/luke/luke.py
2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 |
|
mindnlp.transformers.models.luke.luke.LukeForMultipleChoice.construct(input_ids=None, attention_mask=None, token_type_ids=None, position_ids=None, entity_ids=None, entity_attention_mask=None, entity_token_type_ids=None, entity_position_ids=None, head_mask=None, inputs_embeds=None, labels=None, output_attentions=None, output_hidden_states=None, return_dict=None)
¶
Constructs the LukeForMultipleChoice model.
PARAMETER | DESCRIPTION |
---|---|
self |
The instance of the LukeForMultipleChoice class.
TYPE:
|
input_ids |
The input sequence token IDs of shape [batch_size, num_choices, sequence_length]. (default: None)
TYPE:
|
attention_mask |
The attention mask tensor of shape [batch_size, num_choices, sequence_length]. (default: None)
TYPE:
|
token_type_ids |
The token type IDs tensor of shape [batch_size, num_choices, sequence_length]. (default: None)
TYPE:
|
position_ids |
The position IDs tensor of shape [batch_size, num_choices, sequence_length]. (default: None)
TYPE:
|
entity_ids |
The entity token IDs tensor of shape [batch_size, num_choices, entity_length]. (default: None)
TYPE:
|
entity_attention_mask |
The entity attention mask tensor of shape [batch_size, num_choices, entity_length]. (default: None)
TYPE:
|
entity_token_type_ids |
The entity token type IDs tensor of shape [batch_size, num_choices, entity_length]. (default: None)
TYPE:
|
entity_position_ids |
The entity position IDs tensor of shape [batch_size, num_choices, entity_length]. (default: None)
TYPE:
|
head_mask |
The head mask tensor of shape [num_hidden_layers, num_attention_heads]. (default: None)
TYPE:
|
inputs_embeds |
The input embeddings tensor of shape [batch_size, num_choices, sequence_length, hidden_size]. (default: None)
TYPE:
|
labels |
The labels tensor of shape [batch_size]. (default: None)
TYPE:
|
output_attentions |
Whether to output attentions. (default: None)
TYPE:
|
output_hidden_states |
Whether to output hidden states. (default: None)
TYPE:
|
return_dict |
Whether to return a dictionary instead of a tuple of outputs. (default: None)
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
tuple
|
Tuple of (loss, reshaped_logits, hidden_states, entity_hidden_states, attentions):
|
Source code in mindnlp/transformers/models/luke/luke.py
2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 |
|
mindnlp.transformers.models.luke.luke.LukeForQuestionAnswering
¶
Bases: LukePreTrainedModel
LukeForQuestionAnswering
Source code in mindnlp/transformers/models/luke/luke.py
2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 |
|
mindnlp.transformers.models.luke.luke.LukeForQuestionAnswering.__init__(config)
¶
Initializes the LukeForQuestionAnswering class.
PARAMETER | DESCRIPTION |
---|---|
self |
The instance of the LukeForQuestionAnswering class.
TYPE:
|
config |
The configuration object containing the settings for the Luke model. This parameter is required and should be an instance of the configuration class for Luke models. It must include the following attributes:
|
RETURNS | DESCRIPTION |
---|---|
None. |
RAISES | DESCRIPTION |
---|---|
TypeError
|
If the config parameter is not provided or is of an incorrect type. |
ValueError
|
If the num_labels attribute is not specified in the config object. |
Source code in mindnlp/transformers/models/luke/luke.py
2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 |
|
mindnlp.transformers.models.luke.luke.LukeForQuestionAnswering.construct(input_ids=None, attention_mask=None, token_type_ids=None, position_ids=None, entity_ids=None, entity_attention_mask=None, entity_token_type_ids=None, entity_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)
¶
Constructs the forward pass of the LukeForQuestionAnswering model.
PARAMETER | DESCRIPTION |
---|---|
self |
An instance of the LukeForQuestionAnswering class.
TYPE:
|
input_ids |
Input tensor of shape (batch_size, sequence_length) containing the input token IDs.
TYPE:
|
attention_mask |
Input tensor of shape (batch_size, sequence_length) containing the attention mask.
TYPE:
|
token_type_ids |
Input tensor of shape (batch_size, sequence_length) containing the token type IDs.
TYPE:
|
position_ids |
Input tensor of shape (batch_size, sequence_length) containing the position IDs.
TYPE:
|
entity_ids |
Input tensor of shape (batch_size, sequence_length) containing the entity IDs.
TYPE:
|
entity_attention_mask |
Input tensor of shape (batch_size, sequence_length) containing the entity attention mask.
TYPE:
|
entity_token_type_ids |
Input tensor of shape (batch_size, sequence_length) containing the entity token type IDs.
TYPE:
|
entity_position_ids |
Input tensor of shape (batch_size, sequence_length) containing the entity position IDs.
TYPE:
|
head_mask |
Input tensor of shape (batch_size, num_heads) containing the head mask.
TYPE:
|
inputs_embeds |
Input tensor of shape (batch_size, sequence_length, hidden_size) containing the embedded inputs.
TYPE:
|
start_positions |
Input tensor of shape (batch_size, sequence_length) containing the start positions for answer span prediction.
TYPE:
|
end_positions |
Input tensor of shape (batch_size, sequence_length) containing the end positions for answer span prediction.
TYPE:
|
output_attentions |
Whether to output attentions weights. Default: None.
TYPE:
|
output_hidden_states |
Whether to output hidden states. Default: None.
TYPE:
|
return_dict |
Whether to return a dictionary as output. Default: None.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
tuple
|
A tuple containing the following elements:
|
Source code in mindnlp/transformers/models/luke/luke.py
2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 |
|
mindnlp.transformers.models.luke.luke.LukeForSequenceClassification
¶
Bases: LukePreTrainedModel
LukeForSequenceClassification
Source code in mindnlp/transformers/models/luke/luke.py
1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 |
|
mindnlp.transformers.models.luke.luke.LukeForSequenceClassification.__init__(config)
¶
Initializes a LukeForSequenceClassification instance.
PARAMETER | DESCRIPTION |
---|---|
self |
The current instance of the LukeForSequenceClassification class. |
config |
The configuration object containing various settings for the Luke model. It must include the number of labels (num_labels) for classification tasks.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None. |
RAISES | DESCRIPTION |
---|---|
TypeError
|
If the config parameter is not of type LukeConfig. |
ValueError
|
If the num_labels attribute is missing in the config object. |
Source code in mindnlp/transformers/models/luke/luke.py
1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 |
|
mindnlp.transformers.models.luke.luke.LukeForSequenceClassification.construct(input_ids=None, attention_mask=None, token_type_ids=None, position_ids=None, entity_ids=None, entity_attention_mask=None, entity_token_type_ids=None, entity_position_ids=None, head_mask=None, inputs_embeds=None, labels=None, output_attentions=None, output_hidden_states=None, return_dict=None)
¶
Method 'construct' in the class 'LukeForSequenceClassification'.
PARAMETER | DESCRIPTION |
---|---|
self |
The object instance.
|
input_ids |
Input IDs for the model. Default is None.
TYPE:
|
attention_mask |
Mask to avoid performing attention on padding tokens. Default is None.
TYPE:
|
token_type_ids |
Segment token indices to differentiate between two sequences. Default is None.
TYPE:
|
position_ids |
Position indices for the input tokens. Default is None.
TYPE:
|
entity_ids |
Entity IDs for the input. Default is None.
TYPE:
|
entity_attention_mask |
Mask for entity attention. Default is None.
TYPE:
|
entity_token_type_ids |
Segment token indices for entities. Default is None.
TYPE:
|
entity_position_ids |
Position indices for entity tokens. Default is None.
TYPE:
|
head_mask |
Mask to nullify specific heads of the model. Default is None.
TYPE:
|
inputs_embeds |
Optional input embeddings. Default is None.
TYPE:
|
labels |
Labels for the input. Default is None.
TYPE:
|
output_attentions |
Whether to output attentions. Default is None.
TYPE:
|
output_hidden_states |
Whether to output hidden states. Default is None.
TYPE:
|
return_dict |
Whether to return as a dictionary. Default is None.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
tuple
|
A tuple containing loss, logits, hidden states, entity hidden states, and attentions if they are not None. Otherwise, returns None. |
RAISES | DESCRIPTION |
---|---|
ValueError
|
If the configuration problem type is not recognized. |
RuntimeError
|
If an unexpected error occurs during the computation. |
TypeError
|
If the input types are incorrect. |
Source code in mindnlp/transformers/models/luke/luke.py
2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 |
|
mindnlp.transformers.models.luke.luke.LukeForTokenClassification
¶
Bases: LukePreTrainedModel
LukeForTokenClassification
Source code in mindnlp/transformers/models/luke/luke.py
2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 |
|
mindnlp.transformers.models.luke.luke.LukeForTokenClassification.__init__(config)
¶
Initializes a new instance of the LukeForTokenClassification class.
PARAMETER | DESCRIPTION |
---|---|
self |
The object itself.
|
config |
An instance of class 'LukeConfig' containing the configuration parameters for the LukeForTokenClassification model.
|
RETURNS | DESCRIPTION |
---|---|
None |
Source code in mindnlp/transformers/models/luke/luke.py
2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 |
|
mindnlp.transformers.models.luke.luke.LukeForTokenClassification.construct(input_ids=None, attention_mask=None, token_type_ids=None, position_ids=None, entity_ids=None, entity_attention_mask=None, entity_token_type_ids=None, entity_position_ids=None, head_mask=None, inputs_embeds=None, labels=None, output_attentions=None, output_hidden_states=None, return_dict=None)
¶
Constructs the model for token classification using the Luke architecture.
PARAMETER | DESCRIPTION |
---|---|
self |
The object instance.
|
input_ids |
The input tensor of token indices. Default is None.
TYPE:
|
attention_mask |
The attention mask tensor. Default is None.
TYPE:
|
token_type_ids |
The tensor indicating token types. Default is None.
TYPE:
|
position_ids |
The tensor indicating token positions. Default is None.
TYPE:
|
entity_ids |
The tensor representing entity indices. Default is None.
TYPE:
|
entity_attention_mask |
The attention mask for entity tokens. Default is None.
TYPE:
|
entity_token_type_ids |
The tensor indicating entity token types. Default is None.
TYPE:
|
entity_position_ids |
The tensor indicating entity token positions. Default is None.
TYPE:
|
head_mask |
The tensor for masking heads. Default is None.
TYPE:
|
inputs_embeds |
The embedded input tensor. Default is None.
TYPE:
|
labels |
The tensor of labels for token classification. Default is None.
TYPE:
|
output_attentions |
Whether to output attentions. Default is None.
TYPE:
|
output_hidden_states |
Whether to output hidden states. Default is None.
TYPE:
|
return_dict |
Whether to return a dictionary. Default is None.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Tuple[Optional[Tensor], Tensor, Optional[Tensor], Optional[Tensor], Optional[Tensor]]: A tuple containing the loss, logits, hidden states, entity hidden states, and attentions. Any element that is not None is included in the tuple. |
Source code in mindnlp/transformers/models/luke/luke.py
2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 |
|
mindnlp.transformers.models.luke.luke.LukeIntermediate
¶
Bases: Module
LukeIntermediate
Source code in mindnlp/transformers/models/luke/luke.py
546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 |
|
mindnlp.transformers.models.luke.luke.LukeIntermediate.__init__(config)
¶
Initializes an instance of the LukeIntermediate class.
PARAMETER | DESCRIPTION |
---|---|
self |
The instance of the LukeIntermediate class.
|
config |
A configuration object that contains parameters for initializing the instance.
|
RETURNS | DESCRIPTION |
---|---|
None. |
RAISES | DESCRIPTION |
---|---|
TypeError
|
If the config parameter is not provided. |
ValueError
|
If the config parameter is provided but is not in the correct format. |
Source code in mindnlp/transformers/models/luke/luke.py
550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 |
|
mindnlp.transformers.models.luke.luke.LukeIntermediate.construct(hidden_states)
¶
Constructs the intermediate hidden states in the LukeIntermediate class.
PARAMETER | DESCRIPTION |
---|---|
self |
The instance of the LukeIntermediate class.
|
hidden_states |
The input hidden states.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Tensor
|
The intermediate hidden states after applying the dense layer and intermediate activation function.
TYPE:
|
This method takes in the instance of the LukeIntermediate class and the input hidden states. It applies a dense layer to the hidden states and then applies the intermediate activation function. The resulting intermediate hidden states are returned as a Tensor.
No exceptions are raised by this method.
Source code in mindnlp/transformers/models/luke/luke.py
577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 |
|
mindnlp.transformers.models.luke.luke.LukeLMHead
¶
Bases: Module
LukeLMead
Source code in mindnlp/transformers/models/luke/luke.py
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 1471 |
|
mindnlp.transformers.models.luke.luke.LukeLMHead.__init__(config)
¶
Initializes the LukeLMHead class.
PARAMETER | DESCRIPTION |
---|---|
self |
The instance of the LukeLMHead class.
TYPE:
|
config |
An instance of the configuration class containing the following attributes:
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None. |
RAISES | DESCRIPTION |
---|---|
TypeError
|
If the provided config parameter is not of the correct type. |
ValueError
|
If the hidden_size or vocab_size attributes in the config are not positive integers. |
Source code in mindnlp/transformers/models/luke/luke.py
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 |
|
mindnlp.transformers.models.luke.luke.LukeLMHead.construct(features, **kwargs)
¶
Constructs the output of the LukeLMHead model by performing a series of operations on the input features.
PARAMETER | DESCRIPTION |
---|---|
self |
The instance of the LukeLMHead class.
TYPE:
|
features |
The input features to be processed by the model.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
tensor
|
The output tensor after processing the input features through the model. |
Source code in mindnlp/transformers/models/luke/luke.py
1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 |
|
mindnlp.transformers.models.luke.luke.LukeLayer
¶
Bases: Module
LukeOutput
Source code in mindnlp/transformers/models/luke/luke.py
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 |
|
mindnlp.transformers.models.luke.luke.LukeLayer.__init__(config)
¶
Initializes a new instance of the LukeLayer class.
PARAMETER | DESCRIPTION |
---|---|
self |
The object itself.
|
config |
An instance of the configuration class containing the following attributes:
|
RETURNS | DESCRIPTION |
---|---|
None |
Source code in mindnlp/transformers/models/luke/luke.py
669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 |
|
mindnlp.transformers.models.luke.luke.LukeLayer.construct(word_hidden_states, entity_hidden_states, attention_mask=None, head_mask=None, output_attentions=False)
¶
Constructs the LukeLayer.
PARAMETER | DESCRIPTION |
---|---|
self |
The instance of the LukeLayer class.
TYPE:
|
word_hidden_states |
The hidden states of the word inputs. It has shape [batch_size, seq_length, hidden_size].
TYPE:
|
entity_hidden_states |
The hidden states of the entity inputs. It has shape [batch_size, seq_length, hidden_size].
TYPE:
|
attention_mask |
The attention mask to avoid performing attention on padding tokens. It has shape [batch_size, seq_length]. Defaults to None.
TYPE:
|
head_mask |
The mask to nullify selected heads of the self-attention modules. It has shape [num_heads, seq_length, seq_length]. Defaults to None.
TYPE:
|
output_attentions |
Whether to output attention weights. Defaults to False.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Tuple[Tensor, Tensor, Tuple]: A tuple containing:
|
Source code in mindnlp/transformers/models/luke/luke.py
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 |
|
mindnlp.transformers.models.luke.luke.LukeLayer.feed_forward_chunk(attention_output)
¶
This function applies transformations to an input tensor using two other layers to produce an output tensor.
Source code in mindnlp/transformers/models/luke/luke.py
759 760 761 762 763 764 765 766 |
|
mindnlp.transformers.models.luke.luke.LukeModel
¶
Bases: LukePreTrainedModel
LukeModel
Source code in mindnlp/transformers/models/luke/luke.py
1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 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 1276 1277 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 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 |
|
mindnlp.transformers.models.luke.luke.LukeModel.__init__(config, add_pooling_layer=True)
¶
Initializes a new LukeModel instance.
PARAMETER | DESCRIPTION |
---|---|
self |
The instance of the LukeModel class.
|
config |
An instance of LukeConfig containing the configuration for the model.
TYPE:
|
add_pooling_layer |
A boolean indicating whether to add a pooling layer. Defaults to True.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None. |
RAISES | DESCRIPTION |
---|---|
TypeError
|
If the config parameter is not an instance of LukeConfig. |
ValueError
|
If the add_pooling_layer parameter is not a boolean. |
Source code in mindnlp/transformers/models/luke/luke.py
1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 |
|
mindnlp.transformers.models.luke.luke.LukeModel.construct(input_ids=None, attention_mask=None, token_type_ids=None, position_ids=None, entity_ids=None, entity_attention_mask=None, entity_token_type_ids=None, entity_position_ids=None, head_mask=None, inputs_embeds=None, output_attentions=None, output_hidden_states=None, return_dict=None)
¶
The 'construct' method in the 'LukeModel' class is responsible for constructing the model based on the provided inputs and configuration.
PARAMETER | DESCRIPTION |
---|---|
self |
The instance of the class.
|
input_ids |
The input tensor representing the token ids. Default is None.
TYPE:
|
attention_mask |
The attention mask tensor indicating the positions of the padded tokens. Default is None.
TYPE:
|
token_type_ids |
The tensor representing the token type ids. Default is None.
TYPE:
|
position_ids |
The tensor representing the position ids. Default is None.
TYPE:
|
entity_ids |
The tensor representing the entity ids. Default is None.
TYPE:
|
entity_attention_mask |
The attention mask tensor for entity tokens. Default is None.
TYPE:
|
entity_token_type_ids |
The tensor representing the token type ids for entities. Default is None.
TYPE:
|
entity_position_ids |
The tensor representing the position ids for entities. Default is None.
TYPE:
|
head_mask |
The tensor representing the head mask. Default is None.
TYPE:
|
inputs_embeds |
The embedded inputs tensor. Default is None.
TYPE:
|
output_attentions |
Whether to return attentions. Default is None.
TYPE:
|
output_hidden_states |
Whether to return hidden states. Default is None.
TYPE:
|
return_dict |
Whether to return a dictionary. Default is None.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None. |
RAISES | DESCRIPTION |
---|---|
ValueError
|
|
Source code in mindnlp/transformers/models/luke/luke.py
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 1276 1277 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 |
|