import{S as gv,i as _v,s as vv,e as s,k as c,w as h,t as n,M as yv,c as r,d as t,m as d,a as i,x as m,h as a,b as l,F as e,g as u,y as f,q as g,o as _,B as v}from"../../chunks/vendor-4833417e.js";import{T as ji}from"../../chunks/Tip-fffd6df1.js";import{D as I}from"../../chunks/Docstring-4f315ed9.js";import{C as Y}from"../../chunks/CodeBlock-6a3d1b46.js";import{I as ie}from"../../chunks/IconCopyLink-4b81c553.js";import"../../chunks/CopyButton-dacfbfaf.js";function bv(le){let y,q,b,T,P;return{c(){y=s("p"),q=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),b=s("code"),T=n("Module"),P=n(`
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(L){y=r(L,"P",{});var w=i(y);q=a(w,"Although the recipe for forward pass needs to be defined within this function, one should call the "),b=r(w,"CODE",{});var A=i(b);T=a(A,"Module"),A.forEach(t),P=a(w,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),w.forEach(t)},m(L,w){u(L,y,w),e(y,q),e(y,b),e(b,T),e(y,P)},d(L){L&&t(y)}}}function Lv(le){let y,q,b,T,P;return{c(){y=s("p"),q=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),b=s("code"),T=n("Module"),P=n(`
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(L){y=r(L,"P",{});var w=i(y);q=a(w,"Although the recipe for forward pass needs to be defined within this function, one should call the "),b=r(w,"CODE",{});var A=i(b);T=a(A,"Module"),A.forEach(t),P=a(w,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),w.forEach(t)},m(L,w){u(L,y,w),e(y,q),e(y,b),e(b,T),e(y,P)},d(L){L&&t(y)}}}function wv(le){let y,q,b,T,P;return{c(){y=s("p"),q=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),b=s("code"),T=n("Module"),P=n(`
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(L){y=r(L,"P",{});var w=i(y);q=a(w,"Although the recipe for forward pass needs to be defined within this function, one should call the "),b=r(w,"CODE",{});var A=i(b);T=a(A,"Module"),A.forEach(t),P=a(w,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),w.forEach(t)},m(L,w){u(L,y,w),e(y,q),e(y,b),e(b,T),e(y,P)},d(L){L&&t(y)}}}function kv(le){let y,q,b,T,P;return{c(){y=s("p"),q=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),b=s("code"),T=n("Module"),P=n(`
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(L){y=r(L,"P",{});var w=i(y);q=a(w,"Although the recipe for forward pass needs to be defined within this function, one should call the "),b=r(w,"CODE",{});var A=i(b);T=a(A,"Module"),A.forEach(t),P=a(w,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),w.forEach(t)},m(L,w){u(L,y,w),e(y,q),e(y,b),e(b,T),e(y,P)},d(L){L&&t(y)}}}function xv(le){let y,q,b,T,P,L,w,A,Ci,ar,$e,Ge,ca,bo,Ii,da,Ai,sr,ue,Oi,Lo,Di,Ni,Zt,Si,Ri,rr,he,Z,Ui,wo,Bi,Wi,ko,Vi,Qi,xo,Gi,Hi,To,Ki,Xi,Yi,Mo,Zi,Eo,Ji,el,ol,zo,tl,$o,nl,al,ir,Jt,sl,lr,en,pa,rl,cr,on,il,dr,B,ua,ll,cl,qo,dl,Fo,pl,ul,hl,Po,ml,jo,fl,gl,_l,qe,vl,Co,yl,bl,Io,Ll,wl,kl,k,xl,ha,Tl,Ml,tn,El,zl,ma,$l,ql,fa,Fl,Pl,ga,jl,Cl,_a,Il,Al,va,Ol,Dl,ya,Nl,Sl,ba,Rl,Ul,nn,Bl,Wl,Ao,Vl,Ql,Oo,Gl,Hl,pr,Do,ur,me,Kl,La,Xl,Yl,wa,Zl,Jl,hr,No,mr,He,ec,an,oc,tc,fr,fe,C,nc,sn,ac,sc,ka,rc,ic,xa,lc,cc,rn,dc,pc,Ta,uc,hc,Ma,mc,fc,Ea,gc,_c,vc,So,yc,ln,bc,Lc,wc,Ro,kc,za,xc,Tc,gr,Ke,Mc,cn,Ec,zc,_r,Fe,Xe,$a,Uo,$c,qa,qc,vr,W,Fc,dn,Pc,jc,pn,Cc,Ic,un,Ac,Oc,hn,Dc,Nc,yr,Bo,br,M,Sc,mn,Rc,Uc,fn,Bc,Wc,Fa,Vc,Qc,gn,Gc,Hc,_n,Kc,Xc,Pa,Yc,Zc,ja,Jc,ed,Ca,od,td,Ia,nd,ad,Aa,sd,rd,Lr,S,vn,id,ld,Wo,cd,dd,yn,pd,ud,Oa,hd,md,Da,fd,gd,wr,bn,_d,kr,Ln,Na,vd,xr,wn,yd,Tr,Vo,Mr,kn,Sa,bd,Er,ge,Ld,Ra,wd,kd,Ua,xd,Td,zr,Qo,$r,xn,Ba,Md,qr,V,Ed,Wa,zd,$d,Va,qd,Fd,Qa,Pd,jd,Ga,Cd,Id,Fr,Go,Pr,Tn,Ha,Ad,jr,Mn,Od,Cr,Ho,Ir,En,Ka,Dd,Ar,zn,Nd,Or,Ko,Dr,Pe,Ye,Xa,Xo,Sd,Ya,Rd,Nr,R,Yo,Ud,je,Bd,$n,Wd,Vd,Zo,Qd,Gd,Hd,Ce,Kd,qn,Xd,Yd,Fn,Zd,Jd,ep,Za,op,tp,Jo,Sr,Ie,Ze,Ja,et,np,es,ap,Rr,J,ot,sp,os,rp,ip,tt,lp,ts,cp,dp,pp,se,nt,up,ns,hp,mp,as,fp,gp,at,Ur,Ae,Je,ss,st,_p,rs,vp,Br,O,rt,yp,D,bp,Pn,Lp,wp,is,kp,xp,ls,Tp,Mp,cs,Ep,zp,ds,$p,qp,ps,Fp,Pp,jp,it,Cp,jn,Ip,Ap,Op,Cn,In,Dp,Np,Sp,eo,lt,Rp,us,Up,Bp,An,ct,Wr,Oe,oo,hs,dt,Wp,ms,Vp,Vr,ee,pt,Qp,ut,Gp,fs,Hp,Kp,Xp,ht,Yp,On,Zp,Jp,eu,to,mt,ou,gs,tu,Qr,De,no,_s,ft,nu,vs,au,Gr,U,gt,su,ys,ru,iu,Dn,Nn,lu,cu,du,$,pu,Sn,uu,hu,Rn,mu,fu,Un,gu,_u,bs,vu,yu,Ls,bu,Lu,ws,wu,ku,ks,xu,Tu,xs,Mu,Eu,Ts,zu,$u,qu,_e,_t,Fu,x,Pu,Ms,ju,Cu,vt,Es,Iu,Au,Ou,Bn,Du,Nu,zs,Su,Ru,$s,Uu,Bu,yt,qs,Wu,Vu,Qu,Fs,Gu,Hu,Wn,Ku,Xu,Ps,Yu,Zu,js,Ju,eh,Cs,oh,th,Is,nh,ah,sh,As,rh,Hr,Ne,ao,Os,bt,ih,Ds,lh,Kr,ce,Lt,ch,wt,dh,kt,ph,uh,hh,Q,xt,mh,Se,fh,Vn,gh,_h,Ns,vh,yh,bh,so,Lh,Ss,wh,kh,Tt,Xr,Re,ro,Rs,Mt,xh,Us,Th,Yr,oe,Et,Mh,zt,Eh,$t,zh,$h,qh,qt,Fh,Ft,Ph,jh,Ch,G,Pt,Ih,Ue,Ah,Qn,Oh,Dh,Bs,Nh,Sh,Rh,io,Uh,Ws,Bh,Wh,jt,Zr,Be,lo,Vs,Ct,Vh,Qs,Qh,Jr,te,It,Gh,ne,Hh,At,Kh,Xh,Ot,Yh,Zh,Dt,Jh,em,Nt,om,tm,nm,St,am,Rt,sm,rm,im,H,Ut,lm,We,cm,Gn,dm,pm,Gs,um,hm,mm,co,fm,Hs,gm,_m,Bt,ei,Ve,po,Ks,Wt,vm,Xs,ym,oi,ae,Vt,bm,de,Lm,Qt,wm,km,Ys,xm,Tm,Zs,Mm,Em,zm,Gt,$m,Ht,qm,Fm,Pm,K,Kt,jm,Qe,Cm,Hn,Im,Am,Js,Om,Dm,Nm,uo,Sm,er,Rm,Um,Xt,ti;return L=new ie({}),bo=new ie({}),Do=new Y({props:{code:`def normalize_bbox(bbox, width, height):
    return [
        int(1000 * (bbox[0] / width)),
        int(1000 * (bbox[1] / height)),
        int(1000 * (bbox[2] / width)),
        int(1000 * (bbox[3] / height)),
    ]`,highlighted:`<span class="hljs-keyword">def</span> <span class="hljs-title function_">normalize_bbox</span>(<span class="hljs-params">bbox, width, height</span>):
    <span class="hljs-keyword">return</span> [
        <span class="hljs-built_in">int</span>(<span class="hljs-number">1000</span> * (bbox[<span class="hljs-number">0</span>] / width)),
        <span class="hljs-built_in">int</span>(<span class="hljs-number">1000</span> * (bbox[<span class="hljs-number">1</span>] / height)),
        <span class="hljs-built_in">int</span>(<span class="hljs-number">1000</span> * (bbox[<span class="hljs-number">2</span>] / width)),
        <span class="hljs-built_in">int</span>(<span class="hljs-number">1000</span> * (bbox[<span class="hljs-number">3</span>] / height)),
    ]`}}),No=new Y({props:{code:`from PIL import Image

image = Image.open("name_of_your_document - can be a png file, pdf, etc.")

width, height = image.size`,highlighted:`<span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image

image = Image.<span class="hljs-built_in">open</span>(<span class="hljs-string">&quot;name_of_your_document - can be a png file, pdf, etc.&quot;</span>)

width, height = image.size`}}),Uo=new ie({}),Bo=new Y({props:{code:`from transformers import LayoutLMv2FeatureExtractor, LayoutLMv2TokenizerFast, LayoutLMv2Processor

feature_extractor = LayoutLMv2FeatureExtractor()  # apply_ocr is set to True by default
tokenizer = LayoutLMv2TokenizerFast.from_pretrained("microsoft/layoutlmv2-base-uncased")
processor = LayoutLMv2Processor(feature_extractor, tokenizer)`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> LayoutLMv2FeatureExtractor, LayoutLMv2TokenizerFast, LayoutLMv2Processor

feature_extractor = LayoutLMv2FeatureExtractor()  <span class="hljs-comment"># apply_ocr is set to True by default</span>
tokenizer = LayoutLMv2TokenizerFast.from_pretrained(<span class="hljs-string">&quot;microsoft/layoutlmv2-base-uncased&quot;</span>)
processor = LayoutLMv2Processor(feature_extractor, tokenizer)`}}),Vo=new Y({props:{code:`from transformers import LayoutLMv2Processor
from PIL import Image

processor = LayoutLMv2Processor.from_pretrained("microsoft/layoutlmv2-base-uncased")

image = Image.open("name_of_your_document - can be a png file, pdf, etc.").convert("RGB")
encoding = processor(
    image, return_tensors="pt"
)  # you can also add all tokenizer parameters here such as padding, truncation
print(encoding.keys())
# dict_keys(['input_ids', 'token_type_ids', 'attention_mask', 'bbox', 'image'])`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> LayoutLMv2Processor
<span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image

processor = LayoutLMv2Processor.from_pretrained(<span class="hljs-string">&quot;microsoft/layoutlmv2-base-uncased&quot;</span>)

image = Image.<span class="hljs-built_in">open</span>(<span class="hljs-string">&quot;name_of_your_document - can be a png file, pdf, etc.&quot;</span>).convert(<span class="hljs-string">&quot;RGB&quot;</span>)
encoding = processor(
    image, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>
)  <span class="hljs-comment"># you can also add all tokenizer parameters here such as padding, truncation</span>
<span class="hljs-built_in">print</span>(encoding.keys())
<span class="hljs-comment"># dict_keys([&#x27;input_ids&#x27;, &#x27;token_type_ids&#x27;, &#x27;attention_mask&#x27;, &#x27;bbox&#x27;, &#x27;image&#x27;])</span>`}}),Qo=new Y({props:{code:`from transformers import LayoutLMv2Processor
from PIL import Image

processor = LayoutLMv2Processor.from_pretrained("microsoft/layoutlmv2-base-uncased", revision="no_ocr")

image = Image.open("name_of_your_document - can be a png file, pdf, etc.").convert("RGB")
words = ["hello", "world"]
boxes = [[1, 2, 3, 4], [5, 6, 7, 8]]  # make sure to normalize your bounding boxes
encoding = processor(image, words, boxes=boxes, return_tensors="pt")
print(encoding.keys())
# dict_keys(['input_ids', 'token_type_ids', 'attention_mask', 'bbox', 'image'])`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> LayoutLMv2Processor
<span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image

processor = LayoutLMv2Processor.from_pretrained(<span class="hljs-string">&quot;microsoft/layoutlmv2-base-uncased&quot;</span>, revision=<span class="hljs-string">&quot;no_ocr&quot;</span>)

image = Image.<span class="hljs-built_in">open</span>(<span class="hljs-string">&quot;name_of_your_document - can be a png file, pdf, etc.&quot;</span>).convert(<span class="hljs-string">&quot;RGB&quot;</span>)
words = [<span class="hljs-string">&quot;hello&quot;</span>, <span class="hljs-string">&quot;world&quot;</span>]
boxes = [[<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-comment"># make sure to normalize your bounding boxes</span>
encoding = processor(image, words, boxes=boxes, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-built_in">print</span>(encoding.keys())
<span class="hljs-comment"># dict_keys([&#x27;input_ids&#x27;, &#x27;token_type_ids&#x27;, &#x27;attention_mask&#x27;, &#x27;bbox&#x27;, &#x27;image&#x27;])</span>`}}),Go=new Y({props:{code:`from transformers import LayoutLMv2Processor
from PIL import Image

processor = LayoutLMv2Processor.from_pretrained("microsoft/layoutlmv2-base-uncased", revision="no_ocr")

image = Image.open("name_of_your_document - can be a png file, pdf, etc.").convert("RGB")
words = ["hello", "world"]
boxes = [[1, 2, 3, 4], [5, 6, 7, 8]]  # make sure to normalize your bounding boxes
word_labels = [1, 2]
encoding = processor(image, words, boxes=boxes, word_labels=word_labels, return_tensors="pt")
print(encoding.keys())
# dict_keys(['input_ids', 'token_type_ids', 'attention_mask', 'bbox', 'labels', 'image'])`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> LayoutLMv2Processor
<span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image

processor = LayoutLMv2Processor.from_pretrained(<span class="hljs-string">&quot;microsoft/layoutlmv2-base-uncased&quot;</span>, revision=<span class="hljs-string">&quot;no_ocr&quot;</span>)

image = Image.<span class="hljs-built_in">open</span>(<span class="hljs-string">&quot;name_of_your_document - can be a png file, pdf, etc.&quot;</span>).convert(<span class="hljs-string">&quot;RGB&quot;</span>)
words = [<span class="hljs-string">&quot;hello&quot;</span>, <span class="hljs-string">&quot;world&quot;</span>]
boxes = [[<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-comment"># make sure to normalize your bounding boxes</span>
word_labels = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>]
encoding = processor(image, words, boxes=boxes, word_labels=word_labels, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-built_in">print</span>(encoding.keys())
<span class="hljs-comment"># dict_keys([&#x27;input_ids&#x27;, &#x27;token_type_ids&#x27;, &#x27;attention_mask&#x27;, &#x27;bbox&#x27;, &#x27;labels&#x27;, &#x27;image&#x27;])</span>`}}),Ho=new Y({props:{code:`from transformers import LayoutLMv2Processor
from PIL import Image

processor = LayoutLMv2Processor.from_pretrained("microsoft/layoutlmv2-base-uncased")

image = Image.open("name_of_your_document - can be a png file, pdf, etc.").convert("RGB")
question = "What's his name?"
encoding = processor(image, question, return_tensors="pt")
print(encoding.keys())
# dict_keys(['input_ids', 'token_type_ids', 'attention_mask', 'bbox', 'image'])`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> LayoutLMv2Processor
<span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image

processor = LayoutLMv2Processor.from_pretrained(<span class="hljs-string">&quot;microsoft/layoutlmv2-base-uncased&quot;</span>)

image = Image.<span class="hljs-built_in">open</span>(<span class="hljs-string">&quot;name_of_your_document - can be a png file, pdf, etc.&quot;</span>).convert(<span class="hljs-string">&quot;RGB&quot;</span>)
question = <span class="hljs-string">&quot;What&#x27;s his name?&quot;</span>
encoding = processor(image, question, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-built_in">print</span>(encoding.keys())
<span class="hljs-comment"># dict_keys([&#x27;input_ids&#x27;, &#x27;token_type_ids&#x27;, &#x27;attention_mask&#x27;, &#x27;bbox&#x27;, &#x27;image&#x27;])</span>`}}),Ko=new Y({props:{code:`from transformers import LayoutLMv2Processor
from PIL import Image

processor = LayoutLMv2Processor.from_pretrained("microsoft/layoutlmv2-base-uncased", revision="no_ocr")

image = Image.open("name_of_your_document - can be a png file, pdf, etc.").convert("RGB")
question = "What's his name?"
words = ["hello", "world"]
boxes = [[1, 2, 3, 4], [5, 6, 7, 8]]  # make sure to normalize your bounding boxes
encoding = processor(image, question, words, boxes=boxes, return_tensors="pt")
print(encoding.keys())
# dict_keys(['input_ids', 'token_type_ids', 'attention_mask', 'bbox', 'image'])`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> LayoutLMv2Processor
<span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image

processor = LayoutLMv2Processor.from_pretrained(<span class="hljs-string">&quot;microsoft/layoutlmv2-base-uncased&quot;</span>, revision=<span class="hljs-string">&quot;no_ocr&quot;</span>)

image = Image.<span class="hljs-built_in">open</span>(<span class="hljs-string">&quot;name_of_your_document - can be a png file, pdf, etc.&quot;</span>).convert(<span class="hljs-string">&quot;RGB&quot;</span>)
question = <span class="hljs-string">&quot;What&#x27;s his name?&quot;</span>
words = [<span class="hljs-string">&quot;hello&quot;</span>, <span class="hljs-string">&quot;world&quot;</span>]
boxes = [[<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-comment"># make sure to normalize your bounding boxes</span>
encoding = processor(image, question, words, boxes=boxes, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-built_in">print</span>(encoding.keys())
<span class="hljs-comment"># dict_keys([&#x27;input_ids&#x27;, &#x27;token_type_ids&#x27;, &#x27;attention_mask&#x27;, &#x27;bbox&#x27;, &#x27;image&#x27;])</span>`}}),Xo=new ie({}),Yo=new I({props:{name:"class transformers.LayoutLMv2Config",anchor:"transformers.LayoutLMv2Config",parameters:[{name:"vocab_size",val:" = 30522"},{name:"hidden_size",val:" = 768"},{name:"num_hidden_layers",val:" = 12"},{name:"num_attention_heads",val:" = 12"},{name:"intermediate_size",val:" = 3072"},{name:"hidden_act",val:" = 'gelu'"},{name:"hidden_dropout_prob",val:" = 0.1"},{name:"attention_probs_dropout_prob",val:" = 0.1"},{name:"max_position_embeddings",val:" = 512"},{name:"type_vocab_size",val:" = 2"},{name:"initializer_range",val:" = 0.02"},{name:"layer_norm_eps",val:" = 1e-12"},{name:"pad_token_id",val:" = 0"},{name:"max_2d_position_embeddings",val:" = 1024"},{name:"max_rel_pos",val:" = 128"},{name:"rel_pos_bins",val:" = 32"},{name:"fast_qkv",val:" = True"},{name:"max_rel_2d_pos",val:" = 256"},{name:"rel_2d_pos_bins",val:" = 64"},{name:"convert_sync_batchnorm",val:" = True"},{name:"image_feature_pool_shape",val:" = [7, 7, 256]"},{name:"coordinate_size",val:" = 128"},{name:"shape_size",val:" = 128"},{name:"has_relative_attention_bias",val:" = True"},{name:"has_spatial_attention_bias",val:" = True"},{name:"has_visual_segment_embedding",val:" = False"},{name:"detectron2_config_args",val:" = None"},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/layoutlmv2/configuration_layoutlmv2.py#L35",parametersDescription:[{anchor:"transformers.LayoutLMv2Config.vocab_size",description:`<strong>vocab_size</strong> (<code>int</code>, <em>optional</em>, defaults to 30522) &#x2014;
Vocabulary size of the LayoutLMv2 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/layoutlmv2#transformers.LayoutLMv2Model">LayoutLMv2Model</a> or <code>TFLayoutLMv2Model</code>.`,name:"vocab_size"},{anchor:"transformers.LayoutLMv2Config.hidden_size",description:`<strong>hidden_size</strong> (<code>int</code>, <em>optional</em>, defaults to 768) &#x2014;
Dimension of the encoder layers and the pooler layer.`,name:"hidden_size"},{anchor:"transformers.LayoutLMv2Config.num_hidden_layers",description:`<strong>num_hidden_layers</strong> (<code>int</code>, <em>optional</em>, defaults to 12) &#x2014;
Number of hidden layers in the Transformer encoder.`,name:"num_hidden_layers"},{anchor:"transformers.LayoutLMv2Config.num_attention_heads",description:`<strong>num_attention_heads</strong> (<code>int</code>, <em>optional</em>, defaults to 12) &#x2014;
Number of attention heads for each attention layer in the Transformer encoder.`,name:"num_attention_heads"},{anchor:"transformers.LayoutLMv2Config.intermediate_size",description:`<strong>intermediate_size</strong> (<code>int</code>, <em>optional</em>, defaults to 3072) &#x2014;
Dimension of the &#x201C;intermediate&#x201D; (i.e., feed-forward) layer in the Transformer encoder.`,name:"intermediate_size"},{anchor:"transformers.LayoutLMv2Config.hidden_act",description:`<strong>hidden_act</strong> (<code>str</code> or <code>function</code>, <em>optional</em>, defaults to <code>&quot;gelu&quot;</code>) &#x2014;
The non-linear activation function (function or string) in the encoder and pooler. If string, <code>&quot;gelu&quot;</code>,
<code>&quot;relu&quot;</code>, <code>&quot;selu&quot;</code> and <code>&quot;gelu_new&quot;</code> are supported.`,name:"hidden_act"},{anchor:"transformers.LayoutLMv2Config.hidden_dropout_prob",description:`<strong>hidden_dropout_prob</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) &#x2014;
The dropout probabilitiy for all fully connected layers in the embeddings, encoder, and pooler.`,name:"hidden_dropout_prob"},{anchor:"transformers.LayoutLMv2Config.attention_probs_dropout_prob",description:`<strong>attention_probs_dropout_prob</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) &#x2014;
The dropout ratio for the attention probabilities.`,name:"attention_probs_dropout_prob"},{anchor:"transformers.LayoutLMv2Config.max_position_embeddings",description:`<strong>max_position_embeddings</strong> (<code>int</code>, <em>optional</em>, defaults to 512) &#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:"max_position_embeddings"},{anchor:"transformers.LayoutLMv2Config.type_vocab_size",description:`<strong>type_vocab_size</strong> (<code>int</code>, <em>optional</em>, defaults to 2) &#x2014;
The vocabulary size of the <code>token_type_ids</code> passed when calling <a href="/docs/transformers/pr_15839/en/model_doc/layoutlmv2#transformers.LayoutLMv2Model">LayoutLMv2Model</a> or
<code>TFLayoutLMv2Model</code>.`,name:"type_vocab_size"},{anchor:"transformers.LayoutLMv2Config.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.LayoutLMv2Config.layer_norm_eps",description:`<strong>layer_norm_eps</strong> (<code>float</code>, <em>optional</em>, defaults to 1e-12) &#x2014;
The epsilon used by the layer normalization layers.`,name:"layer_norm_eps"},{anchor:"transformers.LayoutLMv2Config.max_2d_position_embeddings",description:`<strong>max_2d_position_embeddings</strong> (<code>int</code>, <em>optional</em>, defaults to 1024) &#x2014;
The maximum value that the 2D position embedding might ever be used with. Typically set this to something
large just in case (e.g., 1024).`,name:"max_2d_position_embeddings"},{anchor:"transformers.LayoutLMv2Config.max_rel_pos",description:`<strong>max_rel_pos</strong> (<code>int</code>, <em>optional</em>, defaults to 128) &#x2014;
The maximum number of relative positions to be used in the self-attention mechanism.`,name:"max_rel_pos"},{anchor:"transformers.LayoutLMv2Config.rel_pos_bins",description:`<strong>rel_pos_bins</strong> (<code>int</code>, <em>optional</em>, defaults to 32) &#x2014;
The number of relative position bins to be used in the self-attention mechanism.`,name:"rel_pos_bins"},{anchor:"transformers.LayoutLMv2Config.fast_qkv",description:`<strong>fast_qkv</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to use a single matrix for the queries, keys, values in the self-attention layers.`,name:"fast_qkv"},{anchor:"transformers.LayoutLMv2Config.max_rel_2d_pos",description:`<strong>max_rel_2d_pos</strong> (<code>int</code>, <em>optional</em>, defaults to 256) &#x2014;
The maximum number of relative 2D positions in the self-attention mechanism.`,name:"max_rel_2d_pos"},{anchor:"transformers.LayoutLMv2Config.rel_2d_pos_bins",description:`<strong>rel_2d_pos_bins</strong> (<code>int</code>, <em>optional</em>, defaults to 64) &#x2014;
The number of 2D relative position bins in the self-attention mechanism.`,name:"rel_2d_pos_bins"},{anchor:"transformers.LayoutLMv2Config.image_feature_pool_shape",description:`<strong>image_feature_pool_shape</strong> (<code>List[int]</code>, <em>optional</em>, defaults to [7, 7, 256]) &#x2014;
The shape of the average-pooled feature map.`,name:"image_feature_pool_shape"},{anchor:"transformers.LayoutLMv2Config.coordinate_size",description:`<strong>coordinate_size</strong> (<code>int</code>, <em>optional</em>, defaults to 128) &#x2014;
Dimension of the coordinate embeddings.`,name:"coordinate_size"},{anchor:"transformers.LayoutLMv2Config.shape_size",description:`<strong>shape_size</strong> (<code>int</code>, <em>optional</em>, defaults to 128) &#x2014;
Dimension of the width and height embeddings.`,name:"shape_size"},{anchor:"transformers.LayoutLMv2Config.has_relative_attention_bias",description:`<strong>has_relative_attention_bias</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to use a relative attention bias in the self-attention mechanism.`,name:"has_relative_attention_bias"},{anchor:"transformers.LayoutLMv2Config.has_spatial_attention_bias",description:`<strong>has_spatial_attention_bias</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to use a spatial attention bias in the self-attention mechanism.`,name:"has_spatial_attention_bias"},{anchor:"transformers.LayoutLMv2Config.has_visual_segment_embedding",description:`<strong>has_visual_segment_embedding</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to add visual segment embeddings.`,name:"has_visual_segment_embedding"},{anchor:"transformers.LayoutLMv2Config.detectron2_config_args",description:`<strong>detectron2_config_args</strong> (<code>dict</code>, <em>optional</em>) &#x2014;
Dictionary containing the configuration arguments of the Detectron2 visual backbone. Refer to <a href="https://github.com/microsoft/unilm/blob/master/layoutlmft/layoutlmft/models/layoutlmv2/detectron2_config.py" rel="nofollow">this
file</a>
for details regarding default values.`,name:"detectron2_config_args"}]}}),Jo=new Y({props:{code:`from transformers import LayoutLMv2Model, LayoutLMv2Config

# Initializing a LayoutLMv2 microsoft/layoutlmv2-base-uncased style configuration
configuration = LayoutLMv2Config()

# Initializing a model from the microsoft/layoutlmv2-base-uncased style configuration
model = LayoutLMv2Model(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> LayoutLMv2Model, LayoutLMv2Config

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a LayoutLMv2 microsoft/layoutlmv2-base-uncased style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = LayoutLMv2Config()

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a model from the microsoft/layoutlmv2-base-uncased style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = LayoutLMv2Model(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`}}),et=new ie({}),ot=new I({props:{name:"class transformers.LayoutLMv2FeatureExtractor",anchor:"transformers.LayoutLMv2FeatureExtractor",parameters:[{name:"do_resize",val:" = True"},{name:"size",val:" = 224"},{name:"resample",val:" = 2"},{name:"apply_ocr",val:" = True"},{name:"ocr_lang",val:" = None"},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/layoutlmv2/feature_extraction_layoutlmv2.py#L83",parametersDescription:[{anchor:"transformers.LayoutLMv2FeatureExtractor.do_resize",description:`<strong>do_resize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to resize the input to a certain <code>size</code>.`,name:"do_resize"},{anchor:"transformers.LayoutLMv2FeatureExtractor.size",description:`<strong>size</strong> (<code>int</code> or <code>Tuple(int)</code>, <em>optional</em>, defaults to 224) &#x2014;
Resize the input to the given size. If a tuple is provided, it should be (width, height). If only an
integer is provided, then the input will be resized to (size, size). Only has an effect if <code>do_resize</code> is
set to <code>True</code>.`,name:"size"},{anchor:"transformers.LayoutLMv2FeatureExtractor.resample",description:`<strong>resample</strong> (<code>int</code>, <em>optional</em>, defaults to <code>PIL.Image.BILINEAR</code>) &#x2014;
An optional resampling filter. This can be one of <code>PIL.Image.NEAREST</code>, <code>PIL.Image.BOX</code>,
<code>PIL.Image.BILINEAR</code>, <code>PIL.Image.HAMMING</code>, <code>PIL.Image.BICUBIC</code> or <code>PIL.Image.LANCZOS</code>. Only has an effect
if <code>do_resize</code> is set to <code>True</code>.`,name:"resample"},{anchor:"transformers.LayoutLMv2FeatureExtractor.apply_ocr",description:`<strong>apply_ocr</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to apply the Tesseract OCR engine to get words + normalized bounding boxes.`,name:"apply_ocr"},{anchor:"transformers.LayoutLMv2FeatureExtractor.ocr_lang",description:`<strong>ocr_lang</strong> (<code>Optional[str]</code>, <em>optional</em>) &#x2014;
The language, specified by its ISO code, to be used by the Tesseract OCR engine. By default, English is
used.</p>
<div class="course-tip  bg-gradient-to-br dark:bg-gradient-to-r before:border-green-500 dark:before:border-green-800 from-green-50 dark:from-gray-900 to-white dark:to-gray-950 border border-green-50 text-green-700 dark:text-gray-400">
						
<p>LayoutLMv2FeatureExtractor uses Google&#x2019;s Tesseract OCR engine under the hood.</p>

					</div>`,name:"ocr_lang"}]}}),nt=new I({props:{name:"__call__",anchor:"transformers.LayoutLMv2FeatureExtractor.__call__",parameters:[{name:"images",val:": typing.Union[PIL.Image.Image, numpy.ndarray, ForwardRef('torch.Tensor'), typing.List[PIL.Image.Image], typing.List[numpy.ndarray], typing.List[ForwardRef('torch.Tensor')]]"},{name:"return_tensors",val:": typing.Union[str, transformers.file_utils.TensorType, NoneType] = None"},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/layoutlmv2/feature_extraction_layoutlmv2.py#L124",parametersDescription:[{anchor:"transformers.LayoutLMv2FeatureExtractor.__call__.images",description:`<strong>images</strong> (<code>PIL.Image.Image</code>, <code>np.ndarray</code>, <code>torch.Tensor</code>, <code>List[PIL.Image.Image]</code>, <code>List[np.ndarray]</code>, <code>List[torch.Tensor]</code>) &#x2014;
The image or batch of images to be prepared. Each image can be a PIL image, NumPy array or PyTorch
tensor. In case of a NumPy array/PyTorch tensor, each image should be of shape (C, H, W), where C is a
number of channels, H and W are image height and width.`,name:"images"},{anchor:"transformers.LayoutLMv2FeatureExtractor.__call__.return_tensors",description:`<strong>return_tensors</strong> (<code>str</code> or <a href="/docs/transformers/pr_15839/en/internal/file_utils#transformers.TensorType">TensorType</a>, <em>optional</em>, defaults to <code>&apos;np&apos;</code>) &#x2014;
If set, will return tensors of a particular framework. Acceptable values are:</p>
<ul>
<li><code>&apos;tf&apos;</code>: Return TensorFlow <code>tf.constant</code> objects.</li>
<li><code>&apos;pt&apos;</code>: Return PyTorch <code>torch.Tensor</code> objects.</li>
<li><code>&apos;np&apos;</code>: Return NumPy <code>np.ndarray</code> objects.</li>
<li><code>&apos;jax&apos;</code>: Return JAX <code>jnp.ndarray</code> objects.</li>
</ul>`,name:"return_tensors"}],returnDescription:`
<p>A <a
  href="/docs/transformers/pr_15839/en/main_classes/feature_extractor#transformers.BatchFeature"
>BatchFeature</a> with the following fields:</p>
<ul>
<li><strong>pixel_values</strong> \u2014 Pixel values to be fed to a model, of shape (batch_size, num_channels, height,
width).</li>
<li><strong>words</strong> \u2014 Optional words as identified by Tesseract OCR (only when <a
  href="/docs/transformers/pr_15839/en/model_doc/layoutlmv2#transformers.LayoutLMv2FeatureExtractor"
>LayoutLMv2FeatureExtractor</a> was
initialized with <code>apply_ocr</code> set to <code>True</code>).</li>
<li><strong>boxes</strong> \u2014 Optional bounding boxes as identified by Tesseract OCR, normalized based on the image size
(only when <a
  href="/docs/transformers/pr_15839/en/model_doc/layoutlmv2#transformers.LayoutLMv2FeatureExtractor"
>LayoutLMv2FeatureExtractor</a> was initialized with <code>apply_ocr</code> set to <code>True</code>).</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/pr_15839/en/main_classes/feature_extractor#transformers.BatchFeature"
>BatchFeature</a></p>
`}}),at=new Y({props:{code:`from transformers import LayoutLMv2FeatureExtractor
from PIL import Image

image = Image.open("name_of_your_document - can be a png file, pdf, etc.").convert("RGB")

# option 1: with apply_ocr=True (default)
feature_extractor = LayoutLMv2FeatureExtractor()
encoding = feature_extractor(image, return_tensors="pt")
print(encoding.keys())
# dict_keys(['pixel_values', 'words', 'boxes'])

# option 2: with apply_ocr=False
feature_extractor = LayoutLMv2FeatureExtractor(apply_ocr=False)
encoding = feature_extractor(image, return_tensors="pt")
print(encoding.keys())
# dict_keys(['pixel_values'])`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> LayoutLMv2FeatureExtractor
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image

<span class="hljs-meta">&gt;&gt;&gt; </span>image = Image.<span class="hljs-built_in">open</span>(<span class="hljs-string">&quot;name_of_your_document - can be a png file, pdf, etc.&quot;</span>).convert(<span class="hljs-string">&quot;RGB&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># option 1: with apply_ocr=True (default)</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>feature_extractor = LayoutLMv2FeatureExtractor()
<span class="hljs-meta">&gt;&gt;&gt; </span>encoding = feature_extractor(image, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(encoding.keys())
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># dict_keys([&#x27;pixel_values&#x27;, &#x27;words&#x27;, &#x27;boxes&#x27;])</span>

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># option 2: with apply_ocr=False</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>feature_extractor = LayoutLMv2FeatureExtractor(apply_ocr=<span class="hljs-literal">False</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>encoding = feature_extractor(image, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(encoding.keys())
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># dict_keys([&#x27;pixel_values&#x27;])</span>`}}),st=new ie({}),rt=new I({props:{name:"class transformers.LayoutLMv2Tokenizer",anchor:"transformers.LayoutLMv2Tokenizer",parameters:[{name:"vocab_file",val:""},{name:"do_lower_case",val:" = True"},{name:"do_basic_tokenize",val:" = True"},{name:"never_split",val:" = None"},{name:"unk_token",val:" = '[UNK]'"},{name:"sep_token",val:" = '[SEP]'"},{name:"pad_token",val:" = '[PAD]'"},{name:"cls_token",val:" = '[CLS]'"},{name:"mask_token",val:" = '[MASK]'"},{name:"cls_token_box",val:" = [0, 0, 0, 0]"},{name:"sep_token_box",val:" = [1000, 1000, 1000, 1000]"},{name:"pad_token_box",val:" = [0, 0, 0, 0]"},{name:"pad_token_label",val:" = -100"},{name:"only_label_first_subword",val:" = True"},{name:"tokenize_chinese_chars",val:" = True"},{name:"strip_accents",val:" = None"},{name:"model_max_length",val:": int = 512"},{name:"additional_special_tokens",val:": typing.Optional[typing.List[str]] = None"},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/layoutlmv2/tokenization_layoutlmv2.py#L146"}}),lt=new I({props:{name:"__call__",anchor:"transformers.LayoutLMv2Tokenizer.__call__",parameters:[{name:"text",val:": typing.Union[str, typing.List[str], typing.List[typing.List[str]]]"},{name:"text_pair",val:": typing.Union[typing.List[str], typing.List[typing.List[str]], NoneType] = None"},{name:"boxes",val:": typing.Union[typing.List[typing.List[int]], typing.List[typing.List[typing.List[int]]]] = None"},{name:"word_labels",val:": typing.Union[typing.List[int], typing.List[typing.List[int]], NoneType] = None"},{name:"add_special_tokens",val:": bool = True"},{name:"padding",val:": typing.Union[bool, str, transformers.file_utils.PaddingStrategy] = False"},{name:"truncation",val:": typing.Union[bool, str, transformers.tokenization_utils_base.TruncationStrategy] = False"},{name:"max_length",val:": typing.Optional[int] = None"},{name:"stride",val:": int = 0"},{name:"pad_to_multiple_of",val:": typing.Optional[int] = None"},{name:"return_tensors",val:": typing.Union[str, transformers.file_utils.TensorType, NoneType] = None"},{name:"return_token_type_ids",val:": typing.Optional[bool] = None"},{name:"return_attention_mask",val:": typing.Optional[bool] = None"},{name:"return_overflowing_tokens",val:": bool = False"},{name:"return_special_tokens_mask",val:": bool = False"},{name:"return_offsets_mapping",val:": bool = False"},{name:"return_length",val:": bool = False"},{name:"verbose",val:": bool = True"},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/layoutlmv2/tokenization_layoutlmv2.py#L366",parametersDescription:[{anchor:"transformers.LayoutLMv2Tokenizer.__call__.text",description:`<strong>text</strong> (<code>str</code>, <code>List[str]</code>, <code>List[List[str]]</code>) &#x2014;
The sequence or batch of sequences to be encoded. Each sequence can be a string, a list of strings
(words of a single example or questions of a batch of examples) or a list of list of strings (batch of
words).`,name:"text"},{anchor:"transformers.LayoutLMv2Tokenizer.__call__.text_pair",description:`<strong>text_pair</strong> (<code>List[str]</code>, <code>List[List[str]]</code>) &#x2014;
The sequence or batch of sequences to be encoded. Each sequence should be a list of strings
(pretokenized string).`,name:"text_pair"},{anchor:"transformers.LayoutLMv2Tokenizer.__call__.boxes",description:`<strong>boxes</strong> (<code>List[List[int]]</code>, <code>List[List[List[int]]]</code>) &#x2014;
Word-level bounding boxes. Each bounding box should be normalized to be on a 0-1000 scale.`,name:"boxes"},{anchor:"transformers.LayoutLMv2Tokenizer.__call__.word_labels",description:`<strong>word_labels</strong> (<code>List[int]</code>, <code>List[List[int]]</code>, <em>optional</em>) &#x2014;
Word-level integer labels (for token classification tasks such as FUNSD, CORD).`,name:"word_labels"},{anchor:"transformers.LayoutLMv2Tokenizer.__call__.add_special_tokens",description:`<strong>add_special_tokens</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to encode the sequences with the special tokens relative to their model.`,name:"add_special_tokens"},{anchor:"transformers.LayoutLMv2Tokenizer.__call__.padding",description:`<strong>padding</strong> (<code>bool</code>, <code>str</code> or <a href="/docs/transformers/pr_15839/en/internal/file_utils#transformers.file_utils.PaddingStrategy">PaddingStrategy</a>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Activates and controls padding. Accepts the following values:</p>
<ul>
<li><code>True</code> or <code>&apos;longest&apos;</code>: Pad to the longest sequence in the batch (or no padding if only a single
sequence if provided).</li>
<li><code>&apos;max_length&apos;</code>: Pad to a maximum length specified with the argument <code>max_length</code> or to the maximum
acceptable input length for the model if that argument is not provided.</li>
<li><code>False</code> or <code>&apos;do_not_pad&apos;</code> (default): No padding (i.e., can output a batch with sequences of different
lengths).</li>
</ul>`,name:"padding"},{anchor:"transformers.LayoutLMv2Tokenizer.__call__.truncation",description:`<strong>truncation</strong> (<code>bool</code>, <code>str</code> or <a href="/docs/transformers/pr_15839/en/internal/tokenization_utils#transformers.tokenization_utils_base.TruncationStrategy">TruncationStrategy</a>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Activates and controls truncation. Accepts the following values:</p>
<ul>
<li><code>True</code> or <code>&apos;longest_first&apos;</code>: Truncate to a maximum length specified with the argument <code>max_length</code> or
to the maximum acceptable input length for the model if that argument is not provided. This will
truncate token by token, removing a token from the longest sequence in the pair if a pair of
sequences (or a batch of pairs) is provided.</li>
<li><code>&apos;only_first&apos;</code>: Truncate to a maximum length specified with the argument <code>max_length</code> or to the
maximum acceptable input length for the model if that argument is not provided. This will only
truncate the first sequence of a pair if a pair of sequences (or a batch of pairs) is provided.</li>
<li><code>&apos;only_second&apos;</code>: Truncate to a maximum length specified with the argument <code>max_length</code> or to the
maximum acceptable input length for the model if that argument is not provided. This will only
truncate the second sequence of a pair if a pair of sequences (or a batch of pairs) is provided.</li>
<li><code>False</code> or <code>&apos;do_not_truncate&apos;</code> (default): No truncation (i.e., can output batch with sequence lengths
greater than the model maximum admissible input size).</li>
</ul>`,name:"truncation"},{anchor:"transformers.LayoutLMv2Tokenizer.__call__.max_length",description:`<strong>max_length</strong> (<code>int</code>, <em>optional</em>) &#x2014;
Controls the maximum length to use by one of the truncation/padding parameters.</p>
<p>If left unset or set to <code>None</code>, this will use the predefined model maximum length if a maximum length
is required by one of the truncation/padding parameters. If the model has no specific maximum input
length (like XLNet) truncation/padding to a maximum length will be deactivated.`,name:"max_length"},{anchor:"transformers.LayoutLMv2Tokenizer.__call__.stride",description:`<strong>stride</strong> (<code>int</code>, <em>optional</em>, defaults to 0) &#x2014;
If set to a number along with <code>max_length</code>, the overflowing tokens returned when
<code>return_overflowing_tokens=True</code> will contain some tokens from the end of the truncated sequence
returned to provide some overlap between truncated and overflowing sequences. The value of this
argument defines the number of overlapping tokens.`,name:"stride"},{anchor:"transformers.LayoutLMv2Tokenizer.__call__.is_split_into_words",description:`<strong>is_split_into_words</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not the input is already pre-tokenized (e.g., split into words). If set to <code>True</code>, the
tokenizer assumes the input is already split into words (for instance, by splitting it on whitespace)
which it will tokenize. This is useful for NER or token classification.`,name:"is_split_into_words"},{anchor:"transformers.LayoutLMv2Tokenizer.__call__.pad_to_multiple_of",description:`<strong>pad_to_multiple_of</strong> (<code>int</code>, <em>optional</em>) &#x2014;
If set will pad the sequence to a multiple of the provided value. This is especially useful to enable
the use of Tensor Cores on NVIDIA hardware with compute capability &gt;= 7.5 (Volta).`,name:"pad_to_multiple_of"},{anchor:"transformers.LayoutLMv2Tokenizer.__call__.return_tensors",description:`<strong>return_tensors</strong> (<code>str</code> or <a href="/docs/transformers/pr_15839/en/internal/file_utils#transformers.TensorType">TensorType</a>, <em>optional</em>) &#x2014;
If set, will return tensors instead of list of python integers. Acceptable values are:</p>
<ul>
<li><code>&apos;tf&apos;</code>: Return TensorFlow <code>tf.constant</code> objects.</li>
<li><code>&apos;pt&apos;</code>: Return PyTorch <code>torch.Tensor</code> objects.</li>
<li><code>&apos;np&apos;</code>: Return Numpy <code>np.ndarray</code> objects.</li>
</ul>`,name:"return_tensors"},{anchor:"transformers.LayoutLMv2Tokenizer.__call__.add_special_tokens",description:`<strong>add_special_tokens</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to encode the sequences with the special tokens relative to their model.`,name:"add_special_tokens"},{anchor:"transformers.LayoutLMv2Tokenizer.__call__.padding",description:`<strong>padding</strong> (<code>bool</code>, <code>str</code> or <a href="/docs/transformers/pr_15839/en/internal/file_utils#transformers.file_utils.PaddingStrategy">PaddingStrategy</a>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Activates and controls padding. Accepts the following values:</p>
<ul>
<li><code>True</code> or <code>&apos;longest&apos;</code>: Pad to the longest sequence in the batch (or no padding if only a single
sequence if provided).</li>
<li><code>&apos;max_length&apos;</code>: Pad to a maximum length specified with the argument <code>max_length</code> or to the maximum
acceptable input length for the model if that argument is not provided.</li>
<li><code>False</code> or <code>&apos;do_not_pad&apos;</code> (default): No padding (i.e., can output a batch with sequences of different
lengths).</li>
</ul>`,name:"padding"},{anchor:"transformers.LayoutLMv2Tokenizer.__call__.truncation",description:`<strong>truncation</strong> (<code>bool</code>, <code>str</code> or <a href="/docs/transformers/pr_15839/en/internal/tokenization_utils#transformers.tokenization_utils_base.TruncationStrategy">TruncationStrategy</a>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Activates and controls truncation. Accepts the following values:</p>
<ul>
<li><code>True</code> or <code>&apos;longest_first&apos;</code>: Truncate to a maximum length specified with the argument <code>max_length</code> or
to the maximum acceptable input length for the model if that argument is not provided. This will
truncate token by token, removing a token from the longest sequence in the pair if a pair of
sequences (or a batch of pairs) is provided.</li>
<li><code>&apos;only_first&apos;</code>: Truncate to a maximum length specified with the argument <code>max_length</code> or to the
maximum acceptable input length for the model if that argument is not provided. This will only
truncate the first sequence of a pair if a pair of sequences (or a batch of pairs) is provided.</li>
<li><code>&apos;only_second&apos;</code>: Truncate to a maximum length specified with the argument <code>max_length</code> or to the
maximum acceptable input length for the model if that argument is not provided. This will only
truncate the second sequence of a pair if a pair of sequences (or a batch of pairs) is provided.</li>
<li><code>False</code> or <code>&apos;do_not_truncate&apos;</code> (default): No truncation (i.e., can output batch with sequence lengths
greater than the model maximum admissible input size).</li>
</ul>`,name:"truncation"},{anchor:"transformers.LayoutLMv2Tokenizer.__call__.max_length",description:`<strong>max_length</strong> (<code>int</code>, <em>optional</em>) &#x2014;
Controls the maximum length to use by one of the truncation/padding parameters. If left unset or set to
<code>None</code>, this will use the predefined model maximum length if a maximum length is required by one of the
truncation/padding parameters. If the model has no specific maximum input length (like XLNet)
truncation/padding to a maximum length will be deactivated.`,name:"max_length"},{anchor:"transformers.LayoutLMv2Tokenizer.__call__.stride",description:`<strong>stride</strong> (<code>int</code>, <em>optional</em>, defaults to 0) &#x2014;
If set to a number along with <code>max_length</code>, the overflowing tokens returned when
<code>return_overflowing_tokens=True</code> will contain some tokens from the end of the truncated sequence
returned to provide some overlap between truncated and overflowing sequences. The value of this
argument defines the number of overlapping tokens.`,name:"stride"},{anchor:"transformers.LayoutLMv2Tokenizer.__call__.pad_to_multiple_of",description:`<strong>pad_to_multiple_of</strong> (<code>int</code>, <em>optional</em>) &#x2014;
If set will pad the sequence to a multiple of the provided value. This is especially useful to enable
the use of Tensor Cores on NVIDIA hardware with compute capability &gt;= 7.5 (Volta).`,name:"pad_to_multiple_of"},{anchor:"transformers.LayoutLMv2Tokenizer.__call__.return_tensors",description:`<strong>return_tensors</strong> (<code>str</code> or <a href="/docs/transformers/pr_15839/en/internal/file_utils#transformers.TensorType">TensorType</a>, <em>optional</em>) &#x2014;
If set, will return tensors instead of list of python integers. Acceptable values are:</p>
<ul>
<li><code>&apos;tf&apos;</code>: Return TensorFlow <code>tf.constant</code> objects.</li>
<li><code>&apos;pt&apos;</code>: Return PyTorch <code>torch.Tensor</code> objects.</li>
<li><code>&apos;np&apos;</code>: Return Numpy <code>np.ndarray</code> objects.</li>
</ul>`,name:"return_tensors"}]}}),ct=new I({props:{name:"save_vocabulary",anchor:"transformers.LayoutLMv2Tokenizer.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/layoutlmv2/tokenization_layoutlmv2.py#L346"}}),dt=new ie({}),pt=new I({props:{name:"class transformers.LayoutLMv2TokenizerFast",anchor:"transformers.LayoutLMv2TokenizerFast",parameters:[{name:"vocab_file",val:" = None"},{name:"tokenizer_file",val:" = None"},{name:"do_lower_case",val:" = True"},{name:"unk_token",val:" = '[UNK]'"},{name:"sep_token",val:" = '[SEP]'"},{name:"pad_token",val:" = '[PAD]'"},{name:"cls_token",val:" = '[CLS]'"},{name:"mask_token",val:" = '[MASK]'"},{name:"cls_token_box",val:" = [0, 0, 0, 0]"},{name:"sep_token_box",val:" = [1000, 1000, 1000, 1000]"},{name:"pad_token_box",val:" = [0, 0, 0, 0]"},{name:"pad_token_label",val:" = -100"},{name:"only_label_first_subword",val:" = True"},{name:"tokenize_chinese_chars",val:" = True"},{name:"strip_accents",val:" = None"},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/layoutlmv2/tokenization_layoutlmv2_fast.py#L62",parametersDescription:[{anchor:"transformers.LayoutLMv2TokenizerFast.vocab_file",description:`<strong>vocab_file</strong> (<code>str</code>) &#x2014;
File containing the vocabulary.`,name:"vocab_file"},{anchor:"transformers.LayoutLMv2TokenizerFast.do_lower_case",description:`<strong>do_lower_case</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to lowercase the input when tokenizing.`,name:"do_lower_case"},{anchor:"transformers.LayoutLMv2TokenizerFast.unk_token",description:`<strong>unk_token</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;[UNK]&quot;</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.LayoutLMv2TokenizerFast.sep_token",description:`<strong>sep_token</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;[SEP]&quot;</code>) &#x2014;
The separator token, which is used when building a sequence from multiple sequences, e.g. two sequences for
sequence classification or for a text and a question for question answering. It is also used as the last
token of a sequence built with special tokens.`,name:"sep_token"},{anchor:"transformers.LayoutLMv2TokenizerFast.pad_token",description:`<strong>pad_token</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;[PAD]&quot;</code>) &#x2014;
The token used for padding, for example when batching sequences of different lengths.`,name:"pad_token"},{anchor:"transformers.LayoutLMv2TokenizerFast.cls_token",description:`<strong>cls_token</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;[CLS]&quot;</code>) &#x2014;
The classifier token which is used when doing sequence classification (classification of the whole sequence
instead of per-token classification). It is the first token of the sequence when built with special tokens.`,name:"cls_token"},{anchor:"transformers.LayoutLMv2TokenizerFast.mask_token",description:`<strong>mask_token</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;[MASK]&quot;</code>) &#x2014;
The token used for masking values. This is the token used when training this model with masked language
modeling. This is the token which the model will try to predict.`,name:"mask_token"},{anchor:"transformers.LayoutLMv2TokenizerFast.cls_token_box",description:`<strong>cls_token_box</strong> (<code>List[int]</code>, <em>optional</em>, defaults to <code>[0, 0, 0, 0]</code>) &#x2014;
The bounding box to use for the special [CLS] token.`,name:"cls_token_box"},{anchor:"transformers.LayoutLMv2TokenizerFast.sep_token_box",description:`<strong>sep_token_box</strong> (<code>List[int]</code>, <em>optional</em>, defaults to <code>[1000, 1000, 1000, 1000]</code>) &#x2014;
The bounding box to use for the special [SEP] token.`,name:"sep_token_box"},{anchor:"transformers.LayoutLMv2TokenizerFast.pad_token_box",description:`<strong>pad_token_box</strong> (<code>List[int]</code>, <em>optional</em>, defaults to <code>[0, 0, 0, 0]</code>) &#x2014;
The bounding box to use for the special [PAD] token.`,name:"pad_token_box"},{anchor:"transformers.LayoutLMv2TokenizerFast.pad_token_label",description:`<strong>pad_token_label</strong> (<code>int</code>, <em>optional</em>, defaults to -100) &#x2014;
The label to use for padding tokens. Defaults to -100, which is the <code>ignore_index</code> of PyTorch&#x2019;s
CrossEntropyLoss.`,name:"pad_token_label"},{anchor:"transformers.LayoutLMv2TokenizerFast.only_label_first_subword",description:`<strong>only_label_first_subword</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to only label the first subword, in case word labels are provided.`,name:"only_label_first_subword"},{anchor:"transformers.LayoutLMv2TokenizerFast.tokenize_chinese_chars",description:`<strong>tokenize_chinese_chars</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to tokenize Chinese characters. This should likely be deactivated for Japanese (see <a href="https://github.com/huggingface/transformers/issues/328" rel="nofollow">this
issue</a>).
strip_accents &#x2014; (<code>bool</code>, <em>optional</em>):
Whether or not to strip all accents. If this option is not specified, then it will be determined by the
value for <code>lowercase</code> (as in the original LayoutLMv2).`,name:"tokenize_chinese_chars"}]}}),mt=new I({props:{name:"__call__",anchor:"transformers.LayoutLMv2TokenizerFast.__call__",parameters:[{name:"text",val:": typing.Union[str, typing.List[str], typing.List[typing.List[str]]]"},{name:"text_pair",val:": typing.Union[typing.List[str], typing.List[typing.List[str]], NoneType] = None"},{name:"boxes",val:": typing.Union[typing.List[typing.List[int]], typing.List[typing.List[typing.List[int]]]] = None"},{name:"word_labels",val:": typing.Union[typing.List[int], typing.List[typing.List[int]], NoneType] = None"},{name:"add_special_tokens",val:": bool = True"},{name:"padding",val:": typing.Union[bool, str, transformers.file_utils.PaddingStrategy] = False"},{name:"truncation",val:": typing.Union[bool, str, transformers.tokenization_utils_base.TruncationStrategy] = False"},{name:"max_length",val:": typing.Optional[int] = None"},{name:"stride",val:": int = 0"},{name:"pad_to_multiple_of",val:": typing.Optional[int] = None"},{name:"return_tensors",val:": typing.Union[str, transformers.file_utils.TensorType, NoneType] = None"},{name:"return_token_type_ids",val:": typing.Optional[bool] = None"},{name:"return_attention_mask",val:": typing.Optional[bool] = None"},{name:"return_overflowing_tokens",val:": bool = False"},{name:"return_special_tokens_mask",val:": bool = False"},{name:"return_offsets_mapping",val:": bool = False"},{name:"return_length",val:": bool = False"},{name:"verbose",val:": bool = True"},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/layoutlmv2/tokenization_layoutlmv2_fast.py#L171",parametersDescription:[{anchor:"transformers.LayoutLMv2TokenizerFast.__call__.text",description:`<strong>text</strong> (<code>str</code>, <code>List[str]</code>, <code>List[List[str]]</code>) &#x2014;
The sequence or batch of sequences to be encoded. Each sequence can be a string, a list of strings
(words of a single example or questions of a batch of examples) or a list of list of strings (batch of
words).`,name:"text"},{anchor:"transformers.LayoutLMv2TokenizerFast.__call__.text_pair",description:`<strong>text_pair</strong> (<code>List[str]</code>, <code>List[List[str]]</code>) &#x2014;
The sequence or batch of sequences to be encoded. Each sequence should be a list of strings
(pretokenized string).`,name:"text_pair"},{anchor:"transformers.LayoutLMv2TokenizerFast.__call__.boxes",description:`<strong>boxes</strong> (<code>List[List[int]]</code>, <code>List[List[List[int]]]</code>) &#x2014;
Word-level bounding boxes. Each bounding box should be normalized to be on a 0-1000 scale.`,name:"boxes"},{anchor:"transformers.LayoutLMv2TokenizerFast.__call__.word_labels",description:`<strong>word_labels</strong> (<code>List[int]</code>, <code>List[List[int]]</code>, <em>optional</em>) &#x2014;
Word-level integer labels (for token classification tasks such as FUNSD, CORD).`,name:"word_labels"},{anchor:"transformers.LayoutLMv2TokenizerFast.__call__.add_special_tokens",description:`<strong>add_special_tokens</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to encode the sequences with the special tokens relative to their model.`,name:"add_special_tokens"},{anchor:"transformers.LayoutLMv2TokenizerFast.__call__.padding",description:`<strong>padding</strong> (<code>bool</code>, <code>str</code> or <a href="/docs/transformers/pr_15839/en/internal/file_utils#transformers.file_utils.PaddingStrategy">PaddingStrategy</a>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Activates and controls padding. Accepts the following values:</p>
<ul>
<li><code>True</code> or <code>&apos;longest&apos;</code>: Pad to the longest sequence in the batch (or no padding if only a single
sequence if provided).</li>
<li><code>&apos;max_length&apos;</code>: Pad to a maximum length specified with the argument <code>max_length</code> or to the maximum
acceptable input length for the model if that argument is not provided.</li>
<li><code>False</code> or <code>&apos;do_not_pad&apos;</code> (default): No padding (i.e., can output a batch with sequences of different
lengths).</li>
</ul>`,name:"padding"},{anchor:"transformers.LayoutLMv2TokenizerFast.__call__.truncation",description:`<strong>truncation</strong> (<code>bool</code>, <code>str</code> or <a href="/docs/transformers/pr_15839/en/internal/tokenization_utils#transformers.tokenization_utils_base.TruncationStrategy">TruncationStrategy</a>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Activates and controls truncation. Accepts the following values:</p>
<ul>
<li><code>True</code> or <code>&apos;longest_first&apos;</code>: Truncate to a maximum length specified with the argument <code>max_length</code> or
to the maximum acceptable input length for the model if that argument is not provided. This will
truncate token by token, removing a token from the longest sequence in the pair if a pair of
sequences (or a batch of pairs) is provided.</li>
<li><code>&apos;only_first&apos;</code>: Truncate to a maximum length specified with the argument <code>max_length</code> or to the
maximum acceptable input length for the model if that argument is not provided. This will only
truncate the first sequence of a pair if a pair of sequences (or a batch of pairs) is provided.</li>
<li><code>&apos;only_second&apos;</code>: Truncate to a maximum length specified with the argument <code>max_length</code> or to the
maximum acceptable input length for the model if that argument is not provided. This will only
truncate the second sequence of a pair if a pair of sequences (or a batch of pairs) is provided.</li>
<li><code>False</code> or <code>&apos;do_not_truncate&apos;</code> (default): No truncation (i.e., can output batch with sequence lengths
greater than the model maximum admissible input size).</li>
</ul>`,name:"truncation"},{anchor:"transformers.LayoutLMv2TokenizerFast.__call__.max_length",description:`<strong>max_length</strong> (<code>int</code>, <em>optional</em>) &#x2014;
Controls the maximum length to use by one of the truncation/padding parameters.</p>
<p>If left unset or set to <code>None</code>, this will use the predefined model maximum length if a maximum length
is required by one of the truncation/padding parameters. If the model has no specific maximum input
length (like XLNet) truncation/padding to a maximum length will be deactivated.`,name:"max_length"},{anchor:"transformers.LayoutLMv2TokenizerFast.__call__.stride",description:`<strong>stride</strong> (<code>int</code>, <em>optional</em>, defaults to 0) &#x2014;
If set to a number along with <code>max_length</code>, the overflowing tokens returned when
<code>return_overflowing_tokens=True</code> will contain some tokens from the end of the truncated sequence
returned to provide some overlap between truncated and overflowing sequences. The value of this
argument defines the number of overlapping tokens.`,name:"stride"},{anchor:"transformers.LayoutLMv2TokenizerFast.__call__.is_split_into_words",description:`<strong>is_split_into_words</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not the input is already pre-tokenized (e.g., split into words). If set to <code>True</code>, the
tokenizer assumes the input is already split into words (for instance, by splitting it on whitespace)
which it will tokenize. This is useful for NER or token classification.`,name:"is_split_into_words"},{anchor:"transformers.LayoutLMv2TokenizerFast.__call__.pad_to_multiple_of",description:`<strong>pad_to_multiple_of</strong> (<code>int</code>, <em>optional</em>) &#x2014;
If set will pad the sequence to a multiple of the provided value. This is especially useful to enable
the use of Tensor Cores on NVIDIA hardware with compute capability &gt;= 7.5 (Volta).`,name:"pad_to_multiple_of"},{anchor:"transformers.LayoutLMv2TokenizerFast.__call__.return_tensors",description:`<strong>return_tensors</strong> (<code>str</code> or <a href="/docs/transformers/pr_15839/en/internal/file_utils#transformers.TensorType">TensorType</a>, <em>optional</em>) &#x2014;
If set, will return tensors instead of list of python integers. Acceptable values are:</p>
<ul>
<li><code>&apos;tf&apos;</code>: Return TensorFlow <code>tf.constant</code> objects.</li>
<li><code>&apos;pt&apos;</code>: Return PyTorch <code>torch.Tensor</code> objects.</li>
<li><code>&apos;np&apos;</code>: Return Numpy <code>np.ndarray</code> objects.</li>
</ul>`,name:"return_tensors"},{anchor:"transformers.LayoutLMv2TokenizerFast.__call__.add_special_tokens",description:`<strong>add_special_tokens</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to encode the sequences with the special tokens relative to their model.`,name:"add_special_tokens"},{anchor:"transformers.LayoutLMv2TokenizerFast.__call__.padding",description:`<strong>padding</strong> (<code>bool</code>, <code>str</code> or <a href="/docs/transformers/pr_15839/en/internal/file_utils#transformers.file_utils.PaddingStrategy">PaddingStrategy</a>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Activates and controls padding. Accepts the following values:</p>
<ul>
<li><code>True</code> or <code>&apos;longest&apos;</code>: Pad to the longest sequence in the batch (or no padding if only a single
sequence if provided).</li>
<li><code>&apos;max_length&apos;</code>: Pad to a maximum length specified with the argument <code>max_length</code> or to the maximum
acceptable input length for the model if that argument is not provided.</li>
<li><code>False</code> or <code>&apos;do_not_pad&apos;</code> (default): No padding (i.e., can output a batch with sequences of different
lengths).</li>
</ul>`,name:"padding"},{anchor:"transformers.LayoutLMv2TokenizerFast.__call__.truncation",description:`<strong>truncation</strong> (<code>bool</code>, <code>str</code> or <a href="/docs/transformers/pr_15839/en/internal/tokenization_utils#transformers.tokenization_utils_base.TruncationStrategy">TruncationStrategy</a>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Activates and controls truncation. Accepts the following values:</p>
<ul>
<li><code>True</code> or <code>&apos;longest_first&apos;</code>: Truncate to a maximum length specified with the argument <code>max_length</code> or
to the maximum acceptable input length for the model if that argument is not provided. This will
truncate token by token, removing a token from the longest sequence in the pair if a pair of
sequences (or a batch of pairs) is provided.</li>
<li><code>&apos;only_first&apos;</code>: Truncate to a maximum length specified with the argument <code>max_length</code> or to the
maximum acceptable input length for the model if that argument is not provided. This will only
truncate the first sequence of a pair if a pair of sequences (or a batch of pairs) is provided.</li>
<li><code>&apos;only_second&apos;</code>: Truncate to a maximum length specified with the argument <code>max_length</code> or to the
maximum acceptable input length for the model if that argument is not provided. This will only
truncate the second sequence of a pair if a pair of sequences (or a batch of pairs) is provided.</li>
<li><code>False</code> or <code>&apos;do_not_truncate&apos;</code> (default): No truncation (i.e., can output batch with sequence lengths
greater than the model maximum admissible input size).</li>
</ul>`,name:"truncation"},{anchor:"transformers.LayoutLMv2TokenizerFast.__call__.max_length",description:`<strong>max_length</strong> (<code>int</code>, <em>optional</em>) &#x2014;
Controls the maximum length to use by one of the truncation/padding parameters. If left unset or set to
<code>None</code>, this will use the predefined model maximum length if a maximum length is required by one of the
truncation/padding parameters. If the model has no specific maximum input length (like XLNet)
truncation/padding to a maximum length will be deactivated.`,name:"max_length"},{anchor:"transformers.LayoutLMv2TokenizerFast.__call__.stride",description:`<strong>stride</strong> (<code>int</code>, <em>optional</em>, defaults to 0) &#x2014;
If set to a number along with <code>max_length</code>, the overflowing tokens returned when
<code>return_overflowing_tokens=True</code> will contain some tokens from the end of the truncated sequence
returned to provide some overlap between truncated and overflowing sequences. The value of this
argument defines the number of overlapping tokens.`,name:"stride"},{anchor:"transformers.LayoutLMv2TokenizerFast.__call__.pad_to_multiple_of",description:`<strong>pad_to_multiple_of</strong> (<code>int</code>, <em>optional</em>) &#x2014;
If set will pad the sequence to a multiple of the provided value. This is especially useful to enable
the use of Tensor Cores on NVIDIA hardware with compute capability &gt;= 7.5 (Volta).`,name:"pad_to_multiple_of"},{anchor:"transformers.LayoutLMv2TokenizerFast.__call__.return_tensors",description:`<strong>return_tensors</strong> (<code>str</code> or <a href="/docs/transformers/pr_15839/en/internal/file_utils#transformers.TensorType">TensorType</a>, <em>optional</em>) &#x2014;
If set, will return tensors instead of list of python integers. Acceptable values are:</p>
<ul>
<li><code>&apos;tf&apos;</code>: Return TensorFlow <code>tf.constant</code> objects.</li>
<li><code>&apos;pt&apos;</code>: Return PyTorch <code>torch.Tensor</code> objects.</li>
<li><code>&apos;np&apos;</code>: Return Numpy <code>np.ndarray</code> objects.</li>
</ul>`,name:"return_tensors"}]}}),ft=new ie({}),gt=new I({props:{name:"class transformers.LayoutLMv2Processor",anchor:"transformers.LayoutLMv2Processor",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/layoutlmv2/processing_layoutlmv2.py#L25",parametersDescription:[{anchor:"transformers.LayoutLMv2Processor.feature_extractor",description:`<strong>feature_extractor</strong> (<code>LayoutLMv2FeatureExtractor</code>) &#x2014;
An instance of <a href="/docs/transformers/pr_15839/en/model_doc/layoutlmv2#transformers.LayoutLMv2FeatureExtractor">LayoutLMv2FeatureExtractor</a>. The feature extractor is a required input.`,name:"feature_extractor"},{anchor:"transformers.LayoutLMv2Processor.tokenizer",description:`<strong>tokenizer</strong> (<code>LayoutLMv2Tokenizer</code> or <code>LayoutLMv2TokenizerFast</code>) &#x2014;
An instance of <a href="/docs/transformers/pr_15839/en/model_doc/layoutlmv2#transformers.LayoutLMv2Tokenizer">LayoutLMv2Tokenizer</a> or <a href="/docs/transformers/pr_15839/en/model_doc/layoutlmv2#transformers.LayoutLMv2TokenizerFast">LayoutLMv2TokenizerFast</a>. The tokenizer is a required input.`,name:"tokenizer"}]}}),_t=new I({props:{name:"__call__",anchor:"transformers.LayoutLMv2Processor.__call__",parameters:[{name:"images",val:""},{name:"text",val:": typing.Union[str, typing.List[str], typing.List[typing.List[str]]] = None"},{name:"text_pair",val:": typing.Union[typing.List[str], typing.List[typing.List[str]], NoneType] = None"},{name:"boxes",val:": typing.Union[typing.List[typing.List[int]], typing.List[typing.List[typing.List[int]]]] = None"},{name:"word_labels",val:": typing.Union[typing.List[int], typing.List[typing.List[int]], NoneType] = None"},{name:"add_special_tokens",val:": bool = True"},{name:"padding",val:": typing.Union[bool, str, transformers.file_utils.PaddingStrategy] = False"},{name:"truncation",val:": typing.Union[bool, str, transformers.tokenization_utils_base.TruncationStrategy] = False"},{name:"max_length",val:": typing.Optional[int] = None"},{name:"stride",val:": int = 0"},{name:"pad_to_multiple_of",val:": typing.Optional[int] = None"},{name:"return_token_type_ids",val:": typing.Optional[bool] = None"},{name:"return_attention_mask",val:": typing.Optional[bool] = None"},{name:"return_overflowing_tokens",val:": bool = False"},{name:"return_special_tokens_mask",val:": bool = False"},{name:"return_offsets_mapping",val:": bool = False"},{name:"return_length",val:": bool = False"},{name:"verbose",val:": bool = True"},{name:"return_tensors",val:": typing.Union[str, transformers.file_utils.TensorType, NoneType] = None"},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/layoutlmv2/processing_layoutlmv2.py#L47"}}),bt=new ie({}),Lt=new I({props:{name:"class transformers.LayoutLMv2Model",anchor:"transformers.LayoutLMv2Model",parameters:[{name:"config",val:""}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/layoutlmv2/modeling_layoutlmv2.py#L708",parametersDescription:[{anchor:"transformers.LayoutLMv2Model.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_15839/en/model_doc/layoutlmv2#transformers.LayoutLMv2Config">LayoutLMv2Config</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"}]}}),xt=new I({props:{name:"forward",anchor:"transformers.LayoutLMv2Model.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"bbox",val:": typing.Optional[torch.LongTensor] = None"},{name:"image",val:": typing.Optional[torch.FloatTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"token_type_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"position_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{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/layoutlmv2/modeling_layoutlmv2.py#L806",parametersDescription:[{anchor:"transformers.LayoutLMv2Model.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>) &#x2014;
Indices of input sequence tokens in the vocabulary.</p>
<p>Indices can be obtained using <a href="/docs/transformers/pr_15839/en/model_doc/layoutlmv2#transformers.LayoutLMv2Tokenizer">LayoutLMv2Tokenizer</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.LayoutLMv2Model.forward.bbox",description:`<strong>bbox</strong> (<code>torch.LongTensor</code> of shape <code>((batch_size, sequence_length), 4)</code>, <em>optional</em>) &#x2014;
Bounding boxes of each input sequence tokens. Selected in the range <code>[0, config.max_2d_position_embeddings-1]</code>. Each bounding box should be a normalized version in (x0, y0, x1, y1)
format, where (x0, y0) corresponds to the position of the upper left corner in the bounding box, and (x1,
y1) represents the position of the lower right corner.`,name:"bbox"},{anchor:"transformers.LayoutLMv2Model.forward.image",description:`<strong>image</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, height, width)</code> or <code>detectron.structures.ImageList</code> whose <code>tensors</code> is of shape <code>(batch_size, num_channels, height, width)</code>) &#x2014;
Batch of document images.`,name:"image"},{anchor:"transformers.LayoutLMv2Model.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.LayoutLMv2Model.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</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.LayoutLMv2Model.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.LayoutLMv2Model.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.LayoutLMv2Model.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 <em>input_ids</em> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.LayoutLMv2Model.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.LayoutLMv2Model.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.LayoutLMv2Model.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.BaseModelOutput"
>transformers.modeling_outputs.BaseModelOutput</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/layoutlmv2#transformers.LayoutLMv2Config"
>LayoutLMv2Config</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>
</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.BaseModelOutput"
>transformers.modeling_outputs.BaseModelOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),so=new ji({props:{$$slots:{default:[bv]},$$scope:{ctx:le}}}),Tt=new Y({props:{code:`from transformers import LayoutLMv2Processor, LayoutLMv2Model
from PIL import Image

processor = LayoutLMv2Processor.from_pretrained("microsoft/layoutlmv2-base-uncased")
model = LayoutLMv2Model.from_pretrained("microsoft/layoutlmv2-base-uncased")

image = Image.open("name_of_your_document - can be a png file, pdf, etc.").convert("RGB")

encoding = processor(image, return_tensors="pt")

outputs = model(**encoding)
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> LayoutLMv2Processor, LayoutLMv2Model
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image

<span class="hljs-meta">&gt;&gt;&gt; </span>processor = LayoutLMv2Processor.from_pretrained(<span class="hljs-string">&quot;microsoft/layoutlmv2-base-uncased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = LayoutLMv2Model.from_pretrained(<span class="hljs-string">&quot;microsoft/layoutlmv2-base-uncased&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>image = Image.<span class="hljs-built_in">open</span>(<span class="hljs-string">&quot;name_of_your_document - can be a png file, pdf, etc.&quot;</span>).convert(<span class="hljs-string">&quot;RGB&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>encoding = processor(image, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**encoding)
<span class="hljs-meta">&gt;&gt;&gt; </span>last_hidden_states = outputs.last_hidden_state`}}),Mt=new ie({}),Et=new I({props:{name:"class transformers.LayoutLMv2ForSequenceClassification",anchor:"transformers.LayoutLMv2ForSequenceClassification",parameters:[{name:"config",val:""}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/layoutlmv2/modeling_layoutlmv2.py#L953",parametersDescription:[{anchor:"transformers.LayoutLMv2ForSequenceClassification.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_15839/en/model_doc/layoutlmv2#transformers.LayoutLMv2Config">LayoutLMv2Config</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"}]}}),Pt=new I({props:{name:"forward",anchor:"transformers.LayoutLMv2ForSequenceClassification.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"bbox",val:": typing.Optional[torch.LongTensor] = None"},{name:"image",val:": typing.Optional[torch.FloatTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"token_type_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"position_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"labels",val:": typing.Optional[torch.LongTensor] = None"},{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/layoutlmv2/modeling_layoutlmv2.py#L967",parametersDescription:[{anchor:"transformers.LayoutLMv2ForSequenceClassification.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>batch_size, sequence_length</code>) &#x2014;
Indices of input sequence tokens in the vocabulary.</p>
<p>Indices can be obtained using <a href="/docs/transformers/pr_15839/en/model_doc/layoutlmv2#transformers.LayoutLMv2Tokenizer">LayoutLMv2Tokenizer</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.LayoutLMv2ForSequenceClassification.forward.bbox",description:`<strong>bbox</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length, 4)</code>, <em>optional</em>) &#x2014;
Bounding boxes of each input sequence tokens. Selected in the range <code>[0, config.max_2d_position_embeddings-1]</code>. Each bounding box should be a normalized version in (x0, y0, x1, y1)
format, where (x0, y0) corresponds to the position of the upper left corner in the bounding box, and (x1,
y1) represents the position of the lower right corner.`,name:"bbox"},{anchor:"transformers.LayoutLMv2ForSequenceClassification.forward.image",description:`<strong>image</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, height, width)</code> or <code>detectron.structures.ImageList</code> whose <code>tensors</code> is of shape <code>(batch_size, num_channels, height, width)</code>) &#x2014;
Batch of document images.`,name:"image"},{anchor:"transformers.LayoutLMv2ForSequenceClassification.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.LayoutLMv2ForSequenceClassification.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</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.LayoutLMv2ForSequenceClassification.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.LayoutLMv2ForSequenceClassification.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.LayoutLMv2ForSequenceClassification.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 <em>input_ids</em> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.LayoutLMv2ForSequenceClassification.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.LayoutLMv2ForSequenceClassification.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.LayoutLMv2ForSequenceClassification.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.LayoutLMv2ForSequenceClassification.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.SequenceClassifierOutput"
>transformers.modeling_outputs.SequenceClassifierOutput</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/layoutlmv2#transformers.LayoutLMv2Config"
>LayoutLMv2Config</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>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.SequenceClassifierOutput"
>transformers.modeling_outputs.SequenceClassifierOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),io=new ji({props:{$$slots:{default:[Lv]},$$scope:{ctx:le}}}),jt=new Y({props:{code:`from transformers import LayoutLMv2Processor, LayoutLMv2ForSequenceClassification
from PIL import Image
import torch

processor = LayoutLMv2Processor.from_pretrained("microsoft/layoutlmv2-base-uncased")
model = LayoutLMv2ForSequenceClassification.from_pretrained("microsoft/layoutlmv2-base-uncased")

image = Image.open("name_of_your_document - can be a png file, pdf, etc.").convert("RGB")

encoding = processor(image, return_tensors="pt")
sequence_label = torch.tensor([1])

outputs = model(**encoding, labels=sequence_label)
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> LayoutLMv2Processor, LayoutLMv2ForSequenceClassification
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>processor = LayoutLMv2Processor.from_pretrained(<span class="hljs-string">&quot;microsoft/layoutlmv2-base-uncased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = LayoutLMv2ForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;microsoft/layoutlmv2-base-uncased&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>image = Image.<span class="hljs-built_in">open</span>(<span class="hljs-string">&quot;name_of_your_document - can be a png file, pdf, etc.&quot;</span>).convert(<span class="hljs-string">&quot;RGB&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>encoding = processor(image, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>sequence_label = torch.tensor([<span class="hljs-number">1</span>])

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**encoding, labels=sequence_label)
<span class="hljs-meta">&gt;&gt;&gt; </span>loss = outputs.loss
<span class="hljs-meta">&gt;&gt;&gt; </span>logits = outputs.logits`}}),Ct=new ie({}),It=new I({props:{name:"class transformers.LayoutLMv2ForTokenClassification",anchor:"transformers.LayoutLMv2ForTokenClassification",parameters:[{name:"config",val:""}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/layoutlmv2/modeling_layoutlmv2.py#L1122",parametersDescription:[{anchor:"transformers.LayoutLMv2ForTokenClassification.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_15839/en/model_doc/layoutlmv2#transformers.LayoutLMv2Config">LayoutLMv2Config</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"}]}}),Ut=new I({props:{name:"forward",anchor:"transformers.LayoutLMv2ForTokenClassification.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"bbox",val:": typing.Optional[torch.LongTensor] = None"},{name:"image",val:": typing.Optional[torch.FloatTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"token_type_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"position_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"labels",val:": typing.Optional[torch.LongTensor] = None"},{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/layoutlmv2/modeling_layoutlmv2.py#L1136",parametersDescription:[{anchor:"transformers.LayoutLMv2ForTokenClassification.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>batch_size, sequence_length</code>) &#x2014;
Indices of input sequence tokens in the vocabulary.</p>
<p>Indices can be obtained using <a href="/docs/transformers/pr_15839/en/model_doc/layoutlmv2#transformers.LayoutLMv2Tokenizer">LayoutLMv2Tokenizer</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.LayoutLMv2ForTokenClassification.forward.bbox",description:`<strong>bbox</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length, 4)</code>, <em>optional</em>) &#x2014;
Bounding boxes of each input sequence tokens. Selected in the range <code>[0, config.max_2d_position_embeddings-1]</code>. Each bounding box should be a normalized version in (x0, y0, x1, y1)
format, where (x0, y0) corresponds to the position of the upper left corner in the bounding box, and (x1,
y1) represents the position of the lower right corner.`,name:"bbox"},{anchor:"transformers.LayoutLMv2ForTokenClassification.forward.image",description:`<strong>image</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, height, width)</code> or <code>detectron.structures.ImageList</code> whose <code>tensors</code> is of shape <code>(batch_size, num_channels, height, width)</code>) &#x2014;
Batch of document images.`,name:"image"},{anchor:"transformers.LayoutLMv2ForTokenClassification.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.LayoutLMv2ForTokenClassification.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</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.LayoutLMv2ForTokenClassification.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.LayoutLMv2ForTokenClassification.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.LayoutLMv2ForTokenClassification.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 <em>input_ids</em> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.LayoutLMv2ForTokenClassification.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.LayoutLMv2ForTokenClassification.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.LayoutLMv2ForTokenClassification.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.LayoutLMv2ForTokenClassification.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Labels for computing the token classification loss. Indices should be in <code>[0, ..., config.num_labels - 1]</code>.`,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/layoutlmv2#transformers.LayoutLMv2Config"
>LayoutLMv2Config</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>
`}}),co=new ji({props:{$$slots:{default:[wv]},$$scope:{ctx:le}}}),Bt=new Y({props:{code:`from transformers import LayoutLMv2Processor, LayoutLMv2ForTokenClassification
from PIL import Image

processor = LayoutLMv2Processor.from_pretrained("microsoft/layoutlmv2-base-uncased", revision="no_ocr")
model = LayoutLMv2ForTokenClassification.from_pretrained("microsoft/layoutlmv2-base-uncased")

image = Image.open("name_of_your_document - can be a png file, pdf, etc.").convert("RGB")
words = ["hello", "world"]
boxes = [[1, 2, 3, 4], [5, 6, 7, 8]]  # make sure to normalize your bounding boxes
word_labels = [0, 1]

encoding = processor(image, words, boxes=boxes, word_labels=word_labels, return_tensors="pt")

outputs = model(**encoding)
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> LayoutLMv2Processor, LayoutLMv2ForTokenClassification
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image

<span class="hljs-meta">&gt;&gt;&gt; </span>processor = LayoutLMv2Processor.from_pretrained(<span class="hljs-string">&quot;microsoft/layoutlmv2-base-uncased&quot;</span>, revision=<span class="hljs-string">&quot;no_ocr&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = LayoutLMv2ForTokenClassification.from_pretrained(<span class="hljs-string">&quot;microsoft/layoutlmv2-base-uncased&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>image = Image.<span class="hljs-built_in">open</span>(<span class="hljs-string">&quot;name_of_your_document - can be a png file, pdf, etc.&quot;</span>).convert(<span class="hljs-string">&quot;RGB&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>words = [<span class="hljs-string">&quot;hello&quot;</span>, <span class="hljs-string">&quot;world&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>boxes = [[<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-comment"># make sure to normalize your bounding boxes</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>word_labels = [<span class="hljs-number">0</span>, <span class="hljs-number">1</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span>encoding = processor(image, words, boxes=boxes, word_labels=word_labels, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**encoding)
<span class="hljs-meta">&gt;&gt;&gt; </span>loss = outputs.loss
<span class="hljs-meta">&gt;&gt;&gt; </span>logits = outputs.logits`}}),Wt=new ie({}),Vt=new I({props:{name:"class transformers.LayoutLMv2ForQuestionAnswering",anchor:"transformers.LayoutLMv2ForQuestionAnswering",parameters:[{name:"config",val:""},{name:"has_visual_segment_embedding",val:" = True"}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/layoutlmv2/modeling_layoutlmv2.py#L1231",parametersDescription:[{anchor:"transformers.LayoutLMv2ForQuestionAnswering.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_15839/en/model_doc/layoutlmv2#transformers.LayoutLMv2Config">LayoutLMv2Config</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"}]}}),Kt=new I({props:{name:"forward",anchor:"transformers.LayoutLMv2ForQuestionAnswering.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"bbox",val:": typing.Optional[torch.LongTensor] = None"},{name:"image",val:": typing.Optional[torch.FloatTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"token_type_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"position_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"start_positions",val:": typing.Optional[torch.LongTensor] = None"},{name:"end_positions",val:": typing.Optional[torch.LongTensor] = None"},{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/layoutlmv2/modeling_layoutlmv2.py#L1245",parametersDescription:[{anchor:"transformers.LayoutLMv2ForQuestionAnswering.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>batch_size, sequence_length</code>) &#x2014;
Indices of input sequence tokens in the vocabulary.</p>
<p>Indices can be obtained using <a href="/docs/transformers/pr_15839/en/model_doc/layoutlmv2#transformers.LayoutLMv2Tokenizer">LayoutLMv2Tokenizer</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.LayoutLMv2ForQuestionAnswering.forward.bbox",description:`<strong>bbox</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length, 4)</code>, <em>optional</em>) &#x2014;
Bounding boxes of each input sequence tokens. Selected in the range <code>[0, config.max_2d_position_embeddings-1]</code>. Each bounding box should be a normalized version in (x0, y0, x1, y1)
format, where (x0, y0) corresponds to the position of the upper left corner in the bounding box, and (x1,
y1) represents the position of the lower right corner.`,name:"bbox"},{anchor:"transformers.LayoutLMv2ForQuestionAnswering.forward.image",description:`<strong>image</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, height, width)</code> or <code>detectron.structures.ImageList</code> whose <code>tensors</code> is of shape <code>(batch_size, num_channels, height, width)</code>) &#x2014;
Batch of document images.`,name:"image"},{anchor:"transformers.LayoutLMv2ForQuestionAnswering.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.LayoutLMv2ForQuestionAnswering.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</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.LayoutLMv2ForQuestionAnswering.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.LayoutLMv2ForQuestionAnswering.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.LayoutLMv2ForQuestionAnswering.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 <em>input_ids</em> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.LayoutLMv2ForQuestionAnswering.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.LayoutLMv2ForQuestionAnswering.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.LayoutLMv2ForQuestionAnswering.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.LayoutLMv2ForQuestionAnswering.forward.start_positions",description:`<strong>start_positions</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size,)</code>, <em>optional</em>) &#x2014;
Labels for position (index) of the start of the labelled span for computing the token classification loss.
Positions are clamped to the length of the sequence (<code>sequence_length</code>). Position outside of the sequence
are not taken into account for computing the loss.`,name:"start_positions"},{anchor:"transformers.LayoutLMv2ForQuestionAnswering.forward.end_positions",description:`<strong>end_positions</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size,)</code>, <em>optional</em>) &#x2014;
Labels for position (index) of the end of the labelled span for computing the token classification loss.
Positions are clamped to the length of the sequence (<code>sequence_length</code>). Position outside of the sequence
are not taken into account for computing the loss.`,name:"end_positions"}],returnDescription:`
<p>A <a
  href="/docs/transformers/pr_15839/en/main_classes/output#transformers.modeling_outputs.QuestionAnsweringModelOutput"
>transformers.modeling_outputs.QuestionAnsweringModelOutput</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/layoutlmv2#transformers.LayoutLMv2Config"
>LayoutLMv2Config</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 Total span extraction loss is the sum of a Cross-Entropy for the start and end positions.</p>
</li>
<li>
<p><strong>start_logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code>) \u2014 Span-start scores (before SoftMax).</p>
</li>
<li>
<p><strong>end_logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code>) \u2014 Span-end 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.QuestionAnsweringModelOutput"
>transformers.modeling_outputs.QuestionAnsweringModelOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),uo=new ji({props:{$$slots:{default:[kv]},$$scope:{ctx:le}}}),Xt=new Y({props:{code:`from transformers import LayoutLMv2Processor, LayoutLMv2ForQuestionAnswering
from PIL import Image
import torch

processor = LayoutLMv2Processor.from_pretrained("microsoft/layoutlmv2-base-uncased")
model = LayoutLMv2ForQuestionAnswering.from_pretrained("microsoft/layoutlmv2-base-uncased")

image = Image.open("name_of_your_document - can be a png file, pdf, etc.").convert("RGB")
question = "what's his name?"

encoding = processor(image, question, return_tensors="pt")
start_positions = torch.tensor([1])
end_positions = torch.tensor([3])

outputs = model(**encoding, start_positions=start_positions, end_positions=end_positions)
loss = outputs.loss
start_scores = outputs.start_logits
end_scores = outputs.end_logits`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> LayoutLMv2Processor, LayoutLMv2ForQuestionAnswering
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>processor = LayoutLMv2Processor.from_pretrained(<span class="hljs-string">&quot;microsoft/layoutlmv2-base-uncased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = LayoutLMv2ForQuestionAnswering.from_pretrained(<span class="hljs-string">&quot;microsoft/layoutlmv2-base-uncased&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>image = Image.<span class="hljs-built_in">open</span>(<span class="hljs-string">&quot;name_of_your_document - can be a png file, pdf, etc.&quot;</span>).convert(<span class="hljs-string">&quot;RGB&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>question = <span class="hljs-string">&quot;what&#x27;s his name?&quot;</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>encoding = processor(image, question, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>start_positions = torch.tensor([<span class="hljs-number">1</span>])
<span class="hljs-meta">&gt;&gt;&gt; </span>end_positions = torch.tensor([<span class="hljs-number">3</span>])

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**encoding, start_positions=start_positions, end_positions=end_positions)
<span class="hljs-meta">&gt;&gt;&gt; </span>loss = outputs.loss
<span class="hljs-meta">&gt;&gt;&gt; </span>start_scores = outputs.start_logits
<span class="hljs-meta">&gt;&gt;&gt; </span>end_scores = outputs.end_logits`}}),{c(){y=s("meta"),q=c(),b=s("h1"),T=s("a"),P=s("span"),h(L.$$.fragment),w=c(),A=s("span"),Ci=n("LayoutLMV2"),ar=c(),$e=s("h2"),Ge=s("a"),ca=s("span"),h(bo.$$.fragment),Ii=c(),da=s("span"),Ai=n("Overview"),sr=c(),ue=s("p"),Oi=n("The LayoutLMV2 model was proposed in "),Lo=s("a"),Di=n("LayoutLMv2: Multi-modal Pre-training for Visually-Rich Document Understanding"),Ni=n(` by Yang Xu, Yiheng Xu, Tengchao Lv, Lei Cui, Furu Wei, Guoxin Wang, Yijuan Lu,
Dinei Florencio, Cha Zhang, Wanxiang Che, Min Zhang, Lidong Zhou. LayoutLMV2 improves `),Zt=s("a"),Si=n("LayoutLM"),Ri=n(` to obtain
state-of-the-art results across several document image understanding benchmarks:`),rr=c(),he=s("ul"),Z=s("li"),Ui=n("information extraction from scanned documents: the "),wo=s("a"),Bi=n("FUNSD"),Wi=n(` dataset (a
collection of 199 annotated forms comprising more than 30,000 words), the `),ko=s("a"),Vi=n("CORD"),Qi=n(`
dataset (a collection of 800 receipts for training, 100 for validation and 100 for testing), the `),xo=s("a"),Gi=n("SROIE"),Hi=n(` dataset (a collection of 626 receipts for training and 347 receipts for testing)
and the `),To=s("a"),Ki=n("Kleister-NDA"),Xi=n(` dataset (a collection of non-disclosure
agreements from the EDGAR database, including 254 documents for training, 83 documents for validation, and 203
documents for testing).`),Yi=c(),Mo=s("li"),Zi=n("document image classification: the "),Eo=s("a"),Ji=n("RVL-CDIP"),el=n(` dataset (a collection of
400,000 images belonging to one of 16 classes).`),ol=c(),zo=s("li"),tl=n("document visual question answering: the "),$o=s("a"),nl=n("DocVQA"),al=n(` dataset (a collection of 50,000
questions defined on 12,000+ document images).`),ir=c(),Jt=s("p"),sl=n("The abstract from the paper is the following:"),lr=c(),en=s("p"),pa=s("em"),rl=n(`Pre-training of text and layout has proved effective in a variety of visually-rich document understanding tasks due to
its effective model architecture and the advantage of large-scale unlabeled scanned/digital-born documents. In this
paper, we present LayoutLMv2 by pre-training text, layout and image in a multi-modal framework, where new model
architectures and pre-training tasks are leveraged. Specifically, LayoutLMv2 not only uses the existing masked
visual-language modeling task but also the new text-image alignment and text-image matching tasks in the pre-training
stage, where cross-modality interaction is better learned. Meanwhile, it also integrates a spatial-aware self-attention
mechanism into the Transformer architecture, so that the model can fully understand the relative positional
relationship among different text blocks. Experiment results show that LayoutLMv2 outperforms strong baselines and
achieves new state-of-the-art results on a wide variety of downstream visually-rich document understanding tasks,
including FUNSD (0.7895 -> 0.8420), CORD (0.9493 -> 0.9601), SROIE (0.9524 -> 0.9781), Kleister-NDA (0.834 -> 0.852),
RVL-CDIP (0.9443 -> 0.9564), and DocVQA (0.7295 -> 0.8672). The pre-trained LayoutLMv2 model is publicly available at
this https URL.`),cr=c(),on=s("p"),il=n("Tips:"),dr=c(),B=s("ul"),ua=s("li"),ll=n(`The main difference between LayoutLMv1 and LayoutLMv2 is that the latter incorporates visual embeddings during
pre-training (while LayoutLMv1 only adds visual embeddings during fine-tuning).`),cl=c(),qo=s("li"),dl=n(`LayoutLMv2 adds both a relative 1D attention bias as well as a spatial 2D attention bias to the attention scores in
the self-attention layers. Details can be found on page 5 of the `),Fo=s("a"),pl=n("paper"),ul=n("."),hl=c(),Po=s("li"),ml=n("Demo notebooks on how to use the LayoutLMv2 model on RVL-CDIP, FUNSD, DocVQA, CORD can be found "),jo=s("a"),fl=n("here"),gl=n("."),_l=c(),qe=s("li"),vl=n("LayoutLMv2 uses Facebook AI\u2019s "),Co=s("a"),yl=n("Detectron2"),bl=n(` package for its visual
backbone. See `),Io=s("a"),Ll=n("this link"),wl=n(` for installation
instructions.`),kl=c(),k=s("li"),xl=n("In addition to "),ha=s("code"),Tl=n("input_ids"),Ml=n(", "),tn=s("a"),El=n("forward()"),zl=n(` expects 2 additional inputs, namely
`),ma=s("code"),$l=n("image"),ql=n(" and "),fa=s("code"),Fl=n("bbox"),Pl=n(". The "),ga=s("code"),jl=n("image"),Cl=n(` input corresponds to the original document image in which the text
tokens occur. The model expects each document image to be of size 224x224. This means that if you have a batch of
document images, `),_a=s("code"),Il=n("image"),Al=n(` should be a tensor of shape (batch_size, 3, 224, 224). This can be either a
`),va=s("code"),Ol=n("torch.Tensor"),Dl=n(" or a "),ya=s("code"),Nl=n("Detectron2.structures.ImageList"),Sl=n(`. You don\u2019t need to normalize the channels, as this is
done by the model. Important to note is that the visual backbone expects BGR channels instead of RGB, as all models
in Detectron2 are pre-trained using the BGR format. The `),ba=s("code"),Rl=n("bbox"),Ul=n(` input are the bounding boxes (i.e. 2D-positions)
of the input text tokens. This is identical to `),nn=s("a"),Bl=n("LayoutLMModel"),Wl=n(`. These can be obtained using an
external OCR engine such as Google\u2019s `),Ao=s("a"),Vl=n("Tesseract"),Ql=n(" (there\u2019s a "),Oo=s("a"),Gl=n(`Python
wrapper`),Hl=n(` available). Each bounding box should be in (x0, y0, x1, y1)
format, where (x0, y0) corresponds to the position of the upper left corner in the bounding box, and (x1, y1)
represents the position of the lower right corner. Note that one first needs to normalize the bounding boxes to be on
a 0-1000 scale. To normalize, you can use the following function:`),pr=c(),h(Do.$$.fragment),ur=c(),me=s("p"),Kl=n("Here, "),La=s("code"),Xl=n("width"),Yl=n(" and "),wa=s("code"),Zl=n("height"),Jl=n(` correspond to the width and height of the original document in which the token
occurs (before resizing the image). Those can be obtained using the Python Image Library (PIL) library for example, as
follows:`),hr=c(),h(No.$$.fragment),mr=c(),He=s("p"),ec=n("However, this model includes a brand new "),an=s("a"),oc=n("LayoutLMv2Processor"),tc=n(` which can be used to directly
prepare data for the model (including applying OCR under the hood). More information can be found in the \u201CUsage\u201D
section below.`),fr=c(),fe=s("ul"),C=s("li"),nc=n("Internally, "),sn=s("a"),ac=n("LayoutLMv2Model"),sc=n(" will send the "),ka=s("code"),rc=n("image"),ic=n(` input through its visual backbone to
obtain a lower-resolution feature map, whose shape is equal to the `),xa=s("code"),lc=n("image_feature_pool_shape"),cc=n(` attribute of
`),rn=s("a"),dc=n("LayoutLMv2Config"),pc=n(`. This feature map is then flattened to obtain a sequence of image tokens. As
the size of the feature map is 7x7 by default, one obtains 49 image tokens. These are then concatenated with the text
tokens, and send through the Transformer encoder. This means that the last hidden states of the model will have a
length of 512 + 49 = 561, if you pad the text tokens up to the max length. More generally, the last hidden states
will have a shape of `),Ta=s("code"),uc=n("seq_length"),hc=n(" + "),Ma=s("code"),mc=n("image_feature_pool_shape[0]"),fc=n(` *
`),Ea=s("code"),gc=n("config.image_feature_pool_shape[1]"),_c=n("."),vc=c(),So=s("li"),yc=n("When calling "),ln=s("a"),bc=n("from_pretrained()"),Lc=n(`, a warning will be printed with a long list of
parameter names that are not initialized. This is not a problem, as these parameters are batch normalization
statistics, which are going to have values when fine-tuning on a custom dataset.`),wc=c(),Ro=s("li"),kc=n("If you want to train the model in a distributed environment, make sure to call "),za=s("code"),xc=n("synchronize_batch_norm"),Tc=n(` on the
model in order to properly synchronize the batch normalization layers of the visual backbone.`),gr=c(),Ke=s("p"),Mc=n(`In addition, there\u2019s LayoutXLM, which is a multilingual version of LayoutLMv2. More information can be found on
`),cn=s("a"),Ec=n("LayoutXLM\u2019s documentation page"),zc=n("."),_r=c(),Fe=s("h2"),Xe=s("a"),$a=s("span"),h(Uo.$$.fragment),$c=c(),qa=s("span"),qc=n("Usage: LayoutLMv2Processor"),vr=c(),W=s("p"),Fc=n("The easiest way to prepare data for the model is to use "),dn=s("a"),Pc=n("LayoutLMv2Processor"),jc=n(`, which internally
combines a feature extractor (`),pn=s("a"),Cc=n("LayoutLMv2FeatureExtractor"),Ic=n(`) and a tokenizer
(`),un=s("a"),Ac=n("LayoutLMv2Tokenizer"),Oc=n(" or "),hn=s("a"),Dc=n("LayoutLMv2TokenizerFast"),Nc=n(`). The feature extractor
handles the image modality, while the tokenizer handles the text modality. A processor combines both, which is ideal
for a multi-modal model like LayoutLMv2. Note that you can still use both separately, if you only want to handle one
modality.`),yr=c(),h(Bo.$$.fragment),br=c(),M=s("p"),Sc=n("In short, one can provide a document image (and possibly additional data) to "),mn=s("a"),Rc=n("LayoutLMv2Processor"),Uc=n(`,
and it will create the inputs expected by the model. Internally, the processor first uses
`),fn=s("a"),Bc=n("LayoutLMv2FeatureExtractor"),Wc=n(` to apply OCR on the image to get a list of words and normalized
bounding boxes, as well to resize the image to a given size in order to get the `),Fa=s("code"),Vc=n("image"),Qc=n(` input. The words and
normalized bounding boxes are then provided to `),gn=s("a"),Gc=n("LayoutLMv2Tokenizer"),Hc=n(` or
`),_n=s("a"),Kc=n("LayoutLMv2TokenizerFast"),Xc=n(", which converts them to token-level "),Pa=s("code"),Yc=n("input_ids"),Zc=n(`,
`),ja=s("code"),Jc=n("attention_mask"),ed=n(", "),Ca=s("code"),od=n("token_type_ids"),td=n(", "),Ia=s("code"),nd=n("bbox"),ad=n(`. Optionally, one can provide word labels to the processor,
which are turned into token-level `),Aa=s("code"),sd=n("labels"),rd=n("."),Lr=c(),S=s("p"),vn=s("a"),id=n("LayoutLMv2Processor"),ld=n(" uses "),Wo=s("a"),cd=n("PyTesseract"),dd=n(`, a Python
wrapper around Google\u2019s Tesseract OCR engine, under the hood. Note that you can still use your own OCR engine of
choice, and provide the words and normalized boxes yourself. This requires initializing
`),yn=s("a"),pd=n("LayoutLMv2FeatureExtractor"),ud=n(" with "),Oa=s("code"),hd=n("apply_ocr"),md=n(" set to "),Da=s("code"),fd=n("False"),gd=n("."),wr=c(),bn=s("p"),_d=n(`In total, there are 5 use cases that are supported by the processor. Below, we list them all. Note that each of these
use cases work for both batched and non-batched inputs (we illustrate them for non-batched inputs).`),kr=c(),Ln=s("p"),Na=s("strong"),vd=n(`Use case 1: document image classification (training, inference) + token classification (inference), apply_ocr =
True`),xr=c(),wn=s("p"),yd=n(`This is the simplest case, in which the processor (actually the feature extractor) will perform OCR on the image to get
the words and normalized bounding boxes.`),Tr=c(),h(Vo.$$.fragment),Mr=c(),kn=s("p"),Sa=s("strong"),bd=n("Use case 2: document image classification (training, inference) + token classification (inference), apply_ocr=False"),Er=c(),ge=s("p"),Ld=n("In case one wants to do OCR themselves, one can initialize the feature extractor with "),Ra=s("code"),wd=n("apply_ocr"),kd=n(` set to
`),Ua=s("code"),xd=n("False"),Td=n(`. In that case, one should provide the words and corresponding (normalized) bounding boxes themselves to
the processor.`),zr=c(),h(Qo.$$.fragment),$r=c(),xn=s("p"),Ba=s("strong"),Md=n("Use case 3: token classification (training), apply_ocr=False"),qr=c(),V=s("p"),Ed=n(`For token classification tasks (such as FUNSD, CORD, SROIE, Kleister-NDA), one can also provide the corresponding word
labels in order to train a model. The processor will then convert these into token-level `),Wa=s("code"),zd=n("labels"),$d=n(`. By default, it
will only label the first wordpiece of a word, and label the remaining wordpieces with -100, which is the
`),Va=s("code"),qd=n("ignore_index"),Fd=n(` of PyTorch\u2019s CrossEntropyLoss. In case you want all wordpieces of a word to be labeled, you can
initialize the tokenizer with `),Qa=s("code"),Pd=n("only_label_first_subword"),jd=n(" set to "),Ga=s("code"),Cd=n("False"),Id=n("."),Fr=c(),h(Go.$$.fragment),Pr=c(),Tn=s("p"),Ha=s("strong"),Ad=n("Use case 4: visual question answering (inference), apply_ocr=True"),jr=c(),Mn=s("p"),Od=n(`For visual question answering tasks (such as DocVQA), you can provide a question to the processor. By default, the
processor will apply OCR on the image, and create [CLS] question tokens [SEP] word tokens [SEP].`),Cr=c(),h(Ho.$$.fragment),Ir=c(),En=s("p"),Ka=s("strong"),Dd=n("Use case 5: visual question answering (inference), apply_ocr=False"),Ar=c(),zn=s("p"),Nd=n(`For visual question answering tasks (such as DocVQA), you can provide a question to the processor. If you want to
perform OCR yourself, you can provide your own words and (normalized) bounding boxes to the processor.`),Or=c(),h(Ko.$$.fragment),Dr=c(),Pe=s("h2"),Ye=s("a"),Xa=s("span"),h(Xo.$$.fragment),Sd=c(),Ya=s("span"),Rd=n("LayoutLMv2Config"),Nr=c(),R=s("div"),h(Yo.$$.fragment),Ud=c(),je=s("p"),Bd=n("This is the configuration class to store the configuration of a "),$n=s("a"),Wd=n("LayoutLMv2Model"),Vd=n(`. It is used to instantiate an
LayoutLMv2 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 LayoutLMv2
`),Zo=s("a"),Qd=n("microsoft/layoutlmv2-base-uncased"),Gd=n(" architecture."),Hd=c(),Ce=s("p"),Kd=n("Configuration objects inherit from "),qn=s("a"),Xd=n("PretrainedConfig"),Yd=n(` and can be used to control the model outputs. Read the
documentation from `),Fn=s("a"),Zd=n("PretrainedConfig"),Jd=n(" for more information."),ep=c(),Za=s("p"),op=n("Example:"),tp=c(),h(Jo.$$.fragment),Sr=c(),Ie=s("h2"),Ze=s("a"),Ja=s("span"),h(et.$$.fragment),np=c(),es=s("span"),ap=n("LayoutLMv2FeatureExtractor"),Rr=c(),J=s("div"),h(ot.$$.fragment),sp=c(),os=s("p"),rp=n(`Constructs a LayoutLMv2 feature extractor. This can be used to resize document images to the same size, as well as
to apply OCR on them in order to get a list of words and normalized bounding boxes.`),ip=c(),tt=s("p"),lp=n("This feature extractor inherits from "),ts=s("code"),cp=n("PreTrainedFeatureExtractor()"),dp=n(`which contains most
of the main methods. Users should refer to this superclass for more information regarding those methods.`),pp=c(),se=s("div"),h(nt.$$.fragment),up=c(),ns=s("p"),hp=n("Main method to prepare for the model one or several image(s)."),mp=c(),as=s("p"),fp=n("Examples:"),gp=c(),h(at.$$.fragment),Ur=c(),Ae=s("h2"),Je=s("a"),ss=s("span"),h(st.$$.fragment),_p=c(),rs=s("span"),vp=n("LayoutLMv2Tokenizer"),Br=c(),O=s("div"),h(rt.$$.fragment),yp=c(),D=s("p"),bp=n("Construct a LayoutLMv2 tokenizer. Based on WordPiece. "),Pn=s("a"),Lp=n("LayoutLMv2Tokenizer"),wp=n(` can be used to turn words, word-level
bounding boxes and optional word labels to token-level `),is=s("code"),kp=n("input_ids"),xp=n(", "),ls=s("code"),Tp=n("attention_mask"),Mp=n(", "),cs=s("code"),Ep=n("token_type_ids"),zp=n(", "),ds=s("code"),$p=n("bbox"),qp=n(`, and
optional `),ps=s("code"),Fp=n("labels"),Pp=n(" (for token classification)."),jp=c(),it=s("p"),Cp=n("This tokenizer inherits from "),jn=s("a"),Ip=n("PreTrainedTokenizer"),Ap=n(` which contains most of the main methods. Users should refer to
this superclass for more information regarding those methods.`),Op=c(),Cn=s("p"),In=s("a"),Dp=n("LayoutLMv2Tokenizer"),Np=n(` runs end-to-end tokenization: punctuation splitting and wordpiece. It also turns the
word-level bounding boxes into token-level bounding boxes.`),Sp=c(),eo=s("div"),h(lt.$$.fragment),Rp=c(),us=s("p"),Up=n(`Main method to tokenize and prepare for the model one or several sequence(s) or one or several pair(s) of
sequences with word-level normalized bounding boxes and optional labels.`),Bp=c(),An=s("div"),h(ct.$$.fragment),Wr=c(),Oe=s("h2"),oo=s("a"),hs=s("span"),h(dt.$$.fragment),Wp=c(),ms=s("span"),Vp=n("LayoutLMv2TokenizerFast"),Vr=c(),ee=s("div"),h(pt.$$.fragment),Qp=c(),ut=s("p"),Gp=n("Construct a \u201Cfast\u201D LayoutLMv2 tokenizer (backed by HuggingFace\u2019s "),fs=s("em"),Hp=n("tokenizers"),Kp=n(" library). Based on WordPiece."),Xp=c(),ht=s("p"),Yp=n("This tokenizer inherits from "),On=s("a"),Zp=n("PreTrainedTokenizerFast"),Jp=n(` which contains most of the main methods. Users should
refer to this superclass for more information regarding those methods.`),eu=c(),to=s("div"),h(mt.$$.fragment),ou=c(),gs=s("p"),tu=n(`Main method to tokenize and prepare for the model one or several sequence(s) or one or several pair(s) of
sequences with word-level normalized bounding boxes and optional labels.`),Qr=c(),De=s("h2"),no=s("a"),_s=s("span"),h(ft.$$.fragment),nu=c(),vs=s("span"),au=n("LayoutLMv2Processor"),Gr=c(),U=s("div"),h(gt.$$.fragment),su=c(),ys=s("p"),ru=n(`Constructs a LayoutLMv2 processor which combines a LayoutLMv2 feature extractor and a LayoutLMv2 tokenizer into a
single processor.`),iu=c(),Dn=s("p"),Nn=s("a"),lu=n("LayoutLMv2Processor"),cu=n(" offers all the functionalities you need to prepare data for the model."),du=c(),$=s("p"),pu=n("It first uses "),Sn=s("a"),uu=n("LayoutLMv2FeatureExtractor"),hu=n(` to resize document images to a fixed size, and optionally applies OCR
to get words and normalized bounding boxes. These are then provided to `),Rn=s("a"),mu=n("LayoutLMv2Tokenizer"),fu=n(` or
`),Un=s("a"),gu=n("LayoutLMv2TokenizerFast"),_u=n(", which turns the words and bounding boxes into token-level "),bs=s("code"),vu=n("input_ids"),yu=n(`,
`),Ls=s("code"),bu=n("attention_mask"),Lu=n(", "),ws=s("code"),wu=n("token_type_ids"),ku=n(", "),ks=s("code"),xu=n("bbox"),Tu=n(". Optionally, one can provide integer "),xs=s("code"),Mu=n("word_labels"),Eu=n(`, which are turned
into token-level `),Ts=s("code"),zu=n("labels"),$u=n(" for token classification tasks (such as FUNSD, CORD)."),qu=c(),_e=s("div"),h(_t.$$.fragment),Fu=c(),x=s("p"),Pu=n("This method first forwards the "),Ms=s("code"),ju=n("images"),Cu=n(" argument to "),vt=s("a"),Es=s("strong"),Iu=n("call"),Au=n("()"),Ou=n(`. In case
`),Bn=s("a"),Du=n("LayoutLMv2FeatureExtractor"),Nu=n(" was initialized with "),zs=s("code"),Su=n("apply_ocr"),Ru=n(" set to "),$s=s("code"),Uu=n("True"),Bu=n(`, it passes the obtained words and
bounding boxes along with the additional arguments to `),yt=s("a"),qs=s("strong"),Wu=n("call"),Vu=n("()"),Qu=n(` and returns the output,
together with resized `),Fs=s("code"),Gu=n("images"),Hu=n(". In case "),Wn=s("a"),Ku=n("LayoutLMv2FeatureExtractor"),Xu=n(" was initialized with "),Ps=s("code"),Yu=n("apply_ocr"),Zu=n(` set to
`),js=s("code"),Ju=n("False"),eh=n(", it passes the words ("),Cs=s("code"),oh=n("text"),th=n("/"),Is=s("code"),nh=n("text_pair`) and `boxes` specified by the user along with the additional arguments to [__call__()](/docs/transformers/pr_15839/en/model_doc/layoutlmv2#transformers.LayoutLMv2Tokenizer.__call__) and returns the output, together with resized `images"),ah=n("."),sh=c(),As=s("p"),rh=n("Please refer to the docstring of the above two methods for more information."),Hr=c(),Ne=s("h2"),ao=s("a"),Os=s("span"),h(bt.$$.fragment),ih=c(),Ds=s("span"),lh=n("LayoutLMv2Model"),Kr=c(),ce=s("div"),h(Lt.$$.fragment),ch=c(),wt=s("p"),dh=n(`The bare LayoutLMv2 Model transformer outputting raw hidden-states without any specific head on top.
This model is a PyTorch `),kt=s("a"),ph=n("torch.nn.Module"),uh=n(` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),hh=c(),Q=s("div"),h(xt.$$.fragment),mh=c(),Se=s("p"),fh=n("The "),Vn=s("a"),gh=n("LayoutLMv2Model"),_h=n(" forward method, overrides the "),Ns=s("code"),vh=n("__call__"),yh=n(" special method."),bh=c(),h(so.$$.fragment),Lh=c(),Ss=s("p"),wh=n("Examples:"),kh=c(),h(Tt.$$.fragment),Xr=c(),Re=s("h2"),ro=s("a"),Rs=s("span"),h(Mt.$$.fragment),xh=c(),Us=s("span"),Th=n("LayoutLMv2ForSequenceClassification"),Yr=c(),oe=s("div"),h(Et.$$.fragment),Mh=c(),zt=s("p"),Eh=n(`LayoutLMv2 Model with a sequence classification head on top (a linear layer on top of the concatenation of the
final hidden state of the [CLS] token, average-pooled initial visual embeddings and average-pooled final visual
embeddings, e.g. for document image classification tasks such as the
`),$t=s("a"),zh=n("RVL-CDIP"),$h=n(" dataset."),qh=c(),qt=s("p"),Fh=n("This model is a PyTorch "),Ft=s("a"),Ph=n("torch.nn.Module"),jh=n(` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Ch=c(),G=s("div"),h(Pt.$$.fragment),Ih=c(),Ue=s("p"),Ah=n("The "),Qn=s("a"),Oh=n("LayoutLMv2ForSequenceClassification"),Dh=n(" forward method, overrides the "),Bs=s("code"),Nh=n("__call__"),Sh=n(" special method."),Rh=c(),h(io.$$.fragment),Uh=c(),Ws=s("p"),Bh=n("Examples:"),Wh=c(),h(jt.$$.fragment),Zr=c(),Be=s("h2"),lo=s("a"),Vs=s("span"),h(Ct.$$.fragment),Vh=c(),Qs=s("span"),Qh=n("LayoutLMv2ForTokenClassification"),Jr=c(),te=s("div"),h(It.$$.fragment),Gh=c(),ne=s("p"),Hh=n(`LayoutLMv2 Model with a token classification head on top (a linear layer on top of the text part of the hidden
states) e.g. for sequence labeling (information extraction) tasks such as
`),At=s("a"),Kh=n("FUNSD"),Xh=n(", "),Ot=s("a"),Yh=n("SROIE"),Zh=n(`,
`),Dt=s("a"),Jh=n("CORD"),em=n(" and "),Nt=s("a"),om=n("Kleister-NDA"),tm=n("."),nm=c(),St=s("p"),am=n("This model is a PyTorch "),Rt=s("a"),sm=n("torch.nn.Module"),rm=n(` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),im=c(),H=s("div"),h(Ut.$$.fragment),lm=c(),We=s("p"),cm=n("The "),Gn=s("a"),dm=n("LayoutLMv2ForTokenClassification"),pm=n(" forward method, overrides the "),Gs=s("code"),um=n("__call__"),hm=n(" special method."),mm=c(),h(co.$$.fragment),fm=c(),Hs=s("p"),gm=n("Examples:"),_m=c(),h(Bt.$$.fragment),ei=c(),Ve=s("h2"),po=s("a"),Ks=s("span"),h(Wt.$$.fragment),vm=c(),Xs=s("span"),ym=n("LayoutLMv2ForQuestionAnswering"),oi=c(),ae=s("div"),h(Vt.$$.fragment),bm=c(),de=s("p"),Lm=n(`LayoutLMv2 Model with a span classification head on top for extractive question-answering tasks such as
`),Qt=s("a"),wm=n("DocVQA"),km=n(` (a linear layer on top of the text part of the hidden-states output to
compute `),Ys=s("code"),xm=n("span start logits"),Tm=n(" and "),Zs=s("code"),Mm=n("span end logits"),Em=n(")."),zm=c(),Gt=s("p"),$m=n("This model is a PyTorch "),Ht=s("a"),qm=n("torch.nn.Module"),Fm=n(` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Pm=c(),K=s("div"),h(Kt.$$.fragment),jm=c(),Qe=s("p"),Cm=n("The "),Hn=s("a"),Im=n("LayoutLMv2ForQuestionAnswering"),Am=n(" forward method, overrides the "),Js=s("code"),Om=n("__call__"),Dm=n(" special method."),Nm=c(),h(uo.$$.fragment),Sm=c(),er=s("p"),Rm=n("Examples:"),Um=c(),h(Xt.$$.fragment),this.h()},l(o){const p=yv('[data-svelte="svelte-1phssyn"]',document.head);y=r(p,"META",{name:!0,content:!0}),p.forEach(t),q=d(o),b=r(o,"H1",{class:!0});var Yt=i(b);T=r(Yt,"A",{id:!0,class:!0,href:!0});var or=i(T);P=r(or,"SPAN",{});var tr=i(P);m(L.$$.fragment,tr),tr.forEach(t),or.forEach(t),w=d(Yt),A=r(Yt,"SPAN",{});var nr=i(A);Ci=a(nr,"LayoutLMV2"),nr.forEach(t),Yt.forEach(t),ar=d(o),$e=r(o,"H2",{class:!0});var ni=i($e);Ge=r(ni,"A",{id:!0,class:!0,href:!0});var Gm=i(Ge);ca=r(Gm,"SPAN",{});var Hm=i(ca);m(bo.$$.fragment,Hm),Hm.forEach(t),Gm.forEach(t),Ii=d(ni),da=r(ni,"SPAN",{});var Km=i(da);Ai=a(Km,"Overview"),Km.forEach(t),ni.forEach(t),sr=d(o),ue=r(o,"P",{});var Kn=i(ue);Oi=a(Kn,"The LayoutLMV2 model was proposed in "),Lo=r(Kn,"A",{href:!0,rel:!0});var Xm=i(Lo);Di=a(Xm,"LayoutLMv2: Multi-modal Pre-training for Visually-Rich Document Understanding"),Xm.forEach(t),Ni=a(Kn,` by Yang Xu, Yiheng Xu, Tengchao Lv, Lei Cui, Furu Wei, Guoxin Wang, Yijuan Lu,
Dinei Florencio, Cha Zhang, Wanxiang Che, Min Zhang, Lidong Zhou. LayoutLMV2 improves `),Zt=r(Kn,"A",{href:!0});var Ym=i(Zt);Si=a(Ym,"LayoutLM"),Ym.forEach(t),Ri=a(Kn,` to obtain
state-of-the-art results across several document image understanding benchmarks:`),Kn.forEach(t),rr=d(o),he=r(o,"UL",{});var Xn=i(he);Z=r(Xn,"LI",{});var ve=i(Z);Ui=a(ve,"information extraction from scanned documents: the "),wo=r(ve,"A",{href:!0,rel:!0});var Zm=i(wo);Bi=a(Zm,"FUNSD"),Zm.forEach(t),Wi=a(ve,` dataset (a
collection of 199 annotated forms comprising more than 30,000 words), the `),ko=r(ve,"A",{href:!0,rel:!0});var Jm=i(ko);Vi=a(Jm,"CORD"),Jm.forEach(t),Qi=a(ve,`
dataset (a collection of 800 receipts for training, 100 for validation and 100 for testing), the `),xo=r(ve,"A",{href:!0,rel:!0});var ef=i(xo);Gi=a(ef,"SROIE"),ef.forEach(t),Hi=a(ve,` dataset (a collection of 626 receipts for training and 347 receipts for testing)
and the `),To=r(ve,"A",{href:!0,rel:!0});var of=i(To);Ki=a(of,"Kleister-NDA"),of.forEach(t),Xi=a(ve,` dataset (a collection of non-disclosure
agreements from the EDGAR database, including 254 documents for training, 83 documents for validation, and 203
documents for testing).`),ve.forEach(t),Yi=d(Xn),Mo=r(Xn,"LI",{});var ai=i(Mo);Zi=a(ai,"document image classification: the "),Eo=r(ai,"A",{href:!0,rel:!0});var tf=i(Eo);Ji=a(tf,"RVL-CDIP"),tf.forEach(t),el=a(ai,` dataset (a collection of
400,000 images belonging to one of 16 classes).`),ai.forEach(t),ol=d(Xn),zo=r(Xn,"LI",{});var si=i(zo);tl=a(si,"document visual question answering: the "),$o=r(si,"A",{href:!0,rel:!0});var nf=i($o);nl=a(nf,"DocVQA"),nf.forEach(t),al=a(si,` dataset (a collection of 50,000
questions defined on 12,000+ document images).`),si.forEach(t),Xn.forEach(t),ir=d(o),Jt=r(o,"P",{});var af=i(Jt);sl=a(af,"The abstract from the paper is the following:"),af.forEach(t),lr=d(o),en=r(o,"P",{});var sf=i(en);pa=r(sf,"EM",{});var rf=i(pa);rl=a(rf,`Pre-training of text and layout has proved effective in a variety of visually-rich document understanding tasks due to
its effective model architecture and the advantage of large-scale unlabeled scanned/digital-born documents. In this
paper, we present LayoutLMv2 by pre-training text, layout and image in a multi-modal framework, where new model
architectures and pre-training tasks are leveraged. Specifically, LayoutLMv2 not only uses the existing masked
visual-language modeling task but also the new text-image alignment and text-image matching tasks in the pre-training
stage, where cross-modality interaction is better learned. Meanwhile, it also integrates a spatial-aware self-attention
mechanism into the Transformer architecture, so that the model can fully understand the relative positional
relationship among different text blocks. Experiment results show that LayoutLMv2 outperforms strong baselines and
achieves new state-of-the-art results on a wide variety of downstream visually-rich document understanding tasks,
including FUNSD (0.7895 -> 0.8420), CORD (0.9493 -> 0.9601), SROIE (0.9524 -> 0.9781), Kleister-NDA (0.834 -> 0.852),
RVL-CDIP (0.9443 -> 0.9564), and DocVQA (0.7295 -> 0.8672). The pre-trained LayoutLMv2 model is publicly available at
this https URL.`),rf.forEach(t),sf.forEach(t),cr=d(o),on=r(o,"P",{});var lf=i(on);il=a(lf,"Tips:"),lf.forEach(t),dr=d(o),B=r(o,"UL",{});var ye=i(B);ua=r(ye,"LI",{});var cf=i(ua);ll=a(cf,`The main difference between LayoutLMv1 and LayoutLMv2 is that the latter incorporates visual embeddings during
pre-training (while LayoutLMv1 only adds visual embeddings during fine-tuning).`),cf.forEach(t),cl=d(ye),qo=r(ye,"LI",{});var ri=i(qo);dl=a(ri,`LayoutLMv2 adds both a relative 1D attention bias as well as a spatial 2D attention bias to the attention scores in
the self-attention layers. Details can be found on page 5 of the `),Fo=r(ri,"A",{href:!0,rel:!0});var df=i(Fo);pl=a(df,"paper"),df.forEach(t),ul=a(ri,"."),ri.forEach(t),hl=d(ye),Po=r(ye,"LI",{});var ii=i(Po);ml=a(ii,"Demo notebooks on how to use the LayoutLMv2 model on RVL-CDIP, FUNSD, DocVQA, CORD can be found "),jo=r(ii,"A",{href:!0,rel:!0});var pf=i(jo);fl=a(pf,"here"),pf.forEach(t),gl=a(ii,"."),ii.forEach(t),_l=d(ye),qe=r(ye,"LI",{});var Yn=i(qe);vl=a(Yn,"LayoutLMv2 uses Facebook AI\u2019s "),Co=r(Yn,"A",{href:!0,rel:!0});var uf=i(Co);yl=a(uf,"Detectron2"),uf.forEach(t),bl=a(Yn,` package for its visual
backbone. See `),Io=r(Yn,"A",{href:!0,rel:!0});var hf=i(Io);Ll=a(hf,"this link"),hf.forEach(t),wl=a(Yn,` for installation
instructions.`),Yn.forEach(t),kl=d(ye),k=r(ye,"LI",{});var E=i(k);xl=a(E,"In addition to "),ha=r(E,"CODE",{});var mf=i(ha);Tl=a(mf,"input_ids"),mf.forEach(t),Ml=a(E,", "),tn=r(E,"A",{href:!0});var ff=i(tn);El=a(ff,"forward()"),ff.forEach(t),zl=a(E,` expects 2 additional inputs, namely
`),ma=r(E,"CODE",{});var gf=i(ma);$l=a(gf,"image"),gf.forEach(t),ql=a(E," and "),fa=r(E,"CODE",{});var _f=i(fa);Fl=a(_f,"bbox"),_f.forEach(t),Pl=a(E,". The "),ga=r(E,"CODE",{});var vf=i(ga);jl=a(vf,"image"),vf.forEach(t),Cl=a(E,` input corresponds to the original document image in which the text
tokens occur. The model expects each document image to be of size 224x224. This means that if you have a batch of
document images, `),_a=r(E,"CODE",{});var yf=i(_a);Il=a(yf,"image"),yf.forEach(t),Al=a(E,` should be a tensor of shape (batch_size, 3, 224, 224). This can be either a
`),va=r(E,"CODE",{});var bf=i(va);Ol=a(bf,"torch.Tensor"),bf.forEach(t),Dl=a(E," or a "),ya=r(E,"CODE",{});var Lf=i(ya);Nl=a(Lf,"Detectron2.structures.ImageList"),Lf.forEach(t),Sl=a(E,`. You don\u2019t need to normalize the channels, as this is
done by the model. Important to note is that the visual backbone expects BGR channels instead of RGB, as all models
in Detectron2 are pre-trained using the BGR format. The `),ba=r(E,"CODE",{});var wf=i(ba);Rl=a(wf,"bbox"),wf.forEach(t),Ul=a(E,` input are the bounding boxes (i.e. 2D-positions)
of the input text tokens. This is identical to `),nn=r(E,"A",{href:!0});var kf=i(nn);Bl=a(kf,"LayoutLMModel"),kf.forEach(t),Wl=a(E,`. These can be obtained using an
external OCR engine such as Google\u2019s `),Ao=r(E,"A",{href:!0,rel:!0});var xf=i(Ao);Vl=a(xf,"Tesseract"),xf.forEach(t),Ql=a(E," (there\u2019s a "),Oo=r(E,"A",{href:!0,rel:!0});var Tf=i(Oo);Gl=a(Tf,`Python
wrapper`),Tf.forEach(t),Hl=a(E,` available). Each bounding box should be in (x0, y0, x1, y1)
format, where (x0, y0) corresponds to the position of the upper left corner in the bounding box, and (x1, y1)
represents the position of the lower right corner. Note that one first needs to normalize the bounding boxes to be on
a 0-1000 scale. To normalize, you can use the following function:`),E.forEach(t),ye.forEach(t),pr=d(o),m(Do.$$.fragment,o),ur=d(o),me=r(o,"P",{});var Zn=i(me);Kl=a(Zn,"Here, "),La=r(Zn,"CODE",{});var Mf=i(La);Xl=a(Mf,"width"),Mf.forEach(t),Yl=a(Zn," and "),wa=r(Zn,"CODE",{});var Ef=i(wa);Zl=a(Ef,"height"),Ef.forEach(t),Jl=a(Zn,` correspond to the width and height of the original document in which the token
occurs (before resizing the image). Those can be obtained using the Python Image Library (PIL) library for example, as
follows:`),Zn.forEach(t),hr=d(o),m(No.$$.fragment,o),mr=d(o),He=r(o,"P",{});var li=i(He);ec=a(li,"However, this model includes a brand new "),an=r(li,"A",{href:!0});var zf=i(an);oc=a(zf,"LayoutLMv2Processor"),zf.forEach(t),tc=a(li,` which can be used to directly
prepare data for the model (including applying OCR under the hood). More information can be found in the \u201CUsage\u201D
section below.`),li.forEach(t),fr=d(o),fe=r(o,"UL",{});var Jn=i(fe);C=r(Jn,"LI",{});var N=i(C);nc=a(N,"Internally, "),sn=r(N,"A",{href:!0});var $f=i(sn);ac=a($f,"LayoutLMv2Model"),$f.forEach(t),sc=a(N," will send the "),ka=r(N,"CODE",{});var qf=i(ka);rc=a(qf,"image"),qf.forEach(t),ic=a(N,` input through its visual backbone to
obtain a lower-resolution feature map, whose shape is equal to the `),xa=r(N,"CODE",{});var Ff=i(xa);lc=a(Ff,"image_feature_pool_shape"),Ff.forEach(t),cc=a(N,` attribute of
`),rn=r(N,"A",{href:!0});var Pf=i(rn);dc=a(Pf,"LayoutLMv2Config"),Pf.forEach(t),pc=a(N,`. This feature map is then flattened to obtain a sequence of image tokens. As
the size of the feature map is 7x7 by default, one obtains 49 image tokens. These are then concatenated with the text
tokens, and send through the Transformer encoder. This means that the last hidden states of the model will have a
length of 512 + 49 = 561, if you pad the text tokens up to the max length. More generally, the last hidden states
will have a shape of `),Ta=r(N,"CODE",{});var jf=i(Ta);uc=a(jf,"seq_length"),jf.forEach(t),hc=a(N," + "),Ma=r(N,"CODE",{});var Cf=i(Ma);mc=a(Cf,"image_feature_pool_shape[0]"),Cf.forEach(t),fc=a(N,` *
`),Ea=r(N,"CODE",{});var If=i(Ea);gc=a(If,"config.image_feature_pool_shape[1]"),If.forEach(t),_c=a(N,"."),N.forEach(t),vc=d(Jn),So=r(Jn,"LI",{});var ci=i(So);yc=a(ci,"When calling "),ln=r(ci,"A",{href:!0});var Af=i(ln);bc=a(Af,"from_pretrained()"),Af.forEach(t),Lc=a(ci,`, a warning will be printed with a long list of
parameter names that are not initialized. This is not a problem, as these parameters are batch normalization
statistics, which are going to have values when fine-tuning on a custom dataset.`),ci.forEach(t),wc=d(Jn),Ro=r(Jn,"LI",{});var di=i(Ro);kc=a(di,"If you want to train the model in a distributed environment, make sure to call "),za=r(di,"CODE",{});var Of=i(za);xc=a(Of,"synchronize_batch_norm"),Of.forEach(t),Tc=a(di,` on the
model in order to properly synchronize the batch normalization layers of the visual backbone.`),di.forEach(t),Jn.forEach(t),gr=d(o),Ke=r(o,"P",{});var pi=i(Ke);Mc=a(pi,`In addition, there\u2019s LayoutXLM, which is a multilingual version of LayoutLMv2. More information can be found on
`),cn=r(pi,"A",{href:!0});var Df=i(cn);Ec=a(Df,"LayoutXLM\u2019s documentation page"),Df.forEach(t),zc=a(pi,"."),pi.forEach(t),_r=d(o),Fe=r(o,"H2",{class:!0});var ui=i(Fe);Xe=r(ui,"A",{id:!0,class:!0,href:!0});var Nf=i(Xe);$a=r(Nf,"SPAN",{});var Sf=i($a);m(Uo.$$.fragment,Sf),Sf.forEach(t),Nf.forEach(t),$c=d(ui),qa=r(ui,"SPAN",{});var Rf=i(qa);qc=a(Rf,"Usage: LayoutLMv2Processor"),Rf.forEach(t),ui.forEach(t),vr=d(o),W=r(o,"P",{});var be=i(W);Fc=a(be,"The easiest way to prepare data for the model is to use "),dn=r(be,"A",{href:!0});var Uf=i(dn);Pc=a(Uf,"LayoutLMv2Processor"),Uf.forEach(t),jc=a(be,`, which internally
combines a feature extractor (`),pn=r(be,"A",{href:!0});var Bf=i(pn);Cc=a(Bf,"LayoutLMv2FeatureExtractor"),Bf.forEach(t),Ic=a(be,`) and a tokenizer
(`),un=r(be,"A",{href:!0});var Wf=i(un);Ac=a(Wf,"LayoutLMv2Tokenizer"),Wf.forEach(t),Oc=a(be," or "),hn=r(be,"A",{href:!0});var Vf=i(hn);Dc=a(Vf,"LayoutLMv2TokenizerFast"),Vf.forEach(t),Nc=a(be,`). The feature extractor
handles the image modality, while the tokenizer handles the text modality. A processor combines both, which is ideal
for a multi-modal model like LayoutLMv2. Note that you can still use both separately, if you only want to handle one
modality.`),be.forEach(t),yr=d(o),m(Bo.$$.fragment,o),br=d(o),M=r(o,"P",{});var F=i(M);Sc=a(F,"In short, one can provide a document image (and possibly additional data) to "),mn=r(F,"A",{href:!0});var Qf=i(mn);Rc=a(Qf,"LayoutLMv2Processor"),Qf.forEach(t),Uc=a(F,`,
and it will create the inputs expected by the model. Internally, the processor first uses
`),fn=r(F,"A",{href:!0});var Gf=i(fn);Bc=a(Gf,"LayoutLMv2FeatureExtractor"),Gf.forEach(t),Wc=a(F,` to apply OCR on the image to get a list of words and normalized
bounding boxes, as well to resize the image to a given size in order to get the `),Fa=r(F,"CODE",{});var Hf=i(Fa);Vc=a(Hf,"image"),Hf.forEach(t),Qc=a(F,` input. The words and
normalized bounding boxes are then provided to `),gn=r(F,"A",{href:!0});var Kf=i(gn);Gc=a(Kf,"LayoutLMv2Tokenizer"),Kf.forEach(t),Hc=a(F,` or
`),_n=r(F,"A",{href:!0});var Xf=i(_n);Kc=a(Xf,"LayoutLMv2TokenizerFast"),Xf.forEach(t),Xc=a(F,", which converts them to token-level "),Pa=r(F,"CODE",{});var Yf=i(Pa);Yc=a(Yf,"input_ids"),Yf.forEach(t),Zc=a(F,`,
`),ja=r(F,"CODE",{});var Zf=i(ja);Jc=a(Zf,"attention_mask"),Zf.forEach(t),ed=a(F,", "),Ca=r(F,"CODE",{});var Jf=i(Ca);od=a(Jf,"token_type_ids"),Jf.forEach(t),td=a(F,", "),Ia=r(F,"CODE",{});var eg=i(Ia);nd=a(eg,"bbox"),eg.forEach(t),ad=a(F,`. Optionally, one can provide word labels to the processor,
which are turned into token-level `),Aa=r(F,"CODE",{});var og=i(Aa);sd=a(og,"labels"),og.forEach(t),rd=a(F,"."),F.forEach(t),Lr=d(o),S=r(o,"P",{});var pe=i(S);vn=r(pe,"A",{href:!0});var tg=i(vn);id=a(tg,"LayoutLMv2Processor"),tg.forEach(t),ld=a(pe," uses "),Wo=r(pe,"A",{href:!0,rel:!0});var ng=i(Wo);cd=a(ng,"PyTesseract"),ng.forEach(t),dd=a(pe,`, a Python
wrapper around Google\u2019s Tesseract OCR engine, under the hood. Note that you can still use your own OCR engine of
choice, and provide the words and normalized boxes yourself. This requires initializing
`),yn=r(pe,"A",{href:!0});var ag=i(yn);pd=a(ag,"LayoutLMv2FeatureExtractor"),ag.forEach(t),ud=a(pe," with "),Oa=r(pe,"CODE",{});var sg=i(Oa);hd=a(sg,"apply_ocr"),sg.forEach(t),md=a(pe," set to "),Da=r(pe,"CODE",{});var rg=i(Da);fd=a(rg,"False"),rg.forEach(t),gd=a(pe,"."),pe.forEach(t),wr=d(o),bn=r(o,"P",{});var ig=i(bn);_d=a(ig,`In total, there are 5 use cases that are supported by the processor. Below, we list them all. Note that each of these
use cases work for both batched and non-batched inputs (we illustrate them for non-batched inputs).`),ig.forEach(t),kr=d(o),Ln=r(o,"P",{});var lg=i(Ln);Na=r(lg,"STRONG",{});var cg=i(Na);vd=a(cg,`Use case 1: document image classification (training, inference) + token classification (inference), apply_ocr =
True`),cg.forEach(t),lg.forEach(t),xr=d(o),wn=r(o,"P",{});var dg=i(wn);yd=a(dg,`This is the simplest case, in which the processor (actually the feature extractor) will perform OCR on the image to get
the words and normalized bounding boxes.`),dg.forEach(t),Tr=d(o),m(Vo.$$.fragment,o),Mr=d(o),kn=r(o,"P",{});var pg=i(kn);Sa=r(pg,"STRONG",{});var ug=i(Sa);bd=a(ug,"Use case 2: document image classification (training, inference) + token classification (inference), apply_ocr=False"),ug.forEach(t),pg.forEach(t),Er=d(o),ge=r(o,"P",{});var ea=i(ge);Ld=a(ea,"In case one wants to do OCR themselves, one can initialize the feature extractor with "),Ra=r(ea,"CODE",{});var hg=i(Ra);wd=a(hg,"apply_ocr"),hg.forEach(t),kd=a(ea,` set to
`),Ua=r(ea,"CODE",{});var mg=i(Ua);xd=a(mg,"False"),mg.forEach(t),Td=a(ea,`. In that case, one should provide the words and corresponding (normalized) bounding boxes themselves to
the processor.`),ea.forEach(t),zr=d(o),m(Qo.$$.fragment,o),$r=d(o),xn=r(o,"P",{});var fg=i(xn);Ba=r(fg,"STRONG",{});var gg=i(Ba);Md=a(gg,"Use case 3: token classification (training), apply_ocr=False"),gg.forEach(t),fg.forEach(t),qr=d(o),V=r(o,"P",{});var Le=i(V);Ed=a(Le,`For token classification tasks (such as FUNSD, CORD, SROIE, Kleister-NDA), one can also provide the corresponding word
labels in order to train a model. The processor will then convert these into token-level `),Wa=r(Le,"CODE",{});var _g=i(Wa);zd=a(_g,"labels"),_g.forEach(t),$d=a(Le,`. By default, it
will only label the first wordpiece of a word, and label the remaining wordpieces with -100, which is the
`),Va=r(Le,"CODE",{});var vg=i(Va);qd=a(vg,"ignore_index"),vg.forEach(t),Fd=a(Le,` of PyTorch\u2019s CrossEntropyLoss. In case you want all wordpieces of a word to be labeled, you can
initialize the tokenizer with `),Qa=r(Le,"CODE",{});var yg=i(Qa);Pd=a(yg,"only_label_first_subword"),yg.forEach(t),jd=a(Le," set to "),Ga=r(Le,"CODE",{});var bg=i(Ga);Cd=a(bg,"False"),bg.forEach(t),Id=a(Le,"."),Le.forEach(t),Fr=d(o),m(Go.$$.fragment,o),Pr=d(o),Tn=r(o,"P",{});var Lg=i(Tn);Ha=r(Lg,"STRONG",{});var wg=i(Ha);Ad=a(wg,"Use case 4: visual question answering (inference), apply_ocr=True"),wg.forEach(t),Lg.forEach(t),jr=d(o),Mn=r(o,"P",{});var kg=i(Mn);Od=a(kg,`For visual question answering tasks (such as DocVQA), you can provide a question to the processor. By default, the
processor will apply OCR on the image, and create [CLS] question tokens [SEP] word tokens [SEP].`),kg.forEach(t),Cr=d(o),m(Ho.$$.fragment,o),Ir=d(o),En=r(o,"P",{});var xg=i(En);Ka=r(xg,"STRONG",{});var Tg=i(Ka);Dd=a(Tg,"Use case 5: visual question answering (inference), apply_ocr=False"),Tg.forEach(t),xg.forEach(t),Ar=d(o),zn=r(o,"P",{});var Mg=i(zn);Nd=a(Mg,`For visual question answering tasks (such as DocVQA), you can provide a question to the processor. If you want to
perform OCR yourself, you can provide your own words and (normalized) bounding boxes to the processor.`),Mg.forEach(t),Or=d(o),m(Ko.$$.fragment,o),Dr=d(o),Pe=r(o,"H2",{class:!0});var hi=i(Pe);Ye=r(hi,"A",{id:!0,class:!0,href:!0});var Eg=i(Ye);Xa=r(Eg,"SPAN",{});var zg=i(Xa);m(Xo.$$.fragment,zg),zg.forEach(t),Eg.forEach(t),Sd=d(hi),Ya=r(hi,"SPAN",{});var $g=i(Ya);Rd=a($g,"LayoutLMv2Config"),$g.forEach(t),hi.forEach(t),Nr=d(o),R=r(o,"DIV",{class:!0});var we=i(R);m(Yo.$$.fragment,we),Ud=d(we),je=r(we,"P",{});var oa=i(je);Bd=a(oa,"This is the configuration class to store the configuration of a "),$n=r(oa,"A",{href:!0});var qg=i($n);Wd=a(qg,"LayoutLMv2Model"),qg.forEach(t),Vd=a(oa,`. It is used to instantiate an
LayoutLMv2 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 LayoutLMv2
`),Zo=r(oa,"A",{href:!0,rel:!0});var Fg=i(Zo);Qd=a(Fg,"microsoft/layoutlmv2-base-uncased"),Fg.forEach(t),Gd=a(oa," architecture."),oa.forEach(t),Hd=d(we),Ce=r(we,"P",{});var ta=i(Ce);Kd=a(ta,"Configuration objects inherit from "),qn=r(ta,"A",{href:!0});var Pg=i(qn);Xd=a(Pg,"PretrainedConfig"),Pg.forEach(t),Yd=a(ta,` and can be used to control the model outputs. Read the
documentation from `),Fn=r(ta,"A",{href:!0});var jg=i(Fn);Zd=a(jg,"PretrainedConfig"),jg.forEach(t),Jd=a(ta," for more information."),ta.forEach(t),ep=d(we),Za=r(we,"P",{});var Cg=i(Za);op=a(Cg,"Example:"),Cg.forEach(t),tp=d(we),m(Jo.$$.fragment,we),we.forEach(t),Sr=d(o),Ie=r(o,"H2",{class:!0});var mi=i(Ie);Ze=r(mi,"A",{id:!0,class:!0,href:!0});var Ig=i(Ze);Ja=r(Ig,"SPAN",{});var Ag=i(Ja);m(et.$$.fragment,Ag),Ag.forEach(t),Ig.forEach(t),np=d(mi),es=r(mi,"SPAN",{});var Og=i(es);ap=a(Og,"LayoutLMv2FeatureExtractor"),Og.forEach(t),mi.forEach(t),Rr=d(o),J=r(o,"DIV",{class:!0});var ho=i(J);m(ot.$$.fragment,ho),sp=d(ho),os=r(ho,"P",{});var Dg=i(os);rp=a(Dg,`Constructs a LayoutLMv2 feature extractor. This can be used to resize document images to the same size, as well as
to apply OCR on them in order to get a list of words and normalized bounding boxes.`),Dg.forEach(t),ip=d(ho),tt=r(ho,"P",{});var fi=i(tt);lp=a(fi,"This feature extractor inherits from "),ts=r(fi,"CODE",{});var Ng=i(ts);cp=a(Ng,"PreTrainedFeatureExtractor()"),Ng.forEach(t),dp=a(fi,`which contains most
of the main methods. Users should refer to this superclass for more information regarding those methods.`),fi.forEach(t),pp=d(ho),se=r(ho,"DIV",{class:!0});var mo=i(se);m(nt.$$.fragment,mo),up=d(mo),ns=r(mo,"P",{});var Sg=i(ns);hp=a(Sg,"Main method to prepare for the model one or several image(s)."),Sg.forEach(t),mp=d(mo),as=r(mo,"P",{});var Rg=i(as);fp=a(Rg,"Examples:"),Rg.forEach(t),gp=d(mo),m(at.$$.fragment,mo),mo.forEach(t),ho.forEach(t),Ur=d(o),Ae=r(o,"H2",{class:!0});var gi=i(Ae);Je=r(gi,"A",{id:!0,class:!0,href:!0});var Ug=i(Je);ss=r(Ug,"SPAN",{});var Bg=i(ss);m(st.$$.fragment,Bg),Bg.forEach(t),Ug.forEach(t),_p=d(gi),rs=r(gi,"SPAN",{});var Wg=i(rs);vp=a(Wg,"LayoutLMv2Tokenizer"),Wg.forEach(t),gi.forEach(t),Br=d(o),O=r(o,"DIV",{class:!0});var re=i(O);m(rt.$$.fragment,re),yp=d(re),D=r(re,"P",{});var X=i(D);bp=a(X,"Construct a LayoutLMv2 tokenizer. Based on WordPiece. "),Pn=r(X,"A",{href:!0});var Vg=i(Pn);Lp=a(Vg,"LayoutLMv2Tokenizer"),Vg.forEach(t),wp=a(X,` can be used to turn words, word-level
bounding boxes and optional word labels to token-level `),is=r(X,"CODE",{});var Qg=i(is);kp=a(Qg,"input_ids"),Qg.forEach(t),xp=a(X,", "),ls=r(X,"CODE",{});var Gg=i(ls);Tp=a(Gg,"attention_mask"),Gg.forEach(t),Mp=a(X,", "),cs=r(X,"CODE",{});var Hg=i(cs);Ep=a(Hg,"token_type_ids"),Hg.forEach(t),zp=a(X,", "),ds=r(X,"CODE",{});var Kg=i(ds);$p=a(Kg,"bbox"),Kg.forEach(t),qp=a(X,`, and
optional `),ps=r(X,"CODE",{});var Xg=i(ps);Fp=a(Xg,"labels"),Xg.forEach(t),Pp=a(X," (for token classification)."),X.forEach(t),jp=d(re),it=r(re,"P",{});var _i=i(it);Cp=a(_i,"This tokenizer inherits from "),jn=r(_i,"A",{href:!0});var Yg=i(jn);Ip=a(Yg,"PreTrainedTokenizer"),Yg.forEach(t),Ap=a(_i,` which contains most of the main methods. Users should refer to
this superclass for more information regarding those methods.`),_i.forEach(t),Op=d(re),Cn=r(re,"P",{});var Bm=i(Cn);In=r(Bm,"A",{href:!0});var Zg=i(In);Dp=a(Zg,"LayoutLMv2Tokenizer"),Zg.forEach(t),Np=a(Bm,` runs end-to-end tokenization: punctuation splitting and wordpiece. It also turns the
word-level bounding boxes into token-level bounding boxes.`),Bm.forEach(t),Sp=d(re),eo=r(re,"DIV",{class:!0});var vi=i(eo);m(lt.$$.fragment,vi),Rp=d(vi),us=r(vi,"P",{});var Jg=i(us);Up=a(Jg,`Main method to tokenize and prepare for the model one or several sequence(s) or one or several pair(s) of
sequences with word-level normalized bounding boxes and optional labels.`),Jg.forEach(t),vi.forEach(t),Bp=d(re),An=r(re,"DIV",{class:!0});var e_=i(An);m(ct.$$.fragment,e_),e_.forEach(t),re.forEach(t),Wr=d(o),Oe=r(o,"H2",{class:!0});var yi=i(Oe);oo=r(yi,"A",{id:!0,class:!0,href:!0});var o_=i(oo);hs=r(o_,"SPAN",{});var t_=i(hs);m(dt.$$.fragment,t_),t_.forEach(t),o_.forEach(t),Wp=d(yi),ms=r(yi,"SPAN",{});var n_=i(ms);Vp=a(n_,"LayoutLMv2TokenizerFast"),n_.forEach(t),yi.forEach(t),Vr=d(o),ee=r(o,"DIV",{class:!0});var fo=i(ee);m(pt.$$.fragment,fo),Qp=d(fo),ut=r(fo,"P",{});var bi=i(ut);Gp=a(bi,"Construct a \u201Cfast\u201D LayoutLMv2 tokenizer (backed by HuggingFace\u2019s "),fs=r(bi,"EM",{});var a_=i(fs);Hp=a(a_,"tokenizers"),a_.forEach(t),Kp=a(bi," library). Based on WordPiece."),bi.forEach(t),Xp=d(fo),ht=r(fo,"P",{});var Li=i(ht);Yp=a(Li,"This tokenizer inherits from "),On=r(Li,"A",{href:!0});var s_=i(On);Zp=a(s_,"PreTrainedTokenizerFast"),s_.forEach(t),Jp=a(Li,` which contains most of the main methods. Users should
refer to this superclass for more information regarding those methods.`),Li.forEach(t),eu=d(fo),to=r(fo,"DIV",{class:!0});var wi=i(to);m(mt.$$.fragment,wi),ou=d(wi),gs=r(wi,"P",{});var r_=i(gs);tu=a(r_,`Main method to tokenize and prepare for the model one or several sequence(s) or one or several pair(s) of
sequences with word-level normalized bounding boxes and optional labels.`),r_.forEach(t),wi.forEach(t),fo.forEach(t),Qr=d(o),De=r(o,"H2",{class:!0});var ki=i(De);no=r(ki,"A",{id:!0,class:!0,href:!0});var i_=i(no);_s=r(i_,"SPAN",{});var l_=i(_s);m(ft.$$.fragment,l_),l_.forEach(t),i_.forEach(t),nu=d(ki),vs=r(ki,"SPAN",{});var c_=i(vs);au=a(c_,"LayoutLMv2Processor"),c_.forEach(t),ki.forEach(t),Gr=d(o),U=r(o,"DIV",{class:!0});var ke=i(U);m(gt.$$.fragment,ke),su=d(ke),ys=r(ke,"P",{});var d_=i(ys);ru=a(d_,`Constructs a LayoutLMv2 processor which combines a LayoutLMv2 feature extractor and a LayoutLMv2 tokenizer into a
single processor.`),d_.forEach(t),iu=d(ke),Dn=r(ke,"P",{});var Wm=i(Dn);Nn=r(Wm,"A",{href:!0});var p_=i(Nn);lu=a(p_,"LayoutLMv2Processor"),p_.forEach(t),cu=a(Wm," offers all the functionalities you need to prepare data for the model."),Wm.forEach(t),du=d(ke),$=r(ke,"P",{});var j=i($);pu=a(j,"It first uses "),Sn=r(j,"A",{href:!0});var u_=i(Sn);uu=a(u_,"LayoutLMv2FeatureExtractor"),u_.forEach(t),hu=a(j,` to resize document images to a fixed size, and optionally applies OCR
to get words and normalized bounding boxes. These are then provided to `),Rn=r(j,"A",{href:!0});var h_=i(Rn);mu=a(h_,"LayoutLMv2Tokenizer"),h_.forEach(t),fu=a(j,` or
`),Un=r(j,"A",{href:!0});var m_=i(Un);gu=a(m_,"LayoutLMv2TokenizerFast"),m_.forEach(t),_u=a(j,", which turns the words and bounding boxes into token-level "),bs=r(j,"CODE",{});var f_=i(bs);vu=a(f_,"input_ids"),f_.forEach(t),yu=a(j,`,
`),Ls=r(j,"CODE",{});var g_=i(Ls);bu=a(g_,"attention_mask"),g_.forEach(t),Lu=a(j,", "),ws=r(j,"CODE",{});var __=i(ws);wu=a(__,"token_type_ids"),__.forEach(t),ku=a(j,", "),ks=r(j,"CODE",{});var v_=i(ks);xu=a(v_,"bbox"),v_.forEach(t),Tu=a(j,". Optionally, one can provide integer "),xs=r(j,"CODE",{});var y_=i(xs);Mu=a(y_,"word_labels"),y_.forEach(t),Eu=a(j,`, which are turned
into token-level `),Ts=r(j,"CODE",{});var b_=i(Ts);zu=a(b_,"labels"),b_.forEach(t),$u=a(j," for token classification tasks (such as FUNSD, CORD)."),j.forEach(t),qu=d(ke),_e=r(ke,"DIV",{class:!0});var na=i(_e);m(_t.$$.fragment,na),Fu=d(na),x=r(na,"P",{});var z=i(x);Pu=a(z,"This method first forwards the "),Ms=r(z,"CODE",{});var L_=i(Ms);ju=a(L_,"images"),L_.forEach(t),Cu=a(z," argument to "),vt=r(z,"A",{href:!0});var Vm=i(vt);Es=r(Vm,"STRONG",{});var w_=i(Es);Iu=a(w_,"call"),w_.forEach(t),Au=a(Vm,"()"),Vm.forEach(t),Ou=a(z,`. In case
`),Bn=r(z,"A",{href:!0});var k_=i(Bn);Du=a(k_,"LayoutLMv2FeatureExtractor"),k_.forEach(t),Nu=a(z," was initialized with "),zs=r(z,"CODE",{});var x_=i(zs);Su=a(x_,"apply_ocr"),x_.forEach(t),Ru=a(z," set to "),$s=r(z,"CODE",{});var T_=i($s);Uu=a(T_,"True"),T_.forEach(t),Bu=a(z,`, it passes the obtained words and
bounding boxes along with the additional arguments to `),yt=r(z,"A",{href:!0});var Qm=i(yt);qs=r(Qm,"STRONG",{});var M_=i(qs);Wu=a(M_,"call"),M_.forEach(t),Vu=a(Qm,"()"),Qm.forEach(t),Qu=a(z,` and returns the output,
together with resized `),Fs=r(z,"CODE",{});var E_=i(Fs);Gu=a(E_,"images"),E_.forEach(t),Hu=a(z,". In case "),Wn=r(z,"A",{href:!0});var z_=i(Wn);Ku=a(z_,"LayoutLMv2FeatureExtractor"),z_.forEach(t),Xu=a(z," was initialized with "),Ps=r(z,"CODE",{});var $_=i(Ps);Yu=a($_,"apply_ocr"),$_.forEach(t),Zu=a(z,` set to
`),js=r(z,"CODE",{});var q_=i(js);Ju=a(q_,"False"),q_.forEach(t),eh=a(z,", it passes the words ("),Cs=r(z,"CODE",{});var F_=i(Cs);oh=a(F_,"text"),F_.forEach(t),th=a(z,"/"),Is=r(z,"CODE",{});var P_=i(Is);nh=a(P_,"text_pair`) and `boxes` specified by the user along with the additional arguments to [__call__()](/docs/transformers/pr_15839/en/model_doc/layoutlmv2#transformers.LayoutLMv2Tokenizer.__call__) and returns the output, together with resized `images"),P_.forEach(t),ah=a(z,"."),z.forEach(t),sh=d(na),As=r(na,"P",{});var j_=i(As);rh=a(j_,"Please refer to the docstring of the above two methods for more information."),j_.forEach(t),na.forEach(t),ke.forEach(t),Hr=d(o),Ne=r(o,"H2",{class:!0});var xi=i(Ne);ao=r(xi,"A",{id:!0,class:!0,href:!0});var C_=i(ao);Os=r(C_,"SPAN",{});var I_=i(Os);m(bt.$$.fragment,I_),I_.forEach(t),C_.forEach(t),ih=d(xi),Ds=r(xi,"SPAN",{});var A_=i(Ds);lh=a(A_,"LayoutLMv2Model"),A_.forEach(t),xi.forEach(t),Kr=d(o),ce=r(o,"DIV",{class:!0});var aa=i(ce);m(Lt.$$.fragment,aa),ch=d(aa),wt=r(aa,"P",{});var Ti=i(wt);dh=a(Ti,`The bare LayoutLMv2 Model transformer outputting raw hidden-states without any specific head on top.
This model is a PyTorch `),kt=r(Ti,"A",{href:!0,rel:!0});var O_=i(kt);ph=a(O_,"torch.nn.Module"),O_.forEach(t),uh=a(Ti,` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Ti.forEach(t),hh=d(aa),Q=r(aa,"DIV",{class:!0});var xe=i(Q);m(xt.$$.fragment,xe),mh=d(xe),Se=r(xe,"P",{});var sa=i(Se);fh=a(sa,"The "),Vn=r(sa,"A",{href:!0});var D_=i(Vn);gh=a(D_,"LayoutLMv2Model"),D_.forEach(t),_h=a(sa," forward method, overrides the "),Ns=r(sa,"CODE",{});var N_=i(Ns);vh=a(N_,"__call__"),N_.forEach(t),yh=a(sa," special method."),sa.forEach(t),bh=d(xe),m(so.$$.fragment,xe),Lh=d(xe),Ss=r(xe,"P",{});var S_=i(Ss);wh=a(S_,"Examples:"),S_.forEach(t),kh=d(xe),m(Tt.$$.fragment,xe),xe.forEach(t),aa.forEach(t),Xr=d(o),Re=r(o,"H2",{class:!0});var Mi=i(Re);ro=r(Mi,"A",{id:!0,class:!0,href:!0});var R_=i(ro);Rs=r(R_,"SPAN",{});var U_=i(Rs);m(Mt.$$.fragment,U_),U_.forEach(t),R_.forEach(t),xh=d(Mi),Us=r(Mi,"SPAN",{});var B_=i(Us);Th=a(B_,"LayoutLMv2ForSequenceClassification"),B_.forEach(t),Mi.forEach(t),Yr=d(o),oe=r(o,"DIV",{class:!0});var go=i(oe);m(Et.$$.fragment,go),Mh=d(go),zt=r(go,"P",{});var Ei=i(zt);Eh=a(Ei,`LayoutLMv2 Model with a sequence classification head on top (a linear layer on top of the concatenation of the
final hidden state of the [CLS] token, average-pooled initial visual embeddings and average-pooled final visual
embeddings, e.g. for document image classification tasks such as the
`),$t=r(Ei,"A",{href:!0,rel:!0});var W_=i($t);zh=a(W_,"RVL-CDIP"),W_.forEach(t),$h=a(Ei," dataset."),Ei.forEach(t),qh=d(go),qt=r(go,"P",{});var zi=i(qt);Fh=a(zi,"This model is a PyTorch "),Ft=r(zi,"A",{href:!0,rel:!0});var V_=i(Ft);Ph=a(V_,"torch.nn.Module"),V_.forEach(t),jh=a(zi,` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),zi.forEach(t),Ch=d(go),G=r(go,"DIV",{class:!0});var Te=i(G);m(Pt.$$.fragment,Te),Ih=d(Te),Ue=r(Te,"P",{});var ra=i(Ue);Ah=a(ra,"The "),Qn=r(ra,"A",{href:!0});var Q_=i(Qn);Oh=a(Q_,"LayoutLMv2ForSequenceClassification"),Q_.forEach(t),Dh=a(ra," forward method, overrides the "),Bs=r(ra,"CODE",{});var G_=i(Bs);Nh=a(G_,"__call__"),G_.forEach(t),Sh=a(ra," special method."),ra.forEach(t),Rh=d(Te),m(io.$$.fragment,Te),Uh=d(Te),Ws=r(Te,"P",{});var H_=i(Ws);Bh=a(H_,"Examples:"),H_.forEach(t),Wh=d(Te),m(jt.$$.fragment,Te),Te.forEach(t),go.forEach(t),Zr=d(o),Be=r(o,"H2",{class:!0});var $i=i(Be);lo=r($i,"A",{id:!0,class:!0,href:!0});var K_=i(lo);Vs=r(K_,"SPAN",{});var X_=i(Vs);m(Ct.$$.fragment,X_),X_.forEach(t),K_.forEach(t),Vh=d($i),Qs=r($i,"SPAN",{});var Y_=i(Qs);Qh=a(Y_,"LayoutLMv2ForTokenClassification"),Y_.forEach(t),$i.forEach(t),Jr=d(o),te=r(o,"DIV",{class:!0});var _o=i(te);m(It.$$.fragment,_o),Gh=d(_o),ne=r(_o,"P",{});var Me=i(ne);Hh=a(Me,`LayoutLMv2 Model with a token classification head on top (a linear layer on top of the text part of the hidden
states) e.g. for sequence labeling (information extraction) tasks such as
`),At=r(Me,"A",{href:!0,rel:!0});var Z_=i(At);Kh=a(Z_,"FUNSD"),Z_.forEach(t),Xh=a(Me,", "),Ot=r(Me,"A",{href:!0,rel:!0});var J_=i(Ot);Yh=a(J_,"SROIE"),J_.forEach(t),Zh=a(Me,`,
`),Dt=r(Me,"A",{href:!0,rel:!0});var ev=i(Dt);Jh=a(ev,"CORD"),ev.forEach(t),em=a(Me," and "),Nt=r(Me,"A",{href:!0,rel:!0});var ov=i(Nt);om=a(ov,"Kleister-NDA"),ov.forEach(t),tm=a(Me,"."),Me.forEach(t),nm=d(_o),St=r(_o,"P",{});var qi=i(St);am=a(qi,"This model is a PyTorch "),Rt=r(qi,"A",{href:!0,rel:!0});var tv=i(Rt);sm=a(tv,"torch.nn.Module"),tv.forEach(t),rm=a(qi,` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),qi.forEach(t),im=d(_o),H=r(_o,"DIV",{class:!0});var Ee=i(H);m(Ut.$$.fragment,Ee),lm=d(Ee),We=r(Ee,"P",{});var ia=i(We);cm=a(ia,"The "),Gn=r(ia,"A",{href:!0});var nv=i(Gn);dm=a(nv,"LayoutLMv2ForTokenClassification"),nv.forEach(t),pm=a(ia," forward method, overrides the "),Gs=r(ia,"CODE",{});var av=i(Gs);um=a(av,"__call__"),av.forEach(t),hm=a(ia," special method."),ia.forEach(t),mm=d(Ee),m(co.$$.fragment,Ee),fm=d(Ee),Hs=r(Ee,"P",{});var sv=i(Hs);gm=a(sv,"Examples:"),sv.forEach(t),_m=d(Ee),m(Bt.$$.fragment,Ee),Ee.forEach(t),_o.forEach(t),ei=d(o),Ve=r(o,"H2",{class:!0});var Fi=i(Ve);po=r(Fi,"A",{id:!0,class:!0,href:!0});var rv=i(po);Ks=r(rv,"SPAN",{});var iv=i(Ks);m(Wt.$$.fragment,iv),iv.forEach(t),rv.forEach(t),vm=d(Fi),Xs=r(Fi,"SPAN",{});var lv=i(Xs);ym=a(lv,"LayoutLMv2ForQuestionAnswering"),lv.forEach(t),Fi.forEach(t),oi=d(o),ae=r(o,"DIV",{class:!0});var vo=i(ae);m(Vt.$$.fragment,vo),bm=d(vo),de=r(vo,"P",{});var yo=i(de);Lm=a(yo,`LayoutLMv2 Model with a span classification head on top for extractive question-answering tasks such as
`),Qt=r(yo,"A",{href:!0,rel:!0});var cv=i(Qt);wm=a(cv,"DocVQA"),cv.forEach(t),km=a(yo,` (a linear layer on top of the text part of the hidden-states output to
compute `),Ys=r(yo,"CODE",{});var dv=i(Ys);xm=a(dv,"span start logits"),dv.forEach(t),Tm=a(yo," and "),Zs=r(yo,"CODE",{});var pv=i(Zs);Mm=a(pv,"span end logits"),pv.forEach(t),Em=a(yo,")."),yo.forEach(t),zm=d(vo),Gt=r(vo,"P",{});var Pi=i(Gt);$m=a(Pi,"This model is a PyTorch "),Ht=r(Pi,"A",{href:!0,rel:!0});var uv=i(Ht);qm=a(uv,"torch.nn.Module"),uv.forEach(t),Fm=a(Pi,` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Pi.forEach(t),Pm=d(vo),K=r(vo,"DIV",{class:!0});var ze=i(K);m(Kt.$$.fragment,ze),jm=d(ze),Qe=r(ze,"P",{});var la=i(Qe);Cm=a(la,"The "),Hn=r(la,"A",{href:!0});var hv=i(Hn);Im=a(hv,"LayoutLMv2ForQuestionAnswering"),hv.forEach(t),Am=a(la," forward method, overrides the "),Js=r(la,"CODE",{});var mv=i(Js);Om=a(mv,"__call__"),mv.forEach(t),Dm=a(la," special method."),la.forEach(t),Nm=d(ze),m(uo.$$.fragment,ze),Sm=d(ze),er=r(ze,"P",{});var fv=i(er);Rm=a(fv,"Examples:"),fv.forEach(t),Um=d(ze),m(Xt.$$.fragment,ze),ze.forEach(t),vo.forEach(t),this.h()},h(){l(y,"name","hf:doc:metadata"),l(y,"content",JSON.stringify(Tv)),l(T,"id","layoutlmv2"),l(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"),l(T,"href","#layoutlmv2"),l(b,"class","relative group"),l(Ge,"id","overview"),l(Ge,"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"),l(Ge,"href","#overview"),l($e,"class","relative group"),l(Lo,"href","https://arxiv.org/abs/2012.14740"),l(Lo,"rel","nofollow"),l(Zt,"href","layoutlm"),l(wo,"href","https://guillaumejaume.github.io/FUNSD/"),l(wo,"rel","nofollow"),l(ko,"href","https://github.com/clovaai/cord"),l(ko,"rel","nofollow"),l(xo,"href","https://rrc.cvc.uab.es/?ch=13"),l(xo,"rel","nofollow"),l(To,"href","https://github.com/applicaai/kleister-nda"),l(To,"rel","nofollow"),l(Eo,"href","https://www.cs.cmu.edu/~aharley/rvl-cdip/"),l(Eo,"rel","nofollow"),l($o,"href","https://arxiv.org/abs/2007.00398"),l($o,"rel","nofollow"),l(Fo,"href","https://arxiv.org/abs/2012.14740"),l(Fo,"rel","nofollow"),l(jo,"href","https://github.com/NielsRogge/Transformers-Tutorials"),l(jo,"rel","nofollow"),l(Co,"href","https://github.com/facebookresearch/detectron2/"),l(Co,"rel","nofollow"),l(Io,"href","https://detectron2.readthedocs.io/en/latest/tutorials/install.html"),l(Io,"rel","nofollow"),l(tn,"href","/docs/transformers/pr_15839/en/model_doc/layoutlmv2#transformers.LayoutLMv2Model.forward"),l(nn,"href","/docs/transformers/pr_15839/en/model_doc/layoutlm#transformers.LayoutLMModel"),l(Ao,"href","https://github.com/tesseract-ocr/tesseract"),l(Ao,"rel","nofollow"),l(Oo,"href","https://pypi.org/project/pytesseract/"),l(Oo,"rel","nofollow"),l(an,"href","/docs/transformers/pr_15839/en/model_doc/layoutlmv2#transformers.LayoutLMv2Processor"),l(sn,"href","/docs/transformers/pr_15839/en/model_doc/layoutlmv2#transformers.LayoutLMv2Model"),l(rn,"href","/docs/transformers/pr_15839/en/model_doc/layoutlmv2#transformers.LayoutLMv2Config"),l(ln,"href","/docs/transformers/pr_15839/en/main_classes/model#transformers.PreTrainedModel.from_pretrained"),l(cn,"href","layoutxlm"),l(Xe,"id","usage-layoutlmv2processor"),l(Xe,"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"),l(Xe,"href","#usage-layoutlmv2processor"),l(Fe,"class","relative group"),l(dn,"href","/docs/transformers/pr_15839/en/model_doc/layoutlmv2#transformers.LayoutLMv2Processor"),l(pn,"href","/docs/transformers/pr_15839/en/model_doc/layoutlmv2#transformers.LayoutLMv2FeatureExtractor"),l(un,"href","/docs/transformers/pr_15839/en/model_doc/layoutlmv2#transformers.LayoutLMv2Tokenizer"),l(hn,"href","/docs/transformers/pr_15839/en/model_doc/layoutlmv2#transformers.LayoutLMv2TokenizerFast"),l(mn,"href","/docs/transformers/pr_15839/en/model_doc/layoutlmv2#transformers.LayoutLMv2Processor"),l(fn,"href","/docs/transformers/pr_15839/en/model_doc/layoutlmv2#transformers.LayoutLMv2FeatureExtractor"),l(gn,"href","/docs/transformers/pr_15839/en/model_doc/layoutlmv2#transformers.LayoutLMv2Tokenizer"),l(_n,"href","/docs/transformers/pr_15839/en/model_doc/layoutlmv2#transformers.LayoutLMv2TokenizerFast"),l(vn,"href","/docs/transformers/pr_15839/en/model_doc/layoutlmv2#transformers.LayoutLMv2Processor"),l(Wo,"href","https://pypi.org/project/pytesseract/"),l(Wo,"rel","nofollow"),l(yn,"href","/docs/transformers/pr_15839/en/model_doc/layoutlmv2#transformers.LayoutLMv2FeatureExtractor"),l(Ye,"id","transformers.LayoutLMv2Config"),l(Ye,"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"),l(Ye,"href","#transformers.LayoutLMv2Config"),l(Pe,"class","relative group"),l($n,"href","/docs/transformers/pr_15839/en/model_doc/layoutlmv2#transformers.LayoutLMv2Model"),l(Zo,"href","https://huggingface.co/microsoft/layoutlmv2-base-uncased"),l(Zo,"rel","nofollow"),l(qn,"href","/docs/transformers/pr_15839/en/main_classes/configuration#transformers.PretrainedConfig"),l(Fn,"href","/docs/transformers/pr_15839/en/main_classes/configuration#transformers.PretrainedConfig"),l(R,"class","docstring"),l(Ze,"id","transformers.LayoutLMv2FeatureExtractor"),l(Ze,"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"),l(Ze,"href","#transformers.LayoutLMv2FeatureExtractor"),l(Ie,"class","relative group"),l(se,"class","docstring"),l(J,"class","docstring"),l(Je,"id","transformers.LayoutLMv2Tokenizer"),l(Je,"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"),l(Je,"href","#transformers.LayoutLMv2Tokenizer"),l(Ae,"class","relative group"),l(Pn,"href","/docs/transformers/pr_15839/en/model_doc/layoutlmv2#transformers.LayoutLMv2Tokenizer"),l(jn,"href","/docs/transformers/pr_15839/en/main_classes/tokenizer#transformers.PreTrainedTokenizer"),l(In,"href","/docs/transformers/pr_15839/en/model_doc/layoutlmv2#transformers.LayoutLMv2Tokenizer"),l(eo,"class","docstring"),l(An,"class","docstring"),l(O,"class","docstring"),l(oo,"id","transformers.LayoutLMv2TokenizerFast"),l(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"),l(oo,"href","#transformers.LayoutLMv2TokenizerFast"),l(Oe,"class","relative group"),l(On,"href","/docs/transformers/pr_15839/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast"),l(to,"class","docstring"),l(ee,"class","docstring"),l(no,"id","transformers.LayoutLMv2Processor"),l(no,"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"),l(no,"href","#transformers.LayoutLMv2Processor"),l(De,"class","relative group"),l(Nn,"href","/docs/transformers/pr_15839/en/model_doc/layoutlmv2#transformers.LayoutLMv2Processor"),l(Sn,"href","/docs/transformers/pr_15839/en/model_doc/layoutlmv2#transformers.LayoutLMv2FeatureExtractor"),l(Rn,"href","/docs/transformers/pr_15839/en/model_doc/layoutlmv2#transformers.LayoutLMv2Tokenizer"),l(Un,"href","/docs/transformers/pr_15839/en/model_doc/layoutlmv2#transformers.LayoutLMv2TokenizerFast"),l(vt,"href","/docs/transformers/pr_15839/en/model_doc/layoutlmv2#transformers.LayoutLMv2FeatureExtractor.__call__"),l(Bn,"href","/docs/transformers/pr_15839/en/model_doc/layoutlmv2#transformers.LayoutLMv2FeatureExtractor"),l(yt,"href","/docs/transformers/pr_15839/en/model_doc/layoutlmv2#transformers.LayoutLMv2Tokenizer.__call__"),l(Wn,"href","/docs/transformers/pr_15839/en/model_doc/layoutlmv2#transformers.LayoutLMv2FeatureExtractor"),l(_e,"class","docstring"),l(U,"class","docstring"),l(ao,"id","transformers.LayoutLMv2Model"),l(ao,"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"),l(ao,"href","#transformers.LayoutLMv2Model"),l(Ne,"class","relative group"),l(kt,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),l(kt,"rel","nofollow"),l(Vn,"href","/docs/transformers/pr_15839/en/model_doc/layoutlmv2#transformers.LayoutLMv2Model"),l(Q,"class","docstring"),l(ce,"class","docstring"),l(ro,"id","transformers.LayoutLMv2ForSequenceClassification"),l(ro,"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"),l(ro,"href","#transformers.LayoutLMv2ForSequenceClassification"),l(Re,"class","relative group"),l($t,"href","https://www.cs.cmu.edu/~aharley/rvl-cdip/"),l($t,"rel","nofollow"),l(Ft,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),l(Ft,"rel","nofollow"),l(Qn,"href","/docs/transformers/pr_15839/en/model_doc/layoutlmv2#transformers.LayoutLMv2ForSequenceClassification"),l(G,"class","docstring"),l(oe,"class","docstring"),l(lo,"id","transformers.LayoutLMv2ForTokenClassification"),l(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"),l(lo,"href","#transformers.LayoutLMv2ForTokenClassification"),l(Be,"class","relative group"),l(At,"href","https://guillaumejaume.github.io/FUNSD/"),l(At,"rel","nofollow"),l(Ot,"href","https://rrc.cvc.uab.es/?ch=13"),l(Ot,"rel","nofollow"),l(Dt,"href","https://github.com/clovaai/cord"),l(Dt,"rel","nofollow"),l(Nt,"href","https://github.com/applicaai/kleister-nda"),l(Nt,"rel","nofollow"),l(Rt,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),l(Rt,"rel","nofollow"),l(Gn,"href","/docs/transformers/pr_15839/en/model_doc/layoutlmv2#transformers.LayoutLMv2ForTokenClassification"),l(H,"class","docstring"),l(te,"class","docstring"),l(po,"id","transformers.LayoutLMv2ForQuestionAnswering"),l(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"),l(po,"href","#transformers.LayoutLMv2ForQuestionAnswering"),l(Ve,"class","relative group"),l(Qt,"href","https://rrc.cvc.uab.es/?ch=17"),l(Qt,"rel","nofollow"),l(Ht,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),l(Ht,"rel","nofollow"),l(Hn,"href","/docs/transformers/pr_15839/en/model_doc/layoutlmv2#transformers.LayoutLMv2ForQuestionAnswering"),l(K,"class","docstring"),l(ae,"class","docstring")},m(o,p){e(document.head,y),u(o,q,p),u(o,b,p),e(b,T),e(T,P),f(L,P,null),e(b,w),e(b,A),e(A,Ci),u(o,ar,p),u(o,$e,p),e($e,Ge),e(Ge,ca),f(bo,ca,null),e($e,Ii),e($e,da),e(da,Ai),u(o,sr,p),u(o,ue,p),e(ue,Oi),e(ue,Lo),e(Lo,Di),e(ue,Ni),e(ue,Zt),e(Zt,Si),e(ue,Ri),u(o,rr,p),u(o,he,p),e(he,Z),e(Z,Ui),e(Z,wo),e(wo,Bi),e(Z,Wi),e(Z,ko),e(ko,Vi),e(Z,Qi),e(Z,xo),e(xo,Gi),e(Z,Hi),e(Z,To),e(To,Ki),e(Z,Xi),e(he,Yi),e(he,Mo),e(Mo,Zi),e(Mo,Eo),e(Eo,Ji),e(Mo,el),e(he,ol),e(he,zo),e(zo,tl),e(zo,$o),e($o,nl),e(zo,al),u(o,ir,p),u(o,Jt,p),e(Jt,sl),u(o,lr,p),u(o,en,p),e(en,pa),e(pa,rl),u(o,cr,p),u(o,on,p),e(on,il),u(o,dr,p),u(o,B,p),e(B,ua),e(ua,ll),e(B,cl),e(B,qo),e(qo,dl),e(qo,Fo),e(Fo,pl),e(qo,ul),e(B,hl),e(B,Po),e(Po,ml),e(Po,jo),e(jo,fl),e(Po,gl),e(B,_l),e(B,qe),e(qe,vl),e(qe,Co),e(Co,yl),e(qe,bl),e(qe,Io),e(Io,Ll),e(qe,wl),e(B,kl),e(B,k),e(k,xl),e(k,ha),e(ha,Tl),e(k,Ml),e(k,tn),e(tn,El),e(k,zl),e(k,ma),e(ma,$l),e(k,ql),e(k,fa),e(fa,Fl),e(k,Pl),e(k,ga),e(ga,jl),e(k,Cl),e(k,_a),e(_a,Il),e(k,Al),e(k,va),e(va,Ol),e(k,Dl),e(k,ya),e(ya,Nl),e(k,Sl),e(k,ba),e(ba,Rl),e(k,Ul),e(k,nn),e(nn,Bl),e(k,Wl),e(k,Ao),e(Ao,Vl),e(k,Ql),e(k,Oo),e(Oo,Gl),e(k,Hl),u(o,pr,p),f(Do,o,p),u(o,ur,p),u(o,me,p),e(me,Kl),e(me,La),e(La,Xl),e(me,Yl),e(me,wa),e(wa,Zl),e(me,Jl),u(o,hr,p),f(No,o,p),u(o,mr,p),u(o,He,p),e(He,ec),e(He,an),e(an,oc),e(He,tc),u(o,fr,p),u(o,fe,p),e(fe,C),e(C,nc),e(C,sn),e(sn,ac),e(C,sc),e(C,ka),e(ka,rc),e(C,ic),e(C,xa),e(xa,lc),e(C,cc),e(C,rn),e(rn,dc),e(C,pc),e(C,Ta),e(Ta,uc),e(C,hc),e(C,Ma),e(Ma,mc),e(C,fc),e(C,Ea),e(Ea,gc),e(C,_c),e(fe,vc),e(fe,So),e(So,yc),e(So,ln),e(ln,bc),e(So,Lc),e(fe,wc),e(fe,Ro),e(Ro,kc),e(Ro,za),e(za,xc),e(Ro,Tc),u(o,gr,p),u(o,Ke,p),e(Ke,Mc),e(Ke,cn),e(cn,Ec),e(Ke,zc),u(o,_r,p),u(o,Fe,p),e(Fe,Xe),e(Xe,$a),f(Uo,$a,null),e(Fe,$c),e(Fe,qa),e(qa,qc),u(o,vr,p),u(o,W,p),e(W,Fc),e(W,dn),e(dn,Pc),e(W,jc),e(W,pn),e(pn,Cc),e(W,Ic),e(W,un),e(un,Ac),e(W,Oc),e(W,hn),e(hn,Dc),e(W,Nc),u(o,yr,p),f(Bo,o,p),u(o,br,p),u(o,M,p),e(M,Sc),e(M,mn),e(mn,Rc),e(M,Uc),e(M,fn),e(fn,Bc),e(M,Wc),e(M,Fa),e(Fa,Vc),e(M,Qc),e(M,gn),e(gn,Gc),e(M,Hc),e(M,_n),e(_n,Kc),e(M,Xc),e(M,Pa),e(Pa,Yc),e(M,Zc),e(M,ja),e(ja,Jc),e(M,ed),e(M,Ca),e(Ca,od),e(M,td),e(M,Ia),e(Ia,nd),e(M,ad),e(M,Aa),e(Aa,sd),e(M,rd),u(o,Lr,p),u(o,S,p),e(S,vn),e(vn,id),e(S,ld),e(S,Wo),e(Wo,cd),e(S,dd),e(S,yn),e(yn,pd),e(S,ud),e(S,Oa),e(Oa,hd),e(S,md),e(S,Da),e(Da,fd),e(S,gd),u(o,wr,p),u(o,bn,p),e(bn,_d),u(o,kr,p),u(o,Ln,p),e(Ln,Na),e(Na,vd),u(o,xr,p),u(o,wn,p),e(wn,yd),u(o,Tr,p),f(Vo,o,p),u(o,Mr,p),u(o,kn,p),e(kn,Sa),e(Sa,bd),u(o,Er,p),u(o,ge,p),e(ge,Ld),e(ge,Ra),e(Ra,wd),e(ge,kd),e(ge,Ua),e(Ua,xd),e(ge,Td),u(o,zr,p),f(Qo,o,p),u(o,$r,p),u(o,xn,p),e(xn,Ba),e(Ba,Md),u(o,qr,p),u(o,V,p),e(V,Ed),e(V,Wa),e(Wa,zd),e(V,$d),e(V,Va),e(Va,qd),e(V,Fd),e(V,Qa),e(Qa,Pd),e(V,jd),e(V,Ga),e(Ga,Cd),e(V,Id),u(o,Fr,p),f(Go,o,p),u(o,Pr,p),u(o,Tn,p),e(Tn,Ha),e(Ha,Ad),u(o,jr,p),u(o,Mn,p),e(Mn,Od),u(o,Cr,p),f(Ho,o,p),u(o,Ir,p),u(o,En,p),e(En,Ka),e(Ka,Dd),u(o,Ar,p),u(o,zn,p),e(zn,Nd),u(o,Or,p),f(Ko,o,p),u(o,Dr,p),u(o,Pe,p),e(Pe,Ye),e(Ye,Xa),f(Xo,Xa,null),e(Pe,Sd),e(Pe,Ya),e(Ya,Rd),u(o,Nr,p),u(o,R,p),f(Yo,R,null),e(R,Ud),e(R,je),e(je,Bd),e(je,$n),e($n,Wd),e(je,Vd),e(je,Zo),e(Zo,Qd),e(je,Gd),e(R,Hd),e(R,Ce),e(Ce,Kd),e(Ce,qn),e(qn,Xd),e(Ce,Yd),e(Ce,Fn),e(Fn,Zd),e(Ce,Jd),e(R,ep),e(R,Za),e(Za,op),e(R,tp),f(Jo,R,null),u(o,Sr,p),u(o,Ie,p),e(Ie,Ze),e(Ze,Ja),f(et,Ja,null),e(Ie,np),e(Ie,es),e(es,ap),u(o,Rr,p),u(o,J,p),f(ot,J,null),e(J,sp),e(J,os),e(os,rp),e(J,ip),e(J,tt),e(tt,lp),e(tt,ts),e(ts,cp),e(tt,dp),e(J,pp),e(J,se),f(nt,se,null),e(se,up),e(se,ns),e(ns,hp),e(se,mp),e(se,as),e(as,fp),e(se,gp),f(at,se,null),u(o,Ur,p),u(o,Ae,p),e(Ae,Je),e(Je,ss),f(st,ss,null),e(Ae,_p),e(Ae,rs),e(rs,vp),u(o,Br,p),u(o,O,p),f(rt,O,null),e(O,yp),e(O,D),e(D,bp),e(D,Pn),e(Pn,Lp),e(D,wp),e(D,is),e(is,kp),e(D,xp),e(D,ls),e(ls,Tp),e(D,Mp),e(D,cs),e(cs,Ep),e(D,zp),e(D,ds),e(ds,$p),e(D,qp),e(D,ps),e(ps,Fp),e(D,Pp),e(O,jp),e(O,it),e(it,Cp),e(it,jn),e(jn,Ip),e(it,Ap),e(O,Op),e(O,Cn),e(Cn,In),e(In,Dp),e(Cn,Np),e(O,Sp),e(O,eo),f(lt,eo,null),e(eo,Rp),e(eo,us),e(us,Up),e(O,Bp),e(O,An),f(ct,An,null),u(o,Wr,p),u(o,Oe,p),e(Oe,oo),e(oo,hs),f(dt,hs,null),e(Oe,Wp),e(Oe,ms),e(ms,Vp),u(o,Vr,p),u(o,ee,p),f(pt,ee,null),e(ee,Qp),e(ee,ut),e(ut,Gp),e(ut,fs),e(fs,Hp),e(ut,Kp),e(ee,Xp),e(ee,ht),e(ht,Yp),e(ht,On),e(On,Zp),e(ht,Jp),e(ee,eu),e(ee,to),f(mt,to,null),e(to,ou),e(to,gs),e(gs,tu),u(o,Qr,p),u(o,De,p),e(De,no),e(no,_s),f(ft,_s,null),e(De,nu),e(De,vs),e(vs,au),u(o,Gr,p),u(o,U,p),f(gt,U,null),e(U,su),e(U,ys),e(ys,ru),e(U,iu),e(U,Dn),e(Dn,Nn),e(Nn,lu),e(Dn,cu),e(U,du),e(U,$),e($,pu),e($,Sn),e(Sn,uu),e($,hu),e($,Rn),e(Rn,mu),e($,fu),e($,Un),e(Un,gu),e($,_u),e($,bs),e(bs,vu),e($,yu),e($,Ls),e(Ls,bu),e($,Lu),e($,ws),e(ws,wu),e($,ku),e($,ks),e(ks,xu),e($,Tu),e($,xs),e(xs,Mu),e($,Eu),e($,Ts),e(Ts,zu),e($,$u),e(U,qu),e(U,_e),f(_t,_e,null),e(_e,Fu),e(_e,x),e(x,Pu),e(x,Ms),e(Ms,ju),e(x,Cu),e(x,vt),e(vt,Es),e(Es,Iu),e(vt,Au),e(x,Ou),e(x,Bn),e(Bn,Du),e(x,Nu),e(x,zs),e(zs,Su),e(x,Ru),e(x,$s),e($s,Uu),e(x,Bu),e(x,yt),e(yt,qs),e(qs,Wu),e(yt,Vu),e(x,Qu),e(x,Fs),e(Fs,Gu),e(x,Hu),e(x,Wn),e(Wn,Ku),e(x,Xu),e(x,Ps),e(Ps,Yu),e(x,Zu),e(x,js),e(js,Ju),e(x,eh),e(x,Cs),e(Cs,oh),e(x,th),e(x,Is),e(Is,nh),e(x,ah),e(_e,sh),e(_e,As),e(As,rh),u(o,Hr,p),u(o,Ne,p),e(Ne,ao),e(ao,Os),f(bt,Os,null),e(Ne,ih),e(Ne,Ds),e(Ds,lh),u(o,Kr,p),u(o,ce,p),f(Lt,ce,null),e(ce,ch),e(ce,wt),e(wt,dh),e(wt,kt),e(kt,ph),e(wt,uh),e(ce,hh),e(ce,Q),f(xt,Q,null),e(Q,mh),e(Q,Se),e(Se,fh),e(Se,Vn),e(Vn,gh),e(Se,_h),e(Se,Ns),e(Ns,vh),e(Se,yh),e(Q,bh),f(so,Q,null),e(Q,Lh),e(Q,Ss),e(Ss,wh),e(Q,kh),f(Tt,Q,null),u(o,Xr,p),u(o,Re,p),e(Re,ro),e(ro,Rs),f(Mt,Rs,null),e(Re,xh),e(Re,Us),e(Us,Th),u(o,Yr,p),u(o,oe,p),f(Et,oe,null),e(oe,Mh),e(oe,zt),e(zt,Eh),e(zt,$t),e($t,zh),e(zt,$h),e(oe,qh),e(oe,qt),e(qt,Fh),e(qt,Ft),e(Ft,Ph),e(qt,jh),e(oe,Ch),e(oe,G),f(Pt,G,null),e(G,Ih),e(G,Ue),e(Ue,Ah),e(Ue,Qn),e(Qn,Oh),e(Ue,Dh),e(Ue,Bs),e(Bs,Nh),e(Ue,Sh),e(G,Rh),f(io,G,null),e(G,Uh),e(G,Ws),e(Ws,Bh),e(G,Wh),f(jt,G,null),u(o,Zr,p),u(o,Be,p),e(Be,lo),e(lo,Vs),f(Ct,Vs,null),e(Be,Vh),e(Be,Qs),e(Qs,Qh),u(o,Jr,p),u(o,te,p),f(It,te,null),e(te,Gh),e(te,ne),e(ne,Hh),e(ne,At),e(At,Kh),e(ne,Xh),e(ne,Ot),e(Ot,Yh),e(ne,Zh),e(ne,Dt),e(Dt,Jh),e(ne,em),e(ne,Nt),e(Nt,om),e(ne,tm),e(te,nm),e(te,St),e(St,am),e(St,Rt),e(Rt,sm),e(St,rm),e(te,im),e(te,H),f(Ut,H,null),e(H,lm),e(H,We),e(We,cm),e(We,Gn),e(Gn,dm),e(We,pm),e(We,Gs),e(Gs,um),e(We,hm),e(H,mm),f(co,H,null),e(H,fm),e(H,Hs),e(Hs,gm),e(H,_m),f(Bt,H,null),u(o,ei,p),u(o,Ve,p),e(Ve,po),e(po,Ks),f(Wt,Ks,null),e(Ve,vm),e(Ve,Xs),e(Xs,ym),u(o,oi,p),u(o,ae,p),f(Vt,ae,null),e(ae,bm),e(ae,de),e(de,Lm),e(de,Qt),e(Qt,wm),e(de,km),e(de,Ys),e(Ys,xm),e(de,Tm),e(de,Zs),e(Zs,Mm),e(de,Em),e(ae,zm),e(ae,Gt),e(Gt,$m),e(Gt,Ht),e(Ht,qm),e(Gt,Fm),e(ae,Pm),e(ae,K),f(Kt,K,null),e(K,jm),e(K,Qe),e(Qe,Cm),e(Qe,Hn),e(Hn,Im),e(Qe,Am),e(Qe,Js),e(Js,Om),e(Qe,Dm),e(K,Nm),f(uo,K,null),e(K,Sm),e(K,er),e(er,Rm),e(K,Um),f(Xt,K,null),ti=!0},p(o,[p]){const Yt={};p&2&&(Yt.$$scope={dirty:p,ctx:o}),so.$set(Yt);const or={};p&2&&(or.$$scope={dirty:p,ctx:o}),io.$set(or);const tr={};p&2&&(tr.$$scope={dirty:p,ctx:o}),co.$set(tr);const nr={};p&2&&(nr.$$scope={dirty:p,ctx:o}),uo.$set(nr)},i(o){ti||(g(L.$$.fragment,o),g(bo.$$.fragment,o),g(Do.$$.fragment,o),g(No.$$.fragment,o),g(Uo.$$.fragment,o),g(Bo.$$.fragment,o),g(Vo.$$.fragment,o),g(Qo.$$.fragment,o),g(Go.$$.fragment,o),g(Ho.$$.fragment,o),g(Ko.$$.fragment,o),g(Xo.$$.fragment,o),g(Yo.$$.fragment,o),g(Jo.$$.fragment,o),g(et.$$.fragment,o),g(ot.$$.fragment,o),g(nt.$$.fragment,o),g(at.$$.fragment,o),g(st.$$.fragment,o),g(rt.$$.fragment,o),g(lt.$$.fragment,o),g(ct.$$.fragment,o),g(dt.$$.fragment,o),g(pt.$$.fragment,o),g(mt.$$.fragment,o),g(ft.$$.fragment,o),g(gt.$$.fragment,o),g(_t.$$.fragment,o),g(bt.$$.fragment,o),g(Lt.$$.fragment,o),g(xt.$$.fragment,o),g(so.$$.fragment,o),g(Tt.$$.fragment,o),g(Mt.$$.fragment,o),g(Et.$$.fragment,o),g(Pt.$$.fragment,o),g(io.$$.fragment,o),g(jt.$$.fragment,o),g(Ct.$$.fragment,o),g(It.$$.fragment,o),g(Ut.$$.fragment,o),g(co.$$.fragment,o),g(Bt.$$.fragment,o),g(Wt.$$.fragment,o),g(Vt.$$.fragment,o),g(Kt.$$.fragment,o),g(uo.$$.fragment,o),g(Xt.$$.fragment,o),ti=!0)},o(o){_(L.$$.fragment,o),_(bo.$$.fragment,o),_(Do.$$.fragment,o),_(No.$$.fragment,o),_(Uo.$$.fragment,o),_(Bo.$$.fragment,o),_(Vo.$$.fragment,o),_(Qo.$$.fragment,o),_(Go.$$.fragment,o),_(Ho.$$.fragment,o),_(Ko.$$.fragment,o),_(Xo.$$.fragment,o),_(Yo.$$.fragment,o),_(Jo.$$.fragment,o),_(et.$$.fragment,o),_(ot.$$.fragment,o),_(nt.$$.fragment,o),_(at.$$.fragment,o),_(st.$$.fragment,o),_(rt.$$.fragment,o),_(lt.$$.fragment,o),_(ct.$$.fragment,o),_(dt.$$.fragment,o),_(pt.$$.fragment,o),_(mt.$$.fragment,o),_(ft.$$.fragment,o),_(gt.$$.fragment,o),_(_t.$$.fragment,o),_(bt.$$.fragment,o),_(Lt.$$.fragment,o),_(xt.$$.fragment,o),_(so.$$.fragment,o),_(Tt.$$.fragment,o),_(Mt.$$.fragment,o),_(Et.$$.fragment,o),_(Pt.$$.fragment,o),_(io.$$.fragment,o),_(jt.$$.fragment,o),_(Ct.$$.fragment,o),_(It.$$.fragment,o),_(Ut.$$.fragment,o),_(co.$$.fragment,o),_(Bt.$$.fragment,o),_(Wt.$$.fragment,o),_(Vt.$$.fragment,o),_(Kt.$$.fragment,o),_(uo.$$.fragment,o),_(Xt.$$.fragment,o),ti=!1},d(o){t(y),o&&t(q),o&&t(b),v(L),o&&t(ar),o&&t($e),v(bo),o&&t(sr),o&&t(ue),o&&t(rr),o&&t(he),o&&t(ir),o&&t(Jt),o&&t(lr),o&&t(en),o&&t(cr),o&&t(on),o&&t(dr),o&&t(B),o&&t(pr),v(Do,o),o&&t(ur),o&&t(me),o&&t(hr),v(No,o),o&&t(mr),o&&t(He),o&&t(fr),o&&t(fe),o&&t(gr),o&&t(Ke),o&&t(_r),o&&t(Fe),v(Uo),o&&t(vr),o&&t(W),o&&t(yr),v(Bo,o),o&&t(br),o&&t(M),o&&t(Lr),o&&t(S),o&&t(wr),o&&t(bn),o&&t(kr),o&&t(Ln),o&&t(xr),o&&t(wn),o&&t(Tr),v(Vo,o),o&&t(Mr),o&&t(kn),o&&t(Er),o&&t(ge),o&&t(zr),v(Qo,o),o&&t($r),o&&t(xn),o&&t(qr),o&&t(V),o&&t(Fr),v(Go,o),o&&t(Pr),o&&t(Tn),o&&t(jr),o&&t(Mn),o&&t(Cr),v(Ho,o),o&&t(Ir),o&&t(En),o&&t(Ar),o&&t(zn),o&&t(Or),v(Ko,o),o&&t(Dr),o&&t(Pe),v(Xo),o&&t(Nr),o&&t(R),v(Yo),v(Jo),o&&t(Sr),o&&t(Ie),v(et),o&&t(Rr),o&&t(J),v(ot),v(nt),v(at),o&&t(Ur),o&&t(Ae),v(st),o&&t(Br),o&&t(O),v(rt),v(lt),v(ct),o&&t(Wr),o&&t(Oe),v(dt),o&&t(Vr),o&&t(ee),v(pt),v(mt),o&&t(Qr),o&&t(De),v(ft),o&&t(Gr),o&&t(U),v(gt),v(_t),o&&t(Hr),o&&t(Ne),v(bt),o&&t(Kr),o&&t(ce),v(Lt),v(xt),v(so),v(Tt),o&&t(Xr),o&&t(Re),v(Mt),o&&t(Yr),o&&t(oe),v(Et),v(Pt),v(io),v(jt),o&&t(Zr),o&&t(Be),v(Ct),o&&t(Jr),o&&t(te),v(It),v(Ut),v(co),v(Bt),o&&t(ei),o&&t(Ve),v(Wt),o&&t(oi),o&&t(ae),v(Vt),v(Kt),v(uo),v(Xt)}}}const Tv={local:"layoutlmv2",sections:[{local:"overview",title:"Overview"},{local:"usage-layoutlmv2processor",title:"Usage: LayoutLMv2Processor"},{local:"transformers.LayoutLMv2Config",title:"LayoutLMv2Config"},{local:"transformers.LayoutLMv2FeatureExtractor",title:"LayoutLMv2FeatureExtractor"},{local:"transformers.LayoutLMv2Tokenizer",title:"LayoutLMv2Tokenizer"},{local:"transformers.LayoutLMv2TokenizerFast",title:"LayoutLMv2TokenizerFast"},{local:"transformers.LayoutLMv2Processor",title:"LayoutLMv2Processor"},{local:"transformers.LayoutLMv2Model",title:"LayoutLMv2Model"},{local:"transformers.LayoutLMv2ForSequenceClassification",title:"LayoutLMv2ForSequenceClassification"},{local:"transformers.LayoutLMv2ForTokenClassification",title:"LayoutLMv2ForTokenClassification"},{local:"transformers.LayoutLMv2ForQuestionAnswering",title:"LayoutLMv2ForQuestionAnswering"}],title:"LayoutLMV2"};function Mv(le,y,q){let{fw:b}=y;return le.$$set=T=>{"fw"in T&&q(0,b=T.fw)},[b]}class jv extends gv{constructor(y){super();_v(this,y,Mv,xv,vv,{fw:0})}}export{jv as default,Tv as metadata};
