gpt_bigcode
mindnlp.transformers.models.gpt_bigcode.configuration_gpt_bigcode
¶
MindNLP gpt_bigcode config
mindnlp.transformers.models.gpt_bigcode.configuration_gpt_bigcode.GPTBigCodeConfig
¶
Bases: PretrainedConfig
GPT BigCode config
Source code in mindnlp\transformers\models\gpt_bigcode\configuration_gpt_bigcode.py
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 | |
mindnlp.transformers.models.gpt_bigcode.configuration_gpt_bigcode.GPTBigCodeConfig.__init__(vocab_size=50257, n_positions=1024, n_embd=768, n_layer=12, n_head=12, n_inner=None, activation_function='gelu_approximate', resid_pdrop=0.1, embd_pdrop=0.1, attn_pdrop=0.1, layer_norm_epsilon=1e-05, initializer_range=0.02, scale_attn_weights=True, use_cache=True, bos_token_id=50256, eos_token_id=50256, attention_softmax_in_fp32=True, scale_attention_softmax_in_fp32=True, multi_query=True, **kwargs)
¶
init
Initialize a new GPTBigCodeConfig object.
| PARAMETER | DESCRIPTION |
|---|---|
vocab_size
|
The size of the vocabulary. Default is 50257.
TYPE:
|
n_positions
|
The maximum sequence length for the model. Default is 1024.
TYPE:
|
n_embd
|
The dimension of the embeddings and hidden states. Default is 768.
TYPE:
|
n_layer
|
The number of layers in the model. Default is 12.
TYPE:
|
n_head
|
The number of attention heads in the model. Default is 12.
TYPE:
|
n_inner
|
The inner dimension of the feedforward layers. Default is None.
TYPE:
|
activation_function
|
The activation function used in the model. Default is 'gelu_approximate'.
TYPE:
|
resid_pdrop
|
The dropout probability for residual connections. Default is 0.1.
TYPE:
|
embd_pdrop
|
The dropout probability for embeddings. Default is 0.1.
TYPE:
|
attn_pdrop
|
The dropout probability for attention layers. Default is 0.1.
TYPE:
|
layer_norm_epsilon
|
The epsilon value for layer normalization. Default is 1e-05.
TYPE:
|
initializer_range
|
The range for parameter initializers. Default is 0.02.
TYPE:
|
scale_attn_weights
|
Whether to scale the attention weights. Default is True.
TYPE:
|
use_cache
|
Whether to use caching during inference. Default is True.
TYPE:
|
bos_token_id
|
The token id for the beginning of sequence. Default is 50256.
TYPE:
|
eos_token_id
|
The token id for the end of sequence. Default is 50256.
TYPE:
|
attention_softmax_in_fp32
|
Whether to use fp32 for attention softmax. Default is True.
TYPE:
|
scale_attention_softmax_in_fp32
|
Whether to scale attention softmax in fp32. Default is True.
TYPE:
|
multi_query
|
Whether to use multi-query attention. Default is True.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
|
None. |
Source code in mindnlp\transformers\models\gpt_bigcode\configuration_gpt_bigcode.py
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 | |
mindnlp.transformers.models.gpt_bigcode.modeling_gpt_bigcode
¶
MindSpore GPTBigCode model.
mindnlp.transformers.models.gpt_bigcode.modeling_gpt_bigcode.GPTBigCodeForCausalLM
¶
Bases: GPTBigCodePreTrainedModel
Source code in mindnlp\transformers\models\gpt_bigcode\modeling_gpt_bigcode.py
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 | |
mindnlp.transformers.models.gpt_bigcode.modeling_gpt_bigcode.GPTBigCodeForCausalLM.forward(input_ids=None, past_key_values=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, use_cache=None, output_attentions=None, output_hidden_states=None, return_dict=None)
¶
labels (mindspore.Tensor of shape (batch_size, sequence_length), optional):
Labels for language modeling. Note that the labels are shifted inside the model, i.e. you can set
labels = input_ids Indices are selected in [-100, 0, ..., config.vocab_size] All labels set to -100
are ignored (masked), the loss is only computed for labels in [0, ..., config.vocab_size]
Source code in mindnlp\transformers\models\gpt_bigcode\modeling_gpt_bigcode.py
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 | |
mindnlp.transformers.models.gpt_bigcode.modeling_gpt_bigcode.GPTBigCodeForSequenceClassification
¶
Bases: GPTBigCodePreTrainedModel
Source code in mindnlp\transformers\models\gpt_bigcode\modeling_gpt_bigcode.py
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 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 | |
mindnlp.transformers.models.gpt_bigcode.modeling_gpt_bigcode.GPTBigCodeForSequenceClassification.forward(input_ids=None, past_key_values=None, attention_mask=None, token_type_ids=None, position_ids=None, head_mask=None, inputs_embeds=None, labels=None, use_cache=None, output_attentions=None, output_hidden_states=None, return_dict=None)
¶
labels (mindspore.Tensor of shape (batch_size,), optional):
Labels for computing the sequence classification/regression loss. Indices should be in [0, ...,
config.num_labels - 1]. If config.num_labels == 1 a regression loss is computed (Mean-Square loss), If
config.num_labels > 1 a classification loss is computed (Cross-Entropy).
Source code in mindnlp\transformers\models\gpt_bigcode\modeling_gpt_bigcode.py
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 | |
mindnlp.transformers.models.gpt_bigcode.modeling_gpt_bigcode.GPTBigCodeForTokenClassification
¶
Bases: GPTBigCodePreTrainedModel
Source code in mindnlp\transformers\models\gpt_bigcode\modeling_gpt_bigcode.py
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 | |
mindnlp.transformers.models.gpt_bigcode.modeling_gpt_bigcode.GPTBigCodeForTokenClassification.forward(input_ids=None, past_key_values=None, attention_mask=None, token_type_ids=None, position_ids=None, head_mask=None, inputs_embeds=None, labels=None, use_cache=None, output_attentions=None, output_hidden_states=None, return_dict=None)
¶
labels (mindspore.Tensor of shape (batch_size, sequence_length), optional):
Labels for computing the sequence classification/regression loss. Indices should be in [0, ...,
config.num_labels - 1]. If config.num_labels == 1 a regression loss is computed (Mean-Square loss), If
config.num_labels > 1 a classification loss is computed (Cross-Entropy).
Source code in mindnlp\transformers\models\gpt_bigcode\modeling_gpt_bigcode.py
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 | |
mindnlp.transformers.models.gpt_bigcode.modeling_gpt_bigcode.GPTBigCodePreTrainedModel
¶
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\gpt_bigcode\modeling_gpt_bigcode.py
370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 | |