jamba
mindnlp.transformers.models.jamba.configuration_jamba
¶
Jamba model configuration
mindnlp.transformers.models.jamba.configuration_jamba.JambaConfig
¶
Bases: PretrainedConfig
This is the configuration class to store the configuration of a [JambaModel
]. It is used to instantiate a
Jamba 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 jamba-small architecture.
ai21labs/jamba-small
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 Jamba model. Defines the number of different tokens that can be represented by the
TYPE:
|
tie_word_embeddings |
Whether the model's input and output word embeddings should be tied. Note that this is only relevant if the model has a output word embedding layer.
TYPE:
|
hidden_size |
Dimension of the hidden representations.
TYPE:
|
intermediate_size |
Dimension of the MLP representations.
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:
|
num_key_value_heads |
This is the number of key_value heads that should be used to implement Grouped Query Attention. If
TYPE:
|
hidden_act |
The non-linear activation function (function or string) in the decoder.
TYPE:
|
initializer_range |
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
TYPE:
|
rms_norm_eps |
The epsilon used by the rms normalization layers.
TYPE:
|
use_cache |
Whether or not the model should return the last key/values attentions (not used by all models). Only
relevant if
TYPE:
|
calc_logits_for_entire_prompt |
Whether or not to calculate logits for entire prompt during generation. If
TYPE:
|
output_router_logits |
Whether or not the router logits should be returned by the model. Enabling this will also allow the model to output the auxiliary loss. See here for more details
TYPE:
|
router_aux_loss_coef |
The aux loss factor for the total loss.
TYPE:
|
pad_token_id |
The id of the padding token.
TYPE:
|
bos_token_id |
The id of the "beginning-of-sequence" token.
TYPE:
|
eos_token_id |
The id of the "end-of-sequence" token.
TYPE:
|
sliding_window |
Sliding window attention window size. If not specified, will default to
TYPE:
|
n_ctx |
This value doesn't have any real effect. The maximum sequence length that this model is intended to be used with. It can be used with longer sequences, but performance may degrade.
TYPE:
|
attention_dropout |
The dropout ratio for the attention probabilities.
TYPE:
|
num_experts_per_tok |
The number of experts to root per-token, can be also interpreted as the
TYPE:
|
num_experts |
Number of experts per Sparse MLP layer.
TYPE:
|
expert_layer_period |
Once in this many layers, we will have an expert layer
TYPE:
|
expert_layer_offset |
The first layer index that contains an expert mlp layer
TYPE:
|
attn_layer_period |
Once in this many layers, we will have a vanilla attention layer
TYPE:
|
attn_layer_offset |
The first layer index that contains a vanilla attention mlp layer
TYPE:
|
use_mamba_kernels |
Flag indicating whether or not to use the fast mamba kernels. These are available only if
TYPE:
|
mamba_d_state |
The dimension the mamba state space latents
TYPE:
|
mamba_d_conv |
The size of the mamba convolution kernel
TYPE:
|
mamba_expand |
Expanding factor (relative to hidden_size) used to determine the mamba intermediate size
TYPE:
|
mamba_dt_rank |
Rank of the the mamba discretization projection matrix.
TYPE:
|
mamba_conv_bias |
Flag indicating whether or not to use bias in the convolution layer of the mamba mixer block.
TYPE:
|
mamba_proj_bias |
Flag indicating whether or not to use bias in the input and output projections (["in_proj", "out_proj"]) of the mamba mixer block
TYPE:
|
mamba_inner_layernorms |
Flag indicating whether or not to apply layernorms to internal mamba activations
TYPE:
|
Source code in mindnlp/transformers/models/jamba/configuration_jamba.py
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 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 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 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 |
|
mindnlp.transformers.models.jamba.configuration_jamba.JambaConfig.__init__(vocab_size=65536, tie_word_embeddings=False, hidden_size=4096, intermediate_size=14336, num_hidden_layers=32, num_attention_heads=32, num_key_value_heads=8, hidden_act='silu', initializer_range=0.02, rms_norm_eps=1e-06, use_cache=True, calc_logits_for_entire_prompt=False, output_router_logits=False, router_aux_loss_coef=0.001, pad_token_id=0, bos_token_id=1, eos_token_id=2, sliding_window=None, n_ctx=262144, attention_dropout=0.0, num_experts_per_tok=2, num_experts=16, expert_layer_period=2, expert_layer_offset=1, attn_layer_period=8, attn_layer_offset=4, use_mamba_kernels=True, mamba_d_state=16, mamba_d_conv=4, mamba_expand=2, mamba_dt_rank='auto', mamba_conv_bias=True, mamba_proj_bias=False, mamba_inner_layernorms=True, **kwargs)
¶
Initializes a new instance of the JambaConfig class.
PARAMETER | DESCRIPTION |
---|---|
self |
The object instance.
|
vocab_size |
The size of the vocabulary. Default is 65536.
TYPE:
|
tie_word_embeddings |
Whether to tie the word embeddings. Default is False.
TYPE:
|
hidden_size |
The size of the hidden layers. Default is 4096.
TYPE:
|
intermediate_size |
The size of the intermediate layers. Default is 14336.
TYPE:
|
num_hidden_layers |
The number of hidden layers. Default is 32.
TYPE:
|
num_attention_heads |
The number of attention heads. Default is 32.
TYPE:
|
num_key_value_heads |
The number of key-value heads. Default is 8.
TYPE:
|
hidden_act |
The activation function for the hidden layers. Default is 'silu'.
TYPE:
|
initializer_range |
The range for weight initialization. Default is 0.02.
TYPE:
|
rms_norm_eps |
The epsilon value for RMS normalization. Default is 1e-06.
TYPE:
|
use_cache |
Whether to use cache for attention layers. Default is True.
TYPE:
|
calc_logits_for_entire_prompt |
Whether to calculate logits for the entire prompt. Default is False.
TYPE:
|
output_router_logits |
Whether to output router logits. Default is False.
TYPE:
|
router_aux_loss_coef |
The coefficient for the router auxiliary loss. Default is 0.001.
TYPE:
|
pad_token_id |
The token ID for padding. Default is 0.
TYPE:
|
bos_token_id |
The token ID for the beginning of sentence. Default is 1.
TYPE:
|
eos_token_id |
The token ID for the end of sentence. Default is 2.
TYPE:
|
sliding_window |
The size of the sliding window. Default is None.
TYPE:
|
n_ctx |
The size of the context window. Default is 262144.
TYPE:
|
attention_dropout |
The dropout rate for attention layers. Default is 0.0.
TYPE:
|
num_experts_per_tok |
The number of experts per token. Default is 2.
TYPE:
|
num_experts |
The total number of experts. Default is 16.
TYPE:
|
expert_layer_period |
The period for expert layers. Default is 2.
TYPE:
|
expert_layer_offset |
The offset for expert layers. Default is 1.
TYPE:
|
attn_layer_period |
The period for attention layers. Default is 8.
TYPE:
|
attn_layer_offset |
The offset for attention layers. Default is 4.
TYPE:
|
use_mamba_kernels |
Whether to use Mamba kernels. Default is True.
TYPE:
|
mamba_d_state |
The state dimension for Mamba. Default is 16.
TYPE:
|
mamba_d_conv |
The convolutional dimension for Mamba. Default is 4.
TYPE:
|
mamba_expand |
The expansion factor for Mamba. Default is 2.
TYPE:
|
mamba_dt_rank |
The rank for Mamba's data tensors. Default is 'auto'.
TYPE:
|
mamba_conv_bias |
Whether to include biases in Mamba's convolution layers. Default is True.
TYPE:
|
mamba_proj_bias |
Whether to include biases in Mamba's projection layers. Default is False.
TYPE:
|
mamba_inner_layernorms |
Whether to use inner layer normalization in Mamba. Default is True.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None |
Source code in mindnlp/transformers/models/jamba/configuration_jamba.py
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 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 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 |
|
mindnlp.transformers.models.jamba.modeling_jamba.JambaModel
¶
Bases: JambaPreTrainedModel
Transformer decoder consisting of config.num_hidden_layers layers. Each layer is a [JambaDecoderLayer
]
PARAMETER | DESCRIPTION |
---|---|
config |
JambaConfig
TYPE:
|
Source code in mindnlp/transformers/models/jamba/modeling_jamba.py
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 1472 1473 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 1630 1631 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 |
|
mindnlp.transformers.models.jamba.modeling_jamba.JambaModel.__init__(config)
¶
Initializes a JambaModel instance with the provided configuration.
PARAMETER | DESCRIPTION |
---|---|
self |
The instance of the JambaModel class.
TYPE:
|
config |
An instance of JambaConfig containing configuration parameters for the model. The configuration should include:
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None. |
RAISES | DESCRIPTION |
---|---|
ValueError
|
|
Source code in mindnlp/transformers/models/jamba/modeling_jamba.py
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 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 |
|
mindnlp.transformers.models.jamba.modeling_jamba.JambaModel.forward(input_ids=None, attention_mask=None, position_ids=None, past_key_values=None, inputs_embeds=None, use_cache=None, output_attentions=None, output_hidden_states=None, output_router_logits=None, return_dict=None)
¶
This method 'forward' in the class 'JambaModel' forwards the model by processing input data through the layers of the model.
PARAMETER | DESCRIPTION |
---|---|
self |
The instance of the class.
|
input_ids |
The input tensor containing token ids for the input sequence.
TYPE:
|
attention_mask |
An optional tensor specifying the attention mask to be applied.
TYPE:
|
position_ids |
An optional tensor containing positional ids for the input sequence.
TYPE:
|
past_key_values |
Optional past key values for attention mechanism.
TYPE:
|
inputs_embeds |
Optional tensor containing input embeddings.
TYPE:
|
use_cache |
Optional boolean specifying whether to use cache for the model.
TYPE:
|
output_attentions |
Optional boolean specifying whether to output attentions.
TYPE:
|
output_hidden_states |
Optional boolean specifying whether to output hidden states.
TYPE:
|
output_router_logits |
Optional boolean specifying whether to output router logits.
TYPE:
|
return_dict |
Optional boolean specifying whether to return the output as a dictionary.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Union[Tuple, MoeModelOutputWithPast]
|
Union[Tuple, MoeModelOutputWithPast]: The return value can either be a tuple containing relevant outputs or an instance of MoeModelOutputWithPast class. |
RAISES | DESCRIPTION |
---|---|
ValueError
|
Raised if both input_ids and inputs_embeds are specified at the same time, or if neither input_ids nor inputs_embeds are specified. |
Warning
|
Raised as a warning if 'use_cache=True' is incompatible with gradient checkpointing, and it automatically sets 'use_cache=False'. |
Source code in mindnlp/transformers/models/jamba/modeling_jamba.py
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 1630 1631 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 |
|
mindnlp.transformers.models.jamba.modeling_jamba.JambaModel.get_input_embeddings()
¶
Method to retrieve the input embeddings from the JambaModel instance.
PARAMETER | DESCRIPTION |
---|---|
self |
The current instance of the JambaModel class. This parameter is required to access the embed_tokens attribute.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None
|
This method returns the embed_tokens attribute of the JambaModel instance. The embed_tokens attribute represents the input embeddings used by the model. |
Source code in mindnlp/transformers/models/jamba/modeling_jamba.py
1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 |
|
mindnlp.transformers.models.jamba.modeling_jamba.JambaModel.set_input_embeddings(value)
¶
Set the input embeddings for the JambaModel.
PARAMETER | DESCRIPTION |
---|---|
self |
The instance of the JambaModel class.
TYPE:
|
value |
The input embeddings to be set for the model. This can be a tensor, array, or any compatible data structure. It represents the embeddings to be assigned to the model for input processing.
|
RETURNS | DESCRIPTION |
---|---|
None. |
Source code in mindnlp/transformers/models/jamba/modeling_jamba.py
1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 |
|
mindnlp.transformers.models.jamba.modeling_jamba.JambaForCausalLM
¶
Bases: JambaPreTrainedModel
This class represents a Jamba model for causal language modeling tasks. It is a subclass of JambaPreTrainedModel.
The JambaForCausalLM class encapsulates the architecture and functionality of the Jamba model for generating text. It includes methods for initializing the model, getting and setting input and output embeddings, setting the decoder, and forwarding the model.
ATTRIBUTE | DESCRIPTION |
---|---|
model |
The Jamba model used for text generation.
TYPE:
|
vocab_size |
The size of the vocabulary.
TYPE:
|
lm_head |
The linear layer for generating the next token in the sequence.
TYPE:
|
router_aux_loss_coef |
The coefficient for the auxiliary loss used in load balancing.
TYPE:
|
num_experts |
The number of experts used in load balancing.
TYPE:
|
num_experts_per_tok |
The number of experts per token used in load balancing.
TYPE:
|
METHOD | DESCRIPTION |
---|---|
__init__ |
Initializes the JambaForCausalLM instance with the given configuration. |
get_input_embeddings |
Returns the input embeddings of the model. |
set_input_embeddings |
Sets the input embeddings of the model. |
get_output_embeddings |
Returns the output embeddings of the model. |
set_output_embeddings |
Sets the output embeddings of the model. |
set_decoder |
Sets the decoder of the model. |
get_decoder |
Returns the decoder of the model. |
forward |
Constructs the model for generating text and returns the outputs. |
prepare_inputs_for_generation |
Prepares the inputs for text generation by reordering the cache and updating the position ids. |
Please refer to the source code for more details on the implementation of each method.
Source code in mindnlp/transformers/models/jamba/modeling_jamba.py
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 1742 1743 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 1860 1861 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 1989 1990 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 |
|
mindnlp.transformers.models.jamba.modeling_jamba.JambaForCausalLM.__init__(config)
¶
Initializes an instance of the JambaForCausalLM class.
PARAMETER | DESCRIPTION |
---|---|
self |
The instance of the class.
|
config |
An instance of JambaConfig containing the configuration parameters for the model.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None. |
Source code in mindnlp/transformers/models/jamba/modeling_jamba.py
1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 |
|
mindnlp.transformers.models.jamba.modeling_jamba.JambaForCausalLM.forward(input_ids=None, attention_mask=None, position_ids=None, past_key_values=None, inputs_embeds=None, labels=None, use_cache=None, output_attentions=None, output_hidden_states=None, output_router_logits=None, return_dict=None, calc_logits_for_entire_prompt=True)
¶
PARAMETER | DESCRIPTION |
---|---|
labels |
Labels for computing the masked language modeling loss. Indices should either be in
TYPE:
|
calc_logits_for_entire_prompt |
Whether or not to calculate the logits for the entire prompt, or just the last token. Only last token logits are needed for generation, and calculating them only for that token can save memory, which becomes pretty significant for long sequences.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Union[Tuple, MoeCausalLMOutputWithPast]
|
Union[Tuple, MoeCausalLMOutputWithPast] |
```
Source code in mindnlp/transformers/models/jamba/modeling_jamba.py
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 |
|
mindnlp.transformers.models.jamba.modeling_jamba.JambaForCausalLM.get_decoder()
¶
This method returns the decoder model for the JambaForCausalLM class.
PARAMETER | DESCRIPTION |
---|---|
self |
The instance of the JambaForCausalLM class.
|
RETURNS | DESCRIPTION |
---|---|
The decoder model associated with the instance of the JambaForCausalLM class. |
Source code in mindnlp/transformers/models/jamba/modeling_jamba.py
1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 |
|
mindnlp.transformers.models.jamba.modeling_jamba.JambaForCausalLM.get_input_embeddings()
¶
This method retrieves the input embeddings from the JambaForCausalLM model.
PARAMETER | DESCRIPTION |
---|---|
self |
An instance of the JambaForCausalLM class.
|
RETURNS | DESCRIPTION |
---|---|
embed_tokens
|
The method returns the embed_tokens attribute of the model. |
Source code in mindnlp/transformers/models/jamba/modeling_jamba.py
1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 |
|
mindnlp.transformers.models.jamba.modeling_jamba.JambaForCausalLM.get_output_embeddings()
¶
Returns the output embeddings of the JambaForCausalLM model.
PARAMETER | DESCRIPTION |
---|---|
self |
An instance of the JambaForCausalLM class.
|
RETURNS | DESCRIPTION |
---|---|
None. |
Source code in mindnlp/transformers/models/jamba/modeling_jamba.py
1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 |
|
mindnlp.transformers.models.jamba.modeling_jamba.JambaForCausalLM.prepare_inputs_for_generation(input_ids, past_key_values=None, attention_mask=None, inputs_embeds=None, output_router_logits=False, **kwargs)
¶
Prepare inputs for generation in the JambaForCausalLM class.
PARAMETER | DESCRIPTION |
---|---|
self |
The instance of the JambaForCausalLM class.
TYPE:
|
input_ids |
The input token IDs for the generation process.
TYPE:
|
past_key_values |
The past key values from previous generations, which can be a Tuple or a Cache object.
TYPE:
|
attention_mask |
Optional tensor indicating the attention mask for the input.
TYPE:
|
inputs_embeds |
Optional tensor containing the embeddings for the input tokens.
TYPE:
|
output_router_logits |
Flag indicating whether to calculate output router logits.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
dict
|
A dictionary containing the prepared model inputs for generation, including input_ids, position_ids, past_key_values, use_cache, attention_mask, output_router_logits, and calc_logits_for_entire_prompt. |
RAISES | DESCRIPTION |
---|---|
ValueError
|
If the shape of past_key_values is not as expected. |
AttributeError
|
If an attribute error occurs during the method execution. |
RuntimeError
|
If a runtime error occurs during the method execution. |
Source code in mindnlp/transformers/models/jamba/modeling_jamba.py
1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 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 |
|
mindnlp.transformers.models.jamba.modeling_jamba.JambaForCausalLM.set_decoder(decoder)
¶
Sets the decoder for the JambaForCausalLM model.
PARAMETER | DESCRIPTION |
---|---|
self |
The instance of the JambaForCausalLM class.
TYPE:
|
decoder |
The decoder object to be set for the JambaForCausalLM model.
|
RETURNS | DESCRIPTION |
---|---|
None. |
Source code in mindnlp/transformers/models/jamba/modeling_jamba.py
1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 |
|
mindnlp.transformers.models.jamba.modeling_jamba.JambaForCausalLM.set_input_embeddings(value)
¶
Set the input embeddings for the JambaForCausalLM model.
PARAMETER | DESCRIPTION |
---|---|
self |
The instance of the JambaForCausalLM class.
TYPE:
|
value |
The input embeddings to be set.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None. |
Source code in mindnlp/transformers/models/jamba/modeling_jamba.py
1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 |
|
mindnlp.transformers.models.jamba.modeling_jamba.JambaForCausalLM.set_output_embeddings(new_embeddings)
¶
Method to set new output embeddings for the JambaForCausalLM model.
PARAMETER | DESCRIPTION |
---|---|
self |
The instance of the JambaForCausalLM class.
TYPE:
|
new_embeddings |
The new embeddings to be set as the output embeddings for the model. This can be of any type.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None. |
Source code in mindnlp/transformers/models/jamba/modeling_jamba.py
1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 |
|
mindnlp.transformers.models.jamba.modeling_jamba.JambaForSequenceClassification
¶
Bases: JambaPreTrainedModel
JambaForSequenceClassification is a class that represents a sequence classification model based on the Jamba architecture.
This class extends JambaPreTrainedModel and includes methods for initializing the model, getting and setting input embeddings, and forwarding the sequence classification output.
The forward method takes input_ids, attention_mask, position_ids, past_key_values, inputs_embeds, labels, and various optional arguments to generate the sequence classifier output.
It calculates the loss based on the labels provided and handles different types of classification problems such as regression, single-label classification, and multi-label classification.
The class provides flexibility in handling return types and outputs a SequenceClassifierOutputWithPast object if return_dict is set to True.
Source code in mindnlp/transformers/models/jamba/modeling_jamba.py
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 2121 2122 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 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 |
|
mindnlp.transformers.models.jamba.modeling_jamba.JambaForSequenceClassification.__init__(config)
¶
Initializes a new instance of the JambaForSequenceClassification class.
PARAMETER | DESCRIPTION |
---|---|
self |
The object itself.
|
config |
An instance of the JambaConfig class that contains the configuration settings for the Jamba model.
|
RETURNS | DESCRIPTION |
---|---|
None. |
Source code in mindnlp/transformers/models/jamba/modeling_jamba.py
2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 |
|
mindnlp.transformers.models.jamba.modeling_jamba.JambaForSequenceClassification.forward(input_ids=None, attention_mask=None, position_ids=None, past_key_values=None, inputs_embeds=None, labels=None, use_cache=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/jamba/modeling_jamba.py
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 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 |
|
mindnlp.transformers.models.jamba.modeling_jamba.JambaForSequenceClassification.get_input_embeddings()
¶
Method to retrieve input embeddings from the model for JambaForSequenceClassification.
PARAMETER | DESCRIPTION |
---|---|
self |
The instance of the JambaForSequenceClassification class.
|
RETURNS | DESCRIPTION |
---|---|
The input embeddings obtained from the model's embed_tokens attribute. |
Source code in mindnlp/transformers/models/jamba/modeling_jamba.py
2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 |
|
mindnlp.transformers.models.jamba.modeling_jamba.JambaForSequenceClassification.set_input_embeddings(value)
¶
Set the input embeddings for the JambaForSequenceClassification model.
PARAMETER | DESCRIPTION |
---|---|
self |
The instance of the JambaForSequenceClassification class. |
value |
The input embeddings to be set for the model. Should be a torch.Tensor representing the embeddings to be used.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None. |
Source code in mindnlp/transformers/models/jamba/modeling_jamba.py
2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 |
|