import{S as yb,i as wb,s as Pb,e as n,k as l,w as v,t as a,M as $b,c as s,d as t,m as d,a as i,x as b,h as r,b as c,F as e,g as h,y as k,q as y,o as w,B as P}from"../../chunks/vendor-4833417e.js";import{T as Le}from"../../chunks/Tip-fffd6df1.js";import{D as H}from"../../chunks/Docstring-4f315ed9.js";import{C as Me}from"../../chunks/CodeBlock-6a3d1b46.js";import{I as je}from"../../chunks/IconCopyLink-4b81c553.js";import"../../chunks/CopyButton-dacfbfaf.js";function Mb(q){let p,M,f,T,$;return{c(){p=n("p"),M=a("When used with "),f=n("code"),T=a("is_split_into_words=True"),$=a(", this tokenizer will add a space before each word (even the first one).")},l(_){p=s(_,"P",{});var g=i(p);M=r(g,"When used with "),f=s(g,"CODE",{});var z=i(f);T=r(z,"is_split_into_words=True"),z.forEach(t),$=r(g,", this tokenizer will add a space before each word (even the first one)."),g.forEach(t)},m(_,g){h(_,p,g),e(p,M),e(p,f),e(f,T),e(p,$)},d(_){_&&t(p)}}}function Gb(q){let p,M,f,T,$,_,g,z;return{c(){p=n("p"),M=a("When used with "),f=n("code"),T=a("is_split_into_words=True"),$=a(", this tokenizer needs to be instantiated with "),_=n("code"),g=a("add_prefix_space=True"),z=a(".")},l(Q){p=s(Q,"P",{});var C=i(p);M=r(C,"When used with "),f=s(C,"CODE",{});var j=i(f);T=r(j,"is_split_into_words=True"),j.forEach(t),$=r(C,", this tokenizer needs to be instantiated with "),_=s(C,"CODE",{});var R=i(_);g=r(R,"add_prefix_space=True"),R.forEach(t),z=r(C,"."),C.forEach(t)},m(Q,C){h(Q,p,C),e(p,M),e(p,f),e(f,T),e(p,$),e(p,_),e(_,g),e(p,z)},d(Q){Q&&t(p)}}}function zb(q){let p,M,f,T,$;return{c(){p=n("p"),M=a("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=n("code"),T=a("Module"),$=a(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(_){p=s(_,"P",{});var g=i(p);M=r(g,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=s(g,"CODE",{});var z=i(f);T=r(z,"Module"),z.forEach(t),$=r(g,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),g.forEach(t)},m(_,g){h(_,p,g),e(p,M),e(p,f),e(f,T),e(p,$)},d(_){_&&t(p)}}}function jb(q){let p,M,f,T,$;return{c(){p=n("p"),M=a("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=n("code"),T=a("Module"),$=a(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(_){p=s(_,"P",{});var g=i(p);M=r(g,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=s(g,"CODE",{});var z=i(f);T=r(z,"Module"),z.forEach(t),$=r(g,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),g.forEach(t)},m(_,g){h(_,p,g),e(p,M),e(p,f),e(f,T),e(p,$)},d(_){_&&t(p)}}}function Fb(q){let p,M,f,T,$;return{c(){p=n("p"),M=a("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=n("code"),T=a("Module"),$=a(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(_){p=s(_,"P",{});var g=i(p);M=r(g,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=s(g,"CODE",{});var z=i(f);T=r(z,"Module"),z.forEach(t),$=r(g,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),g.forEach(t)},m(_,g){h(_,p,g),e(p,M),e(p,f),e(f,T),e(p,$)},d(_){_&&t(p)}}}function xb(q){let p,M,f,T,$;return{c(){p=n("p"),M=a("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=n("code"),T=a("Module"),$=a(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(_){p=s(_,"P",{});var g=i(p);M=r(g,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=s(g,"CODE",{});var z=i(f);T=r(z,"Module"),z.forEach(t),$=r(g,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),g.forEach(t)},m(_,g){h(_,p,g),e(p,M),e(p,f),e(f,T),e(p,$)},d(_){_&&t(p)}}}function Eb(q){let p,M,f,T,$;return{c(){p=n("p"),M=a("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=n("code"),T=a("Module"),$=a(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(_){p=s(_,"P",{});var g=i(p);M=r(g,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=s(g,"CODE",{});var z=i(f);T=r(z,"Module"),z.forEach(t),$=r(g,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),g.forEach(t)},m(_,g){h(_,p,g),e(p,M),e(p,f),e(f,T),e(p,$)},d(_){_&&t(p)}}}function qb(q){let p,M,f,T,$,_,g,z,Q,C,j,R,S,Z,ue,A,me,ce,W,L,ee,te,F,E,se,V,pe,ae,O,fe,he,x,ge,B,U,re,J,_e,oe,N,ie,K,Te;return{c(){p=n("p"),M=a("TF 2.0 models accepts two formats as inputs:"),f=l(),T=n("ul"),$=n("li"),_=a("having all inputs as keyword arguments (like PyTorch models), or"),g=l(),z=n("li"),Q=a("having all inputs as a list, tuple or dict in the first positional arguments."),C=l(),j=n("p"),R=a("This second option is useful when using "),S=n("code"),Z=a("tf.keras.Model.fit"),ue=a(` method which currently requires having all the
tensors in the first argument of the model call function: `),A=n("code"),me=a("model(inputs)"),ce=a("."),W=l(),L=n("p"),ee=a(`If you choose this second option, there are three possibilities you can use to gather all the input Tensors in the
first positional argument :`),te=l(),F=n("ul"),E=n("li"),se=a("a single Tensor with "),V=n("code"),pe=a("input_ids"),ae=a(" only and nothing else: "),O=n("code"),fe=a("model(inputs_ids)"),he=l(),x=n("li"),ge=a(`a list of varying length with one or several input Tensors IN THE ORDER given in the docstring:
`),B=n("code"),U=a("model([input_ids, attention_mask])"),re=a(" or "),J=n("code"),_e=a("model([input_ids, attention_mask, token_type_ids])"),oe=l(),N=n("li"),ie=a(`a dictionary with one or several input Tensors associated to the input names given in the docstring:
`),K=n("code"),Te=a('model({"input_ids": input_ids, "token_type_ids": token_type_ids})')},l(u){p=s(u,"P",{});var G=i(p);M=r(G,"TF 2.0 models accepts two formats as inputs:"),G.forEach(t),f=d(u),T=s(u,"UL",{});var ne=i(T);$=s(ne,"LI",{});var Fe=i($);_=r(Fe,"having all inputs as keyword arguments (like PyTorch models), or"),Fe.forEach(t),g=d(ne),z=s(ne,"LI",{});var Se=i(z);Q=r(Se,"having all inputs as a list, tuple or dict in the first positional arguments."),Se.forEach(t),ne.forEach(t),C=d(u),j=s(u,"P",{});var I=i(j);R=r(I,"This second option is useful when using "),S=s(I,"CODE",{});var xe=i(S);Z=r(xe,"tf.keras.Model.fit"),xe.forEach(t),ue=r(I,` method which currently requires having all the
tensors in the first argument of the model call function: `),A=s(I,"CODE",{});var Ae=i(A);me=r(Ae,"model(inputs)"),Ae.forEach(t),ce=r(I,"."),I.forEach(t),W=d(u),L=s(u,"P",{});var Oe=i(L);ee=r(Oe,`If you choose this second option, there are three possibilities you can use to gather all the input Tensors in the
first positional argument :`),Oe.forEach(t),te=d(u),F=s(u,"UL",{});var D=i(F);E=s(D,"LI",{});var X=i(E);se=r(X,"a single Tensor with "),V=s(X,"CODE",{});var We=i(V);pe=r(We,"input_ids"),We.forEach(t),ae=r(X," only and nothing else: "),O=s(X,"CODE",{});var Ee=i(O);fe=r(Ee,"model(inputs_ids)"),Ee.forEach(t),X.forEach(t),he=d(D),x=s(D,"LI",{});var Y=i(x);ge=r(Y,`a list of varying length with one or several input Tensors IN THE ORDER given in the docstring:
`),B=s(Y,"CODE",{});var Be=i(B);U=r(Be,"model([input_ids, attention_mask])"),Be.forEach(t),re=r(Y," or "),J=s(Y,"CODE",{});var qe=i(J);_e=r(qe,"model([input_ids, attention_mask, token_type_ids])"),qe.forEach(t),Y.forEach(t),oe=d(D),N=s(D,"LI",{});var ve=i(N);ie=r(ve,`a dictionary with one or several input Tensors associated to the input names given in the docstring:
`),K=s(ve,"CODE",{});var Ue=i(K);Te=r(Ue,'model({"input_ids": input_ids, "token_type_ids": token_type_ids})'),Ue.forEach(t),ve.forEach(t),D.forEach(t)},m(u,G){h(u,p,G),e(p,M),h(u,f,G),h(u,T,G),e(T,$),e($,_),e(T,g),e(T,z),e(z,Q),h(u,C,G),h(u,j,G),e(j,R),e(j,S),e(S,Z),e(j,ue),e(j,A),e(A,me),e(j,ce),h(u,W,G),h(u,L,G),e(L,ee),h(u,te,G),h(u,F,G),e(F,E),e(E,se),e(E,V),e(V,pe),e(E,ae),e(E,O),e(O,fe),e(F,he),e(F,x),e(x,ge),e(x,B),e(B,U),e(x,re),e(x,J),e(J,_e),e(F,oe),e(F,N),e(N,ie),e(N,K),e(K,Te)},d(u){u&&t(p),u&&t(f),u&&t(T),u&&t(C),u&&t(j),u&&t(W),u&&t(L),u&&t(te),u&&t(F)}}}function Cb(q){let p,M,f,T,$;return{c(){p=n("p"),M=a("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=n("code"),T=a("Module"),$=a(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(_){p=s(_,"P",{});var g=i(p);M=r(g,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=s(g,"CODE",{});var z=i(f);T=r(z,"Module"),z.forEach(t),$=r(g,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),g.forEach(t)},m(_,g){h(_,p,g),e(p,M),e(p,f),e(f,T),e(p,$)},d(_){_&&t(p)}}}function Db(q){let p,M,f,T,$,_,g,z,Q,C,j,R,S,Z,ue,A,me,ce,W,L,ee,te,F,E,se,V,pe,ae,O,fe,he,x,ge,B,U,re,J,_e,oe,N,ie,K,Te;return{c(){p=n("p"),M=a("TF 2.0 models accepts two formats as inputs:"),f=l(),T=n("ul"),$=n("li"),_=a("having all inputs as keyword arguments (like PyTorch models), or"),g=l(),z=n("li"),Q=a("having all inputs as a list, tuple or dict in the first positional arguments."),C=l(),j=n("p"),R=a("This second option is useful when using "),S=n("code"),Z=a("tf.keras.Model.fit"),ue=a(` method which currently requires having all the
tensors in the first argument of the model call function: `),A=n("code"),me=a("model(inputs)"),ce=a("."),W=l(),L=n("p"),ee=a(`If you choose this second option, there are three possibilities you can use to gather all the input Tensors in the
first positional argument :`),te=l(),F=n("ul"),E=n("li"),se=a("a single Tensor with "),V=n("code"),pe=a("input_ids"),ae=a(" only and nothing else: "),O=n("code"),fe=a("model(inputs_ids)"),he=l(),x=n("li"),ge=a(`a list of varying length with one or several input Tensors IN THE ORDER given in the docstring:
`),B=n("code"),U=a("model([input_ids, attention_mask])"),re=a(" or "),J=n("code"),_e=a("model([input_ids, attention_mask, token_type_ids])"),oe=l(),N=n("li"),ie=a(`a dictionary with one or several input Tensors associated to the input names given in the docstring:
`),K=n("code"),Te=a('model({"input_ids": input_ids, "token_type_ids": token_type_ids})')},l(u){p=s(u,"P",{});var G=i(p);M=r(G,"TF 2.0 models accepts two formats as inputs:"),G.forEach(t),f=d(u),T=s(u,"UL",{});var ne=i(T);$=s(ne,"LI",{});var Fe=i($);_=r(Fe,"having all inputs as keyword arguments (like PyTorch models), or"),Fe.forEach(t),g=d(ne),z=s(ne,"LI",{});var Se=i(z);Q=r(Se,"having all inputs as a list, tuple or dict in the first positional arguments."),Se.forEach(t),ne.forEach(t),C=d(u),j=s(u,"P",{});var I=i(j);R=r(I,"This second option is useful when using "),S=s(I,"CODE",{});var xe=i(S);Z=r(xe,"tf.keras.Model.fit"),xe.forEach(t),ue=r(I,` method which currently requires having all the
tensors in the first argument of the model call function: `),A=s(I,"CODE",{});var Ae=i(A);me=r(Ae,"model(inputs)"),Ae.forEach(t),ce=r(I,"."),I.forEach(t),W=d(u),L=s(u,"P",{});var Oe=i(L);ee=r(Oe,`If you choose this second option, there are three possibilities you can use to gather all the input Tensors in the
first positional argument :`),Oe.forEach(t),te=d(u),F=s(u,"UL",{});var D=i(F);E=s(D,"LI",{});var X=i(E);se=r(X,"a single Tensor with "),V=s(X,"CODE",{});var We=i(V);pe=r(We,"input_ids"),We.forEach(t),ae=r(X," only and nothing else: "),O=s(X,"CODE",{});var Ee=i(O);fe=r(Ee,"model(inputs_ids)"),Ee.forEach(t),X.forEach(t),he=d(D),x=s(D,"LI",{});var Y=i(x);ge=r(Y,`a list of varying length with one or several input Tensors IN THE ORDER given in the docstring:
`),B=s(Y,"CODE",{});var Be=i(B);U=r(Be,"model([input_ids, attention_mask])"),Be.forEach(t),re=r(Y," or "),J=s(Y,"CODE",{});var qe=i(J);_e=r(qe,"model([input_ids, attention_mask, token_type_ids])"),qe.forEach(t),Y.forEach(t),oe=d(D),N=s(D,"LI",{});var ve=i(N);ie=r(ve,`a dictionary with one or several input Tensors associated to the input names given in the docstring:
`),K=s(ve,"CODE",{});var Ue=i(K);Te=r(Ue,'model({"input_ids": input_ids, "token_type_ids": token_type_ids})'),Ue.forEach(t),ve.forEach(t),D.forEach(t)},m(u,G){h(u,p,G),e(p,M),h(u,f,G),h(u,T,G),e(T,$),e($,_),e(T,g),e(T,z),e(z,Q),h(u,C,G),h(u,j,G),e(j,R),e(j,S),e(S,Z),e(j,ue),e(j,A),e(A,me),e(j,ce),h(u,W,G),h(u,L,G),e(L,ee),h(u,te,G),h(u,F,G),e(F,E),e(E,se),e(E,V),e(V,pe),e(E,ae),e(E,O),e(O,fe),e(F,he),e(F,x),e(x,ge),e(x,B),e(B,U),e(x,re),e(x,J),e(J,_e),e(F,oe),e(F,N),e(N,ie),e(N,K),e(K,Te)},d(u){u&&t(p),u&&t(f),u&&t(T),u&&t(C),u&&t(j),u&&t(W),u&&t(L),u&&t(te),u&&t(F)}}}function Hb(q){let p,M,f,T,$;return{c(){p=n("p"),M=a("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=n("code"),T=a("Module"),$=a(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(_){p=s(_,"P",{});var g=i(p);M=r(g,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=s(g,"CODE",{});var z=i(f);T=r(z,"Module"),z.forEach(t),$=r(g,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),g.forEach(t)},m(_,g){h(_,p,g),e(p,M),e(p,f),e(f,T),e(p,$)},d(_){_&&t(p)}}}function Lb(q){let p,M,f,T,$,_,g,z,Q,C,j,R,S,Z,ue,A,me,ce,W,L,ee,te,F,E,se,V,pe,ae,O,fe,he,x,ge,B,U,re,J,_e,oe,N,ie,K,Te;return{c(){p=n("p"),M=a("TF 2.0 models accepts two formats as inputs:"),f=l(),T=n("ul"),$=n("li"),_=a("having all inputs as keyword arguments (like PyTorch models), or"),g=l(),z=n("li"),Q=a("having all inputs as a list, tuple or dict in the first positional arguments."),C=l(),j=n("p"),R=a("This second option is useful when using "),S=n("code"),Z=a("tf.keras.Model.fit"),ue=a(` method which currently requires having all the
tensors in the first argument of the model call function: `),A=n("code"),me=a("model(inputs)"),ce=a("."),W=l(),L=n("p"),ee=a(`If you choose this second option, there are three possibilities you can use to gather all the input Tensors in the
first positional argument :`),te=l(),F=n("ul"),E=n("li"),se=a("a single Tensor with "),V=n("code"),pe=a("input_ids"),ae=a(" only and nothing else: "),O=n("code"),fe=a("model(inputs_ids)"),he=l(),x=n("li"),ge=a(`a list of varying length with one or several input Tensors IN THE ORDER given in the docstring:
`),B=n("code"),U=a("model([input_ids, attention_mask])"),re=a(" or "),J=n("code"),_e=a("model([input_ids, attention_mask, token_type_ids])"),oe=l(),N=n("li"),ie=a(`a dictionary with one or several input Tensors associated to the input names given in the docstring:
`),K=n("code"),Te=a('model({"input_ids": input_ids, "token_type_ids": token_type_ids})')},l(u){p=s(u,"P",{});var G=i(p);M=r(G,"TF 2.0 models accepts two formats as inputs:"),G.forEach(t),f=d(u),T=s(u,"UL",{});var ne=i(T);$=s(ne,"LI",{});var Fe=i($);_=r(Fe,"having all inputs as keyword arguments (like PyTorch models), or"),Fe.forEach(t),g=d(ne),z=s(ne,"LI",{});var Se=i(z);Q=r(Se,"having all inputs as a list, tuple or dict in the first positional arguments."),Se.forEach(t),ne.forEach(t),C=d(u),j=s(u,"P",{});var I=i(j);R=r(I,"This second option is useful when using "),S=s(I,"CODE",{});var xe=i(S);Z=r(xe,"tf.keras.Model.fit"),xe.forEach(t),ue=r(I,` method which currently requires having all the
tensors in the first argument of the model call function: `),A=s(I,"CODE",{});var Ae=i(A);me=r(Ae,"model(inputs)"),Ae.forEach(t),ce=r(I,"."),I.forEach(t),W=d(u),L=s(u,"P",{});var Oe=i(L);ee=r(Oe,`If you choose this second option, there are three possibilities you can use to gather all the input Tensors in the
first positional argument :`),Oe.forEach(t),te=d(u),F=s(u,"UL",{});var D=i(F);E=s(D,"LI",{});var X=i(E);se=r(X,"a single Tensor with "),V=s(X,"CODE",{});var We=i(V);pe=r(We,"input_ids"),We.forEach(t),ae=r(X," only and nothing else: "),O=s(X,"CODE",{});var Ee=i(O);fe=r(Ee,"model(inputs_ids)"),Ee.forEach(t),X.forEach(t),he=d(D),x=s(D,"LI",{});var Y=i(x);ge=r(Y,`a list of varying length with one or several input Tensors IN THE ORDER given in the docstring:
`),B=s(Y,"CODE",{});var Be=i(B);U=r(Be,"model([input_ids, attention_mask])"),Be.forEach(t),re=r(Y," or "),J=s(Y,"CODE",{});var qe=i(J);_e=r(qe,"model([input_ids, attention_mask, token_type_ids])"),qe.forEach(t),Y.forEach(t),oe=d(D),N=s(D,"LI",{});var ve=i(N);ie=r(ve,`a dictionary with one or several input Tensors associated to the input names given in the docstring:
`),K=s(ve,"CODE",{});var Ue=i(K);Te=r(Ue,'model({"input_ids": input_ids, "token_type_ids": token_type_ids})'),Ue.forEach(t),ve.forEach(t),D.forEach(t)},m(u,G){h(u,p,G),e(p,M),h(u,f,G),h(u,T,G),e(T,$),e($,_),e(T,g),e(T,z),e(z,Q),h(u,C,G),h(u,j,G),e(j,R),e(j,S),e(S,Z),e(j,ue),e(j,A),e(A,me),e(j,ce),h(u,W,G),h(u,L,G),e(L,ee),h(u,te,G),h(u,F,G),e(F,E),e(E,se),e(E,V),e(V,pe),e(E,ae),e(E,O),e(O,fe),e(F,he),e(F,x),e(x,ge),e(x,B),e(B,U),e(x,re),e(x,J),e(J,_e),e(F,oe),e(F,N),e(N,ie),e(N,K),e(K,Te)},d(u){u&&t(p),u&&t(f),u&&t(T),u&&t(C),u&&t(j),u&&t(W),u&&t(L),u&&t(te),u&&t(F)}}}function Nb(q){let p,M,f,T,$;return{c(){p=n("p"),M=a("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=n("code"),T=a("Module"),$=a(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(_){p=s(_,"P",{});var g=i(p);M=r(g,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=s(g,"CODE",{});var z=i(f);T=r(z,"Module"),z.forEach(t),$=r(g,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),g.forEach(t)},m(_,g){h(_,p,g),e(p,M),e(p,f),e(f,T),e(p,$)},d(_){_&&t(p)}}}function Ib(q){let p,M,f,T,$,_,g,z,Q,C,j,R,S,Z,ue,A,me,ce,W,L,ee,te,F,E,se,V,pe,ae,O,fe,he,x,ge,B,U,re,J,_e,oe,N,ie,K,Te;return{c(){p=n("p"),M=a("TF 2.0 models accepts two formats as inputs:"),f=l(),T=n("ul"),$=n("li"),_=a("having all inputs as keyword arguments (like PyTorch models), or"),g=l(),z=n("li"),Q=a("having all inputs as a list, tuple or dict in the first positional arguments."),C=l(),j=n("p"),R=a("This second option is useful when using "),S=n("code"),Z=a("tf.keras.Model.fit"),ue=a(` method which currently requires having all the
tensors in the first argument of the model call function: `),A=n("code"),me=a("model(inputs)"),ce=a("."),W=l(),L=n("p"),ee=a(`If you choose this second option, there are three possibilities you can use to gather all the input Tensors in the
first positional argument :`),te=l(),F=n("ul"),E=n("li"),se=a("a single Tensor with "),V=n("code"),pe=a("input_ids"),ae=a(" only and nothing else: "),O=n("code"),fe=a("model(inputs_ids)"),he=l(),x=n("li"),ge=a(`a list of varying length with one or several input Tensors IN THE ORDER given in the docstring:
`),B=n("code"),U=a("model([input_ids, attention_mask])"),re=a(" or "),J=n("code"),_e=a("model([input_ids, attention_mask, token_type_ids])"),oe=l(),N=n("li"),ie=a(`a dictionary with one or several input Tensors associated to the input names given in the docstring:
`),K=n("code"),Te=a('model({"input_ids": input_ids, "token_type_ids": token_type_ids})')},l(u){p=s(u,"P",{});var G=i(p);M=r(G,"TF 2.0 models accepts two formats as inputs:"),G.forEach(t),f=d(u),T=s(u,"UL",{});var ne=i(T);$=s(ne,"LI",{});var Fe=i($);_=r(Fe,"having all inputs as keyword arguments (like PyTorch models), or"),Fe.forEach(t),g=d(ne),z=s(ne,"LI",{});var Se=i(z);Q=r(Se,"having all inputs as a list, tuple or dict in the first positional arguments."),Se.forEach(t),ne.forEach(t),C=d(u),j=s(u,"P",{});var I=i(j);R=r(I,"This second option is useful when using "),S=s(I,"CODE",{});var xe=i(S);Z=r(xe,"tf.keras.Model.fit"),xe.forEach(t),ue=r(I,` method which currently requires having all the
tensors in the first argument of the model call function: `),A=s(I,"CODE",{});var Ae=i(A);me=r(Ae,"model(inputs)"),Ae.forEach(t),ce=r(I,"."),I.forEach(t),W=d(u),L=s(u,"P",{});var Oe=i(L);ee=r(Oe,`If you choose this second option, there are three possibilities you can use to gather all the input Tensors in the
first positional argument :`),Oe.forEach(t),te=d(u),F=s(u,"UL",{});var D=i(F);E=s(D,"LI",{});var X=i(E);se=r(X,"a single Tensor with "),V=s(X,"CODE",{});var We=i(V);pe=r(We,"input_ids"),We.forEach(t),ae=r(X," only and nothing else: "),O=s(X,"CODE",{});var Ee=i(O);fe=r(Ee,"model(inputs_ids)"),Ee.forEach(t),X.forEach(t),he=d(D),x=s(D,"LI",{});var Y=i(x);ge=r(Y,`a list of varying length with one or several input Tensors IN THE ORDER given in the docstring:
`),B=s(Y,"CODE",{});var Be=i(B);U=r(Be,"model([input_ids, attention_mask])"),Be.forEach(t),re=r(Y," or "),J=s(Y,"CODE",{});var qe=i(J);_e=r(qe,"model([input_ids, attention_mask, token_type_ids])"),qe.forEach(t),Y.forEach(t),oe=d(D),N=s(D,"LI",{});var ve=i(N);ie=r(ve,`a dictionary with one or several input Tensors associated to the input names given in the docstring:
`),K=s(ve,"CODE",{});var Ue=i(K);Te=r(Ue,'model({"input_ids": input_ids, "token_type_ids": token_type_ids})'),Ue.forEach(t),ve.forEach(t),D.forEach(t)},m(u,G){h(u,p,G),e(p,M),h(u,f,G),h(u,T,G),e(T,$),e($,_),e(T,g),e(T,z),e(z,Q),h(u,C,G),h(u,j,G),e(j,R),e(j,S),e(S,Z),e(j,ue),e(j,A),e(A,me),e(j,ce),h(u,W,G),h(u,L,G),e(L,ee),h(u,te,G),h(u,F,G),e(F,E),e(E,se),e(E,V),e(V,pe),e(E,ae),e(E,O),e(O,fe),e(F,he),e(F,x),e(x,ge),e(x,B),e(B,U),e(x,re),e(x,J),e(J,_e),e(F,oe),e(F,N),e(N,ie),e(N,K),e(K,Te)},d(u){u&&t(p),u&&t(f),u&&t(T),u&&t(C),u&&t(j),u&&t(W),u&&t(L),u&&t(te),u&&t(F)}}}function Sb(q){let p,M,f,T,$;return{c(){p=n("p"),M=a("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=n("code"),T=a("Module"),$=a(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(_){p=s(_,"P",{});var g=i(p);M=r(g,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=s(g,"CODE",{});var z=i(f);T=r(z,"Module"),z.forEach(t),$=r(g,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),g.forEach(t)},m(_,g){h(_,p,g),e(p,M),e(p,f),e(f,T),e(p,$)},d(_){_&&t(p)}}}function Ab(q){let p,M,f,T,$;return{c(){p=n("p"),M=a("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=n("code"),T=a("Module"),$=a(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(_){p=s(_,"P",{});var g=i(p);M=r(g,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=s(g,"CODE",{});var z=i(f);T=r(z,"Module"),z.forEach(t),$=r(g,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),g.forEach(t)},m(_,g){h(_,p,g),e(p,M),e(p,f),e(f,T),e(p,$)},d(_){_&&t(p)}}}function Ob(q){let p,M,f,T,$;return{c(){p=n("p"),M=a("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=n("code"),T=a("Module"),$=a(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(_){p=s(_,"P",{});var g=i(p);M=r(g,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=s(g,"CODE",{});var z=i(f);T=r(z,"Module"),z.forEach(t),$=r(g,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),g.forEach(t)},m(_,g){h(_,p,g),e(p,M),e(p,f),e(f,T),e(p,$)},d(_){_&&t(p)}}}function Wb(q){let p,M,f,T,$,_,g,z,Q,C,j,R,S,Z,ue,A,me,ce,W,L,ee,te,F,E,se,V,pe,ae,O,fe,he,x,ge,B,U,re,J,_e,oe,N,ie,K,Te,u,G,ne,Fe,Se,I,xe,Ae,Oe,D,X,We,Ee,Y,Be,qe,ve,Ue,Pa,ac,rc,gr,ic,lc,$a,dc,cc,pc,kt,hc,_r,uc,mc,Tr,fc,gc,dn,_c,Tc,xl,Bt,cn,vc,bc,vr,kc,yc,El,Mt,wc,pn,Pc,$c,hn,Mc,Gc,ql,Ut,wo,br,un,zc,kr,jc,Cl,Re,mn,Fc,yt,xc,Ma,Ec,qc,Ga,Cc,Dc,fn,Hc,Lc,Nc,Rt,Ic,za,Sc,Ac,ja,Oc,Wc,Bc,yr,Uc,Rc,gn,Dl,Vt,Po,wr,_n,Vc,Pr,Jc,Hl,le,Tn,Kc,$r,Xc,Yc,Mr,Qc,Zc,vn,ep,bn,tp,Gr,op,np,sp,$o,ap,kn,rp,Fa,ip,lp,dp,xa,yn,Ll,Jt,Mo,zr,wn,cp,jr,pp,Nl,be,Pn,hp,$n,up,Fr,mp,fp,gp,xr,_p,Tp,Mn,vp,Gn,bp,Er,kp,yp,wp,Go,Pp,zn,$p,Ea,Mp,Gp,Il,Kt,zo,qr,jn,zp,Cr,jp,Sl,Xt,Fn,Fp,Dr,xp,Al,Yt,xn,Ep,Hr,qp,Ol,Qt,jo,Lr,En,Cp,Nr,Dp,Wl,ke,qn,Hp,Ir,Lp,Np,Cn,Ip,qa,Sp,Ap,Op,Dn,Wp,Hn,Bp,Up,Rp,Ke,Ln,Vp,Zt,Jp,Ca,Kp,Xp,Sr,Yp,Qp,Zp,Fo,eh,Ar,th,oh,Nn,nh,Xe,In,sh,Or,ah,rh,Wr,ih,lh,Br,dh,ch,Sn,ph,gt,An,hh,Ur,uh,mh,Rr,fh,gh,On,Bl,eo,xo,Vr,Wn,_h,Jr,Th,Ul,ye,Bn,vh,Kr,bh,kh,Un,yh,Da,wh,Ph,$h,Rn,Mh,Vn,Gh,zh,jh,Ye,Jn,Fh,to,xh,Ha,Eh,qh,Xr,Ch,Dh,Hh,Eo,Lh,Yr,Nh,Ih,Kn,Sh,Qe,Xn,Ah,Qr,Oh,Wh,Zr,Bh,Uh,ei,Rh,Vh,Yn,Jh,_t,Qn,Kh,ti,Xh,Yh,oi,Qh,Zh,Zn,Rl,oo,qo,ni,es,eu,si,tu,Vl,Ve,ts,ou,ai,nu,su,os,au,La,ru,iu,lu,ns,du,ss,cu,pu,hu,Ze,as,uu,no,mu,Na,fu,gu,ri,_u,Tu,vu,Co,bu,ii,ku,yu,rs,Jl,so,Do,li,is,wu,di,Pu,Kl,we,ls,$u,ci,Mu,Gu,Ia,Sa,zu,ju,Fu,mt,xu,pi,Eu,qu,hi,Cu,Du,ui,Hu,Lu,mi,Nu,Iu,Su,ds,Au,Aa,Ou,Wu,Bu,cs,Uu,ps,Ru,Vu,Ju,Ge,hs,Ku,ao,Xu,Oa,Yu,Qu,fi,Zu,em,tm,Ho,om,gi,nm,sm,us,am,_i,rm,im,ms,Xl,ro,Lo,Ti,fs,lm,vi,dm,Yl,Je,gs,cm,bi,pm,hm,_s,um,Wa,mm,fm,gm,Ts,_m,vs,Tm,vm,bm,et,bs,km,io,ym,Ba,wm,Pm,ki,$m,Mm,Gm,No,zm,yi,jm,Fm,ks,Ql,lo,Io,wi,ys,xm,Pi,Em,Zl,Ce,ws,qm,$i,Cm,Dm,Ps,Hm,Ua,Lm,Nm,Im,$s,Sm,Ms,Am,Om,Wm,So,Bm,tt,Gs,Um,co,Rm,Ra,Vm,Jm,Mi,Km,Xm,Ym,Ao,Qm,Gi,Zm,ef,zs,ed,po,Oo,zi,js,tf,ji,of,td,De,Fs,nf,Fi,sf,af,xs,rf,Va,lf,df,cf,Es,pf,qs,hf,uf,mf,Wo,ff,ot,Cs,gf,ho,_f,Ja,Tf,vf,xi,bf,kf,yf,Bo,wf,Ei,Pf,$f,Ds,od,uo,Uo,qi,Hs,Mf,Ci,Gf,nd,He,Ls,zf,Di,jf,Ff,Ns,xf,Ka,Ef,qf,Cf,Is,Df,Ss,Hf,Lf,Nf,Ro,If,nt,As,Sf,mo,Af,Xa,Of,Wf,Hi,Bf,Uf,Rf,Vo,Vf,Li,Jf,Kf,Os,sd,fo,Jo,Ni,Ws,Xf,Ii,Yf,ad,de,Bs,Qf,Si,Zf,eg,Ya,Qa,tg,og,ng,ft,sg,Ai,ag,rg,Oi,ig,lg,Wi,dg,cg,Bi,pg,hg,ug,Us,mg,Za,fg,gg,_g,Rs,Tg,Vs,vg,bg,kg,Ko,yg,st,Js,wg,go,Pg,er,$g,Mg,Ui,Gg,zg,jg,Xo,Fg,Ri,xg,Eg,Ks,rd,_o,Yo,Vi,Xs,qg,Ji,Cg,id,To,Ys,Dg,Ki,Hg,ld,vo,Qo,Xi,Qs,Lg,Yi,Ng,dd,Pe,Zs,Ig,Qi,Sg,Ag,ea,Og,tr,Wg,Bg,Ug,ta,Rg,oa,Vg,Jg,Kg,Zi,Xg,Yg,wt,el,na,Qg,Zg,tl,sa,e_,t_,ol,aa,o_,n_,nl,ra,s_,a_,at,ia,r_,bo,i_,sl,l_,d_,al,c_,p_,h_,Zo,u_,rl,m_,f_,la,cd,ko,en,il,da,g_,ll,__,pd,$e,ca,T_,dl,v_,b_,pa,k_,or,y_,w_,P_,ha,$_,ua,M_,G_,z_,cl,j_,F_,Pt,pl,ma,x_,E_,hl,fa,q_,C_,ul,ga,D_,H_,ml,_a,L_,N_,rt,Ta,I_,yo,S_,fl,A_,O_,gl,W_,B_,U_,tn,R_,_l,V_,J_,va,hd;return _=new je({}),Z=new je({}),un=new je({}),mn=new H({props:{name:"class transformers.GPT2Config",anchor:"transformers.GPT2Config",parameters:[{name:"vocab_size",val:" = 50257"},{name:"n_positions",val:" = 1024"},{name:"n_embd",val:" = 768"},{name:"n_layer",val:" = 12"},{name:"n_head",val:" = 12"},{name:"n_inner",val:" = None"},{name:"activation_function",val:" = 'gelu_new'"},{name:"resid_pdrop",val:" = 0.1"},{name:"embd_pdrop",val:" = 0.1"},{name:"attn_pdrop",val:" = 0.1"},{name:"layer_norm_epsilon",val:" = 1e-05"},{name:"initializer_range",val:" = 0.02"},{name:"summary_type",val:" = 'cls_index'"},{name:"summary_use_proj",val:" = True"},{name:"summary_activation",val:" = None"},{name:"summary_proj_to_labels",val:" = True"},{name:"summary_first_dropout",val:" = 0.1"},{name:"scale_attn_weights",val:" = True"},{name:"use_cache",val:" = True"},{name:"bos_token_id",val:" = 50256"},{name:"eos_token_id",val:" = 50256"},{name:"scale_attn_by_inverse_layer_idx",val:" = False"},{name:"reorder_and_upcast_attn",val:" = False"},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/gpt2/configuration_gpt2.py#L38",parametersDescription:[{anchor:"transformers.GPT2Config.vocab_size",description:`<strong>vocab_size</strong> (<code>int</code>, <em>optional</em>, defaults to 50257) &#x2014;
Vocabulary size of the GPT-2 model. Defines the number of different tokens that can be represented by the
<code>inputs_ids</code> passed when calling <a href="/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.GPT2Model">GPT2Model</a> or <a href="/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.TFGPT2Model">TFGPT2Model</a>.`,name:"vocab_size"},{anchor:"transformers.GPT2Config.n_positions",description:`<strong>n_positions</strong> (<code>int</code>, <em>optional</em>, defaults to 1024) &#x2014;
The maximum sequence length that this model might ever be used with. Typically set this to something large
just in case (e.g., 512 or 1024 or 2048).`,name:"n_positions"},{anchor:"transformers.GPT2Config.n_embd",description:`<strong>n_embd</strong> (<code>int</code>, <em>optional</em>, defaults to 768) &#x2014;
Dimensionality of the embeddings and hidden states.`,name:"n_embd"},{anchor:"transformers.GPT2Config.n_layer",description:`<strong>n_layer</strong> (<code>int</code>, <em>optional</em>, defaults to 12) &#x2014;
Number of hidden layers in the Transformer encoder.`,name:"n_layer"},{anchor:"transformers.GPT2Config.n_head",description:`<strong>n_head</strong> (<code>int</code>, <em>optional</em>, defaults to 12) &#x2014;
Number of attention heads for each attention layer in the Transformer encoder.`,name:"n_head"},{anchor:"transformers.GPT2Config.n_inner",description:`<strong>n_inner</strong> (<code>int</code>, <em>optional</em>, defaults to None) &#x2014;
Dimensionality of the inner feed-forward layers. <code>None</code> will set it to 4 times n_embd`,name:"n_inner"},{anchor:"transformers.GPT2Config.activation_function",description:`<strong>activation_function</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;gelu&quot;</code>) &#x2014;
Activation function, to be selected in the list <code>[&quot;relu&quot;, &quot;silu&quot;, &quot;gelu&quot;, &quot;tanh&quot;, &quot;gelu_new&quot;]</code>.`,name:"activation_function"},{anchor:"transformers.GPT2Config.resid_pdrop",description:`<strong>resid_pdrop</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) &#x2014;
The dropout probability for all fully connected layers in the embeddings, encoder, and pooler.`,name:"resid_pdrop"},{anchor:"transformers.GPT2Config.embd_pdrop",description:`<strong>embd_pdrop</strong> (<code>int</code>, <em>optional</em>, defaults to 0.1) &#x2014;
The dropout ratio for the embeddings.`,name:"embd_pdrop"},{anchor:"transformers.GPT2Config.attn_pdrop",description:`<strong>attn_pdrop</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) &#x2014;
The dropout ratio for the attention.`,name:"attn_pdrop"},{anchor:"transformers.GPT2Config.layer_norm_epsilon",description:`<strong>layer_norm_epsilon</strong> (<code>float</code>, <em>optional</em>, defaults to 1e-5) &#x2014;
The epsilon to use in the layer normalization layers.`,name:"layer_norm_epsilon"},{anchor:"transformers.GPT2Config.initializer_range",description:`<strong>initializer_range</strong> (<code>float</code>, <em>optional</em>, defaults to 0.02) &#x2014;
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.`,name:"initializer_range"},{anchor:"transformers.GPT2Config.summary_type",description:`<strong>summary_type</strong> (<code>string</code>, <em>optional</em>, defaults to <code>&quot;cls_index&quot;</code>) &#x2014;
Argument used when doing sequence summary, used in the models <a href="/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.GPT2DoubleHeadsModel">GPT2DoubleHeadsModel</a> and
<a href="/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.TFGPT2DoubleHeadsModel">TFGPT2DoubleHeadsModel</a>.</p>
<p>Has to be one of the following options:</p>
<ul>
<li><code>&quot;last&quot;</code>: Take the last token hidden state (like XLNet).</li>
<li><code>&quot;first&quot;</code>: Take the first token hidden state (like BERT).</li>
<li><code>&quot;mean&quot;</code>: Take the mean of all tokens hidden states.</li>
<li><code>&quot;cls_index&quot;</code>: Supply a Tensor of classification token position (like GPT/GPT-2).</li>
<li><code>&quot;attn&quot;</code>: Not implemented now, use multi-head attention.</li>
</ul>`,name:"summary_type"},{anchor:"transformers.GPT2Config.summary_use_proj",description:`<strong>summary_use_proj</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Argument used when doing sequence summary, used in the models <a href="/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.GPT2DoubleHeadsModel">GPT2DoubleHeadsModel</a> and
<a href="/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.TFGPT2DoubleHeadsModel">TFGPT2DoubleHeadsModel</a>.</p>
<p>Whether or not to add a projection after the vector extraction.`,name:"summary_use_proj"},{anchor:"transformers.GPT2Config.summary_activation",description:`<strong>summary_activation</strong> (<code>str</code>, <em>optional</em>) &#x2014;
Argument used when doing sequence summary. Used in for the multiple choice head in
<a href="/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.GPT2DoubleHeadsModel">GPT2DoubleHeadsModel</a>.</p>
<p>Pass <code>&quot;tanh&quot;</code> for a tanh activation to the output, any other value will result in no activation.`,name:"summary_activation"},{anchor:"transformers.GPT2Config.summary_proj_to_labels",description:`<strong>summary_proj_to_labels</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Argument used when doing sequence summary, used in the models <a href="/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.GPT2DoubleHeadsModel">GPT2DoubleHeadsModel</a> and
<a href="/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.TFGPT2DoubleHeadsModel">TFGPT2DoubleHeadsModel</a>.</p>
<p>Whether the projection outputs should have <code>config.num_labels</code> or <code>config.hidden_size</code> classes.`,name:"summary_proj_to_labels"},{anchor:"transformers.GPT2Config.summary_first_dropout",description:`<strong>summary_first_dropout</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) &#x2014;
Argument used when doing sequence summary, used in the models <a href="/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.GPT2DoubleHeadsModel">GPT2DoubleHeadsModel</a> and
<a href="/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.TFGPT2DoubleHeadsModel">TFGPT2DoubleHeadsModel</a>.</p>
<p>The dropout ratio to be used after the projection and activation.`,name:"summary_first_dropout"},{anchor:"transformers.GPT2Config.scale_attn_weights",description:`<strong>scale_attn_weights</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Scale attention weights by dividing by sqrt(hidden_size)..`,name:"scale_attn_weights"},{anchor:"transformers.GPT2Config.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not the model should return the last key/values attentions (not used by all models).`,name:"use_cache"},{anchor:"transformers.GPT2Config.scale_attn_by_inverse_layer_idx",description:`<strong>scale_attn_by_inverse_layer_idx</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to additionally scale attention weights by <code>1 / layer_idx + 1</code>.`,name:"scale_attn_by_inverse_layer_idx"},{anchor:"transformers.GPT2Config.reorder_and_upcast_attn",description:`<strong>reorder_and_upcast_attn</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to scale keys (K) prior to computing attention (dot-product) and upcast attention
dot-product/softmax to float() when training with mixed precision.`,name:"reorder_and_upcast_attn"}]}}),gn=new Me({props:{code:`from transformers import GPT2Model, GPT2Config

# Initializing a GPT2 configuration
configuration = GPT2Config()

# Initializing a model from the configuration
model = GPT2Model(configuration)

# Accessing the model configuration
configuration = model.config`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> GPT2Model, GPT2Config

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a GPT2 configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = GPT2Config()

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a model from the configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = GPT2Model(configuration)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Accessing the model configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = model.config`}}),_n=new je({}),Tn=new H({props:{name:"class transformers.GPT2Tokenizer",anchor:"transformers.GPT2Tokenizer",parameters:[{name:"vocab_file",val:""},{name:"merges_file",val:""},{name:"errors",val:" = 'replace'"},{name:"unk_token",val:" = '<|endoftext|>'"},{name:"bos_token",val:" = '<|endoftext|>'"},{name:"eos_token",val:" = '<|endoftext|>'"},{name:"add_prefix_space",val:" = False"},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/gpt2/tokenization_gpt2.py#L104",parametersDescription:[{anchor:"transformers.GPT2Tokenizer.vocab_file",description:`<strong>vocab_file</strong> (<code>str</code>) &#x2014;
Path to the vocabulary file.`,name:"vocab_file"},{anchor:"transformers.GPT2Tokenizer.merges_file",description:`<strong>merges_file</strong> (<code>str</code>) &#x2014;
Path to the merges file.`,name:"merges_file"},{anchor:"transformers.GPT2Tokenizer.errors",description:`<strong>errors</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;replace&quot;</code>) &#x2014;
Paradigm to follow when decoding bytes to UTF-8. See
<a href="https://docs.python.org/3/library/stdtypes.html#bytes.decode" rel="nofollow">bytes.decode</a> for more information.`,name:"errors"},{anchor:"transformers.GPT2Tokenizer.unk_token",description:`<strong>unk_token</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&lt;|endoftext|&gt;</code>) &#x2014;
The unknown token. A token that is not in the vocabulary cannot be converted to an ID and is set to be this
token instead.`,name:"unk_token"},{anchor:"transformers.GPT2Tokenizer.bos_token",description:`<strong>bos_token</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&lt;|endoftext|&gt;</code>) &#x2014;
The beginning of sequence token.`,name:"bos_token"},{anchor:"transformers.GPT2Tokenizer.eos_token",description:`<strong>eos_token</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&lt;|endoftext|&gt;</code>) &#x2014;
The end of sequence token.`,name:"eos_token"},{anchor:"transformers.GPT2Tokenizer.add_prefix_space",description:`<strong>add_prefix_space</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to add an initial space to the input. This allows to treat the leading word just as any
other word. (GPT2 tokenizer detect beginning of words by the preceding space).`,name:"add_prefix_space"}]}}),vn=new Me({props:{code:`from transformers import GPT2Tokenizer
tokenizer = GPT2Tokenizer.from_pretrained("gpt2")
tokenizer("Hello world")['input_ids']
tokenizer(" Hello world")['input_ids']`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt;</span> <span class="language-python"><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> GPT2Tokenizer</span>
<span class="hljs-meta">&gt;&gt;&gt;</span> <span class="language-python">tokenizer = GPT2Tokenizer.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)</span>
<span class="hljs-meta">&gt;&gt;&gt;</span> <span class="language-python">tokenizer(<span class="hljs-string">&quot;Hello world&quot;</span>)[<span class="hljs-string">&#x27;input_ids&#x27;</span>]</span>
[15496, 995]
<span class="hljs-meta">&gt;&gt;&gt;</span> <span class="language-python">tokenizer(<span class="hljs-string">&quot; Hello world&quot;</span>)[<span class="hljs-string">&#x27;input_ids&#x27;</span>]</span>
[18435, 995]`}}),$o=new Le({props:{$$slots:{default:[Mb]},$$scope:{ctx:q}}}),yn=new H({props:{name:"save_vocabulary",anchor:"transformers.GPT2Tokenizer.save_vocabulary",parameters:[{name:"save_directory",val:": str"},{name:"filename_prefix",val:": typing.Optional[str] = None"}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/gpt2/tokenization_gpt2.py#L269"}}),wn=new je({}),Pn=new H({props:{name:"class transformers.GPT2TokenizerFast",anchor:"transformers.GPT2TokenizerFast",parameters:[{name:"vocab_file",val:" = None"},{name:"merges_file",val:" = None"},{name:"tokenizer_file",val:" = None"},{name:"unk_token",val:" = '<|endoftext|>'"},{name:"bos_token",val:" = '<|endoftext|>'"},{name:"eos_token",val:" = '<|endoftext|>'"},{name:"add_prefix_space",val:" = False"},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/gpt2/tokenization_gpt2_fast.py#L70",parametersDescription:[{anchor:"transformers.GPT2TokenizerFast.vocab_file",description:`<strong>vocab_file</strong> (<code>str</code>) &#x2014;
Path to the vocabulary file.`,name:"vocab_file"},{anchor:"transformers.GPT2TokenizerFast.merges_file",description:`<strong>merges_file</strong> (<code>str</code>) &#x2014;
Path to the merges file.`,name:"merges_file"},{anchor:"transformers.GPT2TokenizerFast.errors",description:`<strong>errors</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;replace&quot;</code>) &#x2014;
Paradigm to follow when decoding bytes to UTF-8. See
<a href="https://docs.python.org/3/library/stdtypes.html#bytes.decode" rel="nofollow">bytes.decode</a> for more information.`,name:"errors"},{anchor:"transformers.GPT2TokenizerFast.unk_token",description:`<strong>unk_token</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&lt;|endoftext|&gt;</code>) &#x2014;
The unknown token. A token that is not in the vocabulary cannot be converted to an ID and is set to be this
token instead.`,name:"unk_token"},{anchor:"transformers.GPT2TokenizerFast.bos_token",description:`<strong>bos_token</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&lt;|endoftext|&gt;</code>) &#x2014;
The beginning of sequence token.`,name:"bos_token"},{anchor:"transformers.GPT2TokenizerFast.eos_token",description:`<strong>eos_token</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&lt;|endoftext|&gt;</code>) &#x2014;
The end of sequence token.`,name:"eos_token"},{anchor:"transformers.GPT2TokenizerFast.add_prefix_space",description:`<strong>add_prefix_space</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to add an initial space to the input. This allows to treat the leading word just as any
other word. (GPT2 tokenizer detect beginning of words by the preceding space).`,name:"add_prefix_space"},{anchor:"transformers.GPT2TokenizerFast.trim_offsets",description:`<strong>trim_offsets</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not the post-processing step should trim offsets to avoid including whitespaces.`,name:"trim_offsets"}]}}),Mn=new Me({props:{code:`from transformers import GPT2TokenizerFast
tokenizer = GPT2TokenizerFast.from_pretrained("gpt2")
tokenizer("Hello world")['input_ids']
tokenizer(" Hello world")['input_ids']`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt;</span> <span class="language-python"><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> GPT2TokenizerFast</span>
<span class="hljs-meta">&gt;&gt;&gt;</span> <span class="language-python">tokenizer = GPT2TokenizerFast.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)</span>
<span class="hljs-meta">&gt;&gt;&gt;</span> <span class="language-python">tokenizer(<span class="hljs-string">&quot;Hello world&quot;</span>)[<span class="hljs-string">&#x27;input_ids&#x27;</span>]</span>
[15496, 995]
<span class="hljs-meta">&gt;&gt;&gt;</span> <span class="language-python">tokenizer(<span class="hljs-string">&quot; Hello world&quot;</span>)[<span class="hljs-string">&#x27;input_ids&#x27;</span>]</span>
[18435, 995]`}}),Go=new Le({props:{$$slots:{default:[Gb]},$$scope:{ctx:q}}}),jn=new je({}),Fn=new H({props:{name:"class transformers.models.gpt2.modeling_gpt2.GPT2DoubleHeadsModelOutput",anchor:"transformers.models.gpt2.modeling_gpt2.GPT2DoubleHeadsModelOutput",parameters:[{name:"loss",val:": typing.Optional[torch.FloatTensor] = None"},{name:"mc_loss",val:": typing.Optional[torch.FloatTensor] = None"},{name:"logits",val:": FloatTensor = None"},{name:"mc_logits",val:": FloatTensor = None"},{name:"past_key_values",val:": typing.Optional[typing.Tuple[typing.Tuple[torch.FloatTensor]]] = None"},{name:"hidden_states",val:": typing.Optional[typing.Tuple[torch.FloatTensor]] = None"},{name:"attentions",val:": typing.Optional[typing.Tuple[torch.FloatTensor]] = None"}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/gpt2/modeling_gpt2.py#L492",parametersDescription:[{anchor:"transformers.models.gpt2.modeling_gpt2.GPT2DoubleHeadsModelOutput.loss",description:`<strong>loss</strong> (<code>torch.FloatTensor</code> of shape <code>(1,)</code>, <em>optional</em>, returned when <code>labels</code> is provided) &#x2014;
Language modeling loss.`,name:"loss"},{anchor:"transformers.models.gpt2.modeling_gpt2.GPT2DoubleHeadsModelOutput.mc_loss",description:`<strong>mc_loss</strong> (<code>torch.FloatTensor</code> of shape <code>(1,)</code>, <em>optional</em>, returned when <code>mc_labels</code> is provided) &#x2014;
Multiple choice classification loss.`,name:"mc_loss"},{anchor:"transformers.models.gpt2.modeling_gpt2.GPT2DoubleHeadsModelOutput.logits",description:`<strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_choices, sequence_length, config.vocab_size)</code>) &#x2014;
Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).`,name:"logits"},{anchor:"transformers.models.gpt2.modeling_gpt2.GPT2DoubleHeadsModelOutput.mc_logits",description:`<strong>mc_logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_choices)</code>) &#x2014;
Prediction scores of the multiple choice classification head (scores for each choice before SoftMax).`,name:"mc_logits"},{anchor:"transformers.models.gpt2.modeling_gpt2.GPT2DoubleHeadsModelOutput.past_key_values",description:`<strong>past_key_values</strong> (<code>Tuple[Tuple[torch.Tensor]]</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) &#x2014;
Tuple of length <code>config.n_layers</code>, containing tuples of tensors of shape <code>(batch_size, num_heads, sequence_length, embed_size_per_head)</code>).</p>
<p>Contains pre-computed hidden-states (key and values in the attention blocks) that can be used (see
<code>past_key_values</code> input) to speed up sequential decoding.`,name:"past_key_values"},{anchor:"transformers.models.gpt2.modeling_gpt2.GPT2DoubleHeadsModelOutput.hidden_states",description:`<strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) &#x2014;
Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings + one for the output of each layer) of
shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the initial embedding outputs.`,name:"hidden_states"},{anchor:"transformers.models.gpt2.modeling_gpt2.GPT2DoubleHeadsModelOutput.attentions",description:`<strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) &#x2014;
Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>GPT2Attentions weights after the attention softmax, used to compute the weighted average in the
self-attention heads.`,name:"attentions"}]}}),xn=new H({props:{name:"class transformers.models.gpt2.modeling_tf_gpt2.TFGPT2DoubleHeadsModelOutput",anchor:"transformers.models.gpt2.modeling_tf_gpt2.TFGPT2DoubleHeadsModelOutput",parameters:[{name:"logits",val:": Tensor = None"},{name:"mc_logits",val:": Tensor = None"},{name:"past_key_values",val:": typing.Optional[typing.List[tensorflow.python.framework.ops.Tensor]] = None"},{name:"hidden_states",val:": typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None"},{name:"attentions",val:": typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None"}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/gpt2/modeling_tf_gpt2.py#L588",parametersDescription:[{anchor:"transformers.models.gpt2.modeling_tf_gpt2.TFGPT2DoubleHeadsModelOutput.logits",description:`<strong>logits</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, num_choices, sequence_length, config.vocab_size)</code>) &#x2014;
Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).`,name:"logits"},{anchor:"transformers.models.gpt2.modeling_tf_gpt2.TFGPT2DoubleHeadsModelOutput.mc_logits",description:`<strong>mc_logits</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, num_choices)</code>) &#x2014;
Prediction scores of the multiple choice classification head (scores for each choice before SoftMax).`,name:"mc_logits"},{anchor:"transformers.models.gpt2.modeling_tf_gpt2.TFGPT2DoubleHeadsModelOutput.past_key_values",description:`<strong>past_key_values</strong> (<code>List[tf.Tensor]</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) &#x2014;
List of <code>tf.Tensor</code> of length <code>config.n_layers</code>, with each tensor of shape <code>(2, batch_size, num_heads, sequence_length, embed_size_per_head)</code>).</p>
<p>Contains pre-computed hidden-states (key and values in the attention blocks) that can be used (see
<code>past_key_values</code> input) to speed up sequential decoding.`,name:"past_key_values"},{anchor:"transformers.models.gpt2.modeling_tf_gpt2.TFGPT2DoubleHeadsModelOutput.hidden_states",description:`<strong>hidden_states</strong> (<code>tuple(tf.Tensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) &#x2014;
Tuple of <code>tf.Tensor</code> (one for the output of the embeddings + one for the output of each layer) of shape
<code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the initial embedding outputs.`,name:"hidden_states"},{anchor:"transformers.models.gpt2.modeling_tf_gpt2.TFGPT2DoubleHeadsModelOutput.attentions",description:`<strong>attentions</strong> (<code>tuple(tf.Tensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) &#x2014;
Tuple of <code>tf.Tensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.`,name:"attentions"}]}}),En=new je({}),qn=new H({props:{name:"class transformers.GPT2Model",anchor:"transformers.GPT2Model",parameters:[{name:"config",val:""}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/gpt2/modeling_gpt2.py#L668",parametersDescription:[{anchor:"transformers.GPT2Model.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.GPT2Config">GPT2Config</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/pr_15839/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}]}}),Ln=new H({props:{name:"forward",anchor:"transformers.GPT2Model.forward",parameters:[{name:"input_ids",val:" = None"},{name:"past_key_values",val:" = None"},{name:"attention_mask",val:" = None"},{name:"token_type_ids",val:" = None"},{name:"position_ids",val:" = None"},{name:"head_mask",val:" = None"},{name:"inputs_embeds",val:" = None"},{name:"encoder_hidden_states",val:" = None"},{name:"encoder_attention_mask",val:" = None"},{name:"use_cache",val:" = None"},{name:"output_attentions",val:" = None"},{name:"output_hidden_states",val:" = None"},{name:"return_dict",val:" = None"}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/gpt2/modeling_gpt2.py#L737",parametersDescription:[{anchor:"transformers.GPT2Model.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, input_ids_length)</code>) &#x2014;
<code>input_ids_length</code> = <code>sequence_length</code> if <code>past_key_values</code> is <code>None</code> else
<code>past_key_values[0][0].shape[-2]</code> (<code>sequence_length</code> of input past key value states). Indices of input
sequence tokens in the vocabulary.</p>
<p>If <code>past_key_values</code> is used, only <code>input_ids</code> that do not have their past calculated should be passed as
<code>input_ids</code>.</p>
<p>Indices can be obtained using <a href="/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.GPT2Tokenizer">GPT2Tokenizer</a>. See <a href="/docs/transformers/pr_15839/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/pr_15839/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.GPT2Model.forward.past_key_values",description:`<strong>past_key_values</strong> (<code>Tuple[Tuple[torch.Tensor]]</code> of length <code>config.n_layers</code>) &#x2014;
Contains precomputed hidden-states (key and values in the attention blocks) as computed by the model (see
<code>past_key_values</code> output below). Can be used to speed up sequential decoding. The <code>input_ids</code> which have
their past given to this model should not be passed as <code>input_ids</code> as they have already been computed.`,name:"past_key_values"},{anchor:"transformers.GPT2Model.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.GPT2Model.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, input_ids_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.GPT2Model.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.max_position_embeddings - 1]</code>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.GPT2Model.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.GPT2Model.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.</p>
<p>If <code>past_key_values</code> is used, optionally only the last <code>inputs_embeds</code> have to be input (see
<code>past_key_values</code>).`,name:"inputs_embeds"},{anchor:"transformers.GPT2Model.forward.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
If set to <code>True</code>, <code>past_key_values</code> key value states are returned and can be used to speed up decoding (see
<code>past_key_values</code>).`,name:"use_cache"},{anchor:"transformers.GPT2Model.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.GPT2Model.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.GPT2Model.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/pr_15839/en/main_classes/output#transformers.file_utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],returnDescription:`
<p>A <a
  href="/docs/transformers/pr_15839/en/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPastAndCrossAttentions"
>transformers.modeling_outputs.BaseModelOutputWithPastAndCrossAttentions</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.GPT2Config"
>GPT2Config</a>) and inputs.</p>
<ul>
<li>
<p><strong>last_hidden_state</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>) \u2014 Sequence of hidden-states at the output of the last layer of the model.</p>
<p>If <code>past_key_values</code> is used only the last hidden-state of the sequences of shape <code>(batch_size, 1, hidden_size)</code> is output.</p>
</li>
<li>
<p><strong>past_key_values</strong> (<code>tuple(tuple(torch.FloatTensor))</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) \u2014 Tuple of <code>tuple(torch.FloatTensor)</code> of length <code>config.n_layers</code>, with each tuple having 2 tensors of shape
<code>(batch_size, num_heads, sequence_length, embed_size_per_head)</code>) and optionally if
<code>config.is_encoder_decoder=True</code> 2 additional tensors of shape <code>(batch_size, num_heads, encoder_sequence_length, embed_size_per_head)</code>.</p>
<p>Contains pre-computed hidden-states (key and values in the self-attention blocks and optionally if
<code>config.is_encoder_decoder=True</code> in the cross-attention blocks) that can be used (see <code>past_key_values</code>
input) to speed up sequential decoding.</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings + one for the output of each layer) of
shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
<li>
<p><strong>cross_attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> and <code>config.add_cross_attention=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights of the decoder\u2019s cross-attention layer, after the attention softmax, used to compute the
weighted average in the cross-attention heads.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/pr_15839/en/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPastAndCrossAttentions"
>transformers.modeling_outputs.BaseModelOutputWithPastAndCrossAttentions</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Fo=new Le({props:{$$slots:{default:[zb]},$$scope:{ctx:q}}}),Nn=new Me({props:{code:`from transformers import GPT2Tokenizer, GPT2Model
import torch

tokenizer = GPT2Tokenizer.from_pretrained("gpt2")
model = GPT2Model.from_pretrained("gpt2")

inputs = tokenizer("Hello, my dog is cute", return_tensors="pt")
outputs = model(**inputs)

last_hidden_states = outputs.last_hidden_state`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> GPT2Tokenizer, GPT2Model
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = GPT2Tokenizer.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = GPT2Model.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(<span class="hljs-string">&quot;Hello, my dog is cute&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**inputs)

<span class="hljs-meta">&gt;&gt;&gt; </span>last_hidden_states = outputs.last_hidden_state`}}),In=new H({props:{name:"parallelize",anchor:"transformers.GPT2Model.parallelize",parameters:[{name:"device_map",val:" = None"}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/gpt2/modeling_gpt2.py#L691",parametersDescription:[{anchor:"transformers.GPT2Model.parallelize.device_map",description:`<strong>device_map</strong> (<code>Dict[int, list]</code>, optional, defaults to None) &#x2014;
A dictionary that maps attention modules to devices. Note that the embedding module and LMHead are always
automatically mapped to the first device (for esoteric reasons). That means that the first device should
have fewer attention modules mapped to it than other devices. For reference, the gpt2 models have the
following number of attention modules:</p>
<ul>
<li>gpt2: 12</li>
<li>gpt2-medium: 24</li>
<li>gpt2-large: 36</li>
<li>gpt2-xl: 48</li>
</ul>`,name:"device_map"}]}}),Sn=new Me({props:{code:`# Here is an example of a device map on a machine with 4 GPUs using gpt2-xl, which has a total of 48 attention modules:
model = GPT2LMHeadModel.from_pretrained("gpt2-xl")
device_map = {
    0: [0, 1, 2, 3, 4, 5, 6, 7, 8],
    1: [9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21],
    2: [22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34],
    3: [35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47],
}
model.parallelize(device_map)`,highlighted:`<span class="hljs-comment"># Here is an example of a device map on a machine with 4 GPUs using gpt2-xl, which has a total of 48 attention modules:</span>
model = GPT2LMHeadModel.from_pretrained(<span class="hljs-string">&quot;gpt2-xl&quot;</span>)
device_map = {
    <span class="hljs-number">0</span>: [<span class="hljs-number">0</span>, <span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">5</span>, <span class="hljs-number">6</span>, <span class="hljs-number">7</span>, <span class="hljs-number">8</span>],
    <span class="hljs-number">1</span>: [<span class="hljs-number">9</span>, <span class="hljs-number">10</span>, <span class="hljs-number">11</span>, <span class="hljs-number">12</span>, <span class="hljs-number">13</span>, <span class="hljs-number">14</span>, <span class="hljs-number">15</span>, <span class="hljs-number">16</span>, <span class="hljs-number">17</span>, <span class="hljs-number">18</span>, <span class="hljs-number">19</span>, <span class="hljs-number">20</span>, <span class="hljs-number">21</span>],
    <span class="hljs-number">2</span>: [<span class="hljs-number">22</span>, <span class="hljs-number">23</span>, <span class="hljs-number">24</span>, <span class="hljs-number">25</span>, <span class="hljs-number">26</span>, <span class="hljs-number">27</span>, <span class="hljs-number">28</span>, <span class="hljs-number">29</span>, <span class="hljs-number">30</span>, <span class="hljs-number">31</span>, <span class="hljs-number">32</span>, <span class="hljs-number">33</span>, <span class="hljs-number">34</span>],
    <span class="hljs-number">3</span>: [<span class="hljs-number">35</span>, <span class="hljs-number">36</span>, <span class="hljs-number">37</span>, <span class="hljs-number">38</span>, <span class="hljs-number">39</span>, <span class="hljs-number">40</span>, <span class="hljs-number">41</span>, <span class="hljs-number">42</span>, <span class="hljs-number">43</span>, <span class="hljs-number">44</span>, <span class="hljs-number">45</span>, <span class="hljs-number">46</span>, <span class="hljs-number">47</span>],
}
model.parallelize(device_map)`}}),An=new H({props:{name:"deparallelize",anchor:"transformers.GPT2Model.deparallelize",parameters:[],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/gpt2/modeling_gpt2.py#L711"}}),On=new Me({props:{code:`# On a 4 GPU machine with gpt2-large:
model = GPT2LMHeadModel.from_pretrained("gpt2-large")
device_map = {
    0: [0, 1, 2, 3, 4, 5, 6, 7],
    1: [8, 9, 10, 11, 12, 13, 14, 15],
    2: [16, 17, 18, 19, 20, 21, 22, 23],
    3: [24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35],
}
model.parallelize(device_map)  # Splits the model across several devices
model.deparallelize()  # Put the model back on cpu and cleans memory by calling torch.cuda.empty_cache()`,highlighted:`<span class="hljs-comment"># On a 4 GPU machine with gpt2-large:</span>
model = GPT2LMHeadModel.from_pretrained(<span class="hljs-string">&quot;gpt2-large&quot;</span>)
device_map = {
    <span class="hljs-number">0</span>: [<span class="hljs-number">0</span>, <span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">5</span>, <span class="hljs-number">6</span>, <span class="hljs-number">7</span>],
    <span class="hljs-number">1</span>: [<span class="hljs-number">8</span>, <span class="hljs-number">9</span>, <span class="hljs-number">10</span>, <span class="hljs-number">11</span>, <span class="hljs-number">12</span>, <span class="hljs-number">13</span>, <span class="hljs-number">14</span>, <span class="hljs-number">15</span>],
    <span class="hljs-number">2</span>: [<span class="hljs-number">16</span>, <span class="hljs-number">17</span>, <span class="hljs-number">18</span>, <span class="hljs-number">19</span>, <span class="hljs-number">20</span>, <span class="hljs-number">21</span>, <span class="hljs-number">22</span>, <span class="hljs-number">23</span>],
    <span class="hljs-number">3</span>: [<span class="hljs-number">24</span>, <span class="hljs-number">25</span>, <span class="hljs-number">26</span>, <span class="hljs-number">27</span>, <span class="hljs-number">28</span>, <span class="hljs-number">29</span>, <span class="hljs-number">30</span>, <span class="hljs-number">31</span>, <span class="hljs-number">32</span>, <span class="hljs-number">33</span>, <span class="hljs-number">34</span>, <span class="hljs-number">35</span>],
}
model.parallelize(device_map)  <span class="hljs-comment"># Splits the model across several devices</span>
model.deparallelize()  <span class="hljs-comment"># Put the model back on cpu and cleans memory by calling torch.cuda.empty_cache()</span>`}}),Wn=new je({}),Bn=new H({props:{name:"class transformers.GPT2LMHeadModel",anchor:"transformers.GPT2LMHeadModel",parameters:[{name:"config",val:""}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/gpt2/modeling_gpt2.py#L946",parametersDescription:[{anchor:"transformers.GPT2LMHeadModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.GPT2Config">GPT2Config</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/pr_15839/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}]}}),Jn=new H({props:{name:"forward",anchor:"transformers.GPT2LMHeadModel.forward",parameters:[{name:"input_ids",val:" = None"},{name:"past_key_values",val:" = None"},{name:"attention_mask",val:" = None"},{name:"token_type_ids",val:" = None"},{name:"position_ids",val:" = None"},{name:"head_mask",val:" = None"},{name:"inputs_embeds",val:" = None"},{name:"encoder_hidden_states",val:" = None"},{name:"encoder_attention_mask",val:" = None"},{name:"labels",val:" = None"},{name:"use_cache",val:" = None"},{name:"output_attentions",val:" = None"},{name:"output_hidden_states",val:" = None"},{name:"return_dict",val:" = None"}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/gpt2/modeling_gpt2.py#L1015",parametersDescription:[{anchor:"transformers.GPT2LMHeadModel.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, input_ids_length)</code>) &#x2014;
<code>input_ids_length</code> = <code>sequence_length</code> if <code>past_key_values</code> is <code>None</code> else
<code>past_key_values[0][0].shape[-2]</code> (<code>sequence_length</code> of input past key value states). Indices of input
sequence tokens in the vocabulary.</p>
<p>If <code>past_key_values</code> is used, only <code>input_ids</code> that do not have their past calculated should be passed as
<code>input_ids</code>.</p>
<p>Indices can be obtained using <a href="/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.GPT2Tokenizer">GPT2Tokenizer</a>. See <a href="/docs/transformers/pr_15839/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/pr_15839/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.GPT2LMHeadModel.forward.past_key_values",description:`<strong>past_key_values</strong> (<code>Tuple[Tuple[torch.Tensor]]</code> of length <code>config.n_layers</code>) &#x2014;
Contains precomputed hidden-states (key and values in the attention blocks) as computed by the model (see
<code>past_key_values</code> output below). Can be used to speed up sequential decoding. The <code>input_ids</code> which have
their past given to this model should not be passed as <code>input_ids</code> as they have already been computed.`,name:"past_key_values"},{anchor:"transformers.GPT2LMHeadModel.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.GPT2LMHeadModel.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, input_ids_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.GPT2LMHeadModel.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.max_position_embeddings - 1]</code>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.GPT2LMHeadModel.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.GPT2LMHeadModel.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.</p>
<p>If <code>past_key_values</code> is used, optionally only the last <code>inputs_embeds</code> have to be input (see
<code>past_key_values</code>).`,name:"inputs_embeds"},{anchor:"transformers.GPT2LMHeadModel.forward.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
If set to <code>True</code>, <code>past_key_values</code> key value states are returned and can be used to speed up decoding (see
<code>past_key_values</code>).`,name:"use_cache"},{anchor:"transformers.GPT2LMHeadModel.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.GPT2LMHeadModel.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.GPT2LMHeadModel.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/pr_15839/en/main_classes/output#transformers.file_utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.GPT2LMHeadModel.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Labels for language modeling. Note that the labels <strong>are shifted</strong> inside the model, i.e. you can set
<code>labels = input_ids</code> Indices are selected in <code>[-100, 0, ..., config.vocab_size]</code> All labels set to <code>-100</code>
are ignored (masked), the loss is only computed for labels in <code>[0, ..., config.vocab_size]</code>`,name:"labels"}],returnDescription:`
<p>A <a
  href="/docs/transformers/pr_15839/en/main_classes/output#transformers.modeling_outputs.CausalLMOutputWithCrossAttentions"
>transformers.modeling_outputs.CausalLMOutputWithCrossAttentions</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.GPT2Config"
>GPT2Config</a>) and inputs.</p>
<ul>
<li>
<p><strong>loss</strong> (<code>torch.FloatTensor</code> of shape <code>(1,)</code>, <em>optional</em>, returned when <code>labels</code> is provided) \u2014 Language modeling loss (for next-token prediction).</p>
</li>
<li>
<p><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, config.vocab_size)</code>) \u2014 Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings + one for the output of each layer) of
shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
<li>
<p><strong>cross_attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Cross attentions weights after the attention softmax, used to compute the weighted average in the
cross-attention heads.</p>
</li>
<li>
<p><strong>past_key_values</strong> (<code>tuple(tuple(torch.FloatTensor))</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> tuples of length <code>config.n_layers</code>, with each tuple containing the cached key,
value states of the self-attention and the cross-attention layers if model is used in encoder-decoder
setting. Only relevant if <code>config.is_decoder = True</code>.</p>
<p>Contains pre-computed hidden-states (key and values in the attention blocks) that can be used (see
<code>past_key_values</code> input) to speed up sequential decoding.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/pr_15839/en/main_classes/output#transformers.modeling_outputs.CausalLMOutputWithCrossAttentions"
>transformers.modeling_outputs.CausalLMOutputWithCrossAttentions</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Eo=new Le({props:{$$slots:{default:[jb]},$$scope:{ctx:q}}}),Kn=new Me({props:{code:`import torch
from transformers import GPT2Tokenizer, GPT2LMHeadModel

tokenizer = GPT2Tokenizer.from_pretrained("gpt2")
model = GPT2LMHeadModel.from_pretrained("gpt2")

inputs = tokenizer("Hello, my dog is cute", return_tensors="pt")
outputs = model(**inputs, labels=inputs["input_ids"])
loss = outputs.loss
logits = outputs.logits`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> GPT2Tokenizer, GPT2LMHeadModel

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = GPT2Tokenizer.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = GPT2LMHeadModel.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(<span class="hljs-string">&quot;Hello, my dog is cute&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**inputs, labels=inputs[<span class="hljs-string">&quot;input_ids&quot;</span>])
<span class="hljs-meta">&gt;&gt;&gt; </span>loss = outputs.loss
<span class="hljs-meta">&gt;&gt;&gt; </span>logits = outputs.logits`}}),Xn=new H({props:{name:"parallelize",anchor:"transformers.GPT2LMHeadModel.parallelize",parameters:[{name:"device_map",val:" = None"}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/gpt2/modeling_gpt2.py#L961",parametersDescription:[{anchor:"transformers.GPT2LMHeadModel.parallelize.device_map",description:`<strong>device_map</strong> (<code>Dict[int, list]</code>, optional, defaults to None) &#x2014;
A dictionary that maps attention modules to devices. Note that the embedding module and LMHead are always
automatically mapped to the first device (for esoteric reasons). That means that the first device should
have fewer attention modules mapped to it than other devices. For reference, the gpt2 models have the
following number of attention modules:</p>
<ul>
<li>gpt2: 12</li>
<li>gpt2-medium: 24</li>
<li>gpt2-large: 36</li>
<li>gpt2-xl: 48</li>
</ul>`,name:"device_map"}]}}),Yn=new Me({props:{code:`# Here is an example of a device map on a machine with 4 GPUs using gpt2-xl, which has a total of 48 attention modules:
model = GPT2LMHeadModel.from_pretrained("gpt2-xl")
device_map = {
    0: [0, 1, 2, 3, 4, 5, 6, 7, 8],
    1: [9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21],
    2: [22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34],
    3: [35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47],
}
model.parallelize(device_map)`,highlighted:`<span class="hljs-comment"># Here is an example of a device map on a machine with 4 GPUs using gpt2-xl, which has a total of 48 attention modules:</span>
model = GPT2LMHeadModel.from_pretrained(<span class="hljs-string">&quot;gpt2-xl&quot;</span>)
device_map = {
    <span class="hljs-number">0</span>: [<span class="hljs-number">0</span>, <span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">5</span>, <span class="hljs-number">6</span>, <span class="hljs-number">7</span>, <span class="hljs-number">8</span>],
    <span class="hljs-number">1</span>: [<span class="hljs-number">9</span>, <span class="hljs-number">10</span>, <span class="hljs-number">11</span>, <span class="hljs-number">12</span>, <span class="hljs-number">13</span>, <span class="hljs-number">14</span>, <span class="hljs-number">15</span>, <span class="hljs-number">16</span>, <span class="hljs-number">17</span>, <span class="hljs-number">18</span>, <span class="hljs-number">19</span>, <span class="hljs-number">20</span>, <span class="hljs-number">21</span>],
    <span class="hljs-number">2</span>: [<span class="hljs-number">22</span>, <span class="hljs-number">23</span>, <span class="hljs-number">24</span>, <span class="hljs-number">25</span>, <span class="hljs-number">26</span>, <span class="hljs-number">27</span>, <span class="hljs-number">28</span>, <span class="hljs-number">29</span>, <span class="hljs-number">30</span>, <span class="hljs-number">31</span>, <span class="hljs-number">32</span>, <span class="hljs-number">33</span>, <span class="hljs-number">34</span>],
    <span class="hljs-number">3</span>: [<span class="hljs-number">35</span>, <span class="hljs-number">36</span>, <span class="hljs-number">37</span>, <span class="hljs-number">38</span>, <span class="hljs-number">39</span>, <span class="hljs-number">40</span>, <span class="hljs-number">41</span>, <span class="hljs-number">42</span>, <span class="hljs-number">43</span>, <span class="hljs-number">44</span>, <span class="hljs-number">45</span>, <span class="hljs-number">46</span>, <span class="hljs-number">47</span>],
}
model.parallelize(device_map)`}}),Qn=new H({props:{name:"deparallelize",anchor:"transformers.GPT2LMHeadModel.deparallelize",parameters:[],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/gpt2/modeling_gpt2.py#L973"}}),Zn=new Me({props:{code:`# On a 4 GPU machine with gpt2-large:
model = GPT2LMHeadModel.from_pretrained("gpt2-large")
device_map = {
    0: [0, 1, 2, 3, 4, 5, 6, 7],
    1: [8, 9, 10, 11, 12, 13, 14, 15],
    2: [16, 17, 18, 19, 20, 21, 22, 23],
    3: [24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35],
}
model.parallelize(device_map)  # Splits the model across several devices
model.deparallelize()  # Put the model back on cpu and cleans memory by calling torch.cuda.empty_cache()`,highlighted:`<span class="hljs-comment"># On a 4 GPU machine with gpt2-large:</span>
model = GPT2LMHeadModel.from_pretrained(<span class="hljs-string">&quot;gpt2-large&quot;</span>)
device_map = {
    <span class="hljs-number">0</span>: [<span class="hljs-number">0</span>, <span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">5</span>, <span class="hljs-number">6</span>, <span class="hljs-number">7</span>],
    <span class="hljs-number">1</span>: [<span class="hljs-number">8</span>, <span class="hljs-number">9</span>, <span class="hljs-number">10</span>, <span class="hljs-number">11</span>, <span class="hljs-number">12</span>, <span class="hljs-number">13</span>, <span class="hljs-number">14</span>, <span class="hljs-number">15</span>],
    <span class="hljs-number">2</span>: [<span class="hljs-number">16</span>, <span class="hljs-number">17</span>, <span class="hljs-number">18</span>, <span class="hljs-number">19</span>, <span class="hljs-number">20</span>, <span class="hljs-number">21</span>, <span class="hljs-number">22</span>, <span class="hljs-number">23</span>],
    <span class="hljs-number">3</span>: [<span class="hljs-number">24</span>, <span class="hljs-number">25</span>, <span class="hljs-number">26</span>, <span class="hljs-number">27</span>, <span class="hljs-number">28</span>, <span class="hljs-number">29</span>, <span class="hljs-number">30</span>, <span class="hljs-number">31</span>, <span class="hljs-number">32</span>, <span class="hljs-number">33</span>, <span class="hljs-number">34</span>, <span class="hljs-number">35</span>],
}
model.parallelize(device_map)  <span class="hljs-comment"># Splits the model across several devices</span>
model.deparallelize()  <span class="hljs-comment"># Put the model back on cpu and cleans memory by calling torch.cuda.empty_cache()</span>`}}),es=new je({}),ts=new H({props:{name:"class transformers.GPT2DoubleHeadsModel",anchor:"transformers.GPT2DoubleHeadsModel",parameters:[{name:"config",val:""}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/gpt2/modeling_gpt2.py#L1115",parametersDescription:[{anchor:"transformers.GPT2DoubleHeadsModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.GPT2Config">GPT2Config</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/pr_15839/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}]}}),as=new H({props:{name:"forward",anchor:"transformers.GPT2DoubleHeadsModel.forward",parameters:[{name:"input_ids",val:" = None"},{name:"past_key_values",val:" = None"},{name:"attention_mask",val:" = None"},{name:"token_type_ids",val:" = None"},{name:"position_ids",val:" = None"},{name:"head_mask",val:" = None"},{name:"inputs_embeds",val:" = None"},{name:"mc_token_ids",val:" = None"},{name:"labels",val:" = None"},{name:"mc_labels",val:" = None"},{name:"use_cache",val:" = None"},{name:"output_attentions",val:" = None"},{name:"output_hidden_states",val:" = None"},{name:"return_dict",val:" = None"},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/gpt2/modeling_gpt2.py#L1189",parametersDescription:[{anchor:"transformers.GPT2DoubleHeadsModel.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, input_ids_length)</code>) &#x2014;
<code>input_ids_length</code> = <code>sequence_length</code> if <code>past_key_values</code> is <code>None</code> else
<code>past_key_values[0][0].shape[-2]</code> (<code>sequence_length</code> of input past key value states). Indices of input
sequence tokens in the vocabulary.</p>
<p>If <code>past_key_values</code> is used, only <code>input_ids</code> that do not have their past calculated should be passed as
<code>input_ids</code>.</p>
<p>Indices can be obtained using <a href="/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.GPT2Tokenizer">GPT2Tokenizer</a>. See <a href="/docs/transformers/pr_15839/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/pr_15839/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.GPT2DoubleHeadsModel.forward.past_key_values",description:`<strong>past_key_values</strong> (<code>Tuple[Tuple[torch.Tensor]]</code> of length <code>config.n_layers</code>) &#x2014;
Contains precomputed hidden-states (key and values in the attention blocks) as computed by the model (see
<code>past_key_values</code> output below). Can be used to speed up sequential decoding. The <code>input_ids</code> which have
their past given to this model should not be passed as <code>input_ids</code> as they have already been computed.`,name:"past_key_values"},{anchor:"transformers.GPT2DoubleHeadsModel.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.GPT2DoubleHeadsModel.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, input_ids_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.GPT2DoubleHeadsModel.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.max_position_embeddings - 1]</code>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.GPT2DoubleHeadsModel.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.GPT2DoubleHeadsModel.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.</p>
<p>If <code>past_key_values</code> is used, optionally only the last <code>inputs_embeds</code> have to be input (see
<code>past_key_values</code>).`,name:"inputs_embeds"},{anchor:"transformers.GPT2DoubleHeadsModel.forward.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
If set to <code>True</code>, <code>past_key_values</code> key value states are returned and can be used to speed up decoding (see
<code>past_key_values</code>).`,name:"use_cache"},{anchor:"transformers.GPT2DoubleHeadsModel.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.GPT2DoubleHeadsModel.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.GPT2DoubleHeadsModel.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/pr_15839/en/main_classes/output#transformers.file_utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.GPT2DoubleHeadsModel.forward.mc_token_ids",description:`<strong>mc_token_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, num_choices)</code>, <em>optional</em>, default to index of the last token of the input) &#x2014;
Index of the classification token in each input sequence. Selected in the range <code>[0, input_ids.size(-1) - 1[</code>.`,name:"mc_token_ids"},{anchor:"transformers.GPT2DoubleHeadsModel.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Labels for language modeling. Note that the labels <strong>are shifted</strong> inside the model, i.e. you can set
<code>labels = input_ids</code> Indices are selected in <code>[-100, 0, ..., config.vocab_size - 1]</code> All labels set to
<code>-100</code> are ignored (masked), the loss is only computed for labels in <code>[0, ..., config.vocab_size - 1]</code>`,name:"labels"},{anchor:"transformers.GPT2DoubleHeadsModel.forward.mc_labels",description:`<strong>mc_labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size)</code>, <em>optional</em>) &#x2014;
Labels for computing the multiple choice classification loss. Indices should be in <code>[0, ..., num_choices]</code>
where <em>num_choices</em> is the size of the second dimension of the input tensors. (see <em>input_ids</em> above)`,name:"mc_labels"}],returnDescription:`
<p>A <a
  href="/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.models.gpt2.modeling_gpt2.GPT2DoubleHeadsModelOutput"
>transformers.models.gpt2.modeling_gpt2.GPT2DoubleHeadsModelOutput</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.GPT2Config"
>GPT2Config</a>) and inputs.</p>
<ul>
<li>
<p><strong>loss</strong> (<code>torch.FloatTensor</code> of shape <code>(1,)</code>, <em>optional</em>, returned when <code>labels</code> is provided) \u2014 Language modeling loss.</p>
</li>
<li>
<p><strong>mc_loss</strong> (<code>torch.FloatTensor</code> of shape <code>(1,)</code>, <em>optional</em>, returned when <code>mc_labels</code> is provided) \u2014 Multiple choice classification loss.</p>
</li>
<li>
<p><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_choices, sequence_length, config.vocab_size)</code>) \u2014 Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).</p>
</li>
<li>
<p><strong>mc_logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_choices)</code>) \u2014 Prediction scores of the multiple choice classification head (scores for each choice before SoftMax).</p>
</li>
<li>
<p><strong>past_key_values</strong> (<code>Tuple[Tuple[torch.Tensor]]</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) \u2014 Tuple of length <code>config.n_layers</code>, containing tuples of tensors of shape <code>(batch_size, num_heads, sequence_length, embed_size_per_head)</code>).</p>
<p>Contains pre-computed hidden-states (key and values in the attention blocks) that can be used (see
<code>past_key_values</code> input) to speed up sequential decoding.</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings + one for the output of each layer) of
shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>GPT2Attentions weights after the attention softmax, used to compute the weighted average in the
self-attention heads.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.models.gpt2.modeling_gpt2.GPT2DoubleHeadsModelOutput"
>transformers.models.gpt2.modeling_gpt2.GPT2DoubleHeadsModelOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Co=new Le({props:{$$slots:{default:[Fb]},$$scope:{ctx:q}}}),rs=new Me({props:{code:`import torch
from transformers import GPT2Tokenizer, GPT2DoubleHeadsModel

tokenizer = GPT2Tokenizer.from_pretrained("gpt2")
model = GPT2DoubleHeadsModel.from_pretrained("gpt2")

# Add a [CLS] to the vocabulary (we should train it also!)
num_added_tokens = tokenizer.add_special_tokens({"cls_token": "[CLS]"})

embedding_layer = model.resize_token_embeddings(
    len(tokenizer)
)  # Update the model embeddings with the new vocabulary size

choices = ["Hello, my dog is cute [CLS]", "Hello, my cat is cute [CLS]"]
encoded_choices = [tokenizer.encode(s) for s in choices]
cls_token_location = [tokens.index(tokenizer.cls_token_id) for tokens in encoded_choices]

input_ids = torch.tensor(encoded_choices).unsqueeze(0)  # Batch size: 1, number of choices: 2
mc_token_ids = torch.tensor([cls_token_location])  # Batch size: 1

outputs = model(input_ids, mc_token_ids=mc_token_ids)
lm_logits = outputs.logits
mc_logits = outputs.mc_logits`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> GPT2Tokenizer, GPT2DoubleHeadsModel

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = GPT2Tokenizer.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = GPT2DoubleHeadsModel.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Add a [CLS] to the vocabulary (we should train it also!)</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>num_added_tokens = tokenizer.add_special_tokens({<span class="hljs-string">&quot;cls_token&quot;</span>: <span class="hljs-string">&quot;[CLS]&quot;</span>})

<span class="hljs-meta">&gt;&gt;&gt; </span>embedding_layer = model.resize_token_embeddings(
<span class="hljs-meta">... </span>    <span class="hljs-built_in">len</span>(tokenizer)
<span class="hljs-meta">&gt;&gt;&gt; </span>)  <span class="hljs-comment"># Update the model embeddings with the new vocabulary size</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>choices = [<span class="hljs-string">&quot;Hello, my dog is cute [CLS]&quot;</span>, <span class="hljs-string">&quot;Hello, my cat is cute [CLS]&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>encoded_choices = [tokenizer.encode(s) <span class="hljs-keyword">for</span> s <span class="hljs-keyword">in</span> choices]
<span class="hljs-meta">&gt;&gt;&gt; </span>cls_token_location = [tokens.index(tokenizer.cls_token_id) <span class="hljs-keyword">for</span> tokens <span class="hljs-keyword">in</span> encoded_choices]

<span class="hljs-meta">&gt;&gt;&gt; </span>input_ids = torch.tensor(encoded_choices).unsqueeze(<span class="hljs-number">0</span>)  <span class="hljs-comment"># Batch size: 1, number of choices: 2</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>mc_token_ids = torch.tensor([cls_token_location])  <span class="hljs-comment"># Batch size: 1</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(input_ids, mc_token_ids=mc_token_ids)
<span class="hljs-meta">&gt;&gt;&gt; </span>lm_logits = outputs.logits
<span class="hljs-meta">&gt;&gt;&gt; </span>mc_logits = outputs.mc_logits`}}),is=new je({}),ls=new H({props:{name:"class transformers.GPT2ForSequenceClassification",anchor:"transformers.GPT2ForSequenceClassification",parameters:[{name:"config",val:""}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/gpt2/modeling_gpt2.py#L1331",parametersDescription:[{anchor:"transformers.GPT2ForSequenceClassification.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.GPT2Config">GPT2Config</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/pr_15839/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}]}}),hs=new H({props:{name:"forward",anchor:"transformers.GPT2ForSequenceClassification.forward",parameters:[{name:"input_ids",val:" = None"},{name:"past_key_values",val:" = None"},{name:"attention_mask",val:" = None"},{name:"token_type_ids",val:" = None"},{name:"position_ids",val:" = None"},{name:"head_mask",val:" = None"},{name:"inputs_embeds",val:" = None"},{name:"labels",val:" = None"},{name:"use_cache",val:" = None"},{name:"output_attentions",val:" = None"},{name:"output_hidden_states",val:" = None"},{name:"return_dict",val:" = None"}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/gpt2/modeling_gpt2.py#L1347",parametersDescription:[{anchor:"transformers.GPT2ForSequenceClassification.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, input_ids_length)</code>) &#x2014;
<code>input_ids_length</code> = <code>sequence_length</code> if <code>past_key_values</code> is <code>None</code> else
<code>past_key_values[0][0].shape[-2]</code> (<code>sequence_length</code> of input past key value states). Indices of input
sequence tokens in the vocabulary.</p>
<p>If <code>past_key_values</code> is used, only <code>input_ids</code> that do not have their past calculated should be passed as
<code>input_ids</code>.</p>
<p>Indices can be obtained using <a href="/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.GPT2Tokenizer">GPT2Tokenizer</a>. See <a href="/docs/transformers/pr_15839/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/pr_15839/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.GPT2ForSequenceClassification.forward.past_key_values",description:`<strong>past_key_values</strong> (<code>Tuple[Tuple[torch.Tensor]]</code> of length <code>config.n_layers</code>) &#x2014;
Contains precomputed hidden-states (key and values in the attention blocks) as computed by the model (see
<code>past_key_values</code> output below). Can be used to speed up sequential decoding. The <code>input_ids</code> which have
their past given to this model should not be passed as <code>input_ids</code> as they have already been computed.`,name:"past_key_values"},{anchor:"transformers.GPT2ForSequenceClassification.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.GPT2ForSequenceClassification.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, input_ids_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.GPT2ForSequenceClassification.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.max_position_embeddings - 1]</code>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.GPT2ForSequenceClassification.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.GPT2ForSequenceClassification.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.</p>
<p>If <code>past_key_values</code> is used, optionally only the last <code>inputs_embeds</code> have to be input (see
<code>past_key_values</code>).`,name:"inputs_embeds"},{anchor:"transformers.GPT2ForSequenceClassification.forward.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
If set to <code>True</code>, <code>past_key_values</code> key value states are returned and can be used to speed up decoding (see
<code>past_key_values</code>).`,name:"use_cache"},{anchor:"transformers.GPT2ForSequenceClassification.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.GPT2ForSequenceClassification.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.GPT2ForSequenceClassification.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/pr_15839/en/main_classes/output#transformers.file_utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.GPT2ForSequenceClassification.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size,)</code>, <em>optional</em>) &#x2014;
Labels for computing the sequence classification/regression loss. Indices should be in <code>[0, ..., config.num_labels - 1]</code>. If <code>config.num_labels == 1</code> a regression loss is computed (Mean-Square loss), If
<code>config.num_labels &gt; 1</code> a classification loss is computed (Cross-Entropy).`,name:"labels"}],returnDescription:`
<p>A <code>transformers.modeling_outputs.SequenceClassifierOutputWithPast</code>or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.GPT2Config"
>GPT2Config</a>) and inputs.</p>
<ul>
<li>
<p><strong>loss</strong> (<code>torch.FloatTensor</code> of shape <code>(1,)</code>, <em>optional</em>, returned when <code>labels</code> is provided) \u2014 Classification (or regression if config.num_labels==1) loss.</p>
</li>
<li>
<p><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, config.num_labels)</code>) \u2014 Classification (or regression if config.num_labels==1) scores (before SoftMax).</p>
</li>
<li>
<p><strong>past_key_values</strong> (<code>tuple(tuple(torch.FloatTensor))</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) \u2014 Tuple of <code>tuple(torch.FloatTensor)</code> of length <code>config.n_layers</code>, with each tuple having 2 tensors of shape
<code>(batch_size, num_heads, sequence_length, embed_size_per_head)</code>)</p>
<p>Contains pre-computed hidden-states (key and values in the self-attention blocks) that can be used (see
<code>past_key_values</code> input) to speed up sequential decoding.</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings + one for the output of each layer) of
shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
</ul>
`,returnType:`
<p><code>transformers.modeling_outputs.SequenceClassifierOutputWithPast</code>or <code>tuple(torch.FloatTensor)</code></p>
`}}),Ho=new Le({props:{$$slots:{default:[xb]},$$scope:{ctx:q}}}),us=new Me({props:{code:`import torch
from transformers import GPT2Tokenizer, GPT2ForSequenceClassification

torch.manual_seed(0)
tokenizer = GPT2Tokenizer.from_pretrained("microsoft/DialogRPT-updown")
model = GPT2ForSequenceClassification.from_pretrained("microsoft/DialogRPT-updown", num_labels=2)

inputs = tokenizer("Hello, my dog is cute", return_tensors="pt")
labels = torch.tensor([1]).unsqueeze(0)  # Batch size 1
outputs = model(**inputs, labels=labels)
loss = outputs.loss
logits = outputs.logits
list(logits.shape)
`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> GPT2Tokenizer, GPT2ForSequenceClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>torch.manual_seed(<span class="hljs-number">0</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = GPT2Tokenizer.from_pretrained(<span class="hljs-string">&quot;microsoft/DialogRPT-updown&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = GPT2ForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;microsoft/DialogRPT-updown&quot;</span>, num_labels=<span class="hljs-number">2</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(<span class="hljs-string">&quot;Hello, my dog is cute&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>labels = torch.tensor([<span class="hljs-number">1</span>]).unsqueeze(<span class="hljs-number">0</span>)  <span class="hljs-comment"># Batch size 1</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**inputs, labels=labels)
<span class="hljs-meta">&gt;&gt;&gt; </span>loss = outputs.loss
<span class="hljs-meta">&gt;&gt;&gt; </span>logits = outputs.logits
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">list</span>(logits.shape)
`}}),ms=new Me({props:{code:`import torch
from transformers import GPT2Tokenizer, GPT2ForSequenceClassification

torch.manual_seed(0)
tokenizer = GPT2Tokenizer.from_pretrained("microsoft/DialogRPT-updown")
model = GPT2ForSequenceClassification.from_pretrained("microsoft/DialogRPT-updown", problem_type="multi_label_classification", num_labels=2)

inputs = tokenizer("Hello, my dog is cute", return_tensors="pt")
labels = torch.tensor([[1, 1]], dtype=torch.float)  # need dtype=float for BCEWithLogitsLoss
outputs = model(**inputs, labels=labels)
loss = outputs.loss
list(logits.shape)
`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> GPT2Tokenizer, GPT2ForSequenceClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>torch.manual_seed(<span class="hljs-number">0</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = GPT2Tokenizer.from_pretrained(<span class="hljs-string">&quot;microsoft/DialogRPT-updown&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = GPT2ForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;microsoft/DialogRPT-updown&quot;</span>, problem_type=<span class="hljs-string">&quot;multi_label_classification&quot;</span>, num_labels=<span class="hljs-number">2</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(<span class="hljs-string">&quot;Hello, my dog is cute&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>labels = torch.tensor([[<span class="hljs-number">1</span>, <span class="hljs-number">1</span>]], dtype=torch.<span class="hljs-built_in">float</span>)  <span class="hljs-comment"># need dtype=float for BCEWithLogitsLoss</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**inputs, labels=labels)
<span class="hljs-meta">&gt;&gt;&gt; </span>loss = outputs.loss
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">list</span>(logits.shape)
`}}),fs=new je({}),gs=new H({props:{name:"class transformers.GPT2ForTokenClassification",anchor:"transformers.GPT2ForTokenClassification",parameters:[{name:"config",val:""}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/gpt2/modeling_gpt2.py#L1457",parametersDescription:[{anchor:"transformers.GPT2ForTokenClassification.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.GPT2Config">GPT2Config</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/pr_15839/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}]}}),bs=new H({props:{name:"forward",anchor:"transformers.GPT2ForTokenClassification.forward",parameters:[{name:"input_ids",val:" = None"},{name:"past_key_values",val:" = None"},{name:"attention_mask",val:" = None"},{name:"token_type_ids",val:" = None"},{name:"position_ids",val:" = None"},{name:"head_mask",val:" = None"},{name:"inputs_embeds",val:" = None"},{name:"labels",val:" = None"},{name:"use_cache",val:" = None"},{name:"output_attentions",val:" = None"},{name:"output_hidden_states",val:" = None"},{name:"return_dict",val:" = None"}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/gpt2/modeling_gpt2.py#L1479",parametersDescription:[{anchor:"transformers.GPT2ForTokenClassification.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, input_ids_length)</code>) &#x2014;
<code>input_ids_length</code> = <code>sequence_length</code> if <code>past_key_values</code> is <code>None</code> else
<code>past_key_values[0][0].shape[-2]</code> (<code>sequence_length</code> of input past key value states). Indices of input
sequence tokens in the vocabulary.</p>
<p>If <code>past_key_values</code> is used, only <code>input_ids</code> that do not have their past calculated should be passed as
<code>input_ids</code>.</p>
<p>Indices can be obtained using <a href="/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.GPT2Tokenizer">GPT2Tokenizer</a>. See <a href="/docs/transformers/pr_15839/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/pr_15839/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.GPT2ForTokenClassification.forward.past_key_values",description:`<strong>past_key_values</strong> (<code>Tuple[Tuple[torch.Tensor]]</code> of length <code>config.n_layers</code>) &#x2014;
Contains precomputed hidden-states (key and values in the attention blocks) as computed by the model (see
<code>past_key_values</code> output below). Can be used to speed up sequential decoding. The <code>input_ids</code> which have
their past given to this model should not be passed as <code>input_ids</code> as they have already been computed.`,name:"past_key_values"},{anchor:"transformers.GPT2ForTokenClassification.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.GPT2ForTokenClassification.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, input_ids_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.GPT2ForTokenClassification.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.max_position_embeddings - 1]</code>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.GPT2ForTokenClassification.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.GPT2ForTokenClassification.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.</p>
<p>If <code>past_key_values</code> is used, optionally only the last <code>inputs_embeds</code> have to be input (see
<code>past_key_values</code>).`,name:"inputs_embeds"},{anchor:"transformers.GPT2ForTokenClassification.forward.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
If set to <code>True</code>, <code>past_key_values</code> key value states are returned and can be used to speed up decoding (see
<code>past_key_values</code>).`,name:"use_cache"},{anchor:"transformers.GPT2ForTokenClassification.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.GPT2ForTokenClassification.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.GPT2ForTokenClassification.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/pr_15839/en/main_classes/output#transformers.file_utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.GPT2ForTokenClassification.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size,)</code>, <em>optional</em>) &#x2014;
Labels for computing the sequence classification/regression loss. Indices should be in <code>[0, ..., config.num_labels - 1]</code>. If <code>config.num_labels == 1</code> a regression loss is computed (Mean-Square loss), If
<code>config.num_labels &gt; 1</code> a classification loss is computed (Cross-Entropy).`,name:"labels"}],returnDescription:`
<p>A <a
  href="/docs/transformers/pr_15839/en/main_classes/output#transformers.modeling_outputs.TokenClassifierOutput"
>transformers.modeling_outputs.TokenClassifierOutput</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.GPT2Config"
>GPT2Config</a>) and inputs.</p>
<ul>
<li>
<p><strong>loss</strong> (<code>torch.FloatTensor</code> of shape <code>(1,)</code>, <em>optional</em>, returned when <code>labels</code> is provided)  \u2014 Classification loss.</p>
</li>
<li>
<p><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, config.num_labels)</code>) \u2014 Classification scores (before SoftMax).</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings + one for the output of each layer) of
shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/pr_15839/en/main_classes/output#transformers.modeling_outputs.TokenClassifierOutput"
>transformers.modeling_outputs.TokenClassifierOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),No=new Le({props:{$$slots:{default:[Eb]},$$scope:{ctx:q}}}),ks=new Me({props:{code:`from transformers import GPT2Tokenizer, GPT2ForTokenClassification
import torch

tokenizer = GPT2Tokenizer.from_pretrained("microsoft/DialogRPT-updown")
model = GPT2ForTokenClassification.from_pretrained("microsoft/DialogRPT-updown")

inputs = tokenizer("Hello, my dog is cute", return_tensors="pt")
labels = torch.tensor([1] * inputs["input_ids"].size(1)).unsqueeze(0)  # Batch size 1

outputs = model(**inputs, labels=labels)
loss = outputs.loss
logits = outputs.logits`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> GPT2Tokenizer, GPT2ForTokenClassification
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = GPT2Tokenizer.from_pretrained(<span class="hljs-string">&quot;microsoft/DialogRPT-updown&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = GPT2ForTokenClassification.from_pretrained(<span class="hljs-string">&quot;microsoft/DialogRPT-updown&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(<span class="hljs-string">&quot;Hello, my dog is cute&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>labels = torch.tensor([<span class="hljs-number">1</span>] * inputs[<span class="hljs-string">&quot;input_ids&quot;</span>].size(<span class="hljs-number">1</span>)).unsqueeze(<span class="hljs-number">0</span>)  <span class="hljs-comment"># Batch size 1</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**inputs, labels=labels)
<span class="hljs-meta">&gt;&gt;&gt; </span>loss = outputs.loss
<span class="hljs-meta">&gt;&gt;&gt; </span>logits = outputs.logits`}}),ys=new je({}),ws=new H({props:{name:"class transformers.TFGPT2Model",anchor:"transformers.TFGPT2Model",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/gpt2/modeling_tf_gpt2.py#L727",parametersDescription:[{anchor:"transformers.TFGPT2Model.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.GPT2Config">GPT2Config</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/pr_15839/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}]}}),So=new Le({props:{$$slots:{default:[qb]},$$scope:{ctx:q}}}),Gs=new H({props:{name:"call",anchor:"transformers.TFGPT2Model.call",parameters:[{name:"input_ids",val:" = None"},{name:"past",val:" = None"},{name:"attention_mask",val:" = None"},{name:"token_type_ids",val:" = None"},{name:"position_ids",val:" = None"},{name:"head_mask",val:" = None"},{name:"inputs_embeds",val:" = None"},{name:"encoder_hidden_states",val:" = None"},{name:"encoder_attention_mask",val:" = None"},{name:"use_cache",val:" = None"},{name:"output_attentions",val:" = None"},{name:"output_hidden_states",val:" = None"},{name:"return_dict",val:" = None"},{name:"training",val:" = False"},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/gpt2/modeling_tf_gpt2.py#L732",parametersDescription:[{anchor:"transformers.TFGPT2Model.call.input_ids",description:`<strong>input_ids</strong> (<code>Numpy array</code> or <code>tf.Tensor</code> of shape <code>(batch_size, input_ids_length)</code>) &#x2014;
<code>input_ids_length</code> = <code>sequence_length</code> if <code>past</code> is <code>None</code> else <code>past[0].shape[-2]</code> (<code>sequence_length</code> of
input past key value states). Indices of input sequence tokens in the vocabulary.</p>
<p>If <code>past</code> is used, only input IDs that do not have their past calculated should be passed as <code>input_ids</code>.</p>
<p>Indices can be obtained using <a href="/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.GPT2Tokenizer">GPT2Tokenizer</a>. See <a href="/docs/transformers/pr_15839/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> and
<a href="/docs/transformers/pr_15839/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.TFGPT2Model.call.past",description:`<strong>past</strong> (<code>List[tf.Tensor]</code> of length <code>config.n_layers</code>) &#x2014;
Contains pre-computed hidden-states (key and values in the attention blocks) as computed by the model (see
<code>past</code> output below). Can be used to speed up sequential decoding. The token ids which have their past
given to this model should not be passed as input ids as they have already been computed.`,name:"past"},{anchor:"transformers.TFGPT2Model.call.attention_mask",description:`<strong>attention_mask</strong> (<code>tf.Tensor</code> or <code>Numpy array</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.TFGPT2Model.call.token_type_ids",description:`<strong>token_type_ids</strong> (<code>tf.Tensor</code> or <code>Numpy array</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.TFGPT2Model.call.position_ids",description:`<strong>position_ids</strong> (<code>tf.Tensor</code> or <code>Numpy array</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.max_position_embeddings - 1]</code>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.TFGPT2Model.call.head_mask",description:`<strong>head_mask</strong> (<code>Numpy array</code> or <code>tf.Tensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.TFGPT2Model.call.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.TFGPT2Model.call.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail. This argument can be used only in eager mode, in graph mode the value in the
config will be used instead.`,name:"output_attentions"},{anchor:"transformers.TFGPT2Model.call.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail. This argument can be used only in eager mode, in graph mode the value in the config will be
used instead.`,name:"output_hidden_states"},{anchor:"transformers.TFGPT2Model.call.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/pr_15839/en/main_classes/output#transformers.file_utils.ModelOutput">ModelOutput</a> instead of a plain tuple. This argument can be used
in eager mode, in graph mode the value will always be set to True.`,name:"return_dict"},{anchor:"transformers.TFGPT2Model.call.training",description:`<strong>training</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to use the model in training mode (some modules like dropout modules have different
behaviors between training and evaluation).`,name:"training"},{anchor:"transformers.TFGPT2Model.call.encoder_hidden_states",description:`<strong>encoder_hidden_states</strong>  (<code>tf.Tensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Sequence of hidden-states at the output of the last layer of the encoder. Used in the cross-attention if
the model is configured as a decoder.`,name:"encoder_hidden_states"},{anchor:"transformers.TFGPT2Model.call.encoder_attention_mask",description:`<strong>encoder_attention_mask</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on the padding token indices of the encoder input. This mask is used in
the cross-attention if the model is configured as a decoder. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>`,name:"encoder_attention_mask"},{anchor:"transformers.TFGPT2Model.call.past",description:`<strong>past</strong> (<code>Tuple[Tuple[tf.Tensor]]</code> of length <code>config.n_layers</code>) &#x2014;
contains precomputed key and value hidden states of the attention blocks. Can be used to speed up decoding.
If <code>past</code> are used, the user can optionally input only the last <code>decoder_input_ids</code> (those that don&#x2019;t have
their past key value states given to this model) of shape <code>(batch_size, 1)</code> instead of all
<code>decoder_input_ids</code> of shape <code>(batch_size, sequence_length)</code>.`,name:"past"},{anchor:"transformers.TFGPT2Model.call.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
If set to <code>True</code>, <code>past_key_values</code> key value states are returned and can be used to speed up decoding (see
<code>past</code>). Set to <code>False</code> during training, <code>True</code> during generation`,name:"use_cache"}],returnDescription:`
<p>A <a
  href="/docs/transformers/pr_15839/en/main_classes/output#transformers.modeling_tf_outputs.TFBaseModelOutputWithPastAndCrossAttentions"
>transformers.modeling_tf_outputs.TFBaseModelOutputWithPastAndCrossAttentions</a> or a tuple of <code>tf.Tensor</code> (if
<code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various elements depending on the
configuration (<a
  href="/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.GPT2Config"
>GPT2Config</a>) and inputs.</p>
<ul>
<li>
<p><strong>last_hidden_state</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>) \u2014 Sequence of hidden-states at the output of the last layer of the model.</p>
<p>If <code>past_key_values</code> is used only the last hidden-state of the sequences of shape <code>(batch_size, 1, hidden_size)</code> is output.</p>
</li>
<li>
<p><strong>past_key_values</strong> (<code>List[tf.Tensor]</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) \u2014 List of <code>tf.Tensor</code> of length <code>config.n_layers</code>, with each tensor of shape <code>(2, batch_size, num_heads, sequence_length, embed_size_per_head)</code>).</p>
<p>Contains pre-computed hidden-states (key and values in the attention blocks) that can be used (see
<code>past_key_values</code> input) to speed up sequential decoding.</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(tf.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>tf.Tensor</code> (one for the output of the embeddings + one for the output of each layer) of shape
<code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(tf.Tensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>tf.Tensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
<li>
<p><strong>cross_attentions</strong> (<code>tuple(tf.Tensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>tf.Tensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights of the decoder\u2019s cross-attention layer, after the attention softmax, used to compute the
weighted average in the cross-attention heads.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/pr_15839/en/main_classes/output#transformers.modeling_tf_outputs.TFBaseModelOutputWithPastAndCrossAttentions"
>transformers.modeling_tf_outputs.TFBaseModelOutputWithPastAndCrossAttentions</a> or <code>tuple(tf.Tensor)</code></p>
`}}),Ao=new Le({props:{$$slots:{default:[Cb]},$$scope:{ctx:q}}}),zs=new Me({props:{code:`from transformers import GPT2Tokenizer, TFGPT2Model
import tensorflow as tf

tokenizer = GPT2Tokenizer.from_pretrained("gpt2")
model = TFGPT2Model.from_pretrained("gpt2")

inputs = tokenizer("Hello, my dog is cute", return_tensors="tf")
outputs = model(inputs)

last_hidden_states = outputs.last_hidden_state`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> GPT2Tokenizer, TFGPT2Model
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = GPT2Tokenizer.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFGPT2Model.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(<span class="hljs-string">&quot;Hello, my dog is cute&quot;</span>, return_tensors=<span class="hljs-string">&quot;tf&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(inputs)

<span class="hljs-meta">&gt;&gt;&gt; </span>last_hidden_states = outputs.last_hidden_state`}}),js=new je({}),Fs=new H({props:{name:"class transformers.TFGPT2LMHeadModel",anchor:"transformers.TFGPT2LMHeadModel",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/gpt2/modeling_tf_gpt2.py#L843",parametersDescription:[{anchor:"transformers.TFGPT2LMHeadModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.GPT2Config">GPT2Config</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/pr_15839/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}]}}),Wo=new Le({props:{$$slots:{default:[Db]},$$scope:{ctx:q}}}),Cs=new H({props:{name:"call",anchor:"transformers.TFGPT2LMHeadModel.call",parameters:[{name:"input_ids",val:" = None"},{name:"past",val:" = None"},{name:"attention_mask",val:" = None"},{name:"token_type_ids",val:" = None"},{name:"position_ids",val:" = None"},{name:"head_mask",val:" = None"},{name:"inputs_embeds",val:" = None"},{name:"encoder_hidden_states",val:" = None"},{name:"encoder_attention_mask",val:" = None"},{name:"use_cache",val:" = None"},{name:"output_attentions",val:" = None"},{name:"output_hidden_states",val:" = None"},{name:"return_dict",val:" = None"},{name:"labels",val:" = None"},{name:"training",val:" = False"},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/gpt2/modeling_tf_gpt2.py#L864",parametersDescription:[{anchor:"transformers.TFGPT2LMHeadModel.call.input_ids",description:`<strong>input_ids</strong> (<code>Numpy array</code> or <code>tf.Tensor</code> of shape <code>(batch_size, input_ids_length)</code>) &#x2014;
<code>input_ids_length</code> = <code>sequence_length</code> if <code>past</code> is <code>None</code> else <code>past[0].shape[-2]</code> (<code>sequence_length</code> of
input past key value states). Indices of input sequence tokens in the vocabulary.</p>
<p>If <code>past</code> is used, only input IDs that do not have their past calculated should be passed as <code>input_ids</code>.</p>
<p>Indices can be obtained using <a href="/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.GPT2Tokenizer">GPT2Tokenizer</a>. See <a href="/docs/transformers/pr_15839/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> and
<a href="/docs/transformers/pr_15839/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.TFGPT2LMHeadModel.call.past",description:`<strong>past</strong> (<code>List[tf.Tensor]</code> of length <code>config.n_layers</code>) &#x2014;
Contains pre-computed hidden-states (key and values in the attention blocks) as computed by the model (see
<code>past</code> output below). Can be used to speed up sequential decoding. The token ids which have their past
given to this model should not be passed as input ids as they have already been computed.`,name:"past"},{anchor:"transformers.TFGPT2LMHeadModel.call.attention_mask",description:`<strong>attention_mask</strong> (<code>tf.Tensor</code> or <code>Numpy array</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.TFGPT2LMHeadModel.call.token_type_ids",description:`<strong>token_type_ids</strong> (<code>tf.Tensor</code> or <code>Numpy array</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.TFGPT2LMHeadModel.call.position_ids",description:`<strong>position_ids</strong> (<code>tf.Tensor</code> or <code>Numpy array</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.max_position_embeddings - 1]</code>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.TFGPT2LMHeadModel.call.head_mask",description:`<strong>head_mask</strong> (<code>Numpy array</code> or <code>tf.Tensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.TFGPT2LMHeadModel.call.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.TFGPT2LMHeadModel.call.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail. This argument can be used only in eager mode, in graph mode the value in the
config will be used instead.`,name:"output_attentions"},{anchor:"transformers.TFGPT2LMHeadModel.call.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail. This argument can be used only in eager mode, in graph mode the value in the config will be
used instead.`,name:"output_hidden_states"},{anchor:"transformers.TFGPT2LMHeadModel.call.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/pr_15839/en/main_classes/output#transformers.file_utils.ModelOutput">ModelOutput</a> instead of a plain tuple. This argument can be used
in eager mode, in graph mode the value will always be set to True.`,name:"return_dict"},{anchor:"transformers.TFGPT2LMHeadModel.call.training",description:`<strong>training</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to use the model in training mode (some modules like dropout modules have different
behaviors between training and evaluation).`,name:"training"},{anchor:"transformers.TFGPT2LMHeadModel.call.encoder_hidden_states",description:`<strong>encoder_hidden_states</strong>  (<code>tf.Tensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Sequence of hidden-states at the output of the last layer of the encoder. Used in the cross-attention if
the model is configured as a decoder.`,name:"encoder_hidden_states"},{anchor:"transformers.TFGPT2LMHeadModel.call.encoder_attention_mask",description:`<strong>encoder_attention_mask</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on the padding token indices of the encoder input. This mask is used in
the cross-attention if the model is configured as a decoder. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>`,name:"encoder_attention_mask"},{anchor:"transformers.TFGPT2LMHeadModel.call.past",description:`<strong>past</strong> (<code>Tuple[Tuple[tf.Tensor]]</code> of length <code>config.n_layers</code>) &#x2014;
contains precomputed key and value hidden states of the attention blocks. Can be used to speed up decoding.
If <code>past</code> are used, the user can optionally input only the last <code>decoder_input_ids</code> (those that don&#x2019;t have
their past key value states given to this model) of shape <code>(batch_size, 1)</code> instead of all
<code>decoder_input_ids</code> of shape <code>(batch_size, sequence_length)</code>.`,name:"past"},{anchor:"transformers.TFGPT2LMHeadModel.call.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
If set to <code>True</code>, <code>past_key_values</code> key value states are returned and can be used to speed up decoding (see
<code>past</code>). Set to <code>False</code> during training, <code>True</code> during generation`,name:"use_cache"},{anchor:"transformers.TFGPT2LMHeadModel.call.labels",description:`<strong>labels</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Labels for computing the cross entropy classification loss. Indices should be in <code>[0, ..., config.vocab_size - 1]</code>.`,name:"labels"}],returnDescription:`
<p>A <a
  href="/docs/transformers/pr_15839/en/main_classes/output#transformers.modeling_tf_outputs.TFCausalLMOutputWithCrossAttentions"
>transformers.modeling_tf_outputs.TFCausalLMOutputWithCrossAttentions</a> or a tuple of <code>tf.Tensor</code> (if
<code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various elements depending on the
configuration (<a
  href="/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.GPT2Config"
>GPT2Config</a>) and inputs.</p>
<ul>
<li>
<p><strong>loss</strong> (<code>tf.Tensor</code> of shape <code>(n,)</code>, <em>optional</em>, where n is the number of non-masked labels, returned when <code>labels</code> is provided) \u2014 Language modeling loss (for next-token prediction).</p>
</li>
<li>
<p><strong>logits</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, sequence_length, config.vocab_size)</code>) \u2014 Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(tf.Tensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>tf.Tensor</code> (one for the output of the embeddings + one for the output of each layer) of shape
<code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(tf.Tensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>tf.Tensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
<li>
<p><strong>cross_attentions</strong> (<code>tuple(tf.Tensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>tf.Tensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights of the decoder\u2019s cross-attention layer, after the attention softmax, used to compute the
weighted average in the cross-attention heads.</p>
</li>
<li>
<p><strong>past_key_values</strong> (<code>List[tf.Tensor]</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) \u2014 List of <code>tf.Tensor</code> of length <code>config.n_layers</code>, with each tensor of shape <code>(2, batch_size, num_heads, sequence_length, embed_size_per_head)</code>).</p>
<p>Contains pre-computed hidden-states (key and values in the attention blocks) that can be used (see
<code>past_key_values</code> input) to speed up sequential decoding.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/pr_15839/en/main_classes/output#transformers.modeling_tf_outputs.TFCausalLMOutputWithCrossAttentions"
>transformers.modeling_tf_outputs.TFCausalLMOutputWithCrossAttentions</a> or <code>tuple(tf.Tensor)</code></p>
`}}),Bo=new Le({props:{$$slots:{default:[Hb]},$$scope:{ctx:q}}}),Ds=new Me({props:{code:`from transformers import GPT2Tokenizer, TFGPT2LMHeadModel
import tensorflow as tf

tokenizer = GPT2Tokenizer.from_pretrained("gpt2")
model = TFGPT2LMHeadModel.from_pretrained("gpt2")

inputs = tokenizer("Hello, my dog is cute", return_tensors="tf")
outputs = model(inputs)
logits = outputs.logits`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> GPT2Tokenizer, TFGPT2LMHeadModel
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = GPT2Tokenizer.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFGPT2LMHeadModel.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(<span class="hljs-string">&quot;Hello, my dog is cute&quot;</span>, return_tensors=<span class="hljs-string">&quot;tf&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(inputs)
<span class="hljs-meta">&gt;&gt;&gt; </span>logits = outputs.logits`}}),Hs=new je({}),Ls=new H({props:{name:"class transformers.TFGPT2DoubleHeadsModel",anchor:"transformers.TFGPT2DoubleHeadsModel",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/gpt2/modeling_tf_gpt2.py#L998",parametersDescription:[{anchor:"transformers.TFGPT2DoubleHeadsModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.GPT2Config">GPT2Config</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/pr_15839/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}]}}),Ro=new Le({props:{$$slots:{default:[Lb]},$$scope:{ctx:q}}}),As=new H({props:{name:"call",anchor:"transformers.TFGPT2DoubleHeadsModel.call",parameters:[{name:"input_ids",val:" = None"},{name:"past",val:" = None"},{name:"attention_mask",val:" = None"},{name:"token_type_ids",val:" = None"},{name:"position_ids",val:" = None"},{name:"head_mask",val:" = None"},{name:"inputs_embeds",val:" = None"},{name:"mc_token_ids",val:" = None"},{name:"use_cache",val:" = None"},{name:"output_attentions",val:" = None"},{name:"output_hidden_states",val:" = None"},{name:"return_dict",val:" = None"},{name:"training",val:" = False"},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/gpt2/modeling_tf_gpt2.py#L1007",parametersDescription:[{anchor:"transformers.TFGPT2DoubleHeadsModel.call.input_ids",description:`<strong>input_ids</strong> (<code>Numpy array</code> or <code>tf.Tensor</code> of shape <code>(batch_size, input_ids_length)</code>) &#x2014;
<code>input_ids_length</code> = <code>sequence_length</code> if <code>past</code> is <code>None</code> else <code>past[0].shape[-2]</code> (<code>sequence_length</code> of
input past key value states). Indices of input sequence tokens in the vocabulary.</p>
<p>If <code>past</code> is used, only input IDs that do not have their past calculated should be passed as <code>input_ids</code>.</p>
<p>Indices can be obtained using <a href="/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.GPT2Tokenizer">GPT2Tokenizer</a>. See <a href="/docs/transformers/pr_15839/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> and
<a href="/docs/transformers/pr_15839/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.TFGPT2DoubleHeadsModel.call.past",description:`<strong>past</strong> (<code>List[tf.Tensor]</code> of length <code>config.n_layers</code>) &#x2014;
Contains pre-computed hidden-states (key and values in the attention blocks) as computed by the model (see
<code>past</code> output below). Can be used to speed up sequential decoding. The token ids which have their past
given to this model should not be passed as input ids as they have already been computed.`,name:"past"},{anchor:"transformers.TFGPT2DoubleHeadsModel.call.attention_mask",description:`<strong>attention_mask</strong> (<code>tf.Tensor</code> or <code>Numpy array</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.TFGPT2DoubleHeadsModel.call.token_type_ids",description:`<strong>token_type_ids</strong> (<code>tf.Tensor</code> or <code>Numpy array</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.TFGPT2DoubleHeadsModel.call.position_ids",description:`<strong>position_ids</strong> (<code>tf.Tensor</code> or <code>Numpy array</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.max_position_embeddings - 1]</code>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.TFGPT2DoubleHeadsModel.call.head_mask",description:`<strong>head_mask</strong> (<code>Numpy array</code> or <code>tf.Tensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.TFGPT2DoubleHeadsModel.call.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.TFGPT2DoubleHeadsModel.call.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail. This argument can be used only in eager mode, in graph mode the value in the
config will be used instead.`,name:"output_attentions"},{anchor:"transformers.TFGPT2DoubleHeadsModel.call.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail. This argument can be used only in eager mode, in graph mode the value in the config will be
used instead.`,name:"output_hidden_states"},{anchor:"transformers.TFGPT2DoubleHeadsModel.call.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/pr_15839/en/main_classes/output#transformers.file_utils.ModelOutput">ModelOutput</a> instead of a plain tuple. This argument can be used
in eager mode, in graph mode the value will always be set to True.`,name:"return_dict"},{anchor:"transformers.TFGPT2DoubleHeadsModel.call.training",description:`<strong>training</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to use the model in training mode (some modules like dropout modules have different
behaviors between training and evaluation).`,name:"training"},{anchor:"transformers.TFGPT2DoubleHeadsModel.call.mc_token_ids",description:`<strong>mc_token_ids</strong> (<code>tf.Tensor</code> or <code>Numpy array</code> of shape <code>(batch_size, num_choices)</code>, <em>optional</em>, default to index of the last token of the input) &#x2014;
Index of the classification token in each input sequence. Selected in the range <code>[0, input_ids.size(-1) - 1[</code>.`,name:"mc_token_ids"}],returnDescription:`
<p>A <a
  href="/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.models.gpt2.modeling_tf_gpt2.TFGPT2DoubleHeadsModelOutput"
>transformers.models.gpt2.modeling_tf_gpt2.TFGPT2DoubleHeadsModelOutput</a> or a tuple of <code>tf.Tensor</code> (if
<code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various elements depending on the
configuration (<a
  href="/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.GPT2Config"
>GPT2Config</a>) and inputs.</p>
<ul>
<li>
<p><strong>logits</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, num_choices, sequence_length, config.vocab_size)</code>) \u2014 Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).</p>
</li>
<li>
<p><strong>mc_logits</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, num_choices)</code>) \u2014 Prediction scores of the multiple choice classification head (scores for each choice before SoftMax).</p>
</li>
<li>
<p><strong>past_key_values</strong> (<code>List[tf.Tensor]</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) \u2014 List of <code>tf.Tensor</code> of length <code>config.n_layers</code>, with each tensor of shape <code>(2, batch_size, num_heads, sequence_length, embed_size_per_head)</code>).</p>
<p>Contains pre-computed hidden-states (key and values in the attention blocks) that can be used (see
<code>past_key_values</code> input) to speed up sequential decoding.</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(tf.Tensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>tf.Tensor</code> (one for the output of the embeddings + one for the output of each layer) of shape
<code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(tf.Tensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>tf.Tensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.models.gpt2.modeling_tf_gpt2.TFGPT2DoubleHeadsModelOutput"
>transformers.models.gpt2.modeling_tf_gpt2.TFGPT2DoubleHeadsModelOutput</a> or <code>tuple(tf.Tensor)</code></p>
`}}),Vo=new Le({props:{$$slots:{default:[Nb]},$$scope:{ctx:q}}}),Os=new Me({props:{code:`import tensorflow as tf
from transformers import GPT2Tokenizer, TFGPT2DoubleHeadsModel

tokenizer = GPT2Tokenizer.from_pretrained("gpt2")
model = TFGPT2DoubleHeadsModel.from_pretrained("gpt2")

# Add a [CLS] to the vocabulary (we should train it also!)
num_added_tokens = tokenizer.add_special_tokens({"cls_token": "[CLS]"})

embedding_layer = model.resize_token_embeddings(
    len(tokenizer)
)  # Update the model embeddings with the new vocabulary size

choices = ["Hello, my dog is cute [CLS]", "Hello, my cat is cute [CLS]"]
encoded_choices = [tokenizer.encode(s) for s in choices]
cls_token_location = [tokens.index(tokenizer.cls_token_id) for tokens in encoded_choices]

input_ids = tf.constant(encoded_choices)[None, :]  # Batch size: 1, number of choices: 2
mc_token_ids = tf.constant([cls_token_location])  # Batch size: 1

outputs = model(input_ids, mc_token_ids=mc_token_ids)
lm_prediction_scores, mc_prediction_scores = outputs[:2]`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> GPT2Tokenizer, TFGPT2DoubleHeadsModel

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = GPT2Tokenizer.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFGPT2DoubleHeadsModel.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Add a [CLS] to the vocabulary (we should train it also!)</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>num_added_tokens = tokenizer.add_special_tokens({<span class="hljs-string">&quot;cls_token&quot;</span>: <span class="hljs-string">&quot;[CLS]&quot;</span>})

<span class="hljs-meta">&gt;&gt;&gt; </span>embedding_layer = model.resize_token_embeddings(
<span class="hljs-meta">... </span>    <span class="hljs-built_in">len</span>(tokenizer)
<span class="hljs-meta">&gt;&gt;&gt; </span>)  <span class="hljs-comment"># Update the model embeddings with the new vocabulary size</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>choices = [<span class="hljs-string">&quot;Hello, my dog is cute [CLS]&quot;</span>, <span class="hljs-string">&quot;Hello, my cat is cute [CLS]&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>encoded_choices = [tokenizer.encode(s) <span class="hljs-keyword">for</span> s <span class="hljs-keyword">in</span> choices]
<span class="hljs-meta">&gt;&gt;&gt; </span>cls_token_location = [tokens.index(tokenizer.cls_token_id) <span class="hljs-keyword">for</span> tokens <span class="hljs-keyword">in</span> encoded_choices]

<span class="hljs-meta">&gt;&gt;&gt; </span>input_ids = tf.constant(encoded_choices)[<span class="hljs-literal">None</span>, :]  <span class="hljs-comment"># Batch size: 1, number of choices: 2</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>mc_token_ids = tf.constant([cls_token_location])  <span class="hljs-comment"># Batch size: 1</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(input_ids, mc_token_ids=mc_token_ids)
<span class="hljs-meta">&gt;&gt;&gt; </span>lm_prediction_scores, mc_prediction_scores = outputs[:<span class="hljs-number">2</span>]`}}),Ws=new je({}),Bs=new H({props:{name:"class transformers.TFGPT2ForSequenceClassification",anchor:"transformers.TFGPT2ForSequenceClassification",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/gpt2/modeling_tf_gpt2.py#L1170",parametersDescription:[{anchor:"transformers.TFGPT2ForSequenceClassification.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.GPT2Config">GPT2Config</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/pr_15839/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}]}}),Ko=new Le({props:{$$slots:{default:[Ib]},$$scope:{ctx:q}}}),Js=new H({props:{name:"call",anchor:"transformers.TFGPT2ForSequenceClassification.call",parameters:[{name:"input_ids",val:" = None"},{name:"past",val:" = None"},{name:"attention_mask",val:" = None"},{name:"token_type_ids",val:" = None"},{name:"position_ids",val:" = None"},{name:"head_mask",val:" = None"},{name:"inputs_embeds",val:" = None"},{name:"use_cache",val:" = None"},{name:"output_attentions",val:" = None"},{name:"output_hidden_states",val:" = None"},{name:"return_dict",val:" = None"},{name:"labels",val:" = None"},{name:"training",val:" = False"},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/gpt2/modeling_tf_gpt2.py#L1182",parametersDescription:[{anchor:"transformers.TFGPT2ForSequenceClassification.call.input_ids",description:`<strong>input_ids</strong> (<code>Numpy array</code> or <code>tf.Tensor</code> of shape <code>(batch_size, input_ids_length)</code>) &#x2014;
<code>input_ids_length</code> = <code>sequence_length</code> if <code>past</code> is <code>None</code> else <code>past[0].shape[-2]</code> (<code>sequence_length</code> of
input past key value states). Indices of input sequence tokens in the vocabulary.</p>
<p>If <code>past</code> is used, only input IDs that do not have their past calculated should be passed as <code>input_ids</code>.</p>
<p>Indices can be obtained using <a href="/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.GPT2Tokenizer">GPT2Tokenizer</a>. See <a href="/docs/transformers/pr_15839/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> and
<a href="/docs/transformers/pr_15839/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.TFGPT2ForSequenceClassification.call.past",description:`<strong>past</strong> (<code>List[tf.Tensor]</code> of length <code>config.n_layers</code>) &#x2014;
Contains pre-computed hidden-states (key and values in the attention blocks) as computed by the model (see
<code>past</code> output below). Can be used to speed up sequential decoding. The token ids which have their past
given to this model should not be passed as input ids as they have already been computed.`,name:"past"},{anchor:"transformers.TFGPT2ForSequenceClassification.call.attention_mask",description:`<strong>attention_mask</strong> (<code>tf.Tensor</code> or <code>Numpy array</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.TFGPT2ForSequenceClassification.call.token_type_ids",description:`<strong>token_type_ids</strong> (<code>tf.Tensor</code> or <code>Numpy array</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.TFGPT2ForSequenceClassification.call.position_ids",description:`<strong>position_ids</strong> (<code>tf.Tensor</code> or <code>Numpy array</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.max_position_embeddings - 1]</code>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.TFGPT2ForSequenceClassification.call.head_mask",description:`<strong>head_mask</strong> (<code>Numpy array</code> or <code>tf.Tensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.TFGPT2ForSequenceClassification.call.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.TFGPT2ForSequenceClassification.call.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail. This argument can be used only in eager mode, in graph mode the value in the
config will be used instead.`,name:"output_attentions"},{anchor:"transformers.TFGPT2ForSequenceClassification.call.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail. This argument can be used only in eager mode, in graph mode the value in the config will be
used instead.`,name:"output_hidden_states"},{anchor:"transformers.TFGPT2ForSequenceClassification.call.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/pr_15839/en/main_classes/output#transformers.file_utils.ModelOutput">ModelOutput</a> instead of a plain tuple. This argument can be used
in eager mode, in graph mode the value will always be set to True.`,name:"return_dict"},{anchor:"transformers.TFGPT2ForSequenceClassification.call.training",description:`<strong>training</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to use the model in training mode (some modules like dropout modules have different
behaviors between training and evaluation).`,name:"training"},{anchor:"transformers.TFGPT2ForSequenceClassification.call.labels",description:`<strong>labels</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Labels for computing the cross entropy classification loss. Indices should be in <code>[0, ..., config.vocab_size - 1]</code>.`,name:"labels"}],returnDescription:`
<p>A <a
  href="/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.modeling_tf_outputs.TFSequenceClassifierOutputWithPast"
>transformers.modeling_tf_outputs.TFSequenceClassifierOutputWithPast</a> or a tuple of <code>tf.Tensor</code> (if
<code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various elements depending on the
configuration (<a
  href="/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.GPT2Config"
>GPT2Config</a>) and inputs.</p>
<ul>
<li>
<p><strong>loss</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, )</code>, <em>optional</em>, returned when <code>labels</code> is provided) \u2014 Classification (or regression if config.num_labels==1) loss.</p>
</li>
<li>
<p><strong>logits</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, config.num_labels)</code>) \u2014 Classification (or regression if config.num_labels==1) scores (before SoftMax).</p>
</li>
<li>
<p><strong>past_key_values</strong> (<code>List[tf.Tensor]</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) \u2014 List of <code>tf.Tensor</code> of length <code>config.n_layers</code>, with each tensor of shape <code>(2, batch_size, num_heads, sequence_length, embed_size_per_head)</code>).</p>
<p>Contains pre-computed hidden-states (key and values in the attention blocks) that can be used (see
<code>past_key_values</code> input) to speed up sequential decoding.</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(tf.Tensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>tf.Tensor</code> (one for the output of the embeddings + one for the output of each layer) of shape
<code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(tf.Tensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>tf.Tensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.modeling_tf_outputs.TFSequenceClassifierOutputWithPast"
>transformers.modeling_tf_outputs.TFSequenceClassifierOutputWithPast</a> or <code>tuple(tf.Tensor)</code></p>
`}}),Xo=new Le({props:{$$slots:{default:[Sb]},$$scope:{ctx:q}}}),Ks=new Me({props:{code:`from transformers import GPT2Tokenizer, TFGPT2ForSequenceClassification
import tensorflow as tf

tokenizer = GPT2Tokenizer.from_pretrained("microsoft/DialogRPT-updown")
model = TFGPT2ForSequenceClassification.from_pretrained("microsoft/DialogRPT-updown")

inputs = tokenizer("Hello, my dog is cute", return_tensors="tf")
inputs["labels"] = tf.reshape(tf.constant(1), (-1, 1))  # Batch size 1

outputs = model(inputs)
loss = outputs.loss
logits = outputs.logits`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> GPT2Tokenizer, TFGPT2ForSequenceClassification
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = GPT2Tokenizer.from_pretrained(<span class="hljs-string">&quot;microsoft/DialogRPT-updown&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFGPT2ForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;microsoft/DialogRPT-updown&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(<span class="hljs-string">&quot;Hello, my dog is cute&quot;</span>, return_tensors=<span class="hljs-string">&quot;tf&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs[<span class="hljs-string">&quot;labels&quot;</span>] = tf.reshape(tf.constant(<span class="hljs-number">1</span>), (-<span class="hljs-number">1</span>, <span class="hljs-number">1</span>))  <span class="hljs-comment"># Batch size 1</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(inputs)
<span class="hljs-meta">&gt;&gt;&gt; </span>loss = outputs.loss
<span class="hljs-meta">&gt;&gt;&gt; </span>logits = outputs.logits`}}),Xs=new je({}),Ys=new H({props:{name:"class transformers.modeling_tf_outputs.TFSequenceClassifierOutputWithPast",anchor:"transformers.modeling_tf_outputs.TFSequenceClassifierOutputWithPast",parameters:[{name:"loss",val:": typing.Optional[tensorflow.python.framework.ops.Tensor] = None"},{name:"logits",val:": Tensor = None"},{name:"past_key_values",val:": typing.Optional[typing.List[tensorflow.python.framework.ops.Tensor]] = None"},{name:"hidden_states",val:": typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None"},{name:"attentions",val:": typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None"}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/modeling_tf_outputs.py#L758",parametersDescription:[{anchor:"transformers.modeling_tf_outputs.TFSequenceClassifierOutputWithPast.loss",description:`<strong>loss</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, )</code>, <em>optional</em>, returned when <code>labels</code> is provided) &#x2014;
Classification (or regression if config.num_labels==1) loss.`,name:"loss"},{anchor:"transformers.modeling_tf_outputs.TFSequenceClassifierOutputWithPast.logits",description:`<strong>logits</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, config.num_labels)</code>) &#x2014;
Classification (or regression if config.num_labels==1) scores (before SoftMax).`,name:"logits"},{anchor:"transformers.modeling_tf_outputs.TFSequenceClassifierOutputWithPast.past_key_values",description:`<strong>past_key_values</strong> (<code>List[tf.Tensor]</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) &#x2014;
List of <code>tf.Tensor</code> of length <code>config.n_layers</code>, with each tensor of shape <code>(2, batch_size, num_heads, sequence_length, embed_size_per_head)</code>).</p>
<p>Contains pre-computed hidden-states (key and values in the attention blocks) that can be used (see
<code>past_key_values</code> input) to speed up sequential decoding.`,name:"past_key_values"},{anchor:"transformers.modeling_tf_outputs.TFSequenceClassifierOutputWithPast.hidden_states",description:`<strong>hidden_states</strong> (<code>tuple(tf.Tensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) &#x2014;
Tuple of <code>tf.Tensor</code> (one for the output of the embeddings + one for the output of each layer) of shape
<code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the initial embedding outputs.`,name:"hidden_states"},{anchor:"transformers.modeling_tf_outputs.TFSequenceClassifierOutputWithPast.attentions",description:`<strong>attentions</strong> (<code>tuple(tf.Tensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) &#x2014;
Tuple of <code>tf.Tensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.`,name:"attentions"}]}}),Qs=new je({}),Zs=new H({props:{name:"class transformers.FlaxGPT2Model",anchor:"transformers.FlaxGPT2Model",parameters:[{name:"config",val:": GPT2Config"},{name:"input_shape",val:": typing.Tuple = (1, 1)"},{name:"seed",val:": int = 0"},{name:"dtype",val:": dtype = <class 'jax._src.numpy.lax_numpy.float32'>"},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/gpt2/modeling_flax_gpt2.py#L654",parametersDescription:[{anchor:"transformers.FlaxGPT2Model.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.GPT2Config">GPT2Config</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/pr_15839/en/main_classes/model#transformers.FlaxPreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"},{anchor:"transformers.FlaxGPT2Model.dtype",description:`<strong>dtype</strong> (<code>jax.numpy.dtype</code>, <em>optional</em>, defaults to <code>jax.numpy.float32</code>) &#x2014;
The data type of the computation. Can be one of <code>jax.numpy.float32</code>, <code>jax.numpy.float16</code> (on GPUs) and
<code>jax.numpy.bfloat16</code> (on TPUs).</p>
<p>This can be used to enable mixed-precision training or half-precision inference on GPUs or TPUs. If
specified all the computation will be performed with the given <code>dtype</code>.</p>
<p><strong>Note that this only specifies the dtype of the computation and does not influence the dtype of model
parameters.</strong></p>
<p>If you wish to change the dtype of the model parameters, see <a href="/docs/transformers/pr_15839/en/main_classes/model#transformers.FlaxPreTrainedModel.to_fp16">to_fp16()</a> and
<a href="/docs/transformers/pr_15839/en/main_classes/model#transformers.FlaxPreTrainedModel.to_bf16">to_bf16()</a>.`,name:"dtype"}]}}),ia=new H({props:{name:"__call__",anchor:"transformers.FlaxGPT2PreTrainedModel.__call__",parameters:[{name:"input_ids",val:""},{name:"attention_mask",val:" = None"},{name:"position_ids",val:" = None"},{name:"encoder_hidden_states",val:": typing.Optional[jax._src.numpy.lax_numpy.ndarray] = None"},{name:"encoder_attention_mask",val:": typing.Optional[jax._src.numpy.lax_numpy.ndarray] = None"},{name:"params",val:": dict = None"},{name:"past_key_values",val:": dict = None"},{name:"dropout_rng",val:": PRNGKey = None"},{name:"train",val:": bool = False"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/gpt2/modeling_flax_gpt2.py#L447",parametersDescription:[{anchor:"transformers.FlaxGPT2PreTrainedModel.__call__.input_ids",description:`<strong>input_ids</strong> (<code>numpy.ndarray</code> of shape <code>(batch_size, input_ids_length)</code>) &#x2014;
<code>input_ids_length</code> = <code>sequence_length</code>. Indices of input sequence tokens in the vocabulary.</p>
<p>Indices can be obtained using <a href="/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.GPT2Tokenizer">GPT2Tokenizer</a>. See <a href="/docs/transformers/pr_15839/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/pr_15839/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.FlaxGPT2PreTrainedModel.__call__.attention_mask",description:`<strong>attention_mask</strong> (<code>numpy.ndarray</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.FlaxGPT2PreTrainedModel.__call__.position_ids",description:`<strong>position_ids</strong> (<code>numpy.ndarray</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.max_position_embeddings - 1]</code>.`,name:"position_ids"},{anchor:"transformers.FlaxGPT2PreTrainedModel.__call__.past_key_values",description:`<strong>past_key_values</strong> (<code>Dict[str, np.ndarray]</code>, <em>optional</em>, returned by <code>init_cache</code> or when passing previous <code>past_key_values</code>) &#x2014;
Dictionary of pre-computed hidden-states (key and values in the attention blocks) that can be used for fast
auto-regressive decoding. Pre-computed key and value hidden-states are of shape <em>[batch_size, max_length]</em>.`,name:"past_key_values"},{anchor:"transformers.FlaxGPT2PreTrainedModel.__call__.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.FlaxGPT2PreTrainedModel.__call__.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.FlaxGPT2PreTrainedModel.__call__.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/pr_15839/en/main_classes/output#transformers.file_utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],returnDescription:`
<p>A <a
  href="/docs/transformers/pr_15839/en/main_classes/output#transformers.modeling_flax_outputs.FlaxBaseModelOutputWithPastAndCrossAttentions"
>transformers.modeling_flax_outputs.FlaxBaseModelOutputWithPastAndCrossAttentions</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.GPT2Config"
>GPT2Config</a>) and inputs.</p>
<ul>
<li>
<p><strong>last_hidden_state</strong> (<code>jnp.ndarray</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>) \u2014 Sequence of hidden-states at the output of the last layer of the model.</p>
<p>If <code>past_key_values</code> is used only the last hidden-state of the sequences of shape <code>(batch_size, 1, hidden_size)</code> is output.</p>
</li>
<li>
<p><strong>past_key_values</strong> (<code>tuple(tuple(jnp.ndarray))</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) \u2014 Tuple of <code>tuple(jnp.ndarray)</code> of length <code>config.n_layers</code>, with each tuple having 2 tensors of shape
<code>(batch_size, num_heads, sequence_length, embed_size_per_head)</code>) and optionally if
<code>config.is_encoder_decoder=True</code> 2 additional tensors of shape <code>(batch_size, num_heads, encoder_sequence_length, embed_size_per_head)</code>.</p>
<p>Contains pre-computed hidden-states (key and values in the self-attention blocks and optionally if
<code>config.is_encoder_decoder=True</code> in the cross-attention blocks) that can be used (see <code>past_key_values</code>
input) to speed up sequential decoding.</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(jnp.ndarray)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>jnp.ndarray</code> (one for the output of the embeddings + one for the output of each layer) of shape
<code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(jnp.ndarray)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>jnp.ndarray</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
<li>
<p><strong>cross_attentions</strong> (<code>tuple(jnp.ndarray)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> and <code>config.add_cross_attention=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>jnp.ndarray</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights of the decoder\u2019s cross-attention layer, after the attention softmax, used to compute the
weighted average in the cross-attention heads.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/pr_15839/en/main_classes/output#transformers.modeling_flax_outputs.FlaxBaseModelOutputWithPastAndCrossAttentions"
>transformers.modeling_flax_outputs.FlaxBaseModelOutputWithPastAndCrossAttentions</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Zo=new Le({props:{$$slots:{default:[Ab]},$$scope:{ctx:q}}}),la=new Me({props:{code:`from transformers import GPT2Tokenizer, FlaxGPT2Model

tokenizer = GPT2Tokenizer.from_pretrained("gpt2")
model = FlaxGPT2Model.from_pretrained("gpt2")

inputs = tokenizer("Hello, my dog is cute", return_tensors="jax")
outputs = model(**inputs)

last_hidden_states = outputs.last_hidden_state`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> GPT2Tokenizer, FlaxGPT2Model

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = GPT2Tokenizer.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = FlaxGPT2Model.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(<span class="hljs-string">&quot;Hello, my dog is cute&quot;</span>, return_tensors=<span class="hljs-string">&quot;jax&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**inputs)

<span class="hljs-meta">&gt;&gt;&gt; </span>last_hidden_states = outputs.last_hidden_state`}}),da=new je({}),ca=new H({props:{name:"class transformers.FlaxGPT2LMHeadModel",anchor:"transformers.FlaxGPT2LMHeadModel",parameters:[{name:"config",val:": GPT2Config"},{name:"input_shape",val:": typing.Tuple = (1, 1)"},{name:"seed",val:": int = 0"},{name:"dtype",val:": dtype = <class 'jax._src.numpy.lax_numpy.float32'>"},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/gpt2/modeling_flax_gpt2.py#L732",parametersDescription:[{anchor:"transformers.FlaxGPT2LMHeadModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.GPT2Config">GPT2Config</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/pr_15839/en/main_classes/model#transformers.FlaxPreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"},{anchor:"transformers.FlaxGPT2LMHeadModel.dtype",description:`<strong>dtype</strong> (<code>jax.numpy.dtype</code>, <em>optional</em>, defaults to <code>jax.numpy.float32</code>) &#x2014;
The data type of the computation. Can be one of <code>jax.numpy.float32</code>, <code>jax.numpy.float16</code> (on GPUs) and
<code>jax.numpy.bfloat16</code> (on TPUs).</p>
<p>This can be used to enable mixed-precision training or half-precision inference on GPUs or TPUs. If
specified all the computation will be performed with the given <code>dtype</code>.</p>
<p><strong>Note that this only specifies the dtype of the computation and does not influence the dtype of model
parameters.</strong></p>
<p>If you wish to change the dtype of the model parameters, see <a href="/docs/transformers/pr_15839/en/main_classes/model#transformers.FlaxPreTrainedModel.to_fp16">to_fp16()</a> and
<a href="/docs/transformers/pr_15839/en/main_classes/model#transformers.FlaxPreTrainedModel.to_bf16">to_bf16()</a>.`,name:"dtype"}]}}),Ta=new H({props:{name:"__call__",anchor:"transformers.FlaxGPT2PreTrainedModel.__call__",parameters:[{name:"input_ids",val:""},{name:"attention_mask",val:" = None"},{name:"position_ids",val:" = None"},{name:"encoder_hidden_states",val:": typing.Optional[jax._src.numpy.lax_numpy.ndarray] = None"},{name:"encoder_attention_mask",val:": typing.Optional[jax._src.numpy.lax_numpy.ndarray] = None"},{name:"params",val:": dict = None"},{name:"past_key_values",val:": dict = None"},{name:"dropout_rng",val:": PRNGKey = None"},{name:"train",val:": bool = False"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/gpt2/modeling_flax_gpt2.py#L447",parametersDescription:[{anchor:"transformers.FlaxGPT2PreTrainedModel.__call__.input_ids",description:`<strong>input_ids</strong> (<code>numpy.ndarray</code> of shape <code>(batch_size, input_ids_length)</code>) &#x2014;
<code>input_ids_length</code> = <code>sequence_length</code>. Indices of input sequence tokens in the vocabulary.</p>
<p>Indices can be obtained using <a href="/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.GPT2Tokenizer">GPT2Tokenizer</a>. See <a href="/docs/transformers/pr_15839/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/pr_15839/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.FlaxGPT2PreTrainedModel.__call__.attention_mask",description:`<strong>attention_mask</strong> (<code>numpy.ndarray</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.FlaxGPT2PreTrainedModel.__call__.position_ids",description:`<strong>position_ids</strong> (<code>numpy.ndarray</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.max_position_embeddings - 1]</code>.`,name:"position_ids"},{anchor:"transformers.FlaxGPT2PreTrainedModel.__call__.past_key_values",description:`<strong>past_key_values</strong> (<code>Dict[str, np.ndarray]</code>, <em>optional</em>, returned by <code>init_cache</code> or when passing previous <code>past_key_values</code>) &#x2014;
Dictionary of pre-computed hidden-states (key and values in the attention blocks) that can be used for fast
auto-regressive decoding. Pre-computed key and value hidden-states are of shape <em>[batch_size, max_length]</em>.`,name:"past_key_values"},{anchor:"transformers.FlaxGPT2PreTrainedModel.__call__.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.FlaxGPT2PreTrainedModel.__call__.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.FlaxGPT2PreTrainedModel.__call__.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/pr_15839/en/main_classes/output#transformers.file_utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],returnDescription:`
<p>A <a
  href="/docs/transformers/pr_15839/en/main_classes/output#transformers.modeling_flax_outputs.FlaxCausalLMOutputWithCrossAttentions"
>transformers.modeling_flax_outputs.FlaxCausalLMOutputWithCrossAttentions</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.GPT2Config"
>GPT2Config</a>) and inputs.</p>
<ul>
<li>
<p><strong>logits</strong> (<code>jnp.ndarray</code> of shape <code>(batch_size, sequence_length, config.vocab_size)</code>) \u2014 Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(jnp.ndarray)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>jnp.ndarray</code> (one for the output of the embeddings + one for the output of each layer) of shape
<code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(jnp.ndarray)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>jnp.ndarray</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
<li>
<p><strong>cross_attentions</strong> (<code>tuple(jnp.ndarray)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>jnp.ndarray</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Cross attentions weights after the attention softmax, used to compute the weighted average in the
cross-attention heads.</p>
</li>
<li>
<p><strong>past_key_values</strong> (<code>tuple(tuple(jnp.ndarray))</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) \u2014 Tuple of <code>jnp.ndarray</code> tuples of length <code>config.n_layers</code>, with each tuple containing the cached key, value
states of the self-attention and the cross-attention layers if model is used in encoder-decoder setting.
Only relevant if <code>config.is_decoder = True</code>.</p>
<p>Contains pre-computed hidden-states (key and values in the attention blocks) that can be used (see
<code>past_key_values</code> input) to speed up sequential decoding.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/pr_15839/en/main_classes/output#transformers.modeling_flax_outputs.FlaxCausalLMOutputWithCrossAttentions"
>transformers.modeling_flax_outputs.FlaxCausalLMOutputWithCrossAttentions</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),tn=new Le({props:{$$slots:{default:[Ob]},$$scope:{ctx:q}}}),va=new Me({props:{code:`from transformers import GPT2Tokenizer, FlaxGPT2LMHeadModel

tokenizer = GPT2Tokenizer.from_pretrained("gpt2")
model = FlaxGPT2LMHeadModel.from_pretrained("gpt2")

inputs = tokenizer("Hello, my dog is cute", return_tensors="np")
outputs = model(**inputs)

# retrieve logts for next token
next_token_logits = outputs.logits[:, -1]`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> GPT2Tokenizer, FlaxGPT2LMHeadModel

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = GPT2Tokenizer.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = FlaxGPT2LMHeadModel.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(<span class="hljs-string">&quot;Hello, my dog is cute&quot;</span>, return_tensors=<span class="hljs-string">&quot;np&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**inputs)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># retrieve logts for next token</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>next_token_logits = outputs.logits[:, -<span class="hljs-number">1</span>]`}}),{c(){p=n("meta"),M=l(),f=n("h1"),T=n("a"),$=n("span"),v(_.$$.fragment),g=l(),z=n("span"),Q=a("OpenAI GPT2"),C=l(),j=n("h2"),R=n("a"),S=n("span"),v(Z.$$.fragment),ue=l(),A=n("span"),me=a("Overview"),ce=l(),W=n("p"),L=a("OpenAI GPT-2 model was proposed in "),ee=n("a"),te=a("Language Models are Unsupervised Multitask Learners"),F=a(` by Alec
Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei and Ilya Sutskever. It\u2019s a causal (unidirectional)
transformer pretrained using language modeling on a very large corpus of ~40 GB of text data.`),E=l(),se=n("p"),V=a("The abstract from the paper is the following:"),pe=l(),ae=n("p"),O=n("em"),fe=a(`GPT-2 is a large transformer-based language model with 1.5 billion parameters, trained on a dataset[1] of 8 million
web pages. GPT-2 is trained with a simple objective: predict the next word, given all of the previous words within some
text. The diversity of the dataset causes this simple goal to contain naturally occurring demonstrations of many tasks
across diverse domains. GPT-2 is a direct scale-up of GPT, with more than 10X the parameters and trained on more than
10X the amount of data.`),he=l(),x=n("p"),ge=a("Tips:"),B=l(),U=n("ul"),re=n("li"),J=a(`GPT-2 is a model with absolute position embeddings so it\u2019s usually advised to pad the inputs on the right rather than
the left.`),_e=l(),oe=n("li"),N=a(`GPT-2 was trained with a causal language modeling (CLM) objective and is therefore powerful at predicting the next
token in a sequence. Leveraging this feature allows GPT-2 to generate syntactically coherent text as it can be
observed in the `),ie=n("em"),K=a("run_generation.py"),Te=a(" example script."),u=l(),G=n("li"),ne=a("The model can take the "),Fe=n("em"),Se=a("past_key_values"),I=a(" (for PyTorch) or "),xe=n("em"),Ae=a("past"),Oe=a(` (for TF) as input, which is the previously computed
key/value attention pairs. Using this (`),D=n("em"),X=a("past_key_values"),We=a(" or "),Ee=n("em"),Y=a("past"),Be=a(`) value prevents the model from re-computing
pre-computed values in the context of text generation. For PyTorch, see `),qe=n("em"),ve=a("past_key_values"),Ue=a(` argument of the
`),Pa=n("a"),ac=a("GPT2Model.forward()"),rc=a(" method, or for TF the "),gr=n("em"),ic=a("past"),lc=a(` argument of the
`),$a=n("a"),dc=a("TFGPT2Model.call()"),cc=a(" method for more information on its usage."),pc=l(),kt=n("li"),hc=a("Enabling the "),_r=n("em"),uc=a("scale_attn_by_inverse_layer_idx"),mc=a(" and "),Tr=n("em"),fc=a("reorder_and_upcast_attn"),gc=a(` flags will apply the training stability
improvements from `),dn=n("a"),_c=a("Mistral"),Tc=a(" (for PyTorch only)."),xl=l(),Bt=n("p"),cn=n("a"),vc=a("Write With Transformer"),bc=a(` is a webapp created and hosted by
Hugging Face showcasing the generative capabilities of several models. GPT-2 is one of them and is available in five
different sizes: small, medium, large, xl and a distilled version of the small checkpoint: `),vr=n("em"),kc=a("distilgpt-2"),yc=a("."),El=l(),Mt=n("p"),wc=a("This model was contributed by "),pn=n("a"),Pc=a("thomwolf"),$c=a(". The original code can be found "),hn=n("a"),Mc=a("here"),Gc=a("."),ql=l(),Ut=n("h2"),wo=n("a"),br=n("span"),v(un.$$.fragment),zc=l(),kr=n("span"),jc=a("GPT2Config"),Cl=l(),Re=n("div"),v(mn.$$.fragment),Fc=l(),yt=n("p"),xc=a("This is the configuration class to store the configuration of a "),Ma=n("a"),Ec=a("GPT2Model"),qc=a(" or a "),Ga=n("a"),Cc=a("TFGPT2Model"),Dc=a(`. It is used to
instantiate a GPT-2 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 GPT-2
`),fn=n("a"),Hc=a("small"),Lc=a(" architecture."),Nc=l(),Rt=n("p"),Ic=a("Configuration objects inherit from "),za=n("a"),Sc=a("PretrainedConfig"),Ac=a(` and can be used to control the model outputs. Read the
documentation from `),ja=n("a"),Oc=a("PretrainedConfig"),Wc=a(" for more information."),Bc=l(),yr=n("p"),Uc=a("Example:"),Rc=l(),v(gn.$$.fragment),Dl=l(),Vt=n("h2"),Po=n("a"),wr=n("span"),v(_n.$$.fragment),Vc=l(),Pr=n("span"),Jc=a("GPT2Tokenizer"),Hl=l(),le=n("div"),v(Tn.$$.fragment),Kc=l(),$r=n("p"),Xc=a("Construct a GPT-2 tokenizer. Based on byte-level Byte-Pair-Encoding."),Yc=l(),Mr=n("p"),Qc=a(`This tokenizer has been trained to treat spaces like parts of the tokens (a bit like sentencepiece) so a word will
be encoded differently whether it is at the beginning of the sentence (without space) or not:`),Zc=l(),v(vn.$$.fragment),ep=l(),bn=n("p"),tp=a("You can get around that behavior by passing "),Gr=n("code"),op=a("add_prefix_space=True"),np=a(` when instantiating this tokenizer or when you
call it on some text, but since the model was not pretrained this way, it might yield a decrease in performance.`),sp=l(),v($o.$$.fragment),ap=l(),kn=n("p"),rp=a("This tokenizer inherits from "),Fa=n("a"),ip=a("PreTrainedTokenizer"),lp=a(` which contains most of the main methods. Users should refer to
this superclass for more information regarding those methods.`),dp=l(),xa=n("div"),v(yn.$$.fragment),Ll=l(),Jt=n("h2"),Mo=n("a"),zr=n("span"),v(wn.$$.fragment),cp=l(),jr=n("span"),pp=a("GPT2TokenizerFast"),Nl=l(),be=n("div"),v(Pn.$$.fragment),hp=l(),$n=n("p"),up=a("Construct a \u201Cfast\u201D GPT-2 tokenizer (backed by HuggingFace\u2019s "),Fr=n("em"),mp=a("tokenizers"),fp=a(` library). Based on byte-level
Byte-Pair-Encoding.`),gp=l(),xr=n("p"),_p=a(`This tokenizer has been trained to treat spaces like parts of the tokens (a bit like sentencepiece) so a word will
be encoded differently whether it is at the beginning of the sentence (without space) or not:`),Tp=l(),v(Mn.$$.fragment),vp=l(),Gn=n("p"),bp=a("You can get around that behavior by passing "),Er=n("code"),kp=a("add_prefix_space=True"),yp=a(` when instantiating this tokenizer, but since
the model was not pretrained this way, it might yield a decrease in performance.`),wp=l(),v(Go.$$.fragment),Pp=l(),zn=n("p"),$p=a("This tokenizer inherits from "),Ea=n("a"),Mp=a("PreTrainedTokenizerFast"),Gp=a(` which contains most of the main methods. Users should
refer to this superclass for more information regarding those methods.`),Il=l(),Kt=n("h2"),zo=n("a"),qr=n("span"),v(jn.$$.fragment),zp=l(),Cr=n("span"),jp=a("GPT2 specific outputs"),Sl=l(),Xt=n("div"),v(Fn.$$.fragment),Fp=l(),Dr=n("p"),xp=a("Base class for outputs of models predicting if two sentences are consecutive or not."),Al=l(),Yt=n("div"),v(xn.$$.fragment),Ep=l(),Hr=n("p"),qp=a("Base class for outputs of models predicting if two sentences are consecutive or not."),Ol=l(),Qt=n("h2"),jo=n("a"),Lr=n("span"),v(En.$$.fragment),Cp=l(),Nr=n("span"),Dp=a("GPT2Model"),Wl=l(),ke=n("div"),v(qn.$$.fragment),Hp=l(),Ir=n("p"),Lp=a("The bare GPT2 Model transformer outputting raw hidden-states without any specific head on top."),Np=l(),Cn=n("p"),Ip=a("This model inherits from "),qa=n("a"),Sp=a("PreTrainedModel"),Ap=a(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),Op=l(),Dn=n("p"),Wp=a("This model is also a PyTorch "),Hn=n("a"),Bp=a("torch.nn.Module"),Up=a(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Rp=l(),Ke=n("div"),v(Ln.$$.fragment),Vp=l(),Zt=n("p"),Jp=a("The "),Ca=n("a"),Kp=a("GPT2Model"),Xp=a(" forward method, overrides the "),Sr=n("code"),Yp=a("__call__"),Qp=a(" special method."),Zp=l(),v(Fo.$$.fragment),eh=l(),Ar=n("p"),th=a("Example:"),oh=l(),v(Nn.$$.fragment),nh=l(),Xe=n("div"),v(In.$$.fragment),sh=l(),Or=n("p"),ah=a("This is an experimental feature and is a subject to change at a moment\u2019s notice."),rh=l(),Wr=n("p"),ih=a(`Uses a device map to distribute attention modules of the model across several devices. If no device map is given,
it will evenly distribute blocks across all devices.`),lh=l(),Br=n("p"),dh=a("Example:"),ch=l(),v(Sn.$$.fragment),ph=l(),gt=n("div"),v(An.$$.fragment),hh=l(),Ur=n("p"),uh=a("Moves the model to cpu from a model parallel state."),mh=l(),Rr=n("p"),fh=a("Example:"),gh=l(),v(On.$$.fragment),Bl=l(),eo=n("h2"),xo=n("a"),Vr=n("span"),v(Wn.$$.fragment),_h=l(),Jr=n("span"),Th=a("GPT2LMHeadModel"),Ul=l(),ye=n("div"),v(Bn.$$.fragment),vh=l(),Kr=n("p"),bh=a(`The GPT2 Model transformer with a language modeling head on top (linear layer with weights tied to the input
embeddings).`),kh=l(),Un=n("p"),yh=a("This model inherits from "),Da=n("a"),wh=a("PreTrainedModel"),Ph=a(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),$h=l(),Rn=n("p"),Mh=a("This model is also a PyTorch "),Vn=n("a"),Gh=a("torch.nn.Module"),zh=a(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),jh=l(),Ye=n("div"),v(Jn.$$.fragment),Fh=l(),to=n("p"),xh=a("The "),Ha=n("a"),Eh=a("GPT2LMHeadModel"),qh=a(" forward method, overrides the "),Xr=n("code"),Ch=a("__call__"),Dh=a(" special method."),Hh=l(),v(Eo.$$.fragment),Lh=l(),Yr=n("p"),Nh=a("Example:"),Ih=l(),v(Kn.$$.fragment),Sh=l(),Qe=n("div"),v(Xn.$$.fragment),Ah=l(),Qr=n("p"),Oh=a("This is an experimental feature and is a subject to change at a moment\u2019s notice."),Wh=l(),Zr=n("p"),Bh=a(`Uses a device map to distribute attention modules of the model across several devices. If no device map is given,
it will evenly distribute blocks across all devices.`),Uh=l(),ei=n("p"),Rh=a("Example:"),Vh=l(),v(Yn.$$.fragment),Jh=l(),_t=n("div"),v(Qn.$$.fragment),Kh=l(),ti=n("p"),Xh=a("Moves the model to cpu from a model parallel state."),Yh=l(),oi=n("p"),Qh=a("Example:"),Zh=l(),v(Zn.$$.fragment),Rl=l(),oo=n("h2"),qo=n("a"),ni=n("span"),v(es.$$.fragment),eu=l(),si=n("span"),tu=a("GPT2DoubleHeadsModel"),Vl=l(),Ve=n("div"),v(ts.$$.fragment),ou=l(),ai=n("p"),nu=a(`The GPT2 Model transformer with a language modeling and a multiple-choice classification head on top e.g. for
RocStories/SWAG tasks. The two heads are two linear layers. The language modeling head has its weights tied to the
input embeddings, the classification head takes as input the input of a specified classification token index in the
input sequence).`),su=l(),os=n("p"),au=a("This model inherits from "),La=n("a"),ru=a("PreTrainedModel"),iu=a(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),lu=l(),ns=n("p"),du=a("This model is also a PyTorch "),ss=n("a"),cu=a("torch.nn.Module"),pu=a(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),hu=l(),Ze=n("div"),v(as.$$.fragment),uu=l(),no=n("p"),mu=a("The "),Na=n("a"),fu=a("GPT2DoubleHeadsModel"),gu=a(" forward method, overrides the "),ri=n("code"),_u=a("__call__"),Tu=a(" special method."),vu=l(),v(Co.$$.fragment),bu=l(),ii=n("p"),ku=a("Example:"),yu=l(),v(rs.$$.fragment),Jl=l(),so=n("h2"),Do=n("a"),li=n("span"),v(is.$$.fragment),wu=l(),di=n("span"),Pu=a("GPT2ForSequenceClassification"),Kl=l(),we=n("div"),v(ls.$$.fragment),$u=l(),ci=n("p"),Mu=a("The GPT2 Model transformer with a sequence classification head on top (linear layer)."),Gu=l(),Ia=n("p"),Sa=n("a"),zu=a("GPT2ForSequenceClassification"),ju=a(` uses the last token in order to do the classification, as other causal models
(e.g. GPT-1) do.`),Fu=l(),mt=n("p"),xu=a(`Since it does classification on the last token, it requires to know the position of the last token. If a
`),pi=n("code"),Eu=a("pad_token_id"),qu=a(` is defined in the configuration, it finds the last token that is not a padding token in each row. If
no `),hi=n("code"),Cu=a("pad_token_id"),Du=a(` is defined, it simply takes the last value in each row of the batch. Since it cannot guess the
padding tokens when `),ui=n("code"),Hu=a("inputs_embeds"),Lu=a(" are passed instead of "),mi=n("code"),Nu=a("input_ids"),Iu=a(`, it does the same (take the last value in
each row of the batch).`),Su=l(),ds=n("p"),Au=a("This model inherits from "),Aa=n("a"),Ou=a("PreTrainedModel"),Wu=a(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),Bu=l(),cs=n("p"),Uu=a("This model is also a PyTorch "),ps=n("a"),Ru=a("torch.nn.Module"),Vu=a(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Ju=l(),Ge=n("div"),v(hs.$$.fragment),Ku=l(),ao=n("p"),Xu=a("The "),Oa=n("a"),Yu=a("GPT2ForSequenceClassification"),Qu=a(" forward method, overrides the "),fi=n("code"),Zu=a("__call__"),em=a(" special method."),tm=l(),v(Ho.$$.fragment),om=l(),gi=n("p"),nm=a("Example of single-label classification:"),sm=l(),v(us.$$.fragment),am=l(),_i=n("p"),rm=a("Example of multi-label classification:"),im=l(),v(ms.$$.fragment),Xl=l(),ro=n("h2"),Lo=n("a"),Ti=n("span"),v(fs.$$.fragment),lm=l(),vi=n("span"),dm=a("GPT2ForTokenClassification"),Yl=l(),Je=n("div"),v(gs.$$.fragment),cm=l(),bi=n("p"),pm=a(`GPT2 Model with a token classification head on top (a linear layer on top of the hidden-states output) e.g. for
Named-Entity-Recognition (NER) tasks.`),hm=l(),_s=n("p"),um=a("This model inherits from "),Wa=n("a"),mm=a("PreTrainedModel"),fm=a(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),gm=l(),Ts=n("p"),_m=a("This model is also a PyTorch "),vs=n("a"),Tm=a("torch.nn.Module"),vm=a(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),bm=l(),et=n("div"),v(bs.$$.fragment),km=l(),io=n("p"),ym=a("The "),Ba=n("a"),wm=a("GPT2ForTokenClassification"),Pm=a(" forward method, overrides the "),ki=n("code"),$m=a("__call__"),Mm=a(" special method."),Gm=l(),v(No.$$.fragment),zm=l(),yi=n("p"),jm=a("Example:"),Fm=l(),v(ks.$$.fragment),Ql=l(),lo=n("h2"),Io=n("a"),wi=n("span"),v(ys.$$.fragment),xm=l(),Pi=n("span"),Em=a("TFGPT2Model"),Zl=l(),Ce=n("div"),v(ws.$$.fragment),qm=l(),$i=n("p"),Cm=a("The bare GPT2 Model transformer outputting raw hidden-states without any specific head on top."),Dm=l(),Ps=n("p"),Hm=a("This model inherits from "),Ua=n("a"),Lm=a("TFPreTrainedModel"),Nm=a(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),Im=l(),$s=n("p"),Sm=a("This model is also a "),Ms=n("a"),Am=a("tf.keras.Model"),Om=a(` subclass. Use it
as a regular TF 2.0 Keras Model and refer to the TF 2.0 documentation for all matter related to general usage and
behavior.`),Wm=l(),v(So.$$.fragment),Bm=l(),tt=n("div"),v(Gs.$$.fragment),Um=l(),co=n("p"),Rm=a("The "),Ra=n("a"),Vm=a("TFGPT2Model"),Jm=a(" forward method, overrides the "),Mi=n("code"),Km=a("__call__"),Xm=a(" special method."),Ym=l(),v(Ao.$$.fragment),Qm=l(),Gi=n("p"),Zm=a("Example:"),ef=l(),v(zs.$$.fragment),ed=l(),po=n("h2"),Oo=n("a"),zi=n("span"),v(js.$$.fragment),tf=l(),ji=n("span"),of=a("TFGPT2LMHeadModel"),td=l(),De=n("div"),v(Fs.$$.fragment),nf=l(),Fi=n("p"),sf=a(`The GPT2 Model transformer with a language modeling head on top (linear layer with weights tied to the input
embeddings).`),af=l(),xs=n("p"),rf=a("This model inherits from "),Va=n("a"),lf=a("TFPreTrainedModel"),df=a(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),cf=l(),Es=n("p"),pf=a("This model is also a "),qs=n("a"),hf=a("tf.keras.Model"),uf=a(` subclass. Use it
as a regular TF 2.0 Keras Model and refer to the TF 2.0 documentation for all matter related to general usage and
behavior.`),mf=l(),v(Wo.$$.fragment),ff=l(),ot=n("div"),v(Cs.$$.fragment),gf=l(),ho=n("p"),_f=a("The "),Ja=n("a"),Tf=a("TFGPT2LMHeadModel"),vf=a(" forward method, overrides the "),xi=n("code"),bf=a("__call__"),kf=a(" special method."),yf=l(),v(Bo.$$.fragment),wf=l(),Ei=n("p"),Pf=a("Example:"),$f=l(),v(Ds.$$.fragment),od=l(),uo=n("h2"),Uo=n("a"),qi=n("span"),v(Hs.$$.fragment),Mf=l(),Ci=n("span"),Gf=a("TFGPT2DoubleHeadsModel"),nd=l(),He=n("div"),v(Ls.$$.fragment),zf=l(),Di=n("p"),jf=a(`The GPT2 Model transformer with a language modeling and a multiple-choice classification head on top e.g. for
RocStories/SWAG tasks. The two heads are two linear layers. The language modeling head has its weights tied to the
input embeddings, the classification head takes as input the input of a specified classification token index in the
input sequence).`),Ff=l(),Ns=n("p"),xf=a("This model inherits from "),Ka=n("a"),Ef=a("TFPreTrainedModel"),qf=a(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),Cf=l(),Is=n("p"),Df=a("This model is also a "),Ss=n("a"),Hf=a("tf.keras.Model"),Lf=a(` subclass. Use it
as a regular TF 2.0 Keras Model and refer to the TF 2.0 documentation for all matter related to general usage and
behavior.`),Nf=l(),v(Ro.$$.fragment),If=l(),nt=n("div"),v(As.$$.fragment),Sf=l(),mo=n("p"),Af=a("The "),Xa=n("a"),Of=a("TFGPT2DoubleHeadsModel"),Wf=a(" forward method, overrides the "),Hi=n("code"),Bf=a("__call__"),Uf=a(" special method."),Rf=l(),v(Vo.$$.fragment),Vf=l(),Li=n("p"),Jf=a("Examples:"),Kf=l(),v(Os.$$.fragment),sd=l(),fo=n("h2"),Jo=n("a"),Ni=n("span"),v(Ws.$$.fragment),Xf=l(),Ii=n("span"),Yf=a("TFGPT2ForSequenceClassification"),ad=l(),de=n("div"),v(Bs.$$.fragment),Qf=l(),Si=n("p"),Zf=a("The GPT2 Model transformer with a sequence classification head on top (linear layer)."),eg=l(),Ya=n("p"),Qa=n("a"),tg=a("TFGPT2ForSequenceClassification"),og=a(` uses the last token in order to do the classification, as other causal models
(e.g. GPT-1) do.`),ng=l(),ft=n("p"),sg=a(`Since it does classification on the last token, it requires to know the position of the last token. If a
`),Ai=n("code"),ag=a("pad_token_id"),rg=a(` is defined in the configuration, it finds the last token that is not a padding token in each row. If
no `),Oi=n("code"),ig=a("pad_token_id"),lg=a(` is defined, it simply takes the last value in each row of the batch. Since it cannot guess the
padding tokens when `),Wi=n("code"),dg=a("inputs_embeds"),cg=a(" are passed instead of "),Bi=n("code"),pg=a("input_ids"),hg=a(`, it does the same (take the last value in
each row of the batch).`),ug=l(),Us=n("p"),mg=a("This model inherits from "),Za=n("a"),fg=a("TFPreTrainedModel"),gg=a(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),_g=l(),Rs=n("p"),Tg=a("This model is also a "),Vs=n("a"),vg=a("tf.keras.Model"),bg=a(` subclass. Use it
as a regular TF 2.0 Keras Model and refer to the TF 2.0 documentation for all matter related to general usage and
behavior.`),kg=l(),v(Ko.$$.fragment),yg=l(),st=n("div"),v(Js.$$.fragment),wg=l(),go=n("p"),Pg=a("The "),er=n("a"),$g=a("TFGPT2ForSequenceClassification"),Mg=a(" forward method, overrides the "),Ui=n("code"),Gg=a("__call__"),zg=a(" special method."),jg=l(),v(Xo.$$.fragment),Fg=l(),Ri=n("p"),xg=a("Example:"),Eg=l(),v(Ks.$$.fragment),rd=l(),_o=n("h2"),Yo=n("a"),Vi=n("span"),v(Xs.$$.fragment),qg=l(),Ji=n("span"),Cg=a("TFSequenceClassifierOutputWithPast"),id=l(),To=n("div"),v(Ys.$$.fragment),Dg=l(),Ki=n("p"),Hg=a("Base class for outputs of sentence classification models."),ld=l(),vo=n("h2"),Qo=n("a"),Xi=n("span"),v(Qs.$$.fragment),Lg=l(),Yi=n("span"),Ng=a("FlaxGPT2Model"),dd=l(),Pe=n("div"),v(Zs.$$.fragment),Ig=l(),Qi=n("p"),Sg=a("The bare GPT2 Model transformer outputting raw hidden-states without any specific head on top."),Ag=l(),ea=n("p"),Og=a("This model inherits from "),tr=n("a"),Wg=a("FlaxPreTrainedModel"),Bg=a(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),Ug=l(),ta=n("p"),Rg=a(`This model is also a Flax Linen
`),oa=n("a"),Vg=a("flax.nn.Module"),Jg=a(` subclass. Use it as a
regular Flax Module and refer to the Flax documentation for all matter related to general usage and behavior.`),Kg=l(),Zi=n("p"),Xg=a("Finally, this model supports inherent JAX features such as:"),Yg=l(),wt=n("ul"),el=n("li"),na=n("a"),Qg=a("Just-In-Time (JIT) compilation"),Zg=l(),tl=n("li"),sa=n("a"),e_=a("Automatic Differentiation"),t_=l(),ol=n("li"),aa=n("a"),o_=a("Vectorization"),n_=l(),nl=n("li"),ra=n("a"),s_=a("Parallelization"),a_=l(),at=n("div"),v(ia.$$.fragment),r_=l(),bo=n("p"),i_=a("The "),sl=n("code"),l_=a("FlaxGPT2PreTrainedModel"),d_=a("forward method, overrides the "),al=n("code"),c_=a("__call__"),p_=a(" special method."),h_=l(),v(Zo.$$.fragment),u_=l(),rl=n("p"),m_=a("Example:"),f_=l(),v(la.$$.fragment),cd=l(),ko=n("h2"),en=n("a"),il=n("span"),v(da.$$.fragment),g_=l(),ll=n("span"),__=a("FlaxGPT2LMHeadModel"),pd=l(),$e=n("div"),v(ca.$$.fragment),T_=l(),dl=n("p"),v_=a(`The GPT2 Model transformer with a language modeling head on top (linear layer with weights tied to the input
embeddings).`),b_=l(),pa=n("p"),k_=a("This model inherits from "),or=n("a"),y_=a("FlaxPreTrainedModel"),w_=a(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),P_=l(),ha=n("p"),$_=a(`This model is also a Flax Linen
`),ua=n("a"),M_=a("flax.nn.Module"),G_=a(` subclass. Use it as a
regular Flax Module and refer to the Flax documentation for all matter related to general usage and behavior.`),z_=l(),cl=n("p"),j_=a("Finally, this model supports inherent JAX features such as:"),F_=l(),Pt=n("ul"),pl=n("li"),ma=n("a"),x_=a("Just-In-Time (JIT) compilation"),E_=l(),hl=n("li"),fa=n("a"),q_=a("Automatic Differentiation"),C_=l(),ul=n("li"),ga=n("a"),D_=a("Vectorization"),H_=l(),ml=n("li"),_a=n("a"),L_=a("Parallelization"),N_=l(),rt=n("div"),v(Ta.$$.fragment),I_=l(),yo=n("p"),S_=a("The "),fl=n("code"),A_=a("FlaxGPT2PreTrainedModel"),O_=a("forward method, overrides the "),gl=n("code"),W_=a("__call__"),B_=a(" special method."),U_=l(),v(tn.$$.fragment),R_=l(),_l=n("p"),V_=a("Example:"),J_=l(),v(va.$$.fragment),this.h()},l(o){const m=$b('[data-svelte="svelte-1phssyn"]',document.head);p=s(m,"META",{name:!0,content:!0}),m.forEach(t),M=d(o),f=s(o,"H1",{class:!0});var ba=i(f);T=s(ba,"A",{id:!0,class:!0,href:!0});var Tl=i(T);$=s(Tl,"SPAN",{});var vl=i($);b(_.$$.fragment,vl),vl.forEach(t),Tl.forEach(t),g=d(ba),z=s(ba,"SPAN",{});var bl=i(z);Q=r(bl,"OpenAI GPT2"),bl.forEach(t),ba.forEach(t),C=d(o),j=s(o,"H2",{class:!0});var ka=i(j);R=s(ka,"A",{id:!0,class:!0,href:!0});var kl=i(R);S=s(kl,"SPAN",{});var yl=i(S);b(Z.$$.fragment,yl),yl.forEach(t),kl.forEach(t),ue=d(ka),A=s(ka,"SPAN",{});var wl=i(A);me=r(wl,"Overview"),wl.forEach(t),ka.forEach(t),ce=d(o),W=s(o,"P",{});var ya=i(W);L=r(ya,"OpenAI GPT-2 model was proposed in "),ee=s(ya,"A",{href:!0,rel:!0});var Pl=i(ee);te=r(Pl,"Language Models are Unsupervised Multitask Learners"),Pl.forEach(t),F=r(ya,` by Alec
Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei and Ilya Sutskever. It\u2019s a causal (unidirectional)
transformer pretrained using language modeling on a very large corpus of ~40 GB of text data.`),ya.forEach(t),E=d(o),se=s(o,"P",{});var $l=i(se);V=r($l,"The abstract from the paper is the following:"),$l.forEach(t),pe=d(o),ae=s(o,"P",{});var Ml=i(ae);O=s(Ml,"EM",{});var Gl=i(O);fe=r(Gl,`GPT-2 is a large transformer-based language model with 1.5 billion parameters, trained on a dataset[1] of 8 million
web pages. GPT-2 is trained with a simple objective: predict the next word, given all of the previous words within some
text. The diversity of the dataset causes this simple goal to contain naturally occurring demonstrations of many tasks
across diverse domains. GPT-2 is a direct scale-up of GPT, with more than 10X the parameters and trained on more than
10X the amount of data.`),Gl.forEach(t),Ml.forEach(t),he=d(o),x=s(o,"P",{});var zl=i(x);ge=r(zl,"Tips:"),zl.forEach(t),B=d(o),U=s(o,"UL",{});var $t=i(U);re=s($t,"LI",{});var jl=i(re);J=r(jl,`GPT-2 is a model with absolute position embeddings so it\u2019s usually advised to pad the inputs on the right rather than
the left.`),jl.forEach(t),_e=d($t),oe=s($t,"LI",{});var wa=i(oe);N=r(wa,`GPT-2 was trained with a causal language modeling (CLM) objective and is therefore powerful at predicting the next
token in a sequence. Leveraging this feature allows GPT-2 to generate syntactically coherent text as it can be
observed in the `),ie=s(wa,"EM",{});var Y_=i(ie);K=r(Y_,"run_generation.py"),Y_.forEach(t),Te=r(wa," example script."),wa.forEach(t),u=d($t),G=s($t,"LI",{});var ze=i(G);ne=r(ze,"The model can take the "),Fe=s(ze,"EM",{});var Q_=i(Fe);Se=r(Q_,"past_key_values"),Q_.forEach(t),I=r(ze," (for PyTorch) or "),xe=s(ze,"EM",{});var Z_=i(xe);Ae=r(Z_,"past"),Z_.forEach(t),Oe=r(ze,` (for TF) as input, which is the previously computed
key/value attention pairs. Using this (`),D=s(ze,"EM",{});var eT=i(D);X=r(eT,"past_key_values"),eT.forEach(t),We=r(ze," or "),Ee=s(ze,"EM",{});var tT=i(Ee);Y=r(tT,"past"),tT.forEach(t),Be=r(ze,`) value prevents the model from re-computing
pre-computed values in the context of text generation. For PyTorch, see `),qe=s(ze,"EM",{});var oT=i(qe);ve=r(oT,"past_key_values"),oT.forEach(t),Ue=r(ze,` argument of the
`),Pa=s(ze,"A",{href:!0});var nT=i(Pa);ac=r(nT,"GPT2Model.forward()"),nT.forEach(t),rc=r(ze," method, or for TF the "),gr=s(ze,"EM",{});var sT=i(gr);ic=r(sT,"past"),sT.forEach(t),lc=r(ze,` argument of the
`),$a=s(ze,"A",{href:!0});var aT=i($a);dc=r(aT,"TFGPT2Model.call()"),aT.forEach(t),cc=r(ze," method for more information on its usage."),ze.forEach(t),pc=d($t),kt=s($t,"LI",{});var on=i(kt);hc=r(on,"Enabling the "),_r=s(on,"EM",{});var rT=i(_r);uc=r(rT,"scale_attn_by_inverse_layer_idx"),rT.forEach(t),mc=r(on," and "),Tr=s(on,"EM",{});var iT=i(Tr);fc=r(iT,"reorder_and_upcast_attn"),iT.forEach(t),gc=r(on,` flags will apply the training stability
improvements from `),dn=s(on,"A",{href:!0,rel:!0});var lT=i(dn);_c=r(lT,"Mistral"),lT.forEach(t),Tc=r(on," (for PyTorch only)."),on.forEach(t),$t.forEach(t),xl=d(o),Bt=s(o,"P",{});var Fl=i(Bt);cn=s(Fl,"A",{href:!0,rel:!0});var dT=i(cn);vc=r(dT,"Write With Transformer"),dT.forEach(t),bc=r(Fl,` is a webapp created and hosted by
Hugging Face showcasing the generative capabilities of several models. GPT-2 is one of them and is available in five
different sizes: small, medium, large, xl and a distilled version of the small checkpoint: `),vr=s(Fl,"EM",{});var cT=i(vr);kc=r(cT,"distilgpt-2"),cT.forEach(t),yc=r(Fl,"."),Fl.forEach(t),El=d(o),Mt=s(o,"P",{});var nr=i(Mt);wc=r(nr,"This model was contributed by "),pn=s(nr,"A",{href:!0,rel:!0});var pT=i(pn);Pc=r(pT,"thomwolf"),pT.forEach(t),$c=r(nr,". The original code can be found "),hn=s(nr,"A",{href:!0,rel:!0});var hT=i(hn);Mc=r(hT,"here"),hT.forEach(t),Gc=r(nr,"."),nr.forEach(t),ql=d(o),Ut=s(o,"H2",{class:!0});var ud=i(Ut);wo=s(ud,"A",{id:!0,class:!0,href:!0});var uT=i(wo);br=s(uT,"SPAN",{});var mT=i(br);b(un.$$.fragment,mT),mT.forEach(t),uT.forEach(t),zc=d(ud),kr=s(ud,"SPAN",{});var fT=i(kr);jc=r(fT,"GPT2Config"),fT.forEach(t),ud.forEach(t),Cl=d(o),Re=s(o,"DIV",{class:!0});var Gt=i(Re);b(mn.$$.fragment,Gt),Fc=d(Gt),yt=s(Gt,"P",{});var nn=i(yt);xc=r(nn,"This is the configuration class to store the configuration of a "),Ma=s(nn,"A",{href:!0});var gT=i(Ma);Ec=r(gT,"GPT2Model"),gT.forEach(t),qc=r(nn," or a "),Ga=s(nn,"A",{href:!0});var _T=i(Ga);Cc=r(_T,"TFGPT2Model"),_T.forEach(t),Dc=r(nn,`. It is used to
instantiate a GPT-2 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 GPT-2
`),fn=s(nn,"A",{href:!0,rel:!0});var TT=i(fn);Hc=r(TT,"small"),TT.forEach(t),Lc=r(nn," architecture."),nn.forEach(t),Nc=d(Gt),Rt=s(Gt,"P",{});var sr=i(Rt);Ic=r(sr,"Configuration objects inherit from "),za=s(sr,"A",{href:!0});var vT=i(za);Sc=r(vT,"PretrainedConfig"),vT.forEach(t),Ac=r(sr,` and can be used to control the model outputs. Read the
documentation from `),ja=s(sr,"A",{href:!0});var bT=i(ja);Oc=r(bT,"PretrainedConfig"),bT.forEach(t),Wc=r(sr," for more information."),sr.forEach(t),Bc=d(Gt),yr=s(Gt,"P",{});var kT=i(yr);Uc=r(kT,"Example:"),kT.forEach(t),Rc=d(Gt),b(gn.$$.fragment,Gt),Gt.forEach(t),Dl=d(o),Vt=s(o,"H2",{class:!0});var md=i(Vt);Po=s(md,"A",{id:!0,class:!0,href:!0});var yT=i(Po);wr=s(yT,"SPAN",{});var wT=i(wr);b(_n.$$.fragment,wT),wT.forEach(t),yT.forEach(t),Vc=d(md),Pr=s(md,"SPAN",{});var PT=i(Pr);Jc=r(PT,"GPT2Tokenizer"),PT.forEach(t),md.forEach(t),Hl=d(o),le=s(o,"DIV",{class:!0});var Ne=i(le);b(Tn.$$.fragment,Ne),Kc=d(Ne),$r=s(Ne,"P",{});var $T=i($r);Xc=r($T,"Construct a GPT-2 tokenizer. Based on byte-level Byte-Pair-Encoding."),$T.forEach(t),Yc=d(Ne),Mr=s(Ne,"P",{});var MT=i(Mr);Qc=r(MT,`This tokenizer has been trained to treat spaces like parts of the tokens (a bit like sentencepiece) so a word will
be encoded differently whether it is at the beginning of the sentence (without space) or not:`),MT.forEach(t),Zc=d(Ne),b(vn.$$.fragment,Ne),ep=d(Ne),bn=s(Ne,"P",{});var fd=i(bn);tp=r(fd,"You can get around that behavior by passing "),Gr=s(fd,"CODE",{});var GT=i(Gr);op=r(GT,"add_prefix_space=True"),GT.forEach(t),np=r(fd,` when instantiating this tokenizer or when you
call it on some text, but since the model was not pretrained this way, it might yield a decrease in performance.`),fd.forEach(t),sp=d(Ne),b($o.$$.fragment,Ne),ap=d(Ne),kn=s(Ne,"P",{});var gd=i(kn);rp=r(gd,"This tokenizer inherits from "),Fa=s(gd,"A",{href:!0});var zT=i(Fa);ip=r(zT,"PreTrainedTokenizer"),zT.forEach(t),lp=r(gd,` which contains most of the main methods. Users should refer to
this superclass for more information regarding those methods.`),gd.forEach(t),dp=d(Ne),xa=s(Ne,"DIV",{class:!0});var jT=i(xa);b(yn.$$.fragment,jT),jT.forEach(t),Ne.forEach(t),Ll=d(o),Jt=s(o,"H2",{class:!0});var _d=i(Jt);Mo=s(_d,"A",{id:!0,class:!0,href:!0});var FT=i(Mo);zr=s(FT,"SPAN",{});var xT=i(zr);b(wn.$$.fragment,xT),xT.forEach(t),FT.forEach(t),cp=d(_d),jr=s(_d,"SPAN",{});var ET=i(jr);pp=r(ET,"GPT2TokenizerFast"),ET.forEach(t),_d.forEach(t),Nl=d(o),be=s(o,"DIV",{class:!0});var it=i(be);b(Pn.$$.fragment,it),hp=d(it),$n=s(it,"P",{});var Td=i($n);up=r(Td,"Construct a \u201Cfast\u201D GPT-2 tokenizer (backed by HuggingFace\u2019s "),Fr=s(Td,"EM",{});var qT=i(Fr);mp=r(qT,"tokenizers"),qT.forEach(t),fp=r(Td,` library). Based on byte-level
Byte-Pair-Encoding.`),Td.forEach(t),gp=d(it),xr=s(it,"P",{});var CT=i(xr);_p=r(CT,`This tokenizer has been trained to treat spaces like parts of the tokens (a bit like sentencepiece) so a word will
be encoded differently whether it is at the beginning of the sentence (without space) or not:`),CT.forEach(t),Tp=d(it),b(Mn.$$.fragment,it),vp=d(it),Gn=s(it,"P",{});var vd=i(Gn);bp=r(vd,"You can get around that behavior by passing "),Er=s(vd,"CODE",{});var DT=i(Er);kp=r(DT,"add_prefix_space=True"),DT.forEach(t),yp=r(vd,` when instantiating this tokenizer, but since
the model was not pretrained this way, it might yield a decrease in performance.`),vd.forEach(t),wp=d(it),b(Go.$$.fragment,it),Pp=d(it),zn=s(it,"P",{});var bd=i(zn);$p=r(bd,"This tokenizer inherits from "),Ea=s(bd,"A",{href:!0});var HT=i(Ea);Mp=r(HT,"PreTrainedTokenizerFast"),HT.forEach(t),Gp=r(bd,` which contains most of the main methods. Users should
refer to this superclass for more information regarding those methods.`),bd.forEach(t),it.forEach(t),Il=d(o),Kt=s(o,"H2",{class:!0});var kd=i(Kt);zo=s(kd,"A",{id:!0,class:!0,href:!0});var LT=i(zo);qr=s(LT,"SPAN",{});var NT=i(qr);b(jn.$$.fragment,NT),NT.forEach(t),LT.forEach(t),zp=d(kd),Cr=s(kd,"SPAN",{});var IT=i(Cr);jp=r(IT,"GPT2 specific outputs"),IT.forEach(t),kd.forEach(t),Sl=d(o),Xt=s(o,"DIV",{class:!0});var yd=i(Xt);b(Fn.$$.fragment,yd),Fp=d(yd),Dr=s(yd,"P",{});var ST=i(Dr);xp=r(ST,"Base class for outputs of models predicting if two sentences are consecutive or not."),ST.forEach(t),yd.forEach(t),Al=d(o),Yt=s(o,"DIV",{class:!0});var wd=i(Yt);b(xn.$$.fragment,wd),Ep=d(wd),Hr=s(wd,"P",{});var AT=i(Hr);qp=r(AT,"Base class for outputs of models predicting if two sentences are consecutive or not."),AT.forEach(t),wd.forEach(t),Ol=d(o),Qt=s(o,"H2",{class:!0});var Pd=i(Qt);jo=s(Pd,"A",{id:!0,class:!0,href:!0});var OT=i(jo);Lr=s(OT,"SPAN",{});var WT=i(Lr);b(En.$$.fragment,WT),WT.forEach(t),OT.forEach(t),Cp=d(Pd),Nr=s(Pd,"SPAN",{});var BT=i(Nr);Dp=r(BT,"GPT2Model"),BT.forEach(t),Pd.forEach(t),Wl=d(o),ke=s(o,"DIV",{class:!0});var lt=i(ke);b(qn.$$.fragment,lt),Hp=d(lt),Ir=s(lt,"P",{});var UT=i(Ir);Lp=r(UT,"The bare GPT2 Model transformer outputting raw hidden-states without any specific head on top."),UT.forEach(t),Np=d(lt),Cn=s(lt,"P",{});var $d=i(Cn);Ip=r($d,"This model inherits from "),qa=s($d,"A",{href:!0});var RT=i(qa);Sp=r(RT,"PreTrainedModel"),RT.forEach(t),Ap=r($d,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),$d.forEach(t),Op=d(lt),Dn=s(lt,"P",{});var Md=i(Dn);Wp=r(Md,"This model is also a PyTorch "),Hn=s(Md,"A",{href:!0,rel:!0});var VT=i(Hn);Bp=r(VT,"torch.nn.Module"),VT.forEach(t),Up=r(Md,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Md.forEach(t),Rp=d(lt),Ke=s(lt,"DIV",{class:!0});var zt=i(Ke);b(Ln.$$.fragment,zt),Vp=d(zt),Zt=s(zt,"P",{});var ar=i(Zt);Jp=r(ar,"The "),Ca=s(ar,"A",{href:!0});var JT=i(Ca);Kp=r(JT,"GPT2Model"),JT.forEach(t),Xp=r(ar," forward method, overrides the "),Sr=s(ar,"CODE",{});var KT=i(Sr);Yp=r(KT,"__call__"),KT.forEach(t),Qp=r(ar," special method."),ar.forEach(t),Zp=d(zt),b(Fo.$$.fragment,zt),eh=d(zt),Ar=s(zt,"P",{});var XT=i(Ar);th=r(XT,"Example:"),XT.forEach(t),oh=d(zt),b(Nn.$$.fragment,zt),zt.forEach(t),nh=d(lt),Xe=s(lt,"DIV",{class:!0});var jt=i(Xe);b(In.$$.fragment,jt),sh=d(jt),Or=s(jt,"P",{});var YT=i(Or);ah=r(YT,"This is an experimental feature and is a subject to change at a moment\u2019s notice."),YT.forEach(t),rh=d(jt),Wr=s(jt,"P",{});var QT=i(Wr);ih=r(QT,`Uses a device map to distribute attention modules of the model across several devices. If no device map is given,
it will evenly distribute blocks across all devices.`),QT.forEach(t),lh=d(jt),Br=s(jt,"P",{});var ZT=i(Br);dh=r(ZT,"Example:"),ZT.forEach(t),ch=d(jt),b(Sn.$$.fragment,jt),jt.forEach(t),ph=d(lt),gt=s(lt,"DIV",{class:!0});var sn=i(gt);b(An.$$.fragment,sn),hh=d(sn),Ur=s(sn,"P",{});var e2=i(Ur);uh=r(e2,"Moves the model to cpu from a model parallel state."),e2.forEach(t),mh=d(sn),Rr=s(sn,"P",{});var t2=i(Rr);fh=r(t2,"Example:"),t2.forEach(t),gh=d(sn),b(On.$$.fragment,sn),sn.forEach(t),lt.forEach(t),Bl=d(o),eo=s(o,"H2",{class:!0});var Gd=i(eo);xo=s(Gd,"A",{id:!0,class:!0,href:!0});var o2=i(xo);Vr=s(o2,"SPAN",{});var n2=i(Vr);b(Wn.$$.fragment,n2),n2.forEach(t),o2.forEach(t),_h=d(Gd),Jr=s(Gd,"SPAN",{});var s2=i(Jr);Th=r(s2,"GPT2LMHeadModel"),s2.forEach(t),Gd.forEach(t),Ul=d(o),ye=s(o,"DIV",{class:!0});var dt=i(ye);b(Bn.$$.fragment,dt),vh=d(dt),Kr=s(dt,"P",{});var a2=i(Kr);bh=r(a2,`The GPT2 Model transformer with a language modeling head on top (linear layer with weights tied to the input
embeddings).`),a2.forEach(t),kh=d(dt),Un=s(dt,"P",{});var zd=i(Un);yh=r(zd,"This model inherits from "),Da=s(zd,"A",{href:!0});var r2=i(Da);wh=r(r2,"PreTrainedModel"),r2.forEach(t),Ph=r(zd,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),zd.forEach(t),$h=d(dt),Rn=s(dt,"P",{});var jd=i(Rn);Mh=r(jd,"This model is also a PyTorch "),Vn=s(jd,"A",{href:!0,rel:!0});var i2=i(Vn);Gh=r(i2,"torch.nn.Module"),i2.forEach(t),zh=r(jd,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),jd.forEach(t),jh=d(dt),Ye=s(dt,"DIV",{class:!0});var Ft=i(Ye);b(Jn.$$.fragment,Ft),Fh=d(Ft),to=s(Ft,"P",{});var rr=i(to);xh=r(rr,"The "),Ha=s(rr,"A",{href:!0});var l2=i(Ha);Eh=r(l2,"GPT2LMHeadModel"),l2.forEach(t),qh=r(rr," forward method, overrides the "),Xr=s(rr,"CODE",{});var d2=i(Xr);Ch=r(d2,"__call__"),d2.forEach(t),Dh=r(rr," special method."),rr.forEach(t),Hh=d(Ft),b(Eo.$$.fragment,Ft),Lh=d(Ft),Yr=s(Ft,"P",{});var c2=i(Yr);Nh=r(c2,"Example:"),c2.forEach(t),Ih=d(Ft),b(Kn.$$.fragment,Ft),Ft.forEach(t),Sh=d(dt),Qe=s(dt,"DIV",{class:!0});var xt=i(Qe);b(Xn.$$.fragment,xt),Ah=d(xt),Qr=s(xt,"P",{});var p2=i(Qr);Oh=r(p2,"This is an experimental feature and is a subject to change at a moment\u2019s notice."),p2.forEach(t),Wh=d(xt),Zr=s(xt,"P",{});var h2=i(Zr);Bh=r(h2,`Uses a device map to distribute attention modules of the model across several devices. If no device map is given,
it will evenly distribute blocks across all devices.`),h2.forEach(t),Uh=d(xt),ei=s(xt,"P",{});var u2=i(ei);Rh=r(u2,"Example:"),u2.forEach(t),Vh=d(xt),b(Yn.$$.fragment,xt),xt.forEach(t),Jh=d(dt),_t=s(dt,"DIV",{class:!0});var an=i(_t);b(Qn.$$.fragment,an),Kh=d(an),ti=s(an,"P",{});var m2=i(ti);Xh=r(m2,"Moves the model to cpu from a model parallel state."),m2.forEach(t),Yh=d(an),oi=s(an,"P",{});var f2=i(oi);Qh=r(f2,"Example:"),f2.forEach(t),Zh=d(an),b(Zn.$$.fragment,an),an.forEach(t),dt.forEach(t),Rl=d(o),oo=s(o,"H2",{class:!0});var Fd=i(oo);qo=s(Fd,"A",{id:!0,class:!0,href:!0});var g2=i(qo);ni=s(g2,"SPAN",{});var _2=i(ni);b(es.$$.fragment,_2),_2.forEach(t),g2.forEach(t),eu=d(Fd),si=s(Fd,"SPAN",{});var T2=i(si);tu=r(T2,"GPT2DoubleHeadsModel"),T2.forEach(t),Fd.forEach(t),Vl=d(o),Ve=s(o,"DIV",{class:!0});var Et=i(Ve);b(ts.$$.fragment,Et),ou=d(Et),ai=s(Et,"P",{});var v2=i(ai);nu=r(v2,`The GPT2 Model transformer with a language modeling and a multiple-choice classification head on top e.g. for
RocStories/SWAG tasks. The two heads are two linear layers. The language modeling head has its weights tied to the
input embeddings, the classification head takes as input the input of a specified classification token index in the
input sequence).`),v2.forEach(t),su=d(Et),os=s(Et,"P",{});var xd=i(os);au=r(xd,"This model inherits from "),La=s(xd,"A",{href:!0});var b2=i(La);ru=r(b2,"PreTrainedModel"),b2.forEach(t),iu=r(xd,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),xd.forEach(t),lu=d(Et),ns=s(Et,"P",{});var Ed=i(ns);du=r(Ed,"This model is also a PyTorch "),ss=s(Ed,"A",{href:!0,rel:!0});var k2=i(ss);cu=r(k2,"torch.nn.Module"),k2.forEach(t),pu=r(Ed,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Ed.forEach(t),hu=d(Et),Ze=s(Et,"DIV",{class:!0});var qt=i(Ze);b(as.$$.fragment,qt),uu=d(qt),no=s(qt,"P",{});var ir=i(no);mu=r(ir,"The "),Na=s(ir,"A",{href:!0});var y2=i(Na);fu=r(y2,"GPT2DoubleHeadsModel"),y2.forEach(t),gu=r(ir," forward method, overrides the "),ri=s(ir,"CODE",{});var w2=i(ri);_u=r(w2,"__call__"),w2.forEach(t),Tu=r(ir," special method."),ir.forEach(t),vu=d(qt),b(Co.$$.fragment,qt),bu=d(qt),ii=s(qt,"P",{});var P2=i(ii);ku=r(P2,"Example:"),P2.forEach(t),yu=d(qt),b(rs.$$.fragment,qt),qt.forEach(t),Et.forEach(t),Jl=d(o),so=s(o,"H2",{class:!0});var qd=i(so);Do=s(qd,"A",{id:!0,class:!0,href:!0});var $2=i(Do);li=s($2,"SPAN",{});var M2=i(li);b(is.$$.fragment,M2),M2.forEach(t),$2.forEach(t),wu=d(qd),di=s(qd,"SPAN",{});var G2=i(di);Pu=r(G2,"GPT2ForSequenceClassification"),G2.forEach(t),qd.forEach(t),Kl=d(o),we=s(o,"DIV",{class:!0});var ct=i(we);b(ls.$$.fragment,ct),$u=d(ct),ci=s(ct,"P",{});var z2=i(ci);Mu=r(z2,"The GPT2 Model transformer with a sequence classification head on top (linear layer)."),z2.forEach(t),Gu=d(ct),Ia=s(ct,"P",{});var K_=i(Ia);Sa=s(K_,"A",{href:!0});var j2=i(Sa);zu=r(j2,"GPT2ForSequenceClassification"),j2.forEach(t),ju=r(K_,` uses the last token in order to do the classification, as other causal models
(e.g. GPT-1) do.`),K_.forEach(t),Fu=d(ct),mt=s(ct,"P",{});var Ct=i(mt);xu=r(Ct,`Since it does classification on the last token, it requires to know the position of the last token. If a
`),pi=s(Ct,"CODE",{});var F2=i(pi);Eu=r(F2,"pad_token_id"),F2.forEach(t),qu=r(Ct,` is defined in the configuration, it finds the last token that is not a padding token in each row. If
no `),hi=s(Ct,"CODE",{});var x2=i(hi);Cu=r(x2,"pad_token_id"),x2.forEach(t),Du=r(Ct,` is defined, it simply takes the last value in each row of the batch. Since it cannot guess the
padding tokens when `),ui=s(Ct,"CODE",{});var E2=i(ui);Hu=r(E2,"inputs_embeds"),E2.forEach(t),Lu=r(Ct," are passed instead of "),mi=s(Ct,"CODE",{});var q2=i(mi);Nu=r(q2,"input_ids"),q2.forEach(t),Iu=r(Ct,`, it does the same (take the last value in
each row of the batch).`),Ct.forEach(t),Su=d(ct),ds=s(ct,"P",{});var Cd=i(ds);Au=r(Cd,"This model inherits from "),Aa=s(Cd,"A",{href:!0});var C2=i(Aa);Ou=r(C2,"PreTrainedModel"),C2.forEach(t),Wu=r(Cd,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),Cd.forEach(t),Bu=d(ct),cs=s(ct,"P",{});var Dd=i(cs);Uu=r(Dd,"This model is also a PyTorch "),ps=s(Dd,"A",{href:!0,rel:!0});var D2=i(ps);Ru=r(D2,"torch.nn.Module"),D2.forEach(t),Vu=r(Dd,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Dd.forEach(t),Ju=d(ct),Ge=s(ct,"DIV",{class:!0});var pt=i(Ge);b(hs.$$.fragment,pt),Ku=d(pt),ao=s(pt,"P",{});var lr=i(ao);Xu=r(lr,"The "),Oa=s(lr,"A",{href:!0});var H2=i(Oa);Yu=r(H2,"GPT2ForSequenceClassification"),H2.forEach(t),Qu=r(lr," forward method, overrides the "),fi=s(lr,"CODE",{});var L2=i(fi);Zu=r(L2,"__call__"),L2.forEach(t),em=r(lr," special method."),lr.forEach(t),tm=d(pt),b(Ho.$$.fragment,pt),om=d(pt),gi=s(pt,"P",{});var N2=i(gi);nm=r(N2,"Example of single-label classification:"),N2.forEach(t),sm=d(pt),b(us.$$.fragment,pt),am=d(pt),_i=s(pt,"P",{});var I2=i(_i);rm=r(I2,"Example of multi-label classification:"),I2.forEach(t),im=d(pt),b(ms.$$.fragment,pt),pt.forEach(t),ct.forEach(t),Xl=d(o),ro=s(o,"H2",{class:!0});var Hd=i(ro);Lo=s(Hd,"A",{id:!0,class:!0,href:!0});var S2=i(Lo);Ti=s(S2,"SPAN",{});var A2=i(Ti);b(fs.$$.fragment,A2),A2.forEach(t),S2.forEach(t),lm=d(Hd),vi=s(Hd,"SPAN",{});var O2=i(vi);dm=r(O2,"GPT2ForTokenClassification"),O2.forEach(t),Hd.forEach(t),Yl=d(o),Je=s(o,"DIV",{class:!0});var Dt=i(Je);b(gs.$$.fragment,Dt),cm=d(Dt),bi=s(Dt,"P",{});var W2=i(bi);pm=r(W2,`GPT2 Model with a token classification head on top (a linear layer on top of the hidden-states output) e.g. for
Named-Entity-Recognition (NER) tasks.`),W2.forEach(t),hm=d(Dt),_s=s(Dt,"P",{});var Ld=i(_s);um=r(Ld,"This model inherits from "),Wa=s(Ld,"A",{href:!0});var B2=i(Wa);mm=r(B2,"PreTrainedModel"),B2.forEach(t),fm=r(Ld,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),Ld.forEach(t),gm=d(Dt),Ts=s(Dt,"P",{});var Nd=i(Ts);_m=r(Nd,"This model is also a PyTorch "),vs=s(Nd,"A",{href:!0,rel:!0});var U2=i(vs);Tm=r(U2,"torch.nn.Module"),U2.forEach(t),vm=r(Nd,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Nd.forEach(t),bm=d(Dt),et=s(Dt,"DIV",{class:!0});var Ht=i(et);b(bs.$$.fragment,Ht),km=d(Ht),io=s(Ht,"P",{});var dr=i(io);ym=r(dr,"The "),Ba=s(dr,"A",{href:!0});var R2=i(Ba);wm=r(R2,"GPT2ForTokenClassification"),R2.forEach(t),Pm=r(dr," forward method, overrides the "),ki=s(dr,"CODE",{});var V2=i(ki);$m=r(V2,"__call__"),V2.forEach(t),Mm=r(dr," special method."),dr.forEach(t),Gm=d(Ht),b(No.$$.fragment,Ht),zm=d(Ht),yi=s(Ht,"P",{});var J2=i(yi);jm=r(J2,"Example:"),J2.forEach(t),Fm=d(Ht),b(ks.$$.fragment,Ht),Ht.forEach(t),Dt.forEach(t),Ql=d(o),lo=s(o,"H2",{class:!0});var Id=i(lo);Io=s(Id,"A",{id:!0,class:!0,href:!0});var K2=i(Io);wi=s(K2,"SPAN",{});var X2=i(wi);b(ys.$$.fragment,X2),X2.forEach(t),K2.forEach(t),xm=d(Id),Pi=s(Id,"SPAN",{});var Y2=i(Pi);Em=r(Y2,"TFGPT2Model"),Y2.forEach(t),Id.forEach(t),Zl=d(o),Ce=s(o,"DIV",{class:!0});var Tt=i(Ce);b(ws.$$.fragment,Tt),qm=d(Tt),$i=s(Tt,"P",{});var Q2=i($i);Cm=r(Q2,"The bare GPT2 Model transformer outputting raw hidden-states without any specific head on top."),Q2.forEach(t),Dm=d(Tt),Ps=s(Tt,"P",{});var Sd=i(Ps);Hm=r(Sd,"This model inherits from "),Ua=s(Sd,"A",{href:!0});var Z2=i(Ua);Lm=r(Z2,"TFPreTrainedModel"),Z2.forEach(t),Nm=r(Sd,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),Sd.forEach(t),Im=d(Tt),$s=s(Tt,"P",{});var Ad=i($s);Sm=r(Ad,"This model is also a "),Ms=s(Ad,"A",{href:!0,rel:!0});var ev=i(Ms);Am=r(ev,"tf.keras.Model"),ev.forEach(t),Om=r(Ad,` subclass. Use it
as a regular TF 2.0 Keras Model and refer to the TF 2.0 documentation for all matter related to general usage and
behavior.`),Ad.forEach(t),Wm=d(Tt),b(So.$$.fragment,Tt),Bm=d(Tt),tt=s(Tt,"DIV",{class:!0});var Lt=i(tt);b(Gs.$$.fragment,Lt),Um=d(Lt),co=s(Lt,"P",{});var cr=i(co);Rm=r(cr,"The "),Ra=s(cr,"A",{href:!0});var tv=i(Ra);Vm=r(tv,"TFGPT2Model"),tv.forEach(t),Jm=r(cr," forward method, overrides the "),Mi=s(cr,"CODE",{});var ov=i(Mi);Km=r(ov,"__call__"),ov.forEach(t),Xm=r(cr," special method."),cr.forEach(t),Ym=d(Lt),b(Ao.$$.fragment,Lt),Qm=d(Lt),Gi=s(Lt,"P",{});var nv=i(Gi);Zm=r(nv,"Example:"),nv.forEach(t),ef=d(Lt),b(zs.$$.fragment,Lt),Lt.forEach(t),Tt.forEach(t),ed=d(o),po=s(o,"H2",{class:!0});var Od=i(po);Oo=s(Od,"A",{id:!0,class:!0,href:!0});var sv=i(Oo);zi=s(sv,"SPAN",{});var av=i(zi);b(js.$$.fragment,av),av.forEach(t),sv.forEach(t),tf=d(Od),ji=s(Od,"SPAN",{});var rv=i(ji);of=r(rv,"TFGPT2LMHeadModel"),rv.forEach(t),Od.forEach(t),td=d(o),De=s(o,"DIV",{class:!0});var vt=i(De);b(Fs.$$.fragment,vt),nf=d(vt),Fi=s(vt,"P",{});var iv=i(Fi);sf=r(iv,`The GPT2 Model transformer with a language modeling head on top (linear layer with weights tied to the input
embeddings).`),iv.forEach(t),af=d(vt),xs=s(vt,"P",{});var Wd=i(xs);rf=r(Wd,"This model inherits from "),Va=s(Wd,"A",{href:!0});var lv=i(Va);lf=r(lv,"TFPreTrainedModel"),lv.forEach(t),df=r(Wd,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),Wd.forEach(t),cf=d(vt),Es=s(vt,"P",{});var Bd=i(Es);pf=r(Bd,"This model is also a "),qs=s(Bd,"A",{href:!0,rel:!0});var dv=i(qs);hf=r(dv,"tf.keras.Model"),dv.forEach(t),uf=r(Bd,` subclass. Use it
as a regular TF 2.0 Keras Model and refer to the TF 2.0 documentation for all matter related to general usage and
behavior.`),Bd.forEach(t),mf=d(vt),b(Wo.$$.fragment,vt),ff=d(vt),ot=s(vt,"DIV",{class:!0});var Nt=i(ot);b(Cs.$$.fragment,Nt),gf=d(Nt),ho=s(Nt,"P",{});var pr=i(ho);_f=r(pr,"The "),Ja=s(pr,"A",{href:!0});var cv=i(Ja);Tf=r(cv,"TFGPT2LMHeadModel"),cv.forEach(t),vf=r(pr," forward method, overrides the "),xi=s(pr,"CODE",{});var pv=i(xi);bf=r(pv,"__call__"),pv.forEach(t),kf=r(pr," special method."),pr.forEach(t),yf=d(Nt),b(Bo.$$.fragment,Nt),wf=d(Nt),Ei=s(Nt,"P",{});var hv=i(Ei);Pf=r(hv,"Example:"),hv.forEach(t),$f=d(Nt),b(Ds.$$.fragment,Nt),Nt.forEach(t),vt.forEach(t),od=d(o),uo=s(o,"H2",{class:!0});var Ud=i(uo);Uo=s(Ud,"A",{id:!0,class:!0,href:!0});var uv=i(Uo);qi=s(uv,"SPAN",{});var mv=i(qi);b(Hs.$$.fragment,mv),mv.forEach(t),uv.forEach(t),Mf=d(Ud),Ci=s(Ud,"SPAN",{});var fv=i(Ci);Gf=r(fv,"TFGPT2DoubleHeadsModel"),fv.forEach(t),Ud.forEach(t),nd=d(o),He=s(o,"DIV",{class:!0});var bt=i(He);b(Ls.$$.fragment,bt),zf=d(bt),Di=s(bt,"P",{});var gv=i(Di);jf=r(gv,`The GPT2 Model transformer with a language modeling and a multiple-choice classification head on top e.g. for
RocStories/SWAG tasks. The two heads are two linear layers. The language modeling head has its weights tied to the
input embeddings, the classification head takes as input the input of a specified classification token index in the
input sequence).`),gv.forEach(t),Ff=d(bt),Ns=s(bt,"P",{});var Rd=i(Ns);xf=r(Rd,"This model inherits from "),Ka=s(Rd,"A",{href:!0});var _v=i(Ka);Ef=r(_v,"TFPreTrainedModel"),_v.forEach(t),qf=r(Rd,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),Rd.forEach(t),Cf=d(bt),Is=s(bt,"P",{});var Vd=i(Is);Df=r(Vd,"This model is also a "),Ss=s(Vd,"A",{href:!0,rel:!0});var Tv=i(Ss);Hf=r(Tv,"tf.keras.Model"),Tv.forEach(t),Lf=r(Vd,` subclass. Use it
as a regular TF 2.0 Keras Model and refer to the TF 2.0 documentation for all matter related to general usage and
behavior.`),Vd.forEach(t),Nf=d(bt),b(Ro.$$.fragment,bt),If=d(bt),nt=s(bt,"DIV",{class:!0});var It=i(nt);b(As.$$.fragment,It),Sf=d(It),mo=s(It,"P",{});var hr=i(mo);Af=r(hr,"The "),Xa=s(hr,"A",{href:!0});var vv=i(Xa);Of=r(vv,"TFGPT2DoubleHeadsModel"),vv.forEach(t),Wf=r(hr," forward method, overrides the "),Hi=s(hr,"CODE",{});var bv=i(Hi);Bf=r(bv,"__call__"),bv.forEach(t),Uf=r(hr," special method."),hr.forEach(t),Rf=d(It),b(Vo.$$.fragment,It),Vf=d(It),Li=s(It,"P",{});var kv=i(Li);Jf=r(kv,"Examples:"),kv.forEach(t),Kf=d(It),b(Os.$$.fragment,It),It.forEach(t),bt.forEach(t),sd=d(o),fo=s(o,"H2",{class:!0});var Jd=i(fo);Jo=s(Jd,"A",{id:!0,class:!0,href:!0});var yv=i(Jo);Ni=s(yv,"SPAN",{});var wv=i(Ni);b(Ws.$$.fragment,wv),wv.forEach(t),yv.forEach(t),Xf=d(Jd),Ii=s(Jd,"SPAN",{});var Pv=i(Ii);Yf=r(Pv,"TFGPT2ForSequenceClassification"),Pv.forEach(t),Jd.forEach(t),ad=d(o),de=s(o,"DIV",{class:!0});var Ie=i(de);b(Bs.$$.fragment,Ie),Qf=d(Ie),Si=s(Ie,"P",{});var $v=i(Si);Zf=r($v,"The GPT2 Model transformer with a sequence classification head on top (linear layer)."),$v.forEach(t),eg=d(Ie),Ya=s(Ie,"P",{});var X_=i(Ya);Qa=s(X_,"A",{href:!0});var Mv=i(Qa);tg=r(Mv,"TFGPT2ForSequenceClassification"),Mv.forEach(t),og=r(X_,` uses the last token in order to do the classification, as other causal models
(e.g. GPT-1) do.`),X_.forEach(t),ng=d(Ie),ft=s(Ie,"P",{});var St=i(ft);sg=r(St,`Since it does classification on the last token, it requires to know the position of the last token. If a
`),Ai=s(St,"CODE",{});var Gv=i(Ai);ag=r(Gv,"pad_token_id"),Gv.forEach(t),rg=r(St,` is defined in the configuration, it finds the last token that is not a padding token in each row. If
no `),Oi=s(St,"CODE",{});var zv=i(Oi);ig=r(zv,"pad_token_id"),zv.forEach(t),lg=r(St,` is defined, it simply takes the last value in each row of the batch. Since it cannot guess the
padding tokens when `),Wi=s(St,"CODE",{});var jv=i(Wi);dg=r(jv,"inputs_embeds"),jv.forEach(t),cg=r(St," are passed instead of "),Bi=s(St,"CODE",{});var Fv=i(Bi);pg=r(Fv,"input_ids"),Fv.forEach(t),hg=r(St,`, it does the same (take the last value in
each row of the batch).`),St.forEach(t),ug=d(Ie),Us=s(Ie,"P",{});var Kd=i(Us);mg=r(Kd,"This model inherits from "),Za=s(Kd,"A",{href:!0});var xv=i(Za);fg=r(xv,"TFPreTrainedModel"),xv.forEach(t),gg=r(Kd,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),Kd.forEach(t),_g=d(Ie),Rs=s(Ie,"P",{});var Xd=i(Rs);Tg=r(Xd,"This model is also a "),Vs=s(Xd,"A",{href:!0,rel:!0});var Ev=i(Vs);vg=r(Ev,"tf.keras.Model"),Ev.forEach(t),bg=r(Xd,` subclass. Use it
as a regular TF 2.0 Keras Model and refer to the TF 2.0 documentation for all matter related to general usage and
behavior.`),Xd.forEach(t),kg=d(Ie),b(Ko.$$.fragment,Ie),yg=d(Ie),st=s(Ie,"DIV",{class:!0});var At=i(st);b(Js.$$.fragment,At),wg=d(At),go=s(At,"P",{});var ur=i(go);Pg=r(ur,"The "),er=s(ur,"A",{href:!0});var qv=i(er);$g=r(qv,"TFGPT2ForSequenceClassification"),qv.forEach(t),Mg=r(ur," forward method, overrides the "),Ui=s(ur,"CODE",{});var Cv=i(Ui);Gg=r(Cv,"__call__"),Cv.forEach(t),zg=r(ur," special method."),ur.forEach(t),jg=d(At),b(Xo.$$.fragment,At),Fg=d(At),Ri=s(At,"P",{});var Dv=i(Ri);xg=r(Dv,"Example:"),Dv.forEach(t),Eg=d(At),b(Ks.$$.fragment,At),At.forEach(t),Ie.forEach(t),rd=d(o),_o=s(o,"H2",{class:!0});var Yd=i(_o);Yo=s(Yd,"A",{id:!0,class:!0,href:!0});var Hv=i(Yo);Vi=s(Hv,"SPAN",{});var Lv=i(Vi);b(Xs.$$.fragment,Lv),Lv.forEach(t),Hv.forEach(t),qg=d(Yd),Ji=s(Yd,"SPAN",{});var Nv=i(Ji);Cg=r(Nv,"TFSequenceClassifierOutputWithPast"),Nv.forEach(t),Yd.forEach(t),id=d(o),To=s(o,"DIV",{class:!0});var Qd=i(To);b(Ys.$$.fragment,Qd),Dg=d(Qd),Ki=s(Qd,"P",{});var Iv=i(Ki);Hg=r(Iv,"Base class for outputs of sentence classification models."),Iv.forEach(t),Qd.forEach(t),ld=d(o),vo=s(o,"H2",{class:!0});var Zd=i(vo);Qo=s(Zd,"A",{id:!0,class:!0,href:!0});var Sv=i(Qo);Xi=s(Sv,"SPAN",{});var Av=i(Xi);b(Qs.$$.fragment,Av),Av.forEach(t),Sv.forEach(t),Lg=d(Zd),Yi=s(Zd,"SPAN",{});var Ov=i(Yi);Ng=r(Ov,"FlaxGPT2Model"),Ov.forEach(t),Zd.forEach(t),dd=d(o),Pe=s(o,"DIV",{class:!0});var ht=i(Pe);b(Zs.$$.fragment,ht),Ig=d(ht),Qi=s(ht,"P",{});var Wv=i(Qi);Sg=r(Wv,"The bare GPT2 Model transformer outputting raw hidden-states without any specific head on top."),Wv.forEach(t),Ag=d(ht),ea=s(ht,"P",{});var ec=i(ea);Og=r(ec,"This model inherits from "),tr=s(ec,"A",{href:!0});var Bv=i(tr);Wg=r(Bv,"FlaxPreTrainedModel"),Bv.forEach(t),Bg=r(ec,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),ec.forEach(t),Ug=d(ht),ta=s(ht,"P",{});var tc=i(ta);Rg=r(tc,`This model is also a Flax Linen
`),oa=s(tc,"A",{href:!0,rel:!0});var Uv=i(oa);Vg=r(Uv,"flax.nn.Module"),Uv.forEach(t),Jg=r(tc,` subclass. Use it as a
regular Flax Module and refer to the Flax documentation for all matter related to general usage and behavior.`),tc.forEach(t),Kg=d(ht),Zi=s(ht,"P",{});var Rv=i(Zi);Xg=r(Rv,"Finally, this model supports inherent JAX features such as:"),Rv.forEach(t),Yg=d(ht),wt=s(ht,"UL",{});var rn=i(wt);el=s(rn,"LI",{});var Vv=i(el);na=s(Vv,"A",{href:!0,rel:!0});var Jv=i(na);Qg=r(Jv,"Just-In-Time (JIT) compilation"),Jv.forEach(t),Vv.forEach(t),Zg=d(rn),tl=s(rn,"LI",{});var Kv=i(tl);sa=s(Kv,"A",{href:!0,rel:!0});var Xv=i(sa);e_=r(Xv,"Automatic Differentiation"),Xv.forEach(t),Kv.forEach(t),t_=d(rn),ol=s(rn,"LI",{});var Yv=i(ol);aa=s(Yv,"A",{href:!0,rel:!0});var Qv=i(aa);o_=r(Qv,"Vectorization"),Qv.forEach(t),Yv.forEach(t),n_=d(rn),nl=s(rn,"LI",{});var Zv=i(nl);ra=s(Zv,"A",{href:!0,rel:!0});var eb=i(ra);s_=r(eb,"Parallelization"),eb.forEach(t),Zv.forEach(t),rn.forEach(t),a_=d(ht),at=s(ht,"DIV",{class:!0});var Ot=i(at);b(ia.$$.fragment,Ot),r_=d(Ot),bo=s(Ot,"P",{});var mr=i(bo);i_=r(mr,"The "),sl=s(mr,"CODE",{});var tb=i(sl);l_=r(tb,"FlaxGPT2PreTrainedModel"),tb.forEach(t),d_=r(mr,"forward method, overrides the "),al=s(mr,"CODE",{});var ob=i(al);c_=r(ob,"__call__"),ob.forEach(t),p_=r(mr," special method."),mr.forEach(t),h_=d(Ot),b(Zo.$$.fragment,Ot),u_=d(Ot),rl=s(Ot,"P",{});var nb=i(rl);m_=r(nb,"Example:"),nb.forEach(t),f_=d(Ot),b(la.$$.fragment,Ot),Ot.forEach(t),ht.forEach(t),cd=d(o),ko=s(o,"H2",{class:!0});var oc=i(ko);en=s(oc,"A",{id:!0,class:!0,href:!0});var sb=i(en);il=s(sb,"SPAN",{});var ab=i(il);b(da.$$.fragment,ab),ab.forEach(t),sb.forEach(t),g_=d(oc),ll=s(oc,"SPAN",{});var rb=i(ll);__=r(rb,"FlaxGPT2LMHeadModel"),rb.forEach(t),oc.forEach(t),pd=d(o),$e=s(o,"DIV",{class:!0});var ut=i($e);b(ca.$$.fragment,ut),T_=d(ut),dl=s(ut,"P",{});var ib=i(dl);v_=r(ib,`The GPT2 Model transformer with a language modeling head on top (linear layer with weights tied to the input
embeddings).`),ib.forEach(t),b_=d(ut),pa=s(ut,"P",{});var nc=i(pa);k_=r(nc,"This model inherits from "),or=s(nc,"A",{href:!0});var lb=i(or);y_=r(lb,"FlaxPreTrainedModel"),lb.forEach(t),w_=r(nc,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),nc.forEach(t),P_=d(ut),ha=s(ut,"P",{});var sc=i(ha);$_=r(sc,`This model is also a Flax Linen
`),ua=s(sc,"A",{href:!0,rel:!0});var db=i(ua);M_=r(db,"flax.nn.Module"),db.forEach(t),G_=r(sc,` subclass. Use it as a
regular Flax Module and refer to the Flax documentation for all matter related to general usage and behavior.`),sc.forEach(t),z_=d(ut),cl=s(ut,"P",{});var cb=i(cl);j_=r(cb,"Finally, this model supports inherent JAX features such as:"),cb.forEach(t),F_=d(ut),Pt=s(ut,"UL",{});var ln=i(Pt);pl=s(ln,"LI",{});var pb=i(pl);ma=s(pb,"A",{href:!0,rel:!0});var hb=i(ma);x_=r(hb,"Just-In-Time (JIT) compilation"),hb.forEach(t),pb.forEach(t),E_=d(ln),hl=s(ln,"LI",{});var ub=i(hl);fa=s(ub,"A",{href:!0,rel:!0});var mb=i(fa);q_=r(mb,"Automatic Differentiation"),mb.forEach(t),ub.forEach(t),C_=d(ln),ul=s(ln,"LI",{});var fb=i(ul);ga=s(fb,"A",{href:!0,rel:!0});var gb=i(ga);D_=r(gb,"Vectorization"),gb.forEach(t),fb.forEach(t),H_=d(ln),ml=s(ln,"LI",{});var _b=i(ml);_a=s(_b,"A",{href:!0,rel:!0});var Tb=i(_a);L_=r(Tb,"Parallelization"),Tb.forEach(t),_b.forEach(t),ln.forEach(t),N_=d(ut),rt=s(ut,"DIV",{class:!0});var Wt=i(rt);b(Ta.$$.fragment,Wt),I_=d(Wt),yo=s(Wt,"P",{});var fr=i(yo);S_=r(fr,"The "),fl=s(fr,"CODE",{});var vb=i(fl);A_=r(vb,"FlaxGPT2PreTrainedModel"),vb.forEach(t),O_=r(fr,"forward method, overrides the "),gl=s(fr,"CODE",{});var bb=i(gl);W_=r(bb,"__call__"),bb.forEach(t),B_=r(fr," special method."),fr.forEach(t),U_=d(Wt),b(tn.$$.fragment,Wt),R_=d(Wt),_l=s(Wt,"P",{});var kb=i(_l);V_=r(kb,"Example:"),kb.forEach(t),J_=d(Wt),b(va.$$.fragment,Wt),Wt.forEach(t),ut.forEach(t),this.h()},h(){c(p,"name","hf:doc:metadata"),c(p,"content",JSON.stringify(Bb)),c(T,"id","openai-gpt2"),c(T,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(T,"href","#openai-gpt2"),c(f,"class","relative group"),c(R,"id","overview"),c(R,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(R,"href","#overview"),c(j,"class","relative group"),c(ee,"href","https://cdn.openai.com/better-language-models/language_models_are_unsupervised_multitask_learners.pdf"),c(ee,"rel","nofollow"),c(Pa,"href","/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.GPT2Model.forward"),c($a,"href","/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.TFGPT2Model.call"),c(dn,"href","https://github.com/stanford-crfm/mistral/"),c(dn,"rel","nofollow"),c(cn,"href","https://transformer.huggingface.co/doc/gpt2-large"),c(cn,"rel","nofollow"),c(pn,"href","https://huggingface.co/thomwolf"),c(pn,"rel","nofollow"),c(hn,"href","https://openai.com/blog/better-language-models/"),c(hn,"rel","nofollow"),c(wo,"id","transformers.GPT2Config"),c(wo,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(wo,"href","#transformers.GPT2Config"),c(Ut,"class","relative group"),c(Ma,"href","/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.GPT2Model"),c(Ga,"href","/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.TFGPT2Model"),c(fn,"href","https://huggingface.co/gpt2"),c(fn,"rel","nofollow"),c(za,"href","/docs/transformers/pr_15839/en/main_classes/configuration#transformers.PretrainedConfig"),c(ja,"href","/docs/transformers/pr_15839/en/main_classes/configuration#transformers.PretrainedConfig"),c(Re,"class","docstring"),c(Po,"id","transformers.GPT2Tokenizer"),c(Po,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(Po,"href","#transformers.GPT2Tokenizer"),c(Vt,"class","relative group"),c(Fa,"href","/docs/transformers/pr_15839/en/main_classes/tokenizer#transformers.PreTrainedTokenizer"),c(xa,"class","docstring"),c(le,"class","docstring"),c(Mo,"id","transformers.GPT2TokenizerFast"),c(Mo,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(Mo,"href","#transformers.GPT2TokenizerFast"),c(Jt,"class","relative group"),c(Ea,"href","/docs/transformers/pr_15839/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast"),c(be,"class","docstring"),c(zo,"id","transformers.models.gpt2.modeling_gpt2.GPT2DoubleHeadsModelOutput"),c(zo,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(zo,"href","#transformers.models.gpt2.modeling_gpt2.GPT2DoubleHeadsModelOutput"),c(Kt,"class","relative group"),c(Xt,"class","docstring"),c(Yt,"class","docstring"),c(jo,"id","transformers.GPT2Model"),c(jo,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(jo,"href","#transformers.GPT2Model"),c(Qt,"class","relative group"),c(qa,"href","/docs/transformers/pr_15839/en/main_classes/model#transformers.PreTrainedModel"),c(Hn,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),c(Hn,"rel","nofollow"),c(Ca,"href","/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.GPT2Model"),c(Ke,"class","docstring"),c(Xe,"class","docstring"),c(gt,"class","docstring"),c(ke,"class","docstring"),c(xo,"id","transformers.GPT2LMHeadModel"),c(xo,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(xo,"href","#transformers.GPT2LMHeadModel"),c(eo,"class","relative group"),c(Da,"href","/docs/transformers/pr_15839/en/main_classes/model#transformers.PreTrainedModel"),c(Vn,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),c(Vn,"rel","nofollow"),c(Ha,"href","/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.GPT2LMHeadModel"),c(Ye,"class","docstring"),c(Qe,"class","docstring"),c(_t,"class","docstring"),c(ye,"class","docstring"),c(qo,"id","transformers.GPT2DoubleHeadsModel"),c(qo,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(qo,"href","#transformers.GPT2DoubleHeadsModel"),c(oo,"class","relative group"),c(La,"href","/docs/transformers/pr_15839/en/main_classes/model#transformers.PreTrainedModel"),c(ss,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),c(ss,"rel","nofollow"),c(Na,"href","/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.GPT2DoubleHeadsModel"),c(Ze,"class","docstring"),c(Ve,"class","docstring"),c(Do,"id","transformers.GPT2ForSequenceClassification"),c(Do,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(Do,"href","#transformers.GPT2ForSequenceClassification"),c(so,"class","relative group"),c(Sa,"href","/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.GPT2ForSequenceClassification"),c(Aa,"href","/docs/transformers/pr_15839/en/main_classes/model#transformers.PreTrainedModel"),c(ps,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),c(ps,"rel","nofollow"),c(Oa,"href","/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.GPT2ForSequenceClassification"),c(Ge,"class","docstring"),c(we,"class","docstring"),c(Lo,"id","transformers.GPT2ForTokenClassification"),c(Lo,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(Lo,"href","#transformers.GPT2ForTokenClassification"),c(ro,"class","relative group"),c(Wa,"href","/docs/transformers/pr_15839/en/main_classes/model#transformers.PreTrainedModel"),c(vs,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),c(vs,"rel","nofollow"),c(Ba,"href","/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.GPT2ForTokenClassification"),c(et,"class","docstring"),c(Je,"class","docstring"),c(Io,"id","transformers.TFGPT2Model"),c(Io,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(Io,"href","#transformers.TFGPT2Model"),c(lo,"class","relative group"),c(Ua,"href","/docs/transformers/pr_15839/en/main_classes/model#transformers.TFPreTrainedModel"),c(Ms,"href","https://www.tensorflow.org/api_docs/python/tf/keras/Model"),c(Ms,"rel","nofollow"),c(Ra,"href","/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.TFGPT2Model"),c(tt,"class","docstring"),c(Ce,"class","docstring"),c(Oo,"id","transformers.TFGPT2LMHeadModel"),c(Oo,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(Oo,"href","#transformers.TFGPT2LMHeadModel"),c(po,"class","relative group"),c(Va,"href","/docs/transformers/pr_15839/en/main_classes/model#transformers.TFPreTrainedModel"),c(qs,"href","https://www.tensorflow.org/api_docs/python/tf/keras/Model"),c(qs,"rel","nofollow"),c(Ja,"href","/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.TFGPT2LMHeadModel"),c(ot,"class","docstring"),c(De,"class","docstring"),c(Uo,"id","transformers.TFGPT2DoubleHeadsModel"),c(Uo,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(Uo,"href","#transformers.TFGPT2DoubleHeadsModel"),c(uo,"class","relative group"),c(Ka,"href","/docs/transformers/pr_15839/en/main_classes/model#transformers.TFPreTrainedModel"),c(Ss,"href","https://www.tensorflow.org/api_docs/python/tf/keras/Model"),c(Ss,"rel","nofollow"),c(Xa,"href","/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.TFGPT2DoubleHeadsModel"),c(nt,"class","docstring"),c(He,"class","docstring"),c(Jo,"id","transformers.TFGPT2ForSequenceClassification"),c(Jo,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(Jo,"href","#transformers.TFGPT2ForSequenceClassification"),c(fo,"class","relative group"),c(Qa,"href","/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.TFGPT2ForSequenceClassification"),c(Za,"href","/docs/transformers/pr_15839/en/main_classes/model#transformers.TFPreTrainedModel"),c(Vs,"href","https://www.tensorflow.org/api_docs/python/tf/keras/Model"),c(Vs,"rel","nofollow"),c(er,"href","/docs/transformers/pr_15839/en/model_doc/gpt2#transformers.TFGPT2ForSequenceClassification"),c(st,"class","docstring"),c(de,"class","docstring"),c(Yo,"id","transformers.modeling_tf_outputs.TFSequenceClassifierOutputWithPast"),c(Yo,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(Yo,"href","#transformers.modeling_tf_outputs.TFSequenceClassifierOutputWithPast"),c(_o,"class","relative group"),c(To,"class","docstring"),c(Qo,"id","transformers.FlaxGPT2Model"),c(Qo,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(Qo,"href","#transformers.FlaxGPT2Model"),c(vo,"class","relative group"),c(tr,"href","/docs/transformers/pr_15839/en/main_classes/model#transformers.FlaxPreTrainedModel"),c(oa,"href","https://flax.readthedocs.io/en/latest/_autosummary/flax.nn.module.html"),c(oa,"rel","nofollow"),c(na,"href","https://jax.readthedocs.io/en/latest/jax.html#just-in-time-compilation-jit"),c(na,"rel","nofollow"),c(sa,"href","https://jax.readthedocs.io/en/latest/jax.html#automatic-differentiation"),c(sa,"rel","nofollow"),c(aa,"href","https://jax.readthedocs.io/en/latest/jax.html#vectorization-vmap"),c(aa,"rel","nofollow"),c(ra,"href","https://jax.readthedocs.io/en/latest/jax.html#parallelization-pmap"),c(ra,"rel","nofollow"),c(at,"class","docstring"),c(Pe,"class","docstring"),c(en,"id","transformers.FlaxGPT2LMHeadModel"),c(en,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(en,"href","#transformers.FlaxGPT2LMHeadModel"),c(ko,"class","relative group"),c(or,"href","/docs/transformers/pr_15839/en/main_classes/model#transformers.FlaxPreTrainedModel"),c(ua,"href","https://flax.readthedocs.io/en/latest/_autosummary/flax.nn.module.html"),c(ua,"rel","nofollow"),c(ma,"href","https://jax.readthedocs.io/en/latest/jax.html#just-in-time-compilation-jit"),c(ma,"rel","nofollow"),c(fa,"href","https://jax.readthedocs.io/en/latest/jax.html#automatic-differentiation"),c(fa,"rel","nofollow"),c(ga,"href","https://jax.readthedocs.io/en/latest/jax.html#vectorization-vmap"),c(ga,"rel","nofollow"),c(_a,"href","https://jax.readthedocs.io/en/latest/jax.html#parallelization-pmap"),c(_a,"rel","nofollow"),c(rt,"class","docstring"),c($e,"class","docstring")},m(o,m){e(document.head,p),h(o,M,m),h(o,f,m),e(f,T),e(T,$),k(_,$,null),e(f,g),e(f,z),e(z,Q),h(o,C,m),h(o,j,m),e(j,R),e(R,S),k(Z,S,null),e(j,ue),e(j,A),e(A,me),h(o,ce,m),h(o,W,m),e(W,L),e(W,ee),e(ee,te),e(W,F),h(o,E,m),h(o,se,m),e(se,V),h(o,pe,m),h(o,ae,m),e(ae,O),e(O,fe),h(o,he,m),h(o,x,m),e(x,ge),h(o,B,m),h(o,U,m),e(U,re),e(re,J),e(U,_e),e(U,oe),e(oe,N),e(oe,ie),e(ie,K),e(oe,Te),e(U,u),e(U,G),e(G,ne),e(G,Fe),e(Fe,Se),e(G,I),e(G,xe),e(xe,Ae),e(G,Oe),e(G,D),e(D,X),e(G,We),e(G,Ee),e(Ee,Y),e(G,Be),e(G,qe),e(qe,ve),e(G,Ue),e(G,Pa),e(Pa,ac),e(G,rc),e(G,gr),e(gr,ic),e(G,lc),e(G,$a),e($a,dc),e(G,cc),e(U,pc),e(U,kt),e(kt,hc),e(kt,_r),e(_r,uc),e(kt,mc),e(kt,Tr),e(Tr,fc),e(kt,gc),e(kt,dn),e(dn,_c),e(kt,Tc),h(o,xl,m),h(o,Bt,m),e(Bt,cn),e(cn,vc),e(Bt,bc),e(Bt,vr),e(vr,kc),e(Bt,yc),h(o,El,m),h(o,Mt,m),e(Mt,wc),e(Mt,pn),e(pn,Pc),e(Mt,$c),e(Mt,hn),e(hn,Mc),e(Mt,Gc),h(o,ql,m),h(o,Ut,m),e(Ut,wo),e(wo,br),k(un,br,null),e(Ut,zc),e(Ut,kr),e(kr,jc),h(o,Cl,m),h(o,Re,m),k(mn,Re,null),e(Re,Fc),e(Re,yt),e(yt,xc),e(yt,Ma),e(Ma,Ec),e(yt,qc),e(yt,Ga),e(Ga,Cc),e(yt,Dc),e(yt,fn),e(fn,Hc),e(yt,Lc),e(Re,Nc),e(Re,Rt),e(Rt,Ic),e(Rt,za),e(za,Sc),e(Rt,Ac),e(Rt,ja),e(ja,Oc),e(Rt,Wc),e(Re,Bc),e(Re,yr),e(yr,Uc),e(Re,Rc),k(gn,Re,null),h(o,Dl,m),h(o,Vt,m),e(Vt,Po),e(Po,wr),k(_n,wr,null),e(Vt,Vc),e(Vt,Pr),e(Pr,Jc),h(o,Hl,m),h(o,le,m),k(Tn,le,null),e(le,Kc),e(le,$r),e($r,Xc),e(le,Yc),e(le,Mr),e(Mr,Qc),e(le,Zc),k(vn,le,null),e(le,ep),e(le,bn),e(bn,tp),e(bn,Gr),e(Gr,op),e(bn,np),e(le,sp),k($o,le,null),e(le,ap),e(le,kn),e(kn,rp),e(kn,Fa),e(Fa,ip),e(kn,lp),e(le,dp),e(le,xa),k(yn,xa,null),h(o,Ll,m),h(o,Jt,m),e(Jt,Mo),e(Mo,zr),k(wn,zr,null),e(Jt,cp),e(Jt,jr),e(jr,pp),h(o,Nl,m),h(o,be,m),k(Pn,be,null),e(be,hp),e(be,$n),e($n,up),e($n,Fr),e(Fr,mp),e($n,fp),e(be,gp),e(be,xr),e(xr,_p),e(be,Tp),k(Mn,be,null),e(be,vp),e(be,Gn),e(Gn,bp),e(Gn,Er),e(Er,kp),e(Gn,yp),e(be,wp),k(Go,be,null),e(be,Pp),e(be,zn),e(zn,$p),e(zn,Ea),e(Ea,Mp),e(zn,Gp),h(o,Il,m),h(o,Kt,m),e(Kt,zo),e(zo,qr),k(jn,qr,null),e(Kt,zp),e(Kt,Cr),e(Cr,jp),h(o,Sl,m),h(o,Xt,m),k(Fn,Xt,null),e(Xt,Fp),e(Xt,Dr),e(Dr,xp),h(o,Al,m),h(o,Yt,m),k(xn,Yt,null),e(Yt,Ep),e(Yt,Hr),e(Hr,qp),h(o,Ol,m),h(o,Qt,m),e(Qt,jo),e(jo,Lr),k(En,Lr,null),e(Qt,Cp),e(Qt,Nr),e(Nr,Dp),h(o,Wl,m),h(o,ke,m),k(qn,ke,null),e(ke,Hp),e(ke,Ir),e(Ir,Lp),e(ke,Np),e(ke,Cn),e(Cn,Ip),e(Cn,qa),e(qa,Sp),e(Cn,Ap),e(ke,Op),e(ke,Dn),e(Dn,Wp),e(Dn,Hn),e(Hn,Bp),e(Dn,Up),e(ke,Rp),e(ke,Ke),k(Ln,Ke,null),e(Ke,Vp),e(Ke,Zt),e(Zt,Jp),e(Zt,Ca),e(Ca,Kp),e(Zt,Xp),e(Zt,Sr),e(Sr,Yp),e(Zt,Qp),e(Ke,Zp),k(Fo,Ke,null),e(Ke,eh),e(Ke,Ar),e(Ar,th),e(Ke,oh),k(Nn,Ke,null),e(ke,nh),e(ke,Xe),k(In,Xe,null),e(Xe,sh),e(Xe,Or),e(Or,ah),e(Xe,rh),e(Xe,Wr),e(Wr,ih),e(Xe,lh),e(Xe,Br),e(Br,dh),e(Xe,ch),k(Sn,Xe,null),e(ke,ph),e(ke,gt),k(An,gt,null),e(gt,hh),e(gt,Ur),e(Ur,uh),e(gt,mh),e(gt,Rr),e(Rr,fh),e(gt,gh),k(On,gt,null),h(o,Bl,m),h(o,eo,m),e(eo,xo),e(xo,Vr),k(Wn,Vr,null),e(eo,_h),e(eo,Jr),e(Jr,Th),h(o,Ul,m),h(o,ye,m),k(Bn,ye,null),e(ye,vh),e(ye,Kr),e(Kr,bh),e(ye,kh),e(ye,Un),e(Un,yh),e(Un,Da),e(Da,wh),e(Un,Ph),e(ye,$h),e(ye,Rn),e(Rn,Mh),e(Rn,Vn),e(Vn,Gh),e(Rn,zh),e(ye,jh),e(ye,Ye),k(Jn,Ye,null),e(Ye,Fh),e(Ye,to),e(to,xh),e(to,Ha),e(Ha,Eh),e(to,qh),e(to,Xr),e(Xr,Ch),e(to,Dh),e(Ye,Hh),k(Eo,Ye,null),e(Ye,Lh),e(Ye,Yr),e(Yr,Nh),e(Ye,Ih),k(Kn,Ye,null),e(ye,Sh),e(ye,Qe),k(Xn,Qe,null),e(Qe,Ah),e(Qe,Qr),e(Qr,Oh),e(Qe,Wh),e(Qe,Zr),e(Zr,Bh),e(Qe,Uh),e(Qe,ei),e(ei,Rh),e(Qe,Vh),k(Yn,Qe,null),e(ye,Jh),e(ye,_t),k(Qn,_t,null),e(_t,Kh),e(_t,ti),e(ti,Xh),e(_t,Yh),e(_t,oi),e(oi,Qh),e(_t,Zh),k(Zn,_t,null),h(o,Rl,m),h(o,oo,m),e(oo,qo),e(qo,ni),k(es,ni,null),e(oo,eu),e(oo,si),e(si,tu),h(o,Vl,m),h(o,Ve,m),k(ts,Ve,null),e(Ve,ou),e(Ve,ai),e(ai,nu),e(Ve,su),e(Ve,os),e(os,au),e(os,La),e(La,ru),e(os,iu),e(Ve,lu),e(Ve,ns),e(ns,du),e(ns,ss),e(ss,cu),e(ns,pu),e(Ve,hu),e(Ve,Ze),k(as,Ze,null),e(Ze,uu),e(Ze,no),e(no,mu),e(no,Na),e(Na,fu),e(no,gu),e(no,ri),e(ri,_u),e(no,Tu),e(Ze,vu),k(Co,Ze,null),e(Ze,bu),e(Ze,ii),e(ii,ku),e(Ze,yu),k(rs,Ze,null),h(o,Jl,m),h(o,so,m),e(so,Do),e(Do,li),k(is,li,null),e(so,wu),e(so,di),e(di,Pu),h(o,Kl,m),h(o,we,m),k(ls,we,null),e(we,$u),e(we,ci),e(ci,Mu),e(we,Gu),e(we,Ia),e(Ia,Sa),e(Sa,zu),e(Ia,ju),e(we,Fu),e(we,mt),e(mt,xu),e(mt,pi),e(pi,Eu),e(mt,qu),e(mt,hi),e(hi,Cu),e(mt,Du),e(mt,ui),e(ui,Hu),e(mt,Lu),e(mt,mi),e(mi,Nu),e(mt,Iu),e(we,Su),e(we,ds),e(ds,Au),e(ds,Aa),e(Aa,Ou),e(ds,Wu),e(we,Bu),e(we,cs),e(cs,Uu),e(cs,ps),e(ps,Ru),e(cs,Vu),e(we,Ju),e(we,Ge),k(hs,Ge,null),e(Ge,Ku),e(Ge,ao),e(ao,Xu),e(ao,Oa),e(Oa,Yu),e(ao,Qu),e(ao,fi),e(fi,Zu),e(ao,em),e(Ge,tm),k(Ho,Ge,null),e(Ge,om),e(Ge,gi),e(gi,nm),e(Ge,sm),k(us,Ge,null),e(Ge,am),e(Ge,_i),e(_i,rm),e(Ge,im),k(ms,Ge,null),h(o,Xl,m),h(o,ro,m),e(ro,Lo),e(Lo,Ti),k(fs,Ti,null),e(ro,lm),e(ro,vi),e(vi,dm),h(o,Yl,m),h(o,Je,m),k(gs,Je,null),e(Je,cm),e(Je,bi),e(bi,pm),e(Je,hm),e(Je,_s),e(_s,um),e(_s,Wa),e(Wa,mm),e(_s,fm),e(Je,gm),e(Je,Ts),e(Ts,_m),e(Ts,vs),e(vs,Tm),e(Ts,vm),e(Je,bm),e(Je,et),k(bs,et,null),e(et,km),e(et,io),e(io,ym),e(io,Ba),e(Ba,wm),e(io,Pm),e(io,ki),e(ki,$m),e(io,Mm),e(et,Gm),k(No,et,null),e(et,zm),e(et,yi),e(yi,jm),e(et,Fm),k(ks,et,null),h(o,Ql,m),h(o,lo,m),e(lo,Io),e(Io,wi),k(ys,wi,null),e(lo,xm),e(lo,Pi),e(Pi,Em),h(o,Zl,m),h(o,Ce,m),k(ws,Ce,null),e(Ce,qm),e(Ce,$i),e($i,Cm),e(Ce,Dm),e(Ce,Ps),e(Ps,Hm),e(Ps,Ua),e(Ua,Lm),e(Ps,Nm),e(Ce,Im),e(Ce,$s),e($s,Sm),e($s,Ms),e(Ms,Am),e($s,Om),e(Ce,Wm),k(So,Ce,null),e(Ce,Bm),e(Ce,tt),k(Gs,tt,null),e(tt,Um),e(tt,co),e(co,Rm),e(co,Ra),e(Ra,Vm),e(co,Jm),e(co,Mi),e(Mi,Km),e(co,Xm),e(tt,Ym),k(Ao,tt,null),e(tt,Qm),e(tt,Gi),e(Gi,Zm),e(tt,ef),k(zs,tt,null),h(o,ed,m),h(o,po,m),e(po,Oo),e(Oo,zi),k(js,zi,null),e(po,tf),e(po,ji),e(ji,of),h(o,td,m),h(o,De,m),k(Fs,De,null),e(De,nf),e(De,Fi),e(Fi,sf),e(De,af),e(De,xs),e(xs,rf),e(xs,Va),e(Va,lf),e(xs,df),e(De,cf),e(De,Es),e(Es,pf),e(Es,qs),e(qs,hf),e(Es,uf),e(De,mf),k(Wo,De,null),e(De,ff),e(De,ot),k(Cs,ot,null),e(ot,gf),e(ot,ho),e(ho,_f),e(ho,Ja),e(Ja,Tf),e(ho,vf),e(ho,xi),e(xi,bf),e(ho,kf),e(ot,yf),k(Bo,ot,null),e(ot,wf),e(ot,Ei),e(Ei,Pf),e(ot,$f),k(Ds,ot,null),h(o,od,m),h(o,uo,m),e(uo,Uo),e(Uo,qi),k(Hs,qi,null),e(uo,Mf),e(uo,Ci),e(Ci,Gf),h(o,nd,m),h(o,He,m),k(Ls,He,null),e(He,zf),e(He,Di),e(Di,jf),e(He,Ff),e(He,Ns),e(Ns,xf),e(Ns,Ka),e(Ka,Ef),e(Ns,qf),e(He,Cf),e(He,Is),e(Is,Df),e(Is,Ss),e(Ss,Hf),e(Is,Lf),e(He,Nf),k(Ro,He,null),e(He,If),e(He,nt),k(As,nt,null),e(nt,Sf),e(nt,mo),e(mo,Af),e(mo,Xa),e(Xa,Of),e(mo,Wf),e(mo,Hi),e(Hi,Bf),e(mo,Uf),e(nt,Rf),k(Vo,nt,null),e(nt,Vf),e(nt,Li),e(Li,Jf),e(nt,Kf),k(Os,nt,null),h(o,sd,m),h(o,fo,m),e(fo,Jo),e(Jo,Ni),k(Ws,Ni,null),e(fo,Xf),e(fo,Ii),e(Ii,Yf),h(o,ad,m),h(o,de,m),k(Bs,de,null),e(de,Qf),e(de,Si),e(Si,Zf),e(de,eg),e(de,Ya),e(Ya,Qa),e(Qa,tg),e(Ya,og),e(de,ng),e(de,ft),e(ft,sg),e(ft,Ai),e(Ai,ag),e(ft,rg),e(ft,Oi),e(Oi,ig),e(ft,lg),e(ft,Wi),e(Wi,dg),e(ft,cg),e(ft,Bi),e(Bi,pg),e(ft,hg),e(de,ug),e(de,Us),e(Us,mg),e(Us,Za),e(Za,fg),e(Us,gg),e(de,_g),e(de,Rs),e(Rs,Tg),e(Rs,Vs),e(Vs,vg),e(Rs,bg),e(de,kg),k(Ko,de,null),e(de,yg),e(de,st),k(Js,st,null),e(st,wg),e(st,go),e(go,Pg),e(go,er),e(er,$g),e(go,Mg),e(go,Ui),e(Ui,Gg),e(go,zg),e(st,jg),k(Xo,st,null),e(st,Fg),e(st,Ri),e(Ri,xg),e(st,Eg),k(Ks,st,null),h(o,rd,m),h(o,_o,m),e(_o,Yo),e(Yo,Vi),k(Xs,Vi,null),e(_o,qg),e(_o,Ji),e(Ji,Cg),h(o,id,m),h(o,To,m),k(Ys,To,null),e(To,Dg),e(To,Ki),e(Ki,Hg),h(o,ld,m),h(o,vo,m),e(vo,Qo),e(Qo,Xi),k(Qs,Xi,null),e(vo,Lg),e(vo,Yi),e(Yi,Ng),h(o,dd,m),h(o,Pe,m),k(Zs,Pe,null),e(Pe,Ig),e(Pe,Qi),e(Qi,Sg),e(Pe,Ag),e(Pe,ea),e(ea,Og),e(ea,tr),e(tr,Wg),e(ea,Bg),e(Pe,Ug),e(Pe,ta),e(ta,Rg),e(ta,oa),e(oa,Vg),e(ta,Jg),e(Pe,Kg),e(Pe,Zi),e(Zi,Xg),e(Pe,Yg),e(Pe,wt),e(wt,el),e(el,na),e(na,Qg),e(wt,Zg),e(wt,tl),e(tl,sa),e(sa,e_),e(wt,t_),e(wt,ol),e(ol,aa),e(aa,o_),e(wt,n_),e(wt,nl),e(nl,ra),e(ra,s_),e(Pe,a_),e(Pe,at),k(ia,at,null),e(at,r_),e(at,bo),e(bo,i_),e(bo,sl),e(sl,l_),e(bo,d_),e(bo,al),e(al,c_),e(bo,p_),e(at,h_),k(Zo,at,null),e(at,u_),e(at,rl),e(rl,m_),e(at,f_),k(la,at,null),h(o,cd,m),h(o,ko,m),e(ko,en),e(en,il),k(da,il,null),e(ko,g_),e(ko,ll),e(ll,__),h(o,pd,m),h(o,$e,m),k(ca,$e,null),e($e,T_),e($e,dl),e(dl,v_),e($e,b_),e($e,pa),e(pa,k_),e(pa,or),e(or,y_),e(pa,w_),e($e,P_),e($e,ha),e(ha,$_),e(ha,ua),e(ua,M_),e(ha,G_),e($e,z_),e($e,cl),e(cl,j_),e($e,F_),e($e,Pt),e(Pt,pl),e(pl,ma),e(ma,x_),e(Pt,E_),e(Pt,hl),e(hl,fa),e(fa,q_),e(Pt,C_),e(Pt,ul),e(ul,ga),e(ga,D_),e(Pt,H_),e(Pt,ml),e(ml,_a),e(_a,L_),e($e,N_),e($e,rt),k(Ta,rt,null),e(rt,I_),e(rt,yo),e(yo,S_),e(yo,fl),e(fl,A_),e(yo,O_),e(yo,gl),e(gl,W_),e(yo,B_),e(rt,U_),k(tn,rt,null),e(rt,R_),e(rt,_l),e(_l,V_),e(rt,J_),k(va,rt,null),hd=!0},p(o,[m]){const ba={};m&2&&(ba.$$scope={dirty:m,ctx:o}),$o.$set(ba);const Tl={};m&2&&(Tl.$$scope={dirty:m,ctx:o}),Go.$set(Tl);const vl={};m&2&&(vl.$$scope={dirty:m,ctx:o}),Fo.$set(vl);const bl={};m&2&&(bl.$$scope={dirty:m,ctx:o}),Eo.$set(bl);const ka={};m&2&&(ka.$$scope={dirty:m,ctx:o}),Co.$set(ka);const kl={};m&2&&(kl.$$scope={dirty:m,ctx:o}),Ho.$set(kl);const yl={};m&2&&(yl.$$scope={dirty:m,ctx:o}),No.$set(yl);const wl={};m&2&&(wl.$$scope={dirty:m,ctx:o}),So.$set(wl);const ya={};m&2&&(ya.$$scope={dirty:m,ctx:o}),Ao.$set(ya);const Pl={};m&2&&(Pl.$$scope={dirty:m,ctx:o}),Wo.$set(Pl);const $l={};m&2&&($l.$$scope={dirty:m,ctx:o}),Bo.$set($l);const Ml={};m&2&&(Ml.$$scope={dirty:m,ctx:o}),Ro.$set(Ml);const Gl={};m&2&&(Gl.$$scope={dirty:m,ctx:o}),Vo.$set(Gl);const zl={};m&2&&(zl.$$scope={dirty:m,ctx:o}),Ko.$set(zl);const $t={};m&2&&($t.$$scope={dirty:m,ctx:o}),Xo.$set($t);const jl={};m&2&&(jl.$$scope={dirty:m,ctx:o}),Zo.$set(jl);const wa={};m&2&&(wa.$$scope={dirty:m,ctx:o}),tn.$set(wa)},i(o){hd||(y(_.$$.fragment,o),y(Z.$$.fragment,o),y(un.$$.fragment,o),y(mn.$$.fragment,o),y(gn.$$.fragment,o),y(_n.$$.fragment,o),y(Tn.$$.fragment,o),y(vn.$$.fragment,o),y($o.$$.fragment,o),y(yn.$$.fragment,o),y(wn.$$.fragment,o),y(Pn.$$.fragment,o),y(Mn.$$.fragment,o),y(Go.$$.fragment,o),y(jn.$$.fragment,o),y(Fn.$$.fragment,o),y(xn.$$.fragment,o),y(En.$$.fragment,o),y(qn.$$.fragment,o),y(Ln.$$.fragment,o),y(Fo.$$.fragment,o),y(Nn.$$.fragment,o),y(In.$$.fragment,o),y(Sn.$$.fragment,o),y(An.$$.fragment,o),y(On.$$.fragment,o),y(Wn.$$.fragment,o),y(Bn.$$.fragment,o),y(Jn.$$.fragment,o),y(Eo.$$.fragment,o),y(Kn.$$.fragment,o),y(Xn.$$.fragment,o),y(Yn.$$.fragment,o),y(Qn.$$.fragment,o),y(Zn.$$.fragment,o),y(es.$$.fragment,o),y(ts.$$.fragment,o),y(as.$$.fragment,o),y(Co.$$.fragment,o),y(rs.$$.fragment,o),y(is.$$.fragment,o),y(ls.$$.fragment,o),y(hs.$$.fragment,o),y(Ho.$$.fragment,o),y(us.$$.fragment,o),y(ms.$$.fragment,o),y(fs.$$.fragment,o),y(gs.$$.fragment,o),y(bs.$$.fragment,o),y(No.$$.fragment,o),y(ks.$$.fragment,o),y(ys.$$.fragment,o),y(ws.$$.fragment,o),y(So.$$.fragment,o),y(Gs.$$.fragment,o),y(Ao.$$.fragment,o),y(zs.$$.fragment,o),y(js.$$.fragment,o),y(Fs.$$.fragment,o),y(Wo.$$.fragment,o),y(Cs.$$.fragment,o),y(Bo.$$.fragment,o),y(Ds.$$.fragment,o),y(Hs.$$.fragment,o),y(Ls.$$.fragment,o),y(Ro.$$.fragment,o),y(As.$$.fragment,o),y(Vo.$$.fragment,o),y(Os.$$.fragment,o),y(Ws.$$.fragment,o),y(Bs.$$.fragment,o),y(Ko.$$.fragment,o),y(Js.$$.fragment,o),y(Xo.$$.fragment,o),y(Ks.$$.fragment,o),y(Xs.$$.fragment,o),y(Ys.$$.fragment,o),y(Qs.$$.fragment,o),y(Zs.$$.fragment,o),y(ia.$$.fragment,o),y(Zo.$$.fragment,o),y(la.$$.fragment,o),y(da.$$.fragment,o),y(ca.$$.fragment,o),y(Ta.$$.fragment,o),y(tn.$$.fragment,o),y(va.$$.fragment,o),hd=!0)},o(o){w(_.$$.fragment,o),w(Z.$$.fragment,o),w(un.$$.fragment,o),w(mn.$$.fragment,o),w(gn.$$.fragment,o),w(_n.$$.fragment,o),w(Tn.$$.fragment,o),w(vn.$$.fragment,o),w($o.$$.fragment,o),w(yn.$$.fragment,o),w(wn.$$.fragment,o),w(Pn.$$.fragment,o),w(Mn.$$.fragment,o),w(Go.$$.fragment,o),w(jn.$$.fragment,o),w(Fn.$$.fragment,o),w(xn.$$.fragment,o),w(En.$$.fragment,o),w(qn.$$.fragment,o),w(Ln.$$.fragment,o),w(Fo.$$.fragment,o),w(Nn.$$.fragment,o),w(In.$$.fragment,o),w(Sn.$$.fragment,o),w(An.$$.fragment,o),w(On.$$.fragment,o),w(Wn.$$.fragment,o),w(Bn.$$.fragment,o),w(Jn.$$.fragment,o),w(Eo.$$.fragment,o),w(Kn.$$.fragment,o),w(Xn.$$.fragment,o),w(Yn.$$.fragment,o),w(Qn.$$.fragment,o),w(Zn.$$.fragment,o),w(es.$$.fragment,o),w(ts.$$.fragment,o),w(as.$$.fragment,o),w(Co.$$.fragment,o),w(rs.$$.fragment,o),w(is.$$.fragment,o),w(ls.$$.fragment,o),w(hs.$$.fragment,o),w(Ho.$$.fragment,o),w(us.$$.fragment,o),w(ms.$$.fragment,o),w(fs.$$.fragment,o),w(gs.$$.fragment,o),w(bs.$$.fragment,o),w(No.$$.fragment,o),w(ks.$$.fragment,o),w(ys.$$.fragment,o),w(ws.$$.fragment,o),w(So.$$.fragment,o),w(Gs.$$.fragment,o),w(Ao.$$.fragment,o),w(zs.$$.fragment,o),w(js.$$.fragment,o),w(Fs.$$.fragment,o),w(Wo.$$.fragment,o),w(Cs.$$.fragment,o),w(Bo.$$.fragment,o),w(Ds.$$.fragment,o),w(Hs.$$.fragment,o),w(Ls.$$.fragment,o),w(Ro.$$.fragment,o),w(As.$$.fragment,o),w(Vo.$$.fragment,o),w(Os.$$.fragment,o),w(Ws.$$.fragment,o),w(Bs.$$.fragment,o),w(Ko.$$.fragment,o),w(Js.$$.fragment,o),w(Xo.$$.fragment,o),w(Ks.$$.fragment,o),w(Xs.$$.fragment,o),w(Ys.$$.fragment,o),w(Qs.$$.fragment,o),w(Zs.$$.fragment,o),w(ia.$$.fragment,o),w(Zo.$$.fragment,o),w(la.$$.fragment,o),w(da.$$.fragment,o),w(ca.$$.fragment,o),w(Ta.$$.fragment,o),w(tn.$$.fragment,o),w(va.$$.fragment,o),hd=!1},d(o){t(p),o&&t(M),o&&t(f),P(_),o&&t(C),o&&t(j),P(Z),o&&t(ce),o&&t(W),o&&t(E),o&&t(se),o&&t(pe),o&&t(ae),o&&t(he),o&&t(x),o&&t(B),o&&t(U),o&&t(xl),o&&t(Bt),o&&t(El),o&&t(Mt),o&&t(ql),o&&t(Ut),P(un),o&&t(Cl),o&&t(Re),P(mn),P(gn),o&&t(Dl),o&&t(Vt),P(_n),o&&t(Hl),o&&t(le),P(Tn),P(vn),P($o),P(yn),o&&t(Ll),o&&t(Jt),P(wn),o&&t(Nl),o&&t(be),P(Pn),P(Mn),P(Go),o&&t(Il),o&&t(Kt),P(jn),o&&t(Sl),o&&t(Xt),P(Fn),o&&t(Al),o&&t(Yt),P(xn),o&&t(Ol),o&&t(Qt),P(En),o&&t(Wl),o&&t(ke),P(qn),P(Ln),P(Fo),P(Nn),P(In),P(Sn),P(An),P(On),o&&t(Bl),o&&t(eo),P(Wn),o&&t(Ul),o&&t(ye),P(Bn),P(Jn),P(Eo),P(Kn),P(Xn),P(Yn),P(Qn),P(Zn),o&&t(Rl),o&&t(oo),P(es),o&&t(Vl),o&&t(Ve),P(ts),P(as),P(Co),P(rs),o&&t(Jl),o&&t(so),P(is),o&&t(Kl),o&&t(we),P(ls),P(hs),P(Ho),P(us),P(ms),o&&t(Xl),o&&t(ro),P(fs),o&&t(Yl),o&&t(Je),P(gs),P(bs),P(No),P(ks),o&&t(Ql),o&&t(lo),P(ys),o&&t(Zl),o&&t(Ce),P(ws),P(So),P(Gs),P(Ao),P(zs),o&&t(ed),o&&t(po),P(js),o&&t(td),o&&t(De),P(Fs),P(Wo),P(Cs),P(Bo),P(Ds),o&&t(od),o&&t(uo),P(Hs),o&&t(nd),o&&t(He),P(Ls),P(Ro),P(As),P(Vo),P(Os),o&&t(sd),o&&t(fo),P(Ws),o&&t(ad),o&&t(de),P(Bs),P(Ko),P(Js),P(Xo),P(Ks),o&&t(rd),o&&t(_o),P(Xs),o&&t(id),o&&t(To),P(Ys),o&&t(ld),o&&t(vo),P(Qs),o&&t(dd),o&&t(Pe),P(Zs),P(ia),P(Zo),P(la),o&&t(cd),o&&t(ko),P(da),o&&t(pd),o&&t($e),P(ca),P(Ta),P(tn),P(va)}}}const Bb={local:"openai-gpt2",sections:[{local:"overview",title:"Overview"},{local:"transformers.GPT2Config",title:"GPT2Config"},{local:"transformers.GPT2Tokenizer",title:"GPT2Tokenizer"},{local:"transformers.GPT2TokenizerFast",title:"GPT2TokenizerFast"},{local:"transformers.models.gpt2.modeling_gpt2.GPT2DoubleHeadsModelOutput",title:"GPT2 specific outputs"},{local:"transformers.GPT2Model",title:"GPT2Model"},{local:"transformers.GPT2LMHeadModel",title:"GPT2LMHeadModel"},{local:"transformers.GPT2DoubleHeadsModel",title:"GPT2DoubleHeadsModel"},{local:"transformers.GPT2ForSequenceClassification",title:"GPT2ForSequenceClassification"},{local:"transformers.GPT2ForTokenClassification",title:"GPT2ForTokenClassification"},{local:"transformers.TFGPT2Model",title:"TFGPT2Model"},{local:"transformers.TFGPT2LMHeadModel",title:"TFGPT2LMHeadModel"},{local:"transformers.TFGPT2DoubleHeadsModel",title:"TFGPT2DoubleHeadsModel"},{local:"transformers.TFGPT2ForSequenceClassification",title:"TFGPT2ForSequenceClassification"},{local:"transformers.modeling_tf_outputs.TFSequenceClassifierOutputWithPast",title:"TFSequenceClassifierOutputWithPast"},{local:"transformers.FlaxGPT2Model",title:"FlaxGPT2Model"},{local:"transformers.FlaxGPT2LMHeadModel",title:"FlaxGPT2LMHeadModel"}],title:"OpenAI GPT2"};function Ub(q,p,M){let{fw:f}=p;return q.$$set=T=>{"fw"in T&&M(0,f=T.fw)},[f]}class Qb extends yb{constructor(p){super();wb(this,p,Ub,Wb,Pb,{fw:0})}}export{Qb as default,Bb as metadata};
