import{S as L2,i as k2,s as w2,e as a,k as d,w as g,t as n,M as x2,c as r,d as o,m as p,a as i,x as _,h as s,b as l,G as e,g as u,y as v,q as y,o as b,B as L,v as T2,L as Hs}from"../../chunks/vendor-hf-doc-builder.js";import{T as Gl}from"../../chunks/Tip-hf-doc-builder.js";import{D as C}from"../../chunks/Docstring-hf-doc-builder.js";import{C as B}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as X}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as Gs}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";import{P as Rg}from"../../chunks/PipelineTag-hf-doc-builder.js";function M2(P){let h,x,f,k,T;return k=new B({props:{code:`from transformers import LayoutLMv2Config, LayoutLMv2Model

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

# Initializing a model (with random weights) 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> LayoutLMv2Config, LayoutLMv2Model

<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 (with random weights) 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`}}),{c(){h=a("p"),x=n("Example:"),f=d(),g(k.$$.fragment)},l(m){h=r(m,"P",{});var w=i(h);x=s(w,"Example:"),w.forEach(o),f=p(m),_(k.$$.fragment,m)},m(m,w){u(m,h,w),e(h,x),u(m,f,w),v(k,m,w),T=!0},p:Hs,i(m){T||(y(k.$$.fragment,m),T=!0)},o(m){b(k.$$.fragment,m),T=!1},d(m){m&&o(h),m&&o(f),L(k,m)}}}function $2(P){let h,x,f,k,T;return{c(){h=a("p"),x=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),k=n("Module"),T=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(m){h=r(m,"P",{});var w=i(h);x=s(w,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=r(w,"CODE",{});var O=i(f);k=s(O,"Module"),O.forEach(o),T=s(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(o)},m(m,w){u(m,h,w),e(h,x),e(h,f),e(f,k),e(h,T)},d(m){m&&o(h)}}}function E2(P){let h,x,f,k,T;return k=new B({props:{code:`from transformers import AutoProcessor, LayoutLMv2Model, set_seed
from PIL import Image
import torch
from datasets import load_dataset

set_seed(88)

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


dataset = load_dataset("hf-internal-testing/fixtures_docvqa")
image_path = dataset["test"][0]["file"]
image = Image.open(image_path).convert("RGB")

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

outputs = model(**encoding)
last_hidden_states = outputs.last_hidden_state

last_hidden_states.shape`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoProcessor, LayoutLMv2Model, set_seed
<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><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset

<span class="hljs-meta">&gt;&gt;&gt; </span>set_seed(<span class="hljs-number">88</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>processor = AutoProcessor.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>dataset = load_dataset(<span class="hljs-string">&quot;hf-internal-testing/fixtures_docvqa&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>image_path = dataset[<span class="hljs-string">&quot;test&quot;</span>][<span class="hljs-number">0</span>][<span class="hljs-string">&quot;file&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>image = Image.<span class="hljs-built_in">open</span>(image_path).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

<span class="hljs-meta">&gt;&gt;&gt; </span>last_hidden_states.shape
torch.Size([<span class="hljs-number">1</span>, <span class="hljs-number">342</span>, <span class="hljs-number">768</span>])`}}),{c(){h=a("p"),x=n("Examples:"),f=d(),g(k.$$.fragment)},l(m){h=r(m,"P",{});var w=i(h);x=s(w,"Examples:"),w.forEach(o),f=p(m),_(k.$$.fragment,m)},m(m,w){u(m,h,w),e(h,x),u(m,f,w),v(k,m,w),T=!0},p:Hs,i(m){T||(y(k.$$.fragment,m),T=!0)},o(m){b(k.$$.fragment,m),T=!1},d(m){m&&o(h),m&&o(f),L(k,m)}}}function z2(P){let h,x,f,k,T;return{c(){h=a("p"),x=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),k=n("Module"),T=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(m){h=r(m,"P",{});var w=i(h);x=s(w,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=r(w,"CODE",{});var O=i(f);k=s(O,"Module"),O.forEach(o),T=s(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(o)},m(m,w){u(m,h,w),e(h,x),e(h,f),e(f,k),e(h,T)},d(m){m&&o(h)}}}function q2(P){let h,x,f,k,T;return k=new B({props:{code:`from transformers import AutoProcessor, LayoutLMv2ForSequenceClassification, set_seed
from PIL import Image
import torch
from datasets import load_dataset

set_seed(88)

dataset = load_dataset("rvl_cdip", split="train", streaming=True)
data = next(iter(dataset))
image = data["image"].convert("RGB")

processor = AutoProcessor.from_pretrained("microsoft/layoutlmv2-base-uncased")
model = LayoutLMv2ForSequenceClassification.from_pretrained(
    "microsoft/layoutlmv2-base-uncased", num_labels=dataset.info.features["label"].num_classes
)

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

outputs = model(**encoding, labels=sequence_label)

loss, logits = outputs.loss, outputs.logits
predicted_idx = logits.argmax(dim=-1).item()
predicted_answer = dataset.info.features["label"].names[4]
predicted_idx, predicted_answer`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoProcessor, LayoutLMv2ForSequenceClassification, set_seed
<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><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset

<span class="hljs-meta">&gt;&gt;&gt; </span>set_seed(<span class="hljs-number">88</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = load_dataset(<span class="hljs-string">&quot;rvl_cdip&quot;</span>, split=<span class="hljs-string">&quot;train&quot;</span>, streaming=<span class="hljs-literal">True</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>data = <span class="hljs-built_in">next</span>(<span class="hljs-built_in">iter</span>(dataset))
<span class="hljs-meta">&gt;&gt;&gt; </span>image = data[<span class="hljs-string">&quot;image&quot;</span>].convert(<span class="hljs-string">&quot;RGB&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>processor = AutoProcessor.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-meta">... </span>    <span class="hljs-string">&quot;microsoft/layoutlmv2-base-uncased&quot;</span>, num_labels=dataset.info.features[<span class="hljs-string">&quot;label&quot;</span>].num_classes
<span class="hljs-meta">... </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([data[<span class="hljs-string">&quot;label&quot;</span>]])

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**encoding, labels=sequence_label)

<span class="hljs-meta">&gt;&gt;&gt; </span>loss, logits = outputs.loss, outputs.logits
<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_idx = logits.argmax(dim=-<span class="hljs-number">1</span>).item()
<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_answer = dataset.info.features[<span class="hljs-string">&quot;label&quot;</span>].names[<span class="hljs-number">4</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_idx, predicted_answer
(<span class="hljs-number">4</span>, <span class="hljs-string">&#x27;advertisement&#x27;</span>)`}}),{c(){h=a("p"),x=n("Example:"),f=d(),g(k.$$.fragment)},l(m){h=r(m,"P",{});var w=i(h);x=s(w,"Example:"),w.forEach(o),f=p(m),_(k.$$.fragment,m)},m(m,w){u(m,h,w),e(h,x),u(m,f,w),v(k,m,w),T=!0},p:Hs,i(m){T||(y(k.$$.fragment,m),T=!0)},o(m){b(k.$$.fragment,m),T=!1},d(m){m&&o(h),m&&o(f),L(k,m)}}}function F2(P){let h,x,f,k,T;return{c(){h=a("p"),x=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),k=n("Module"),T=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(m){h=r(m,"P",{});var w=i(h);x=s(w,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=r(w,"CODE",{});var O=i(f);k=s(O,"Module"),O.forEach(o),T=s(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(o)},m(m,w){u(m,h,w),e(h,x),e(h,f),e(f,k),e(h,T)},d(m){m&&o(h)}}}function P2(P){let h,x,f,k,T;return k=new B({props:{code:`from transformers import AutoProcessor, LayoutLMv2ForTokenClassification, set_seed
from PIL import Image
from datasets import load_dataset

set_seed(88)

datasets = load_dataset("nielsr/funsd", split="test")
labels = datasets.features["ner_tags"].feature.names
id2label = {v: k for v, k in enumerate(labels)}

processor = AutoProcessor.from_pretrained("microsoft/layoutlmv2-base-uncased", revision="no_ocr")
model = LayoutLMv2ForTokenClassification.from_pretrained(
    "microsoft/layoutlmv2-base-uncased", num_labels=len(labels)
)

data = datasets[0]
image = Image.open(data["image_path"]).convert("RGB")
words = data["words"]
boxes = data["bboxes"]  # make sure to normalize your bounding boxes
word_labels = data["ner_tags"]
encoding = processor(
    image,
    words,
    boxes=boxes,
    word_labels=word_labels,
    padding="max_length",
    truncation=True,
    return_tensors="pt",
)

outputs = model(**encoding)
logits, loss = outputs.logits, outputs.loss

predicted_token_class_ids = logits.argmax(-1)
predicted_tokens_classes = [id2label[t.item()] for t in predicted_token_class_ids[0]]
predicted_tokens_classes[:5]`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoProcessor, LayoutLMv2ForTokenClassification, set_seed
<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">from</span> datasets <span class="hljs-keyword">import</span> load_dataset

<span class="hljs-meta">&gt;&gt;&gt; </span>set_seed(<span class="hljs-number">88</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>datasets = load_dataset(<span class="hljs-string">&quot;nielsr/funsd&quot;</span>, split=<span class="hljs-string">&quot;test&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>labels = datasets.features[<span class="hljs-string">&quot;ner_tags&quot;</span>].feature.names
<span class="hljs-meta">&gt;&gt;&gt; </span>id2label = {v: k <span class="hljs-keyword">for</span> v, k <span class="hljs-keyword">in</span> <span class="hljs-built_in">enumerate</span>(labels)}

<span class="hljs-meta">&gt;&gt;&gt; </span>processor = AutoProcessor.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-meta">... </span>    <span class="hljs-string">&quot;microsoft/layoutlmv2-base-uncased&quot;</span>, num_labels=<span class="hljs-built_in">len</span>(labels)
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>data = datasets[<span class="hljs-number">0</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>image = Image.<span class="hljs-built_in">open</span>(data[<span class="hljs-string">&quot;image_path&quot;</span>]).convert(<span class="hljs-string">&quot;RGB&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>words = data[<span class="hljs-string">&quot;words&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>boxes = data[<span class="hljs-string">&quot;bboxes&quot;</span>]  <span class="hljs-comment"># make sure to normalize your bounding boxes</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>word_labels = data[<span class="hljs-string">&quot;ner_tags&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>encoding = processor(
<span class="hljs-meta">... </span>    image,
<span class="hljs-meta">... </span>    words,
<span class="hljs-meta">... </span>    boxes=boxes,
<span class="hljs-meta">... </span>    word_labels=word_labels,
<span class="hljs-meta">... </span>    padding=<span class="hljs-string">&quot;max_length&quot;</span>,
<span class="hljs-meta">... </span>    truncation=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    return_tensors=<span class="hljs-string">&quot;pt&quot;</span>,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**encoding)
<span class="hljs-meta">&gt;&gt;&gt; </span>logits, loss = outputs.logits, outputs.loss

<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_token_class_ids = logits.argmax(-<span class="hljs-number">1</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_tokens_classes = [id2label[t.item()] <span class="hljs-keyword">for</span> t <span class="hljs-keyword">in</span> predicted_token_class_ids[<span class="hljs-number">0</span>]]
<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_tokens_classes[:<span class="hljs-number">5</span>]
[<span class="hljs-string">&#x27;B-ANSWER&#x27;</span>, <span class="hljs-string">&#x27;B-HEADER&#x27;</span>, <span class="hljs-string">&#x27;B-HEADER&#x27;</span>, <span class="hljs-string">&#x27;B-HEADER&#x27;</span>, <span class="hljs-string">&#x27;B-HEADER&#x27;</span>]`}}),{c(){h=a("p"),x=n("Example:"),f=d(),g(k.$$.fragment)},l(m){h=r(m,"P",{});var w=i(h);x=s(w,"Example:"),w.forEach(o),f=p(m),_(k.$$.fragment,m)},m(m,w){u(m,h,w),e(h,x),u(m,f,w),v(k,m,w),T=!0},p:Hs,i(m){T||(y(k.$$.fragment,m),T=!0)},o(m){b(k.$$.fragment,m),T=!1},d(m){m&&o(h),m&&o(f),L(k,m)}}}function j2(P){let h,x,f,k,T;return{c(){h=a("p"),x=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),k=n("Module"),T=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(m){h=r(m,"P",{});var w=i(h);x=s(w,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=r(w,"CODE",{});var O=i(f);k=s(O,"Module"),O.forEach(o),T=s(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(o)},m(m,w){u(m,h,w),e(h,x),e(h,f),e(f,k),e(h,T)},d(m){m&&o(h)}}}function I2(P){let h,x;return h=new B({props:{code:`from transformers import AutoProcessor, LayoutLMv2ForQuestionAnswering, set_seed
import torch
from PIL import Image
from datasets import load_dataset

set_seed(88)
processor = AutoProcessor.from_pretrained("microsoft/layoutlmv2-base-uncased")
model = LayoutLMv2ForQuestionAnswering.from_pretrained("microsoft/layoutlmv2-base-uncased")

dataset = load_dataset("hf-internal-testing/fixtures_docvqa")
image_path = dataset["test"][0]["file"]
image = Image.open(image_path).convert("RGB")
question = "When is coffee break?"
encoding = processor(image, question, return_tensors="pt")

outputs = model(**encoding)
predicted_start_idx = outputs.start_logits.argmax(-1).item()
predicted_end_idx = outputs.end_logits.argmax(-1).item()
predicted_start_idx, predicted_end_idx

predicted_answer_tokens = encoding.input_ids.squeeze()[predicted_start_idx : predicted_end_idx + 1]
predicted_answer = processor.tokenizer.decode(predicted_answer_tokens)
predicted_answer  # results are not very good without further fine-tuning`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoProcessor, LayoutLMv2ForQuestionAnswering, set_seed
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset

<span class="hljs-meta">&gt;&gt;&gt; </span>set_seed(<span class="hljs-number">88</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>processor = AutoProcessor.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>dataset = load_dataset(<span class="hljs-string">&quot;hf-internal-testing/fixtures_docvqa&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>image_path = dataset[<span class="hljs-string">&quot;test&quot;</span>][<span class="hljs-number">0</span>][<span class="hljs-string">&quot;file&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>image = Image.<span class="hljs-built_in">open</span>(image_path).convert(<span class="hljs-string">&quot;RGB&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>question = <span class="hljs-string">&quot;When is coffee break?&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>outputs = model(**encoding)
<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_start_idx = outputs.start_logits.argmax(-<span class="hljs-number">1</span>).item()
<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_end_idx = outputs.end_logits.argmax(-<span class="hljs-number">1</span>).item()
<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_start_idx, predicted_end_idx
(<span class="hljs-number">154</span>, <span class="hljs-number">287</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_answer_tokens = encoding.input_ids.squeeze()[predicted_start_idx : predicted_end_idx + <span class="hljs-number">1</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_answer = processor.tokenizer.decode(predicted_answer_tokens)
<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_answer  <span class="hljs-comment"># results are not very good without further fine-tuning</span>
<span class="hljs-string">&#x27;council mem - bers conducted by trrf treasurer philip g. kuehn to get answers which the public ...</span>`}}),{c(){g(h.$$.fragment)},l(f){_(h.$$.fragment,f)},m(f,k){v(h,f,k),x=!0},p:Hs,i(f){x||(y(h.$$.fragment,f),x=!0)},o(f){b(h.$$.fragment,f),x=!1},d(f){L(h,f)}}}function C2(P){let h,x;return h=new B({props:{code:`target_start_index = torch.tensor([7])
target_end_index = torch.tensor([14])
outputs = model(**encoding, start_positions=target_start_index, end_positions=target_end_index)
predicted_answer_span_start = outputs.start_logits.argmax(-1).item()
predicted_answer_span_end = outputs.end_logits.argmax(-1).item()
predicted_answer_span_start, predicted_answer_span_end`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>target_start_index = torch.tensor([<span class="hljs-number">7</span>])
<span class="hljs-meta">&gt;&gt;&gt; </span>target_end_index = torch.tensor([<span class="hljs-number">14</span>])
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**encoding, start_positions=target_start_index, end_positions=target_end_index)
<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_answer_span_start = outputs.start_logits.argmax(-<span class="hljs-number">1</span>).item()
<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_answer_span_end = outputs.end_logits.argmax(-<span class="hljs-number">1</span>).item()
<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_answer_span_start, predicted_answer_span_end
(<span class="hljs-number">154</span>, <span class="hljs-number">287</span>)`}}),{c(){g(h.$$.fragment)},l(f){_(h.$$.fragment,f)},m(f,k){v(h,f,k),x=!0},p:Hs,i(f){x||(y(h.$$.fragment,f),x=!0)},o(f){b(h.$$.fragment,f),x=!1},d(f){L(h,f)}}}function A2(P){let h,x,f,k,T,m,w,O,Hl,Yr,$e,Ke,Ks,Ct,Kl,Xs,Xl,Zr,me,Yl,At,Zl,Jl,Tn,ec,tc,Jr,he,Y,oc,Dt,nc,sc,Ot,ac,rc,Nt,ic,lc,St,cc,dc,pc,Rt,uc,Wt,mc,hc,fc,Ut,gc,Bt,_c,vc,ei,Mn,yc,ti,$n,Ys,bc,oi,se,Lc,Zs,kc,wc,Js,xc,Tc,ea,Mc,$c,ni,Vt,si,En,Ec,ai,zn,zc,ri,V,ta,qc,Fc,Qt,Pc,Gt,jc,Ic,Cc,Ht,Ac,Kt,Dc,Oc,Nc,Ee,Sc,Xt,Rc,Wc,Yt,Uc,Bc,Vc,M,Qc,oa,Gc,Hc,qn,Kc,Xc,na,Yc,Zc,sa,Jc,ed,aa,td,od,ra,nd,sd,ia,ad,rd,la,id,ld,ca,cd,dd,Fn,pd,ud,Zt,md,hd,Jt,fd,gd,ii,eo,li,fe,_d,da,vd,yd,pa,bd,Ld,ci,to,di,Xe,kd,Pn,wd,xd,pi,ge,A,Td,jn,Md,$d,ua,Ed,zd,ma,qd,Fd,In,Pd,jd,ha,Id,Cd,fa,Ad,Dd,ga,Od,Nd,Sd,oo,Rd,Cn,Wd,Ud,Bd,no,Vd,_a,Qd,Gd,ui,Ye,Hd,An,Kd,Xd,mi,ze,Ze,va,so,Yd,ya,Zd,hi,Dn,Jd,fi,ao,gi,Je,ro,ep,io,tp,op,np,On,sp,Nn,ap,_i,lo,vi,_e,co,rp,po,ip,lp,cp,Sn,dp,Rn,pp,up,Wn,mp,Un,hp,yi,uo,bi,ve,mo,fp,ho,gp,_p,vp,fo,yp,go,bp,Lp,kp,Bn,wp,Vn,xp,Li,qe,et,ba,_o,Tp,La,Mp,ki,Q,$p,Qn,Ep,zp,Gn,qp,Fp,Hn,Pp,jp,Kn,Ip,Cp,wi,vo,xi,E,Ap,Xn,Dp,Op,Yn,Np,Sp,ka,Rp,Wp,Zn,Up,Bp,Jn,Vp,Qp,wa,Gp,Hp,xa,Kp,Xp,Ta,Yp,Zp,Ma,Jp,eu,$a,tu,ou,Ti,W,es,nu,su,yo,au,ru,ts,iu,lu,Ea,cu,du,za,pu,uu,Mi,os,mu,$i,ns,qa,hu,Ei,ss,fu,zi,bo,qi,as,Fa,gu,Fi,ye,_u,Pa,vu,yu,ja,bu,Lu,Pi,Lo,ji,rs,Ia,ku,Ii,G,wu,Ca,xu,Tu,Aa,Mu,$u,Da,Eu,zu,Oa,qu,Fu,Ci,ko,Ai,is,Na,Pu,Di,ls,ju,Oi,wo,Ni,cs,Sa,Iu,Si,ds,Cu,Ri,xo,Wi,Fe,tt,Ra,To,Au,Wa,Du,Ui,Z,Mo,Ou,Pe,Nu,ps,Su,Ru,$o,Wu,Uu,Bu,je,Vu,us,Qu,Gu,ms,Hu,Ku,Xu,ot,Bi,Ie,nt,Ua,Eo,Yu,Ba,Zu,Vi,Ce,zo,Ju,st,qo,em,Va,tm,Qi,Ae,at,Qa,Fo,om,Ga,nm,Gi,ce,Po,sm,Ha,am,rm,rt,jo,im,Ka,lm,Hi,De,it,Xa,Io,cm,Ya,dm,Ki,N,Co,pm,S,um,hs,mm,hm,Za,fm,gm,Ja,_m,vm,er,ym,bm,tr,Lm,km,or,wm,xm,Tm,Ao,Mm,fs,$m,Em,zm,gs,_s,qm,Fm,Pm,lt,Do,jm,nr,Im,Cm,vs,Oo,Xi,Oe,ct,sr,No,Am,ar,Dm,Yi,J,So,Om,Ro,Nm,rr,Sm,Rm,Wm,Wo,Um,ys,Bm,Vm,Qm,dt,Uo,Gm,ir,Hm,Zi,Ne,pt,lr,Bo,Km,cr,Xm,Ji,U,Vo,Ym,dr,Zm,Jm,bs,Ls,eh,th,oh,F,nh,ks,sh,ah,ws,rh,ih,xs,lh,ch,pr,dh,ph,ur,uh,mh,mr,hh,fh,hr,gh,_h,fr,vh,yh,gr,bh,Lh,kh,be,Qo,wh,$,xh,_r,Th,Mh,Go,vr,$h,Eh,zh,Ts,qh,Fh,yr,Ph,jh,br,Ih,Ch,Ho,Lr,Ah,Dh,Oh,kr,Nh,Sh,Ms,Rh,Wh,wr,Uh,Bh,xr,Vh,Qh,Tr,Gh,Hh,Mr,Kh,Xh,Yh,$r,Zh,el,Se,ut,Er,Ko,Jh,zr,ef,tl,de,Xo,tf,Yo,of,Zo,nf,sf,af,ae,Jo,rf,Re,lf,$s,cf,df,qr,pf,uf,mf,mt,hf,ht,ol,We,ft,Fr,en,ff,Pr,gf,nl,ee,tn,_f,on,vf,nn,yf,bf,Lf,sn,kf,an,wf,xf,Tf,re,rn,Mf,Ue,$f,Es,Ef,zf,jr,qf,Ff,Pf,gt,jf,_t,sl,Be,vt,Ir,ln,If,Cr,Cf,al,te,cn,Af,oe,Df,dn,Of,Nf,pn,Sf,Rf,un,Wf,Uf,mn,Bf,Vf,Qf,hn,Gf,fn,Hf,Kf,Xf,ie,gn,Yf,Ve,Zf,zs,Jf,eg,Ar,tg,og,ng,yt,sg,bt,rl,Qe,Lt,Dr,_n,ag,Or,rg,il,ne,vn,ig,pe,lg,yn,cg,dg,Nr,pg,ug,Sr,mg,hg,fg,bn,gg,Ln,_g,vg,yg,D,kn,bg,Ge,Lg,qs,kg,wg,Rr,xg,Tg,Mg,kt,$g,Wr,Eg,zg,Ur,qg,Fg,wt,Pg,xt,ll;return m=new X({}),Ct=new X({}),Vt=new B({props:{code:`python -m pip install 'git+https://github.com/facebookresearch/detectron2.git'
python -m pip install torchvision tesseract`,highlighted:`<span class="hljs-keyword">python</span> -m pip install <span class="hljs-string">&#x27;git+https://github.com/facebookresearch/detectron2.git&#x27;</span>
<span class="hljs-keyword">python</span> -m pip install torchvision tesseract`}}),eo=new B({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)),
    ]`}}),to=new B({props:{code:`from PIL import Image

image = Image.open(
    "name_of_your_document - can be a png, jpg, etc. of your documents (PDFs must be converted to images)."
)

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, jpg, etc. of your documents (PDFs must be converted to images).&quot;</span>
)

width, height = image.size`}}),so=new X({}),ao=new Rg({props:{pipeline:"text-classification"}}),lo=new Rg({props:{pipeline:"question-answering"}}),uo=new Rg({props:{pipeline:"token-classification"}}),_o=new X({}),vo=new B({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)`}}),bo=new B({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, jpg, etc. of your documents (PDFs must be converted to images)."
).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, jpg, etc. of your documents (PDFs must be converted to images).&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>`}}),Lo=new B({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, jpg, etc. of your documents (PDFs must be converted to images)."
).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, jpg, etc. of your documents (PDFs must be converted to images).&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>`}}),ko=new B({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, jpg, etc. of your documents (PDFs must be converted to images)."
).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, jpg, etc. of your documents (PDFs must be converted to images).&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>`}}),wo=new B({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, jpg, etc. of your documents (PDFs must be converted to images)."
).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, jpg, etc. of your documents (PDFs must be converted to images).&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>`}}),xo=new B({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, jpg, etc. of your documents (PDFs must be converted to images)."
).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, jpg, etc. of your documents (PDFs must be converted to images).&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>`}}),To=new X({}),Mo=new C({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:""}],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/v4.29.0/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/v4.29.0/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"}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/models/layoutlmv2/configuration_layoutlmv2.py#L34"}}),ot=new Gs({props:{anchor:"transformers.LayoutLMv2Config.example",$$slots:{default:[M2]},$$scope:{ctx:P}}}),Eo=new X({}),zo=new C({props:{name:"class transformers.LayoutLMv2FeatureExtractor",anchor:"transformers.LayoutLMv2FeatureExtractor",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/models/layoutlmv2/feature_extraction_layoutlmv2.py#L28"}}),qo=new C({props:{name:"__call__",anchor:"transformers.LayoutLMv2FeatureExtractor.__call__",parameters:[{name:"images",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/image_processing_utils.py#L462"}}),Fo=new X({}),Po=new C({props:{name:"class transformers.LayoutLMv2ImageProcessor",anchor:"transformers.LayoutLMv2ImageProcessor",parameters:[{name:"do_resize",val:": bool = True"},{name:"size",val:": typing.Dict[str, int] = None"},{name:"resample",val:": Resampling = <Resampling.BILINEAR: 2>"},{name:"apply_ocr",val:": bool = True"},{name:"ocr_lang",val:": typing.Optional[str] = None"},{name:"tesseract_config",val:": typing.Optional[str] = ''"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.LayoutLMv2ImageProcessor.do_resize",description:`<strong>do_resize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to resize the image&#x2019;s (height, width) dimensions to <code>(size[&quot;height&quot;], size[&quot;width&quot;])</code>. Can be
overridden by <code>do_resize</code> in <code>preprocess</code>.`,name:"do_resize"},{anchor:"transformers.LayoutLMv2ImageProcessor.size",description:`<strong>size</strong> (<code>Dict[str, int]</code> <em>optional</em>, defaults to <code>{&quot;height&quot; -- 224, &quot;width&quot;: 224}</code>):
Size of the image after resizing. Can be overridden by <code>size</code> in <code>preprocess</code>.`,name:"size"},{anchor:"transformers.LayoutLMv2ImageProcessor.resample",description:`<strong>resample</strong> (<code>PILImageResampling</code>, <em>optional</em>, defaults to <code>PILImageResampling.BILINEAR</code>) &#x2014;
Resampling filter to use if resizing the image. Can be overridden by the <code>resample</code> parameter in the
<code>preprocess</code> method.`,name:"resample"},{anchor:"transformers.LayoutLMv2ImageProcessor.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. Can be overridden by
<code>apply_ocr</code> in <code>preprocess</code>.`,name:"apply_ocr"},{anchor:"transformers.LayoutLMv2ImageProcessor.ocr_lang",description:`<strong>ocr_lang</strong> (<code>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. Can be overridden by <code>ocr_lang</code> in <code>preprocess</code>.`,name:"ocr_lang"},{anchor:"transformers.LayoutLMv2ImageProcessor.tesseract_config",description:`<strong>tesseract_config</strong> (<code>str</code>, <em>optional</em>) &#x2014;
Any additional custom configuration flags that are forwarded to the <code>config</code> parameter when calling
Tesseract. For example: &#x2018;&#x2014;psm 6&#x2019;. Can be overridden by <code>tesseract_config</code> in <code>preprocess</code>.`,name:"tesseract_config"}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/models/layoutlmv2/image_processing_layoutlmv2.py#L102"}}),jo=new C({props:{name:"preprocess",anchor:"transformers.LayoutLMv2ImageProcessor.preprocess",parameters:[{name:"images",val:": typing.Union[ForwardRef('PIL.Image.Image'), numpy.ndarray, ForwardRef('torch.Tensor'), typing.List[ForwardRef('PIL.Image.Image')], typing.List[numpy.ndarray], typing.List[ForwardRef('torch.Tensor')]]"},{name:"do_resize",val:": bool = None"},{name:"size",val:": typing.Dict[str, int] = None"},{name:"resample",val:": Resampling = None"},{name:"apply_ocr",val:": bool = None"},{name:"ocr_lang",val:": typing.Optional[str] = None"},{name:"tesseract_config",val:": typing.Optional[str] = None"},{name:"return_tensors",val:": typing.Union[str, transformers.utils.generic.TensorType, NoneType] = None"},{name:"data_format",val:": ChannelDimension = <ChannelDimension.FIRST: 'channels_first'>"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.LayoutLMv2ImageProcessor.preprocess.images",description:`<strong>images</strong> (<code>ImageInput</code>) &#x2014;
Image to preprocess.`,name:"images"},{anchor:"transformers.LayoutLMv2ImageProcessor.preprocess.do_resize",description:`<strong>do_resize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_resize</code>) &#x2014;
Whether to resize the image.`,name:"do_resize"},{anchor:"transformers.LayoutLMv2ImageProcessor.preprocess.size",description:`<strong>size</strong> (<code>Dict[str, int]</code>, <em>optional</em>, defaults to <code>self.size</code>) &#x2014;
Desired size of the output image after resizing.`,name:"size"},{anchor:"transformers.LayoutLMv2ImageProcessor.preprocess.resample",description:`<strong>resample</strong> (<code>PILImageResampling</code>, <em>optional</em>, defaults to <code>self.resample</code>) &#x2014;
Resampling filter to use if resizing the image. This can be one of the enum <code>PIL.Image</code> resampling
filter. Only has an effect if <code>do_resize</code> is set to <code>True</code>.`,name:"resample"},{anchor:"transformers.LayoutLMv2ImageProcessor.preprocess.apply_ocr",description:`<strong>apply_ocr</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.apply_ocr</code>) &#x2014;
Whether to apply the Tesseract OCR engine to get words + normalized bounding boxes.`,name:"apply_ocr"},{anchor:"transformers.LayoutLMv2ImageProcessor.preprocess.ocr_lang",description:`<strong>ocr_lang</strong> (<code>str</code>, <em>optional</em>, defaults to <code>self.ocr_lang</code>) &#x2014;
The language, specified by its ISO code, to be used by the Tesseract OCR engine. By default, English is
used.`,name:"ocr_lang"},{anchor:"transformers.LayoutLMv2ImageProcessor.preprocess.tesseract_config",description:`<strong>tesseract_config</strong> (<code>str</code>, <em>optional</em>, defaults to <code>self.tesseract_config</code>) &#x2014;
Any additional custom configuration flags that are forwarded to the <code>config</code> parameter when calling
Tesseract.`,name:"tesseract_config"},{anchor:"transformers.LayoutLMv2ImageProcessor.preprocess.return_tensors",description:`<strong>return_tensors</strong> (<code>str</code> or <code>TensorType</code>, <em>optional</em>) &#x2014;
The type of tensors to return. Can be one of:<ul>
<li>Unset: Return a list of <code>np.ndarray</code>.</li>
<li><code>TensorType.TENSORFLOW</code> or <code>&apos;tf&apos;</code>: Return a batch of type <code>tf.Tensor</code>.</li>
<li><code>TensorType.PYTORCH</code> or <code>&apos;pt&apos;</code>: Return a batch of type <code>torch.Tensor</code>.</li>
<li><code>TensorType.NUMPY</code> or <code>&apos;np&apos;</code>: Return a batch of type <code>np.ndarray</code>.</li>
<li><code>TensorType.JAX</code> or <code>&apos;jax&apos;</code>: Return a batch of type <code>jax.numpy.ndarray</code>.</li>
</ul>`,name:"return_tensors"},{anchor:"transformers.LayoutLMv2ImageProcessor.preprocess.data_format",description:`<strong>data_format</strong> (<code>ChannelDimension</code> or <code>str</code>, <em>optional</em>, defaults to <code>ChannelDimension.FIRST</code>) &#x2014;
The channel dimension format for the output image. Can be one of:<ul>
<li><code>ChannelDimension.FIRST</code>: image in (num_channels, height, width) format.</li>
<li><code>ChannelDimension.LAST</code>: image in (height, width, num_channels) format.</li>
</ul>`,name:"data_format"}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/models/layoutlmv2/image_processing_layoutlmv2.py#L176"}}),Io=new X({}),Co=new C({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/v4.29.0/src/transformers/models/layoutlmv2/tokenization_layoutlmv2.py#L206"}}),Do=new C({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.utils.generic.PaddingStrategy] = False"},{name:"truncation",val:": typing.Union[bool, str, transformers.tokenization_utils_base.TruncationStrategy] = None"},{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.utils.generic.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:""}],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/v4.29.0/en/internal/file_utils#transformers.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/v4.29.0/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__.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 <code>&gt;= 7.5</code> (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/v4.29.0/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__.return_token_type_ids",description:`<strong>return_token_type_ids</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether to return token type IDs. If left to the default, will return the token type IDs according to
the specific tokenizer&#x2019;s default, defined by the <code>return_outputs</code> attribute.</p>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"return_token_type_ids"},{anchor:"transformers.LayoutLMv2Tokenizer.__call__.return_attention_mask",description:`<strong>return_attention_mask</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether to return the attention mask. If left to the default, will return the attention mask according
to the specific tokenizer&#x2019;s default, defined by the <code>return_outputs</code> attribute.</p>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"return_attention_mask"},{anchor:"transformers.LayoutLMv2Tokenizer.__call__.return_overflowing_tokens",description:`<strong>return_overflowing_tokens</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to return overflowing token sequences. If a pair of sequences of input ids (or a batch
of pairs) is provided with <code>truncation_strategy = longest_first</code> or <code>True</code>, an error is raised instead
of returning overflowing tokens.`,name:"return_overflowing_tokens"},{anchor:"transformers.LayoutLMv2Tokenizer.__call__.return_special_tokens_mask",description:`<strong>return_special_tokens_mask</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to return special tokens mask information.`,name:"return_special_tokens_mask"},{anchor:"transformers.LayoutLMv2Tokenizer.__call__.return_offsets_mapping",description:`<strong>return_offsets_mapping</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to return <code>(char_start, char_end)</code> for each token.</p>
<p>This is only available on fast tokenizers inheriting from <a href="/docs/transformers/v4.29.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast">PreTrainedTokenizerFast</a>, if using
Python&#x2019;s tokenizer, this method will raise <code>NotImplementedError</code>.`,name:"return_offsets_mapping"},{anchor:"transformers.LayoutLMv2Tokenizer.__call__.return_length",description:`<strong>return_length</strong>  (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to return the lengths of the encoded inputs.`,name:"return_length"},{anchor:"transformers.LayoutLMv2Tokenizer.__call__.verbose",description:`<strong>verbose</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to print more information and warnings.
**kwargs &#x2014; passed to the <code>self.tokenize()</code> method`,name:"verbose"}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/models/layoutlmv2/tokenization_layoutlmv2.py#L425",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.29.0/en/main_classes/tokenizer#transformers.BatchEncoding"
>BatchEncoding</a> with the following fields:</p>
<ul>
<li>
<p><strong>input_ids</strong> \u2014 List of token ids to be fed to a model.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a></p>
</li>
<li>
<p><strong>bbox</strong> \u2014 List of bounding boxes to be fed to a model.</p>
</li>
<li>
<p><strong>token_type_ids</strong> \u2014 List of token type ids to be fed to a model (when <code>return_token_type_ids=True</code> or
if <em>\u201Ctoken_type_ids\u201D</em> is in <code>self.model_input_names</code>).</p>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a></p>
</li>
<li>
<p><strong>attention_mask</strong> \u2014 List of indices specifying which tokens should be attended to by the model (when
<code>return_attention_mask=True</code> or if <em>\u201Cattention_mask\u201D</em> is in <code>self.model_input_names</code>).</p>
<p><a href="../glossary#attention-mask">What are attention masks?</a></p>
</li>
<li>
<p><strong>labels</strong> \u2014 List of labels to be fed to a model. (when <code>word_labels</code> is specified).</p>
</li>
<li>
<p><strong>overflowing_tokens</strong> \u2014 List of overflowing tokens sequences (when a <code>max_length</code> is specified and
<code>return_overflowing_tokens=True</code>).</p>
</li>
<li>
<p><strong>num_truncated_tokens</strong> \u2014 Number of tokens truncated (when a <code>max_length</code> is specified and
<code>return_overflowing_tokens=True</code>).</p>
</li>
<li>
<p><strong>special_tokens_mask</strong> \u2014 List of 0s and 1s, with 1 specifying added special tokens and 0 specifying
regular sequence tokens (when <code>add_special_tokens=True</code> and <code>return_special_tokens_mask=True</code>).</p>
</li>
<li>
<p><strong>length</strong> \u2014 The length of the inputs (when <code>return_length=True</code>).</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/v4.29.0/en/main_classes/tokenizer#transformers.BatchEncoding"
>BatchEncoding</a></p>
`}}),Oo=new C({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/v4.29.0/src/transformers/models/layoutlmv2/tokenization_layoutlmv2.py#L405"}}),No=new X({}),So=new C({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:""}],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>).`,name:"tokenize_chinese_chars"},{anchor:"transformers.LayoutLMv2TokenizerFast.strip_accents",description:`<strong>strip_accents</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
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:"strip_accents"}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/models/layoutlmv2/tokenization_layoutlmv2_fast.py#L70"}}),Uo=new C({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.utils.generic.PaddingStrategy] = False"},{name:"truncation",val:": typing.Union[bool, str, transformers.tokenization_utils_base.TruncationStrategy] = None"},{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.utils.generic.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:""}],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/v4.29.0/en/internal/file_utils#transformers.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/v4.29.0/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__.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 <code>&gt;= 7.5</code> (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/v4.29.0/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__.return_token_type_ids",description:`<strong>return_token_type_ids</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether to return token type IDs. If left to the default, will return the token type IDs according to
the specific tokenizer&#x2019;s default, defined by the <code>return_outputs</code> attribute.</p>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"return_token_type_ids"},{anchor:"transformers.LayoutLMv2TokenizerFast.__call__.return_attention_mask",description:`<strong>return_attention_mask</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether to return the attention mask. If left to the default, will return the attention mask according
to the specific tokenizer&#x2019;s default, defined by the <code>return_outputs</code> attribute.</p>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"return_attention_mask"},{anchor:"transformers.LayoutLMv2TokenizerFast.__call__.return_overflowing_tokens",description:`<strong>return_overflowing_tokens</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to return overflowing token sequences. If a pair of sequences of input ids (or a batch
of pairs) is provided with <code>truncation_strategy = longest_first</code> or <code>True</code>, an error is raised instead
of returning overflowing tokens.`,name:"return_overflowing_tokens"},{anchor:"transformers.LayoutLMv2TokenizerFast.__call__.return_special_tokens_mask",description:`<strong>return_special_tokens_mask</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to return special tokens mask information.`,name:"return_special_tokens_mask"},{anchor:"transformers.LayoutLMv2TokenizerFast.__call__.return_offsets_mapping",description:`<strong>return_offsets_mapping</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to return <code>(char_start, char_end)</code> for each token.</p>
<p>This is only available on fast tokenizers inheriting from <a href="/docs/transformers/v4.29.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast">PreTrainedTokenizerFast</a>, if using
Python&#x2019;s tokenizer, this method will raise <code>NotImplementedError</code>.`,name:"return_offsets_mapping"},{anchor:"transformers.LayoutLMv2TokenizerFast.__call__.return_length",description:`<strong>return_length</strong>  (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to return the lengths of the encoded inputs.`,name:"return_length"},{anchor:"transformers.LayoutLMv2TokenizerFast.__call__.verbose",description:`<strong>verbose</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to print more information and warnings.
**kwargs &#x2014; passed to the <code>self.tokenize()</code> method`,name:"verbose"}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/models/layoutlmv2/tokenization_layoutlmv2_fast.py#L179",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.29.0/en/main_classes/tokenizer#transformers.BatchEncoding"
>BatchEncoding</a> with the following fields:</p>
<ul>
<li>
<p><strong>input_ids</strong> \u2014 List of token ids to be fed to a model.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a></p>
</li>
<li>
<p><strong>bbox</strong> \u2014 List of bounding boxes to be fed to a model.</p>
</li>
<li>
<p><strong>token_type_ids</strong> \u2014 List of token type ids to be fed to a model (when <code>return_token_type_ids=True</code> or
if <em>\u201Ctoken_type_ids\u201D</em> is in <code>self.model_input_names</code>).</p>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a></p>
</li>
<li>
<p><strong>attention_mask</strong> \u2014 List of indices specifying which tokens should be attended to by the model (when
<code>return_attention_mask=True</code> or if <em>\u201Cattention_mask\u201D</em> is in <code>self.model_input_names</code>).</p>
<p><a href="../glossary#attention-mask">What are attention masks?</a></p>
</li>
<li>
<p><strong>labels</strong> \u2014 List of labels to be fed to a model. (when <code>word_labels</code> is specified).</p>
</li>
<li>
<p><strong>overflowing_tokens</strong> \u2014 List of overflowing tokens sequences (when a <code>max_length</code> is specified and
<code>return_overflowing_tokens=True</code>).</p>
</li>
<li>
<p><strong>num_truncated_tokens</strong> \u2014 Number of tokens truncated (when a <code>max_length</code> is specified and
<code>return_overflowing_tokens=True</code>).</p>
</li>
<li>
<p><strong>special_tokens_mask</strong> \u2014 List of 0s and 1s, with 1 specifying added special tokens and 0 specifying
regular sequence tokens (when <code>add_special_tokens=True</code> and <code>return_special_tokens_mask=True</code>).</p>
</li>
<li>
<p><strong>length</strong> \u2014 The length of the inputs (when <code>return_length=True</code>).</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/v4.29.0/en/main_classes/tokenizer#transformers.BatchEncoding"
>BatchEncoding</a></p>
`}}),Bo=new X({}),Vo=new C({props:{name:"class transformers.LayoutLMv2Processor",anchor:"transformers.LayoutLMv2Processor",parameters:[{name:"image_processor",val:" = None"},{name:"tokenizer",val:" = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.LayoutLMv2Processor.image_processor",description:`<strong>image_processor</strong> (<code>LayoutLMv2ImageProcessor</code>) &#x2014;
An instance of <a href="/docs/transformers/v4.29.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2ImageProcessor">LayoutLMv2ImageProcessor</a>. The image processor is a required input.`,name:"image_processor"},{anchor:"transformers.LayoutLMv2Processor.tokenizer",description:`<strong>tokenizer</strong> (<code>LayoutLMv2Tokenizer</code> or <code>LayoutLMv2TokenizerFast</code>) &#x2014;
An instance of <a href="/docs/transformers/v4.29.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Tokenizer">LayoutLMv2Tokenizer</a> or <a href="/docs/transformers/v4.29.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2TokenizerFast">LayoutLMv2TokenizerFast</a>. The tokenizer is a required input.`,name:"tokenizer"}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/models/layoutlmv2/processing_layoutlmv2.py#L27"}}),Qo=new C({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.utils.generic.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.utils.generic.TensorType, NoneType] = None"},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/models/layoutlmv2/processing_layoutlmv2.py#L67"}}),Ko=new X({}),Xo=new C({props:{name:"class transformers.LayoutLMv2Model",anchor:"transformers.LayoutLMv2Model",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.LayoutLMv2Model.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.29.0/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/v4.29.0/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/models/layoutlmv2/modeling_layoutlmv2.py#L709"}}),Jo=new C({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"}],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/v4.29.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.29.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.29.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.__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/v4.29.0/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/models/layoutlmv2/modeling_layoutlmv2.py#L819",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.29.0/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/v4.29.0/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, if the model has an embedding layer, +
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 optional 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/v4.29.0/en/main_classes/output#transformers.modeling_outputs.BaseModelOutput"
>transformers.modeling_outputs.BaseModelOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),mt=new Gl({props:{$$slots:{default:[$2]},$$scope:{ctx:P}}}),ht=new Gs({props:{anchor:"transformers.LayoutLMv2Model.forward.example",$$slots:{default:[E2]},$$scope:{ctx:P}}}),en=new X({}),tn=new C({props:{name:"class transformers.LayoutLMv2ForSequenceClassification",anchor:"transformers.LayoutLMv2ForSequenceClassification",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.LayoutLMv2ForSequenceClassification.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.29.0/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/v4.29.0/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/models/layoutlmv2/modeling_layoutlmv2.py#L970"}}),rn=new C({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"}],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/v4.29.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.29.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.29.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.__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/v4.29.0/en/main_classes/output#transformers.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"}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/models/layoutlmv2/modeling_layoutlmv2.py#L984",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.29.0/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/v4.29.0/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, if the model has an embedding layer, +
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 optional 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/v4.29.0/en/main_classes/output#transformers.modeling_outputs.SequenceClassifierOutput"
>transformers.modeling_outputs.SequenceClassifierOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),gt=new Gl({props:{$$slots:{default:[z2]},$$scope:{ctx:P}}}),_t=new Gs({props:{anchor:"transformers.LayoutLMv2ForSequenceClassification.forward.example",$$slots:{default:[q2]},$$scope:{ctx:P}}}),ln=new X({}),cn=new C({props:{name:"class transformers.LayoutLMv2ForTokenClassification",anchor:"transformers.LayoutLMv2ForTokenClassification",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.LayoutLMv2ForTokenClassification.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.29.0/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/v4.29.0/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/models/layoutlmv2/modeling_layoutlmv2.py#L1151"}}),gn=new C({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"}],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/v4.29.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.29.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.29.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.__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/v4.29.0/en/main_classes/output#transformers.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"}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/models/layoutlmv2/modeling_layoutlmv2.py#L1165",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.29.0/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/v4.29.0/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, if the model has an embedding layer, +
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 optional 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/v4.29.0/en/main_classes/output#transformers.modeling_outputs.TokenClassifierOutput"
>transformers.modeling_outputs.TokenClassifierOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),yt=new Gl({props:{$$slots:{default:[F2]},$$scope:{ctx:P}}}),bt=new Gs({props:{anchor:"transformers.LayoutLMv2ForTokenClassification.forward.example",$$slots:{default:[P2]},$$scope:{ctx:P}}}),_n=new X({}),vn=new C({props:{name:"class transformers.LayoutLMv2ForQuestionAnswering",anchor:"transformers.LayoutLMv2ForQuestionAnswering",parameters:[{name:"config",val:""},{name:"has_visual_segment_embedding",val:" = True"}],parametersDescription:[{anchor:"transformers.LayoutLMv2ForQuestionAnswering.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.29.0/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/v4.29.0/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/models/layoutlmv2/modeling_layoutlmv2.py#L1282"}}),kn=new C({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"}],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/v4.29.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.29.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.29.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.__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/v4.29.0/en/main_classes/output#transformers.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"}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/models/layoutlmv2/modeling_layoutlmv2.py#L1296",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.29.0/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/v4.29.0/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, if the model has an embedding layer, +
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 optional 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/v4.29.0/en/main_classes/output#transformers.modeling_outputs.QuestionAnsweringModelOutput"
>transformers.modeling_outputs.QuestionAnsweringModelOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),kt=new Gl({props:{$$slots:{default:[j2]},$$scope:{ctx:P}}}),wt=new Gs({props:{anchor:"transformers.LayoutLMv2ForQuestionAnswering.forward.example",$$slots:{default:[I2]},$$scope:{ctx:P}}}),xt=new Gs({props:{anchor:"transformers.LayoutLMv2ForQuestionAnswering.forward.example-2",$$slots:{default:[C2]},$$scope:{ctx:P}}}),{c(){h=a("meta"),x=d(),f=a("h1"),k=a("a"),T=a("span"),g(m.$$.fragment),w=d(),O=a("span"),Hl=n("LayoutLMV2"),Yr=d(),$e=a("h2"),Ke=a("a"),Ks=a("span"),g(Ct.$$.fragment),Kl=d(),Xs=a("span"),Xl=n("Overview"),Zr=d(),me=a("p"),Yl=n("The LayoutLMV2 model was proposed in "),At=a("a"),Zl=n("LayoutLMv2: Multi-modal Pre-training for Visually-Rich Document Understanding"),Jl=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 `),Tn=a("a"),ec=n("LayoutLM"),tc=n(` to obtain
state-of-the-art results across several document image understanding benchmarks:`),Jr=d(),he=a("ul"),Y=a("li"),oc=n("information extraction from scanned documents: the "),Dt=a("a"),nc=n("FUNSD"),sc=n(` dataset (a
collection of 199 annotated forms comprising more than 30,000 words), the `),Ot=a("a"),ac=n("CORD"),rc=n(`
dataset (a collection of 800 receipts for training, 100 for validation and 100 for testing), the `),Nt=a("a"),ic=n("SROIE"),lc=n(` dataset (a collection of 626 receipts for training and 347 receipts for testing)
and the `),St=a("a"),cc=n("Kleister-NDA"),dc=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).`),pc=d(),Rt=a("li"),uc=n("document image classification: the "),Wt=a("a"),mc=n("RVL-CDIP"),hc=n(` dataset (a collection of
400,000 images belonging to one of 16 classes).`),fc=d(),Ut=a("li"),gc=n("document visual question answering: the "),Bt=a("a"),_c=n("DocVQA"),vc=n(` dataset (a collection of 50,000
questions defined on 12,000+ document images).`),ei=d(),Mn=a("p"),yc=n("The abstract from the paper is the following:"),ti=d(),$n=a("p"),Ys=a("em"),bc=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.`),oi=d(),se=a("p"),Lc=n("LayoutLMv2 depends on "),Zs=a("code"),kc=n("detectron2"),wc=n(", "),Js=a("code"),xc=n("torchvision"),Tc=n(" and "),ea=a("code"),Mc=n("tesseract"),$c=n(`. Run the
following to install them:`),ni=d(),g(Vt.$$.fragment),si=d(),En=a("p"),Ec=n("(If you are developing for LayoutLMv2, note that passing the doctests also requires the installation of these packages.)"),ai=d(),zn=a("p"),zc=n("Tips:"),ri=d(),V=a("ul"),ta=a("li"),qc=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).`),Fc=d(),Qt=a("li"),Pc=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 `),Gt=a("a"),jc=n("paper"),Ic=n("."),Cc=d(),Ht=a("li"),Ac=n("Demo notebooks on how to use the LayoutLMv2 model on RVL-CDIP, FUNSD, DocVQA, CORD can be found "),Kt=a("a"),Dc=n("here"),Oc=n("."),Nc=d(),Ee=a("li"),Sc=n("LayoutLMv2 uses Facebook AI\u2019s "),Xt=a("a"),Rc=n("Detectron2"),Wc=n(` package for its visual
backbone. See `),Yt=a("a"),Uc=n("this link"),Bc=n(` for installation
instructions.`),Vc=d(),M=a("li"),Qc=n("In addition to "),oa=a("code"),Gc=n("input_ids"),Hc=n(", "),qn=a("a"),Kc=n("forward()"),Xc=n(` expects 2 additional inputs, namely
`),na=a("code"),Yc=n("image"),Zc=n(" and "),sa=a("code"),Jc=n("bbox"),ed=n(". The "),aa=a("code"),td=n("image"),od=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, `),ra=a("code"),nd=n("image"),sd=n(` should be a tensor of shape (batch_size, 3, 224, 224). This can be either a
`),ia=a("code"),ad=n("torch.Tensor"),rd=n(" or a "),la=a("code"),id=n("Detectron2.structures.ImageList"),ld=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 `),ca=a("code"),cd=n("bbox"),dd=n(` input are the bounding boxes (i.e. 2D-positions)
of the input text tokens. This is identical to `),Fn=a("a"),pd=n("LayoutLMModel"),ud=n(`. These can be obtained using an
external OCR engine such as Google\u2019s `),Zt=a("a"),md=n("Tesseract"),hd=n(" (there\u2019s a "),Jt=a("a"),fd=n(`Python
wrapper`),gd=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:`),ii=d(),g(eo.$$.fragment),li=d(),fe=a("p"),_d=n("Here, "),da=a("code"),vd=n("width"),yd=n(" and "),pa=a("code"),bd=n("height"),Ld=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:`),ci=d(),g(to.$$.fragment),di=d(),Xe=a("p"),kd=n("However, this model includes a brand new "),Pn=a("a"),wd=n("LayoutLMv2Processor"),xd=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.`),pi=d(),ge=a("ul"),A=a("li"),Td=n("Internally, "),jn=a("a"),Md=n("LayoutLMv2Model"),$d=n(" will send the "),ua=a("code"),Ed=n("image"),zd=n(` input through its visual backbone to
obtain a lower-resolution feature map, whose shape is equal to the `),ma=a("code"),qd=n("image_feature_pool_shape"),Fd=n(` attribute of
`),In=a("a"),Pd=n("LayoutLMv2Config"),jd=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 `),ha=a("code"),Id=n("seq_length"),Cd=n(" + "),fa=a("code"),Ad=n("image_feature_pool_shape[0]"),Dd=n(` *
`),ga=a("code"),Od=n("config.image_feature_pool_shape[1]"),Nd=n("."),Sd=d(),oo=a("li"),Rd=n("When calling "),Cn=a("a"),Wd=n("from_pretrained()"),Ud=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.`),Bd=d(),no=a("li"),Vd=n("If you want to train the model in a distributed environment, make sure to call "),_a=a("code"),Qd=n("synchronize_batch_norm"),Gd=n(` on the
model in order to properly synchronize the batch normalization layers of the visual backbone.`),ui=d(),Ye=a("p"),Hd=n(`In addition, there\u2019s LayoutXLM, which is a multilingual version of LayoutLMv2. More information can be found on
`),An=a("a"),Kd=n("LayoutXLM\u2019s documentation page"),Xd=n("."),mi=d(),ze=a("h2"),Ze=a("a"),va=a("span"),g(so.$$.fragment),Yd=d(),ya=a("span"),Zd=n("Resources"),hi=d(),Dn=a("p"),Jd=n("A list of official Hugging Face and community (indicated by \u{1F30E}) resources to help you get started with LayoutLMv2. If you\u2019re interested in submitting a resource to be included here, please feel free to open a Pull Request and we\u2019ll review it! The resource should ideally demonstrate something new instead of duplicating an existing resource."),fi=d(),g(ao.$$.fragment),gi=d(),Je=a("ul"),ro=a("li"),ep=n("A notebook on how to "),io=a("a"),tp=n("finetune LayoutLMv2 for text-classification on RVL-CDIP dataset"),op=n("."),np=d(),On=a("li"),sp=n("See also: "),Nn=a("a"),ap=n("Text classification task guide"),_i=d(),g(lo.$$.fragment),vi=d(),_e=a("ul"),co=a("li"),rp=n("A notebook on how to "),po=a("a"),ip=n("finetune LayoutLMv2 for question-answering on DocVQA dataset"),lp=n("."),cp=d(),Sn=a("li"),dp=n("See also: "),Rn=a("a"),pp=n("Question answering task guide"),up=d(),Wn=a("li"),mp=n("See also: "),Un=a("a"),hp=n("Document question answering task guide"),yi=d(),g(uo.$$.fragment),bi=d(),ve=a("ul"),mo=a("li"),fp=n("A notebook on how to "),ho=a("a"),gp=n("finetune LayoutLMv2 for token-classification on CORD dataset"),_p=n("."),vp=d(),fo=a("li"),yp=n("A notebook on how to "),go=a("a"),bp=n("finetune LayoutLMv2 for token-classification on FUNSD dataset"),Lp=n("."),kp=d(),Bn=a("li"),wp=n("See also: "),Vn=a("a"),xp=n("Token classification task guide"),Li=d(),qe=a("h2"),et=a("a"),ba=a("span"),g(_o.$$.fragment),Tp=d(),La=a("span"),Mp=n("Usage: LayoutLMv2Processor"),ki=d(),Q=a("p"),$p=n("The easiest way to prepare data for the model is to use "),Qn=a("a"),Ep=n("LayoutLMv2Processor"),zp=n(`, which internally
combines a feature extractor (`),Gn=a("a"),qp=n("LayoutLMv2FeatureExtractor"),Fp=n(`) and a tokenizer
(`),Hn=a("a"),Pp=n("LayoutLMv2Tokenizer"),jp=n(" or "),Kn=a("a"),Ip=n("LayoutLMv2TokenizerFast"),Cp=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.`),wi=d(),g(vo.$$.fragment),xi=d(),E=a("p"),Ap=n("In short, one can provide a document image (and possibly additional data) to "),Xn=a("a"),Dp=n("LayoutLMv2Processor"),Op=n(`,
and it will create the inputs expected by the model. Internally, the processor first uses
`),Yn=a("a"),Np=n("LayoutLMv2FeatureExtractor"),Sp=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 `),ka=a("code"),Rp=n("image"),Wp=n(` input. The words and
normalized bounding boxes are then provided to `),Zn=a("a"),Up=n("LayoutLMv2Tokenizer"),Bp=n(` or
`),Jn=a("a"),Vp=n("LayoutLMv2TokenizerFast"),Qp=n(", which converts them to token-level "),wa=a("code"),Gp=n("input_ids"),Hp=n(`,
`),xa=a("code"),Kp=n("attention_mask"),Xp=n(", "),Ta=a("code"),Yp=n("token_type_ids"),Zp=n(", "),Ma=a("code"),Jp=n("bbox"),eu=n(`. Optionally, one can provide word labels to the processor,
which are turned into token-level `),$a=a("code"),tu=n("labels"),ou=n("."),Ti=d(),W=a("p"),es=a("a"),nu=n("LayoutLMv2Processor"),su=n(" uses "),yo=a("a"),au=n("PyTesseract"),ru=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
`),ts=a("a"),iu=n("LayoutLMv2FeatureExtractor"),lu=n(" with "),Ea=a("code"),cu=n("apply_ocr"),du=n(" set to "),za=a("code"),pu=n("False"),uu=n("."),Mi=d(),os=a("p"),mu=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).`),$i=d(),ns=a("p"),qa=a("strong"),hu=n(`Use case 1: document image classification (training, inference) + token classification (inference), apply_ocr =
True`),Ei=d(),ss=a("p"),fu=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.`),zi=d(),g(bo.$$.fragment),qi=d(),as=a("p"),Fa=a("strong"),gu=n("Use case 2: document image classification (training, inference) + token classification (inference), apply_ocr=False"),Fi=d(),ye=a("p"),_u=n("In case one wants to do OCR themselves, one can initialize the feature extractor with "),Pa=a("code"),vu=n("apply_ocr"),yu=n(` set to
`),ja=a("code"),bu=n("False"),Lu=n(`. In that case, one should provide the words and corresponding (normalized) bounding boxes themselves to
the processor.`),Pi=d(),g(Lo.$$.fragment),ji=d(),rs=a("p"),Ia=a("strong"),ku=n("Use case 3: token classification (training), apply_ocr=False"),Ii=d(),G=a("p"),wu=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 `),Ca=a("code"),xu=n("labels"),Tu=n(`. By default, it
will only label the first wordpiece of a word, and label the remaining wordpieces with -100, which is the
`),Aa=a("code"),Mu=n("ignore_index"),$u=n(` of PyTorch\u2019s CrossEntropyLoss. In case you want all wordpieces of a word to be labeled, you can
initialize the tokenizer with `),Da=a("code"),Eu=n("only_label_first_subword"),zu=n(" set to "),Oa=a("code"),qu=n("False"),Fu=n("."),Ci=d(),g(ko.$$.fragment),Ai=d(),is=a("p"),Na=a("strong"),Pu=n("Use case 4: visual question answering (inference), apply_ocr=True"),Di=d(),ls=a("p"),ju=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].`),Oi=d(),g(wo.$$.fragment),Ni=d(),cs=a("p"),Sa=a("strong"),Iu=n("Use case 5: visual question answering (inference), apply_ocr=False"),Si=d(),ds=a("p"),Cu=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.`),Ri=d(),g(xo.$$.fragment),Wi=d(),Fe=a("h2"),tt=a("a"),Ra=a("span"),g(To.$$.fragment),Au=d(),Wa=a("span"),Du=n("LayoutLMv2Config"),Ui=d(),Z=a("div"),g(Mo.$$.fragment),Ou=d(),Pe=a("p"),Nu=n("This is the configuration class to store the configuration of a "),ps=a("a"),Su=n("LayoutLMv2Model"),Ru=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
`),$o=a("a"),Wu=n("microsoft/layoutlmv2-base-uncased"),Uu=n(" architecture."),Bu=d(),je=a("p"),Vu=n("Configuration objects inherit from "),us=a("a"),Qu=n("PretrainedConfig"),Gu=n(` and can be used to control the model outputs. Read the
documentation from `),ms=a("a"),Hu=n("PretrainedConfig"),Ku=n(" for more information."),Xu=d(),g(ot.$$.fragment),Bi=d(),Ie=a("h2"),nt=a("a"),Ua=a("span"),g(Eo.$$.fragment),Yu=d(),Ba=a("span"),Zu=n("LayoutLMv2FeatureExtractor"),Vi=d(),Ce=a("div"),g(zo.$$.fragment),Ju=d(),st=a("div"),g(qo.$$.fragment),em=d(),Va=a("p"),tm=n("Preprocess an image or a batch of images."),Qi=d(),Ae=a("h2"),at=a("a"),Qa=a("span"),g(Fo.$$.fragment),om=d(),Ga=a("span"),nm=n("LayoutLMv2ImageProcessor"),Gi=d(),ce=a("div"),g(Po.$$.fragment),sm=d(),Ha=a("p"),am=n("Constructs a LayoutLMv2 image processor."),rm=d(),rt=a("div"),g(jo.$$.fragment),im=d(),Ka=a("p"),lm=n("Preprocess an image or batch of images."),Hi=d(),De=a("h2"),it=a("a"),Xa=a("span"),g(Io.$$.fragment),cm=d(),Ya=a("span"),dm=n("LayoutLMv2Tokenizer"),Ki=d(),N=a("div"),g(Co.$$.fragment),pm=d(),S=a("p"),um=n("Construct a LayoutLMv2 tokenizer. Based on WordPiece. "),hs=a("a"),mm=n("LayoutLMv2Tokenizer"),hm=n(` can be used to turn words, word-level
bounding boxes and optional word labels to token-level `),Za=a("code"),fm=n("input_ids"),gm=n(", "),Ja=a("code"),_m=n("attention_mask"),vm=n(", "),er=a("code"),ym=n("token_type_ids"),bm=n(", "),tr=a("code"),Lm=n("bbox"),km=n(`, and
optional `),or=a("code"),wm=n("labels"),xm=n(" (for token classification)."),Tm=d(),Ao=a("p"),Mm=n("This tokenizer inherits from "),fs=a("a"),$m=n("PreTrainedTokenizer"),Em=n(` which contains most of the main methods. Users should refer to
this superclass for more information regarding those methods.`),zm=d(),gs=a("p"),_s=a("a"),qm=n("LayoutLMv2Tokenizer"),Fm=n(` runs end-to-end tokenization: punctuation splitting and wordpiece. It also turns the
word-level bounding boxes into token-level bounding boxes.`),Pm=d(),lt=a("div"),g(Do.$$.fragment),jm=d(),nr=a("p"),Im=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.`),Cm=d(),vs=a("div"),g(Oo.$$.fragment),Xi=d(),Oe=a("h2"),ct=a("a"),sr=a("span"),g(No.$$.fragment),Am=d(),ar=a("span"),Dm=n("LayoutLMv2TokenizerFast"),Yi=d(),J=a("div"),g(So.$$.fragment),Om=d(),Ro=a("p"),Nm=n("Construct a \u201Cfast\u201D LayoutLMv2 tokenizer (backed by HuggingFace\u2019s "),rr=a("em"),Sm=n("tokenizers"),Rm=n(" library). Based on WordPiece."),Wm=d(),Wo=a("p"),Um=n("This tokenizer inherits from "),ys=a("a"),Bm=n("PreTrainedTokenizerFast"),Vm=n(` which contains most of the main methods. Users should
refer to this superclass for more information regarding those methods.`),Qm=d(),dt=a("div"),g(Uo.$$.fragment),Gm=d(),ir=a("p"),Hm=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.`),Zi=d(),Ne=a("h2"),pt=a("a"),lr=a("span"),g(Bo.$$.fragment),Km=d(),cr=a("span"),Xm=n("LayoutLMv2Processor"),Ji=d(),U=a("div"),g(Vo.$$.fragment),Ym=d(),dr=a("p"),Zm=n(`Constructs a LayoutLMv2 processor which combines a LayoutLMv2 image processor and a LayoutLMv2 tokenizer into a
single processor.`),Jm=d(),bs=a("p"),Ls=a("a"),eh=n("LayoutLMv2Processor"),th=n(" offers all the functionalities you need to prepare data for the model."),oh=d(),F=a("p"),nh=n("It first uses "),ks=a("a"),sh=n("LayoutLMv2ImageProcessor"),ah=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 `),ws=a("a"),rh=n("LayoutLMv2Tokenizer"),ih=n(` or
`),xs=a("a"),lh=n("LayoutLMv2TokenizerFast"),ch=n(", which turns the words and bounding boxes into token-level "),pr=a("code"),dh=n("input_ids"),ph=n(`,
`),ur=a("code"),uh=n("attention_mask"),mh=n(", "),mr=a("code"),hh=n("token_type_ids"),fh=n(", "),hr=a("code"),gh=n("bbox"),_h=n(". Optionally, one can provide integer "),fr=a("code"),vh=n("word_labels"),yh=n(`, which are turned
into token-level `),gr=a("code"),bh=n("labels"),Lh=n(" for token classification tasks (such as FUNSD, CORD)."),kh=d(),be=a("div"),g(Qo.$$.fragment),wh=d(),$=a("p"),xh=n("This method first forwards the "),_r=a("code"),Th=n("images"),Mh=n(" argument to "),Go=a("a"),vr=a("strong"),$h=n("call"),Eh=n("()"),zh=n(`. In case
`),Ts=a("a"),qh=n("LayoutLMv2ImageProcessor"),Fh=n(" was initialized with "),yr=a("code"),Ph=n("apply_ocr"),jh=n(" set to "),br=a("code"),Ih=n("True"),Ch=n(`, it passes the obtained words and
bounding boxes along with the additional arguments to `),Ho=a("a"),Lr=a("strong"),Ah=n("call"),Dh=n("()"),Oh=n(` and returns the output,
together with resized `),kr=a("code"),Nh=n("images"),Sh=n(". In case "),Ms=a("a"),Rh=n("LayoutLMv2ImageProcessor"),Wh=n(" was initialized with "),wr=a("code"),Uh=n("apply_ocr"),Bh=n(` set to
`),xr=a("code"),Vh=n("False"),Qh=n(", it passes the words ("),Tr=a("code"),Gh=n("text"),Hh=n("/"),Mr=a("code"),Kh=n("text_pair`) and `boxes` specified by the user along with the additional arguments to [__call__()](/docs/transformers/v4.29.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Tokenizer.__call__) and returns the output, together with resized `images"),Xh=n("."),Yh=d(),$r=a("p"),Zh=n("Please refer to the docstring of the above two methods for more information."),el=d(),Se=a("h2"),ut=a("a"),Er=a("span"),g(Ko.$$.fragment),Jh=d(),zr=a("span"),ef=n("LayoutLMv2Model"),tl=d(),de=a("div"),g(Xo.$$.fragment),tf=d(),Yo=a("p"),of=n(`The bare LayoutLMv2 Model transformer outputting raw hidden-states without any specific head on top.
This model is a PyTorch `),Zo=a("a"),nf=n("torch.nn.Module"),sf=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.`),af=d(),ae=a("div"),g(Jo.$$.fragment),rf=d(),Re=a("p"),lf=n("The "),$s=a("a"),cf=n("LayoutLMv2Model"),df=n(" forward method, overrides the "),qr=a("code"),pf=n("__call__"),uf=n(" special method."),mf=d(),g(mt.$$.fragment),hf=d(),g(ht.$$.fragment),ol=d(),We=a("h2"),ft=a("a"),Fr=a("span"),g(en.$$.fragment),ff=d(),Pr=a("span"),gf=n("LayoutLMv2ForSequenceClassification"),nl=d(),ee=a("div"),g(tn.$$.fragment),_f=d(),on=a("p"),vf=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
`),nn=a("a"),yf=n("RVL-CDIP"),bf=n(" dataset."),Lf=d(),sn=a("p"),kf=n("This model is a PyTorch "),an=a("a"),wf=n("torch.nn.Module"),xf=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.`),Tf=d(),re=a("div"),g(rn.$$.fragment),Mf=d(),Ue=a("p"),$f=n("The "),Es=a("a"),Ef=n("LayoutLMv2ForSequenceClassification"),zf=n(" forward method, overrides the "),jr=a("code"),qf=n("__call__"),Ff=n(" special method."),Pf=d(),g(gt.$$.fragment),jf=d(),g(_t.$$.fragment),sl=d(),Be=a("h2"),vt=a("a"),Ir=a("span"),g(ln.$$.fragment),If=d(),Cr=a("span"),Cf=n("LayoutLMv2ForTokenClassification"),al=d(),te=a("div"),g(cn.$$.fragment),Af=d(),oe=a("p"),Df=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
`),dn=a("a"),Of=n("FUNSD"),Nf=n(", "),pn=a("a"),Sf=n("SROIE"),Rf=n(`,
`),un=a("a"),Wf=n("CORD"),Uf=n(" and "),mn=a("a"),Bf=n("Kleister-NDA"),Vf=n("."),Qf=d(),hn=a("p"),Gf=n("This model is a PyTorch "),fn=a("a"),Hf=n("torch.nn.Module"),Kf=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.`),Xf=d(),ie=a("div"),g(gn.$$.fragment),Yf=d(),Ve=a("p"),Zf=n("The "),zs=a("a"),Jf=n("LayoutLMv2ForTokenClassification"),eg=n(" forward method, overrides the "),Ar=a("code"),tg=n("__call__"),og=n(" special method."),ng=d(),g(yt.$$.fragment),sg=d(),g(bt.$$.fragment),rl=d(),Qe=a("h2"),Lt=a("a"),Dr=a("span"),g(_n.$$.fragment),ag=d(),Or=a("span"),rg=n("LayoutLMv2ForQuestionAnswering"),il=d(),ne=a("div"),g(vn.$$.fragment),ig=d(),pe=a("p"),lg=n(`LayoutLMv2 Model with a span classification head on top for extractive question-answering tasks such as
`),yn=a("a"),cg=n("DocVQA"),dg=n(` (a linear layer on top of the text part of the hidden-states output to
compute `),Nr=a("code"),pg=n("span start logits"),ug=n(" and "),Sr=a("code"),mg=n("span end logits"),hg=n(")."),fg=d(),bn=a("p"),gg=n("This model is a PyTorch "),Ln=a("a"),_g=n("torch.nn.Module"),vg=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.`),yg=d(),D=a("div"),g(kn.$$.fragment),bg=d(),Ge=a("p"),Lg=n("The "),qs=a("a"),kg=n("LayoutLMv2ForQuestionAnswering"),wg=n(" forward method, overrides the "),Rr=a("code"),xg=n("__call__"),Tg=n(" special method."),Mg=d(),g(kt.$$.fragment),$g=d(),Wr=a("p"),Eg=n("Example:"),zg=d(),Ur=a("p"),qg=n(`In this example below, we give the LayoutLMv2 model an image (of texts) and ask it a question. It will give us
a prediction of what it thinks the answer is (the span of the answer within the texts parsed from the image).`),Fg=d(),g(wt.$$.fragment),Pg=d(),g(xt.$$.fragment),this.h()},l(t){const c=x2('[data-svelte="svelte-1phssyn"]',document.head);h=r(c,"META",{name:!0,content:!0}),c.forEach(o),x=p(t),f=r(t,"H1",{class:!0});var wn=i(f);k=r(wn,"A",{id:!0,class:!0,href:!0});var Br=i(k);T=r(Br,"SPAN",{});var Vr=i(T);_(m.$$.fragment,Vr),Vr.forEach(o),Br.forEach(o),w=p(wn),O=r(wn,"SPAN",{});var Qr=i(O);Hl=s(Qr,"LayoutLMV2"),Qr.forEach(o),wn.forEach(o),Yr=p(t),$e=r(t,"H2",{class:!0});var xn=i($e);Ke=r(xn,"A",{id:!0,class:!0,href:!0});var Gr=i(Ke);Ks=r(Gr,"SPAN",{});var Hr=i(Ks);_(Ct.$$.fragment,Hr),Hr.forEach(o),Gr.forEach(o),Kl=p(xn),Xs=r(xn,"SPAN",{});var Kr=i(Xs);Xl=s(Kr,"Overview"),Kr.forEach(o),xn.forEach(o),Zr=p(t),me=r(t,"P",{});var He=i(me);Yl=s(He,"The LayoutLMV2 model was proposed in "),At=r(He,"A",{href:!0,rel:!0});var Xr=i(At);Zl=s(Xr,"LayoutLMv2: Multi-modal Pre-training for Visually-Rich Document Understanding"),Xr.forEach(o),Jl=s(He,` 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 `),Tn=r(He,"A",{href:!0});var Wg=i(Tn);ec=s(Wg,"LayoutLM"),Wg.forEach(o),tc=s(He,` to obtain
state-of-the-art results across several document image understanding benchmarks:`),He.forEach(o),Jr=p(t),he=r(t,"UL",{});var Fs=i(he);Y=r(Fs,"LI",{});var Le=i(Y);oc=s(Le,"information extraction from scanned documents: the "),Dt=r(Le,"A",{href:!0,rel:!0});var Ug=i(Dt);nc=s(Ug,"FUNSD"),Ug.forEach(o),sc=s(Le,` dataset (a
collection of 199 annotated forms comprising more than 30,000 words), the `),Ot=r(Le,"A",{href:!0,rel:!0});var Bg=i(Ot);ac=s(Bg,"CORD"),Bg.forEach(o),rc=s(Le,`
dataset (a collection of 800 receipts for training, 100 for validation and 100 for testing), the `),Nt=r(Le,"A",{href:!0,rel:!0});var Vg=i(Nt);ic=s(Vg,"SROIE"),Vg.forEach(o),lc=s(Le,` dataset (a collection of 626 receipts for training and 347 receipts for testing)
and the `),St=r(Le,"A",{href:!0,rel:!0});var Qg=i(St);cc=s(Qg,"Kleister-NDA"),Qg.forEach(o),dc=s(Le,` 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).`),Le.forEach(o),pc=p(Fs),Rt=r(Fs,"LI",{});var cl=i(Rt);uc=s(cl,"document image classification: the "),Wt=r(cl,"A",{href:!0,rel:!0});var Gg=i(Wt);mc=s(Gg,"RVL-CDIP"),Gg.forEach(o),hc=s(cl,` dataset (a collection of
400,000 images belonging to one of 16 classes).`),cl.forEach(o),fc=p(Fs),Ut=r(Fs,"LI",{});var dl=i(Ut);gc=s(dl,"document visual question answering: the "),Bt=r(dl,"A",{href:!0,rel:!0});var Hg=i(Bt);_c=s(Hg,"DocVQA"),Hg.forEach(o),vc=s(dl,` dataset (a collection of 50,000
questions defined on 12,000+ document images).`),dl.forEach(o),Fs.forEach(o),ei=p(t),Mn=r(t,"P",{});var Kg=i(Mn);yc=s(Kg,"The abstract from the paper is the following:"),Kg.forEach(o),ti=p(t),$n=r(t,"P",{});var Xg=i($n);Ys=r(Xg,"EM",{});var Yg=i(Ys);bc=s(Yg,`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.`),Yg.forEach(o),Xg.forEach(o),oi=p(t),se=r(t,"P",{});var Tt=i(se);Lc=s(Tt,"LayoutLMv2 depends on "),Zs=r(Tt,"CODE",{});var Zg=i(Zs);kc=s(Zg,"detectron2"),Zg.forEach(o),wc=s(Tt,", "),Js=r(Tt,"CODE",{});var Jg=i(Js);xc=s(Jg,"torchvision"),Jg.forEach(o),Tc=s(Tt," and "),ea=r(Tt,"CODE",{});var e_=i(ea);Mc=s(e_,"tesseract"),e_.forEach(o),$c=s(Tt,`. Run the
following to install them:`),Tt.forEach(o),ni=p(t),_(Vt.$$.fragment,t),si=p(t),En=r(t,"P",{});var t_=i(En);Ec=s(t_,"(If you are developing for LayoutLMv2, note that passing the doctests also requires the installation of these packages.)"),t_.forEach(o),ai=p(t),zn=r(t,"P",{});var o_=i(zn);zc=s(o_,"Tips:"),o_.forEach(o),ri=p(t),V=r(t,"UL",{});var ke=i(V);ta=r(ke,"LI",{});var n_=i(ta);qc=s(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).`),n_.forEach(o),Fc=p(ke),Qt=r(ke,"LI",{});var pl=i(Qt);Pc=s(pl,`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 `),Gt=r(pl,"A",{href:!0,rel:!0});var s_=i(Gt);jc=s(s_,"paper"),s_.forEach(o),Ic=s(pl,"."),pl.forEach(o),Cc=p(ke),Ht=r(ke,"LI",{});var ul=i(Ht);Ac=s(ul,"Demo notebooks on how to use the LayoutLMv2 model on RVL-CDIP, FUNSD, DocVQA, CORD can be found "),Kt=r(ul,"A",{href:!0,rel:!0});var a_=i(Kt);Dc=s(a_,"here"),a_.forEach(o),Oc=s(ul,"."),ul.forEach(o),Nc=p(ke),Ee=r(ke,"LI",{});var Ps=i(Ee);Sc=s(Ps,"LayoutLMv2 uses Facebook AI\u2019s "),Xt=r(Ps,"A",{href:!0,rel:!0});var r_=i(Xt);Rc=s(r_,"Detectron2"),r_.forEach(o),Wc=s(Ps,` package for its visual
backbone. See `),Yt=r(Ps,"A",{href:!0,rel:!0});var i_=i(Yt);Uc=s(i_,"this link"),i_.forEach(o),Bc=s(Ps,` for installation
instructions.`),Ps.forEach(o),Vc=p(ke),M=r(ke,"LI",{});var z=i(M);Qc=s(z,"In addition to "),oa=r(z,"CODE",{});var l_=i(oa);Gc=s(l_,"input_ids"),l_.forEach(o),Hc=s(z,", "),qn=r(z,"A",{href:!0});var c_=i(qn);Kc=s(c_,"forward()"),c_.forEach(o),Xc=s(z,` expects 2 additional inputs, namely
`),na=r(z,"CODE",{});var d_=i(na);Yc=s(d_,"image"),d_.forEach(o),Zc=s(z," and "),sa=r(z,"CODE",{});var p_=i(sa);Jc=s(p_,"bbox"),p_.forEach(o),ed=s(z,". The "),aa=r(z,"CODE",{});var u_=i(aa);td=s(u_,"image"),u_.forEach(o),od=s(z,` 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, `),ra=r(z,"CODE",{});var m_=i(ra);nd=s(m_,"image"),m_.forEach(o),sd=s(z,` should be a tensor of shape (batch_size, 3, 224, 224). This can be either a
`),ia=r(z,"CODE",{});var h_=i(ia);ad=s(h_,"torch.Tensor"),h_.forEach(o),rd=s(z," or a "),la=r(z,"CODE",{});var f_=i(la);id=s(f_,"Detectron2.structures.ImageList"),f_.forEach(o),ld=s(z,`. 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 `),ca=r(z,"CODE",{});var g_=i(ca);cd=s(g_,"bbox"),g_.forEach(o),dd=s(z,` input are the bounding boxes (i.e. 2D-positions)
of the input text tokens. This is identical to `),Fn=r(z,"A",{href:!0});var __=i(Fn);pd=s(__,"LayoutLMModel"),__.forEach(o),ud=s(z,`. These can be obtained using an
external OCR engine such as Google\u2019s `),Zt=r(z,"A",{href:!0,rel:!0});var v_=i(Zt);md=s(v_,"Tesseract"),v_.forEach(o),hd=s(z," (there\u2019s a "),Jt=r(z,"A",{href:!0,rel:!0});var y_=i(Jt);fd=s(y_,`Python
wrapper`),y_.forEach(o),gd=s(z,` 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:`),z.forEach(o),ke.forEach(o),ii=p(t),_(eo.$$.fragment,t),li=p(t),fe=r(t,"P",{});var js=i(fe);_d=s(js,"Here, "),da=r(js,"CODE",{});var b_=i(da);vd=s(b_,"width"),b_.forEach(o),yd=s(js," and "),pa=r(js,"CODE",{});var L_=i(pa);bd=s(L_,"height"),L_.forEach(o),Ld=s(js,` 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:`),js.forEach(o),ci=p(t),_(to.$$.fragment,t),di=p(t),Xe=r(t,"P",{});var ml=i(Xe);kd=s(ml,"However, this model includes a brand new "),Pn=r(ml,"A",{href:!0});var k_=i(Pn);wd=s(k_,"LayoutLMv2Processor"),k_.forEach(o),xd=s(ml,` 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.`),ml.forEach(o),pi=p(t),ge=r(t,"UL",{});var Is=i(ge);A=r(Is,"LI",{});var R=i(A);Td=s(R,"Internally, "),jn=r(R,"A",{href:!0});var w_=i(jn);Md=s(w_,"LayoutLMv2Model"),w_.forEach(o),$d=s(R," will send the "),ua=r(R,"CODE",{});var x_=i(ua);Ed=s(x_,"image"),x_.forEach(o),zd=s(R,` input through its visual backbone to
obtain a lower-resolution feature map, whose shape is equal to the `),ma=r(R,"CODE",{});var T_=i(ma);qd=s(T_,"image_feature_pool_shape"),T_.forEach(o),Fd=s(R,` attribute of
`),In=r(R,"A",{href:!0});var M_=i(In);Pd=s(M_,"LayoutLMv2Config"),M_.forEach(o),jd=s(R,`. 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 `),ha=r(R,"CODE",{});var $_=i(ha);Id=s($_,"seq_length"),$_.forEach(o),Cd=s(R," + "),fa=r(R,"CODE",{});var E_=i(fa);Ad=s(E_,"image_feature_pool_shape[0]"),E_.forEach(o),Dd=s(R,` *
`),ga=r(R,"CODE",{});var z_=i(ga);Od=s(z_,"config.image_feature_pool_shape[1]"),z_.forEach(o),Nd=s(R,"."),R.forEach(o),Sd=p(Is),oo=r(Is,"LI",{});var hl=i(oo);Rd=s(hl,"When calling "),Cn=r(hl,"A",{href:!0});var q_=i(Cn);Wd=s(q_,"from_pretrained()"),q_.forEach(o),Ud=s(hl,`, 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.`),hl.forEach(o),Bd=p(Is),no=r(Is,"LI",{});var fl=i(no);Vd=s(fl,"If you want to train the model in a distributed environment, make sure to call "),_a=r(fl,"CODE",{});var F_=i(_a);Qd=s(F_,"synchronize_batch_norm"),F_.forEach(o),Gd=s(fl,` on the
model in order to properly synchronize the batch normalization layers of the visual backbone.`),fl.forEach(o),Is.forEach(o),ui=p(t),Ye=r(t,"P",{});var gl=i(Ye);Hd=s(gl,`In addition, there\u2019s LayoutXLM, which is a multilingual version of LayoutLMv2. More information can be found on
`),An=r(gl,"A",{href:!0});var P_=i(An);Kd=s(P_,"LayoutXLM\u2019s documentation page"),P_.forEach(o),Xd=s(gl,"."),gl.forEach(o),mi=p(t),ze=r(t,"H2",{class:!0});var _l=i(ze);Ze=r(_l,"A",{id:!0,class:!0,href:!0});var j_=i(Ze);va=r(j_,"SPAN",{});var I_=i(va);_(so.$$.fragment,I_),I_.forEach(o),j_.forEach(o),Yd=p(_l),ya=r(_l,"SPAN",{});var C_=i(ya);Zd=s(C_,"Resources"),C_.forEach(o),_l.forEach(o),hi=p(t),Dn=r(t,"P",{});var A_=i(Dn);Jd=s(A_,"A list of official Hugging Face and community (indicated by \u{1F30E}) resources to help you get started with LayoutLMv2. If you\u2019re interested in submitting a resource to be included here, please feel free to open a Pull Request and we\u2019ll review it! The resource should ideally demonstrate something new instead of duplicating an existing resource."),A_.forEach(o),fi=p(t),_(ao.$$.fragment,t),gi=p(t),Je=r(t,"UL",{});var vl=i(Je);ro=r(vl,"LI",{});var yl=i(ro);ep=s(yl,"A notebook on how to "),io=r(yl,"A",{href:!0,rel:!0});var D_=i(io);tp=s(D_,"finetune LayoutLMv2 for text-classification on RVL-CDIP dataset"),D_.forEach(o),op=s(yl,"."),yl.forEach(o),np=p(vl),On=r(vl,"LI",{});var jg=i(On);sp=s(jg,"See also: "),Nn=r(jg,"A",{href:!0});var O_=i(Nn);ap=s(O_,"Text classification task guide"),O_.forEach(o),jg.forEach(o),vl.forEach(o),_i=p(t),_(lo.$$.fragment,t),vi=p(t),_e=r(t,"UL",{});var Cs=i(_e);co=r(Cs,"LI",{});var bl=i(co);rp=s(bl,"A notebook on how to "),po=r(bl,"A",{href:!0,rel:!0});var N_=i(po);ip=s(N_,"finetune LayoutLMv2 for question-answering on DocVQA dataset"),N_.forEach(o),lp=s(bl,"."),bl.forEach(o),cp=p(Cs),Sn=r(Cs,"LI",{});var Ig=i(Sn);dp=s(Ig,"See also: "),Rn=r(Ig,"A",{href:!0});var S_=i(Rn);pp=s(S_,"Question answering task guide"),S_.forEach(o),Ig.forEach(o),up=p(Cs),Wn=r(Cs,"LI",{});var Cg=i(Wn);mp=s(Cg,"See also: "),Un=r(Cg,"A",{href:!0});var R_=i(Un);hp=s(R_,"Document question answering task guide"),R_.forEach(o),Cg.forEach(o),Cs.forEach(o),yi=p(t),_(uo.$$.fragment,t),bi=p(t),ve=r(t,"UL",{});var As=i(ve);mo=r(As,"LI",{});var Ll=i(mo);fp=s(Ll,"A notebook on how to "),ho=r(Ll,"A",{href:!0,rel:!0});var W_=i(ho);gp=s(W_,"finetune LayoutLMv2 for token-classification on CORD dataset"),W_.forEach(o),_p=s(Ll,"."),Ll.forEach(o),vp=p(As),fo=r(As,"LI",{});var kl=i(fo);yp=s(kl,"A notebook on how to "),go=r(kl,"A",{href:!0,rel:!0});var U_=i(go);bp=s(U_,"finetune LayoutLMv2 for token-classification on FUNSD dataset"),U_.forEach(o),Lp=s(kl,"."),kl.forEach(o),kp=p(As),Bn=r(As,"LI",{});var Ag=i(Bn);wp=s(Ag,"See also: "),Vn=r(Ag,"A",{href:!0});var B_=i(Vn);xp=s(B_,"Token classification task guide"),B_.forEach(o),Ag.forEach(o),As.forEach(o),Li=p(t),qe=r(t,"H2",{class:!0});var wl=i(qe);et=r(wl,"A",{id:!0,class:!0,href:!0});var V_=i(et);ba=r(V_,"SPAN",{});var Q_=i(ba);_(_o.$$.fragment,Q_),Q_.forEach(o),V_.forEach(o),Tp=p(wl),La=r(wl,"SPAN",{});var G_=i(La);Mp=s(G_,"Usage: LayoutLMv2Processor"),G_.forEach(o),wl.forEach(o),ki=p(t),Q=r(t,"P",{});var we=i(Q);$p=s(we,"The easiest way to prepare data for the model is to use "),Qn=r(we,"A",{href:!0});var H_=i(Qn);Ep=s(H_,"LayoutLMv2Processor"),H_.forEach(o),zp=s(we,`, which internally
combines a feature extractor (`),Gn=r(we,"A",{href:!0});var K_=i(Gn);qp=s(K_,"LayoutLMv2FeatureExtractor"),K_.forEach(o),Fp=s(we,`) and a tokenizer
(`),Hn=r(we,"A",{href:!0});var X_=i(Hn);Pp=s(X_,"LayoutLMv2Tokenizer"),X_.forEach(o),jp=s(we," or "),Kn=r(we,"A",{href:!0});var Y_=i(Kn);Ip=s(Y_,"LayoutLMv2TokenizerFast"),Y_.forEach(o),Cp=s(we,`). 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.`),we.forEach(o),wi=p(t),_(vo.$$.fragment,t),xi=p(t),E=r(t,"P",{});var j=i(E);Ap=s(j,"In short, one can provide a document image (and possibly additional data) to "),Xn=r(j,"A",{href:!0});var Z_=i(Xn);Dp=s(Z_,"LayoutLMv2Processor"),Z_.forEach(o),Op=s(j,`,
and it will create the inputs expected by the model. Internally, the processor first uses
`),Yn=r(j,"A",{href:!0});var J_=i(Yn);Np=s(J_,"LayoutLMv2FeatureExtractor"),J_.forEach(o),Sp=s(j,` 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 `),ka=r(j,"CODE",{});var ev=i(ka);Rp=s(ev,"image"),ev.forEach(o),Wp=s(j,` input. The words and
normalized bounding boxes are then provided to `),Zn=r(j,"A",{href:!0});var tv=i(Zn);Up=s(tv,"LayoutLMv2Tokenizer"),tv.forEach(o),Bp=s(j,` or
`),Jn=r(j,"A",{href:!0});var ov=i(Jn);Vp=s(ov,"LayoutLMv2TokenizerFast"),ov.forEach(o),Qp=s(j,", which converts them to token-level "),wa=r(j,"CODE",{});var nv=i(wa);Gp=s(nv,"input_ids"),nv.forEach(o),Hp=s(j,`,
`),xa=r(j,"CODE",{});var sv=i(xa);Kp=s(sv,"attention_mask"),sv.forEach(o),Xp=s(j,", "),Ta=r(j,"CODE",{});var av=i(Ta);Yp=s(av,"token_type_ids"),av.forEach(o),Zp=s(j,", "),Ma=r(j,"CODE",{});var rv=i(Ma);Jp=s(rv,"bbox"),rv.forEach(o),eu=s(j,`. Optionally, one can provide word labels to the processor,
which are turned into token-level `),$a=r(j,"CODE",{});var iv=i($a);tu=s(iv,"labels"),iv.forEach(o),ou=s(j,"."),j.forEach(o),Ti=p(t),W=r(t,"P",{});var ue=i(W);es=r(ue,"A",{href:!0});var lv=i(es);nu=s(lv,"LayoutLMv2Processor"),lv.forEach(o),su=s(ue," uses "),yo=r(ue,"A",{href:!0,rel:!0});var cv=i(yo);au=s(cv,"PyTesseract"),cv.forEach(o),ru=s(ue,`, 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
`),ts=r(ue,"A",{href:!0});var dv=i(ts);iu=s(dv,"LayoutLMv2FeatureExtractor"),dv.forEach(o),lu=s(ue," with "),Ea=r(ue,"CODE",{});var pv=i(Ea);cu=s(pv,"apply_ocr"),pv.forEach(o),du=s(ue," set to "),za=r(ue,"CODE",{});var uv=i(za);pu=s(uv,"False"),uv.forEach(o),uu=s(ue,"."),ue.forEach(o),Mi=p(t),os=r(t,"P",{});var mv=i(os);mu=s(mv,`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).`),mv.forEach(o),$i=p(t),ns=r(t,"P",{});var hv=i(ns);qa=r(hv,"STRONG",{});var fv=i(qa);hu=s(fv,`Use case 1: document image classification (training, inference) + token classification (inference), apply_ocr =
True`),fv.forEach(o),hv.forEach(o),Ei=p(t),ss=r(t,"P",{});var gv=i(ss);fu=s(gv,`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.`),gv.forEach(o),zi=p(t),_(bo.$$.fragment,t),qi=p(t),as=r(t,"P",{});var _v=i(as);Fa=r(_v,"STRONG",{});var vv=i(Fa);gu=s(vv,"Use case 2: document image classification (training, inference) + token classification (inference), apply_ocr=False"),vv.forEach(o),_v.forEach(o),Fi=p(t),ye=r(t,"P",{});var Ds=i(ye);_u=s(Ds,"In case one wants to do OCR themselves, one can initialize the feature extractor with "),Pa=r(Ds,"CODE",{});var yv=i(Pa);vu=s(yv,"apply_ocr"),yv.forEach(o),yu=s(Ds,` set to
`),ja=r(Ds,"CODE",{});var bv=i(ja);bu=s(bv,"False"),bv.forEach(o),Lu=s(Ds,`. In that case, one should provide the words and corresponding (normalized) bounding boxes themselves to
the processor.`),Ds.forEach(o),Pi=p(t),_(Lo.$$.fragment,t),ji=p(t),rs=r(t,"P",{});var Lv=i(rs);Ia=r(Lv,"STRONG",{});var kv=i(Ia);ku=s(kv,"Use case 3: token classification (training), apply_ocr=False"),kv.forEach(o),Lv.forEach(o),Ii=p(t),G=r(t,"P",{});var xe=i(G);wu=s(xe,`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 `),Ca=r(xe,"CODE",{});var wv=i(Ca);xu=s(wv,"labels"),wv.forEach(o),Tu=s(xe,`. By default, it
will only label the first wordpiece of a word, and label the remaining wordpieces with -100, which is the
`),Aa=r(xe,"CODE",{});var xv=i(Aa);Mu=s(xv,"ignore_index"),xv.forEach(o),$u=s(xe,` of PyTorch\u2019s CrossEntropyLoss. In case you want all wordpieces of a word to be labeled, you can
initialize the tokenizer with `),Da=r(xe,"CODE",{});var Tv=i(Da);Eu=s(Tv,"only_label_first_subword"),Tv.forEach(o),zu=s(xe," set to "),Oa=r(xe,"CODE",{});var Mv=i(Oa);qu=s(Mv,"False"),Mv.forEach(o),Fu=s(xe,"."),xe.forEach(o),Ci=p(t),_(ko.$$.fragment,t),Ai=p(t),is=r(t,"P",{});var $v=i(is);Na=r($v,"STRONG",{});var Ev=i(Na);Pu=s(Ev,"Use case 4: visual question answering (inference), apply_ocr=True"),Ev.forEach(o),$v.forEach(o),Di=p(t),ls=r(t,"P",{});var zv=i(ls);ju=s(zv,`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].`),zv.forEach(o),Oi=p(t),_(wo.$$.fragment,t),Ni=p(t),cs=r(t,"P",{});var qv=i(cs);Sa=r(qv,"STRONG",{});var Fv=i(Sa);Iu=s(Fv,"Use case 5: visual question answering (inference), apply_ocr=False"),Fv.forEach(o),qv.forEach(o),Si=p(t),ds=r(t,"P",{});var Pv=i(ds);Cu=s(Pv,`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.`),Pv.forEach(o),Ri=p(t),_(xo.$$.fragment,t),Wi=p(t),Fe=r(t,"H2",{class:!0});var xl=i(Fe);tt=r(xl,"A",{id:!0,class:!0,href:!0});var jv=i(tt);Ra=r(jv,"SPAN",{});var Iv=i(Ra);_(To.$$.fragment,Iv),Iv.forEach(o),jv.forEach(o),Au=p(xl),Wa=r(xl,"SPAN",{});var Cv=i(Wa);Du=s(Cv,"LayoutLMv2Config"),Cv.forEach(o),xl.forEach(o),Ui=p(t),Z=r(t,"DIV",{class:!0});var Mt=i(Z);_(Mo.$$.fragment,Mt),Ou=p(Mt),Pe=r(Mt,"P",{});var Os=i(Pe);Nu=s(Os,"This is the configuration class to store the configuration of a "),ps=r(Os,"A",{href:!0});var Av=i(ps);Su=s(Av,"LayoutLMv2Model"),Av.forEach(o),Ru=s(Os,`. 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
`),$o=r(Os,"A",{href:!0,rel:!0});var Dv=i($o);Wu=s(Dv,"microsoft/layoutlmv2-base-uncased"),Dv.forEach(o),Uu=s(Os," architecture."),Os.forEach(o),Bu=p(Mt),je=r(Mt,"P",{});var Ns=i(je);Vu=s(Ns,"Configuration objects inherit from "),us=r(Ns,"A",{href:!0});var Ov=i(us);Qu=s(Ov,"PretrainedConfig"),Ov.forEach(o),Gu=s(Ns,` and can be used to control the model outputs. Read the
documentation from `),ms=r(Ns,"A",{href:!0});var Nv=i(ms);Hu=s(Nv,"PretrainedConfig"),Nv.forEach(o),Ku=s(Ns," for more information."),Ns.forEach(o),Xu=p(Mt),_(ot.$$.fragment,Mt),Mt.forEach(o),Bi=p(t),Ie=r(t,"H2",{class:!0});var Tl=i(Ie);nt=r(Tl,"A",{id:!0,class:!0,href:!0});var Sv=i(nt);Ua=r(Sv,"SPAN",{});var Rv=i(Ua);_(Eo.$$.fragment,Rv),Rv.forEach(o),Sv.forEach(o),Yu=p(Tl),Ba=r(Tl,"SPAN",{});var Wv=i(Ba);Zu=s(Wv,"LayoutLMv2FeatureExtractor"),Wv.forEach(o),Tl.forEach(o),Vi=p(t),Ce=r(t,"DIV",{class:!0});var Ml=i(Ce);_(zo.$$.fragment,Ml),Ju=p(Ml),st=r(Ml,"DIV",{class:!0});var $l=i(st);_(qo.$$.fragment,$l),em=p($l),Va=r($l,"P",{});var Uv=i(Va);tm=s(Uv,"Preprocess an image or a batch of images."),Uv.forEach(o),$l.forEach(o),Ml.forEach(o),Qi=p(t),Ae=r(t,"H2",{class:!0});var El=i(Ae);at=r(El,"A",{id:!0,class:!0,href:!0});var Bv=i(at);Qa=r(Bv,"SPAN",{});var Vv=i(Qa);_(Fo.$$.fragment,Vv),Vv.forEach(o),Bv.forEach(o),om=p(El),Ga=r(El,"SPAN",{});var Qv=i(Ga);nm=s(Qv,"LayoutLMv2ImageProcessor"),Qv.forEach(o),El.forEach(o),Gi=p(t),ce=r(t,"DIV",{class:!0});var Ss=i(ce);_(Po.$$.fragment,Ss),sm=p(Ss),Ha=r(Ss,"P",{});var Gv=i(Ha);am=s(Gv,"Constructs a LayoutLMv2 image processor."),Gv.forEach(o),rm=p(Ss),rt=r(Ss,"DIV",{class:!0});var zl=i(rt);_(jo.$$.fragment,zl),im=p(zl),Ka=r(zl,"P",{});var Hv=i(Ka);lm=s(Hv,"Preprocess an image or batch of images."),Hv.forEach(o),zl.forEach(o),Ss.forEach(o),Hi=p(t),De=r(t,"H2",{class:!0});var ql=i(De);it=r(ql,"A",{id:!0,class:!0,href:!0});var Kv=i(it);Xa=r(Kv,"SPAN",{});var Xv=i(Xa);_(Io.$$.fragment,Xv),Xv.forEach(o),Kv.forEach(o),cm=p(ql),Ya=r(ql,"SPAN",{});var Yv=i(Ya);dm=s(Yv,"LayoutLMv2Tokenizer"),Yv.forEach(o),ql.forEach(o),Ki=p(t),N=r(t,"DIV",{class:!0});var le=i(N);_(Co.$$.fragment,le),pm=p(le),S=r(le,"P",{});var H=i(S);um=s(H,"Construct a LayoutLMv2 tokenizer. Based on WordPiece. "),hs=r(H,"A",{href:!0});var Zv=i(hs);mm=s(Zv,"LayoutLMv2Tokenizer"),Zv.forEach(o),hm=s(H,` can be used to turn words, word-level
bounding boxes and optional word labels to token-level `),Za=r(H,"CODE",{});var Jv=i(Za);fm=s(Jv,"input_ids"),Jv.forEach(o),gm=s(H,", "),Ja=r(H,"CODE",{});var ey=i(Ja);_m=s(ey,"attention_mask"),ey.forEach(o),vm=s(H,", "),er=r(H,"CODE",{});var ty=i(er);ym=s(ty,"token_type_ids"),ty.forEach(o),bm=s(H,", "),tr=r(H,"CODE",{});var oy=i(tr);Lm=s(oy,"bbox"),oy.forEach(o),km=s(H,`, and
optional `),or=r(H,"CODE",{});var ny=i(or);wm=s(ny,"labels"),ny.forEach(o),xm=s(H," (for token classification)."),H.forEach(o),Tm=p(le),Ao=r(le,"P",{});var Fl=i(Ao);Mm=s(Fl,"This tokenizer inherits from "),fs=r(Fl,"A",{href:!0});var sy=i(fs);$m=s(sy,"PreTrainedTokenizer"),sy.forEach(o),Em=s(Fl,` which contains most of the main methods. Users should refer to
this superclass for more information regarding those methods.`),Fl.forEach(o),zm=p(le),gs=r(le,"P",{});var Dg=i(gs);_s=r(Dg,"A",{href:!0});var ay=i(_s);qm=s(ay,"LayoutLMv2Tokenizer"),ay.forEach(o),Fm=s(Dg,` runs end-to-end tokenization: punctuation splitting and wordpiece. It also turns the
word-level bounding boxes into token-level bounding boxes.`),Dg.forEach(o),Pm=p(le),lt=r(le,"DIV",{class:!0});var Pl=i(lt);_(Do.$$.fragment,Pl),jm=p(Pl),nr=r(Pl,"P",{});var ry=i(nr);Im=s(ry,`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.`),ry.forEach(o),Pl.forEach(o),Cm=p(le),vs=r(le,"DIV",{class:!0});var iy=i(vs);_(Oo.$$.fragment,iy),iy.forEach(o),le.forEach(o),Xi=p(t),Oe=r(t,"H2",{class:!0});var jl=i(Oe);ct=r(jl,"A",{id:!0,class:!0,href:!0});var ly=i(ct);sr=r(ly,"SPAN",{});var cy=i(sr);_(No.$$.fragment,cy),cy.forEach(o),ly.forEach(o),Am=p(jl),ar=r(jl,"SPAN",{});var dy=i(ar);Dm=s(dy,"LayoutLMv2TokenizerFast"),dy.forEach(o),jl.forEach(o),Yi=p(t),J=r(t,"DIV",{class:!0});var $t=i(J);_(So.$$.fragment,$t),Om=p($t),Ro=r($t,"P",{});var Il=i(Ro);Nm=s(Il,"Construct a \u201Cfast\u201D LayoutLMv2 tokenizer (backed by HuggingFace\u2019s "),rr=r(Il,"EM",{});var py=i(rr);Sm=s(py,"tokenizers"),py.forEach(o),Rm=s(Il," library). Based on WordPiece."),Il.forEach(o),Wm=p($t),Wo=r($t,"P",{});var Cl=i(Wo);Um=s(Cl,"This tokenizer inherits from "),ys=r(Cl,"A",{href:!0});var uy=i(ys);Bm=s(uy,"PreTrainedTokenizerFast"),uy.forEach(o),Vm=s(Cl,` which contains most of the main methods. Users should
refer to this superclass for more information regarding those methods.`),Cl.forEach(o),Qm=p($t),dt=r($t,"DIV",{class:!0});var Al=i(dt);_(Uo.$$.fragment,Al),Gm=p(Al),ir=r(Al,"P",{});var my=i(ir);Hm=s(my,`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.`),my.forEach(o),Al.forEach(o),$t.forEach(o),Zi=p(t),Ne=r(t,"H2",{class:!0});var Dl=i(Ne);pt=r(Dl,"A",{id:!0,class:!0,href:!0});var hy=i(pt);lr=r(hy,"SPAN",{});var fy=i(lr);_(Bo.$$.fragment,fy),fy.forEach(o),hy.forEach(o),Km=p(Dl),cr=r(Dl,"SPAN",{});var gy=i(cr);Xm=s(gy,"LayoutLMv2Processor"),gy.forEach(o),Dl.forEach(o),Ji=p(t),U=r(t,"DIV",{class:!0});var Te=i(U);_(Vo.$$.fragment,Te),Ym=p(Te),dr=r(Te,"P",{});var _y=i(dr);Zm=s(_y,`Constructs a LayoutLMv2 processor which combines a LayoutLMv2 image processor and a LayoutLMv2 tokenizer into a
single processor.`),_y.forEach(o),Jm=p(Te),bs=r(Te,"P",{});var Og=i(bs);Ls=r(Og,"A",{href:!0});var vy=i(Ls);eh=s(vy,"LayoutLMv2Processor"),vy.forEach(o),th=s(Og," offers all the functionalities you need to prepare data for the model."),Og.forEach(o),oh=p(Te),F=r(Te,"P",{});var I=i(F);nh=s(I,"It first uses "),ks=r(I,"A",{href:!0});var yy=i(ks);sh=s(yy,"LayoutLMv2ImageProcessor"),yy.forEach(o),ah=s(I,` to resize document images to a fixed size, and optionally applies OCR to
get words and normalized bounding boxes. These are then provided to `),ws=r(I,"A",{href:!0});var by=i(ws);rh=s(by,"LayoutLMv2Tokenizer"),by.forEach(o),ih=s(I,` or
`),xs=r(I,"A",{href:!0});var Ly=i(xs);lh=s(Ly,"LayoutLMv2TokenizerFast"),Ly.forEach(o),ch=s(I,", which turns the words and bounding boxes into token-level "),pr=r(I,"CODE",{});var ky=i(pr);dh=s(ky,"input_ids"),ky.forEach(o),ph=s(I,`,
`),ur=r(I,"CODE",{});var wy=i(ur);uh=s(wy,"attention_mask"),wy.forEach(o),mh=s(I,", "),mr=r(I,"CODE",{});var xy=i(mr);hh=s(xy,"token_type_ids"),xy.forEach(o),fh=s(I,", "),hr=r(I,"CODE",{});var Ty=i(hr);gh=s(Ty,"bbox"),Ty.forEach(o),_h=s(I,". Optionally, one can provide integer "),fr=r(I,"CODE",{});var My=i(fr);vh=s(My,"word_labels"),My.forEach(o),yh=s(I,`, which are turned
into token-level `),gr=r(I,"CODE",{});var $y=i(gr);bh=s($y,"labels"),$y.forEach(o),Lh=s(I," for token classification tasks (such as FUNSD, CORD)."),I.forEach(o),kh=p(Te),be=r(Te,"DIV",{class:!0});var Rs=i(be);_(Qo.$$.fragment,Rs),wh=p(Rs),$=r(Rs,"P",{});var q=i($);xh=s(q,"This method first forwards the "),_r=r(q,"CODE",{});var Ey=i(_r);Th=s(Ey,"images"),Ey.forEach(o),Mh=s(q," argument to "),Go=r(q,"A",{href:!0});var Ng=i(Go);vr=r(Ng,"STRONG",{});var zy=i(vr);$h=s(zy,"call"),zy.forEach(o),Eh=s(Ng,"()"),Ng.forEach(o),zh=s(q,`. In case
`),Ts=r(q,"A",{href:!0});var qy=i(Ts);qh=s(qy,"LayoutLMv2ImageProcessor"),qy.forEach(o),Fh=s(q," was initialized with "),yr=r(q,"CODE",{});var Fy=i(yr);Ph=s(Fy,"apply_ocr"),Fy.forEach(o),jh=s(q," set to "),br=r(q,"CODE",{});var Py=i(br);Ih=s(Py,"True"),Py.forEach(o),Ch=s(q,`, it passes the obtained words and
bounding boxes along with the additional arguments to `),Ho=r(q,"A",{href:!0});var Sg=i(Ho);Lr=r(Sg,"STRONG",{});var jy=i(Lr);Ah=s(jy,"call"),jy.forEach(o),Dh=s(Sg,"()"),Sg.forEach(o),Oh=s(q,` and returns the output,
together with resized `),kr=r(q,"CODE",{});var Iy=i(kr);Nh=s(Iy,"images"),Iy.forEach(o),Sh=s(q,". In case "),Ms=r(q,"A",{href:!0});var Cy=i(Ms);Rh=s(Cy,"LayoutLMv2ImageProcessor"),Cy.forEach(o),Wh=s(q," was initialized with "),wr=r(q,"CODE",{});var Ay=i(wr);Uh=s(Ay,"apply_ocr"),Ay.forEach(o),Bh=s(q,` set to
`),xr=r(q,"CODE",{});var Dy=i(xr);Vh=s(Dy,"False"),Dy.forEach(o),Qh=s(q,", it passes the words ("),Tr=r(q,"CODE",{});var Oy=i(Tr);Gh=s(Oy,"text"),Oy.forEach(o),Hh=s(q,"/"),Mr=r(q,"CODE",{});var Ny=i(Mr);Kh=s(Ny,"text_pair`) and `boxes` specified by the user along with the additional arguments to [__call__()](/docs/transformers/v4.29.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Tokenizer.__call__) and returns the output, together with resized `images"),Ny.forEach(o),Xh=s(q,"."),q.forEach(o),Yh=p(Rs),$r=r(Rs,"P",{});var Sy=i($r);Zh=s(Sy,"Please refer to the docstring of the above two methods for more information."),Sy.forEach(o),Rs.forEach(o),Te.forEach(o),el=p(t),Se=r(t,"H2",{class:!0});var Ol=i(Se);ut=r(Ol,"A",{id:!0,class:!0,href:!0});var Ry=i(ut);Er=r(Ry,"SPAN",{});var Wy=i(Er);_(Ko.$$.fragment,Wy),Wy.forEach(o),Ry.forEach(o),Jh=p(Ol),zr=r(Ol,"SPAN",{});var Uy=i(zr);ef=s(Uy,"LayoutLMv2Model"),Uy.forEach(o),Ol.forEach(o),tl=p(t),de=r(t,"DIV",{class:!0});var Ws=i(de);_(Xo.$$.fragment,Ws),tf=p(Ws),Yo=r(Ws,"P",{});var Nl=i(Yo);of=s(Nl,`The bare LayoutLMv2 Model transformer outputting raw hidden-states without any specific head on top.
This model is a PyTorch `),Zo=r(Nl,"A",{href:!0,rel:!0});var By=i(Zo);nf=s(By,"torch.nn.Module"),By.forEach(o),sf=s(Nl,` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Nl.forEach(o),af=p(Ws),ae=r(Ws,"DIV",{class:!0});var Et=i(ae);_(Jo.$$.fragment,Et),rf=p(Et),Re=r(Et,"P",{});var Us=i(Re);lf=s(Us,"The "),$s=r(Us,"A",{href:!0});var Vy=i($s);cf=s(Vy,"LayoutLMv2Model"),Vy.forEach(o),df=s(Us," forward method, overrides the "),qr=r(Us,"CODE",{});var Qy=i(qr);pf=s(Qy,"__call__"),Qy.forEach(o),uf=s(Us," special method."),Us.forEach(o),mf=p(Et),_(mt.$$.fragment,Et),hf=p(Et),_(ht.$$.fragment,Et),Et.forEach(o),Ws.forEach(o),ol=p(t),We=r(t,"H2",{class:!0});var Sl=i(We);ft=r(Sl,"A",{id:!0,class:!0,href:!0});var Gy=i(ft);Fr=r(Gy,"SPAN",{});var Hy=i(Fr);_(en.$$.fragment,Hy),Hy.forEach(o),Gy.forEach(o),ff=p(Sl),Pr=r(Sl,"SPAN",{});var Ky=i(Pr);gf=s(Ky,"LayoutLMv2ForSequenceClassification"),Ky.forEach(o),Sl.forEach(o),nl=p(t),ee=r(t,"DIV",{class:!0});var zt=i(ee);_(tn.$$.fragment,zt),_f=p(zt),on=r(zt,"P",{});var Rl=i(on);vf=s(Rl,`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
`),nn=r(Rl,"A",{href:!0,rel:!0});var Xy=i(nn);yf=s(Xy,"RVL-CDIP"),Xy.forEach(o),bf=s(Rl," dataset."),Rl.forEach(o),Lf=p(zt),sn=r(zt,"P",{});var Wl=i(sn);kf=s(Wl,"This model is a PyTorch "),an=r(Wl,"A",{href:!0,rel:!0});var Yy=i(an);wf=s(Yy,"torch.nn.Module"),Yy.forEach(o),xf=s(Wl,` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Wl.forEach(o),Tf=p(zt),re=r(zt,"DIV",{class:!0});var qt=i(re);_(rn.$$.fragment,qt),Mf=p(qt),Ue=r(qt,"P",{});var Bs=i(Ue);$f=s(Bs,"The "),Es=r(Bs,"A",{href:!0});var Zy=i(Es);Ef=s(Zy,"LayoutLMv2ForSequenceClassification"),Zy.forEach(o),zf=s(Bs," forward method, overrides the "),jr=r(Bs,"CODE",{});var Jy=i(jr);qf=s(Jy,"__call__"),Jy.forEach(o),Ff=s(Bs," special method."),Bs.forEach(o),Pf=p(qt),_(gt.$$.fragment,qt),jf=p(qt),_(_t.$$.fragment,qt),qt.forEach(o),zt.forEach(o),sl=p(t),Be=r(t,"H2",{class:!0});var Ul=i(Be);vt=r(Ul,"A",{id:!0,class:!0,href:!0});var e2=i(vt);Ir=r(e2,"SPAN",{});var t2=i(Ir);_(ln.$$.fragment,t2),t2.forEach(o),e2.forEach(o),If=p(Ul),Cr=r(Ul,"SPAN",{});var o2=i(Cr);Cf=s(o2,"LayoutLMv2ForTokenClassification"),o2.forEach(o),Ul.forEach(o),al=p(t),te=r(t,"DIV",{class:!0});var Ft=i(te);_(cn.$$.fragment,Ft),Af=p(Ft),oe=r(Ft,"P",{});var Me=i(oe);Df=s(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
`),dn=r(Me,"A",{href:!0,rel:!0});var n2=i(dn);Of=s(n2,"FUNSD"),n2.forEach(o),Nf=s(Me,", "),pn=r(Me,"A",{href:!0,rel:!0});var s2=i(pn);Sf=s(s2,"SROIE"),s2.forEach(o),Rf=s(Me,`,
`),un=r(Me,"A",{href:!0,rel:!0});var a2=i(un);Wf=s(a2,"CORD"),a2.forEach(o),Uf=s(Me," and "),mn=r(Me,"A",{href:!0,rel:!0});var r2=i(mn);Bf=s(r2,"Kleister-NDA"),r2.forEach(o),Vf=s(Me,"."),Me.forEach(o),Qf=p(Ft),hn=r(Ft,"P",{});var Bl=i(hn);Gf=s(Bl,"This model is a PyTorch "),fn=r(Bl,"A",{href:!0,rel:!0});var i2=i(fn);Hf=s(i2,"torch.nn.Module"),i2.forEach(o),Kf=s(Bl,` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Bl.forEach(o),Xf=p(Ft),ie=r(Ft,"DIV",{class:!0});var Pt=i(ie);_(gn.$$.fragment,Pt),Yf=p(Pt),Ve=r(Pt,"P",{});var Vs=i(Ve);Zf=s(Vs,"The "),zs=r(Vs,"A",{href:!0});var l2=i(zs);Jf=s(l2,"LayoutLMv2ForTokenClassification"),l2.forEach(o),eg=s(Vs," forward method, overrides the "),Ar=r(Vs,"CODE",{});var c2=i(Ar);tg=s(c2,"__call__"),c2.forEach(o),og=s(Vs," special method."),Vs.forEach(o),ng=p(Pt),_(yt.$$.fragment,Pt),sg=p(Pt),_(bt.$$.fragment,Pt),Pt.forEach(o),Ft.forEach(o),rl=p(t),Qe=r(t,"H2",{class:!0});var Vl=i(Qe);Lt=r(Vl,"A",{id:!0,class:!0,href:!0});var d2=i(Lt);Dr=r(d2,"SPAN",{});var p2=i(Dr);_(_n.$$.fragment,p2),p2.forEach(o),d2.forEach(o),ag=p(Vl),Or=r(Vl,"SPAN",{});var u2=i(Or);rg=s(u2,"LayoutLMv2ForQuestionAnswering"),u2.forEach(o),Vl.forEach(o),il=p(t),ne=r(t,"DIV",{class:!0});var jt=i(ne);_(vn.$$.fragment,jt),ig=p(jt),pe=r(jt,"P",{});var It=i(pe);lg=s(It,`LayoutLMv2 Model with a span classification head on top for extractive question-answering tasks such as
`),yn=r(It,"A",{href:!0,rel:!0});var m2=i(yn);cg=s(m2,"DocVQA"),m2.forEach(o),dg=s(It,` (a linear layer on top of the text part of the hidden-states output to
compute `),Nr=r(It,"CODE",{});var h2=i(Nr);pg=s(h2,"span start logits"),h2.forEach(o),ug=s(It," and "),Sr=r(It,"CODE",{});var f2=i(Sr);mg=s(f2,"span end logits"),f2.forEach(o),hg=s(It,")."),It.forEach(o),fg=p(jt),bn=r(jt,"P",{});var Ql=i(bn);gg=s(Ql,"This model is a PyTorch "),Ln=r(Ql,"A",{href:!0,rel:!0});var g2=i(Ln);_g=s(g2,"torch.nn.Module"),g2.forEach(o),vg=s(Ql,` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Ql.forEach(o),yg=p(jt),D=r(jt,"DIV",{class:!0});var K=i(D);_(kn.$$.fragment,K),bg=p(K),Ge=r(K,"P",{});var Qs=i(Ge);Lg=s(Qs,"The "),qs=r(Qs,"A",{href:!0});var _2=i(qs);kg=s(_2,"LayoutLMv2ForQuestionAnswering"),_2.forEach(o),wg=s(Qs," forward method, overrides the "),Rr=r(Qs,"CODE",{});var v2=i(Rr);xg=s(v2,"__call__"),v2.forEach(o),Tg=s(Qs," special method."),Qs.forEach(o),Mg=p(K),_(kt.$$.fragment,K),$g=p(K),Wr=r(K,"P",{});var y2=i(Wr);Eg=s(y2,"Example:"),y2.forEach(o),zg=p(K),Ur=r(K,"P",{});var b2=i(Ur);qg=s(b2,`In this example below, we give the LayoutLMv2 model an image (of texts) and ask it a question. It will give us
a prediction of what it thinks the answer is (the span of the answer within the texts parsed from the image).`),b2.forEach(o),Fg=p(K),_(wt.$$.fragment,K),Pg=p(K),_(xt.$$.fragment,K),K.forEach(o),jt.forEach(o),this.h()},h(){l(h,"name","hf:doc:metadata"),l(h,"content",JSON.stringify(D2)),l(k,"id","layoutlmv2"),l(k,"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(k,"href","#layoutlmv2"),l(f,"class","relative group"),l(Ke,"id","overview"),l(Ke,"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(Ke,"href","#overview"),l($e,"class","relative group"),l(At,"href","https://arxiv.org/abs/2012.14740"),l(At,"rel","nofollow"),l(Tn,"href","layoutlm"),l(Dt,"href","https://guillaumejaume.github.io/FUNSD/"),l(Dt,"rel","nofollow"),l(Ot,"href","https://github.com/clovaai/cord"),l(Ot,"rel","nofollow"),l(Nt,"href","https://rrc.cvc.uab.es/?ch=13"),l(Nt,"rel","nofollow"),l(St,"href","https://github.com/applicaai/kleister-nda"),l(St,"rel","nofollow"),l(Wt,"href","https://www.cs.cmu.edu/~aharley/rvl-cdip/"),l(Wt,"rel","nofollow"),l(Bt,"href","https://arxiv.org/abs/2007.00398"),l(Bt,"rel","nofollow"),l(Gt,"href","https://arxiv.org/abs/2012.14740"),l(Gt,"rel","nofollow"),l(Kt,"href","https://github.com/NielsRogge/Transformers-Tutorials"),l(Kt,"rel","nofollow"),l(Xt,"href","https://github.com/facebookresearch/detectron2/"),l(Xt,"rel","nofollow"),l(Yt,"href","https://detectron2.readthedocs.io/en/latest/tutorials/install.html"),l(Yt,"rel","nofollow"),l(qn,"href","/docs/transformers/v4.29.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Model.forward"),l(Fn,"href","/docs/transformers/v4.29.0/en/model_doc/layoutlm#transformers.LayoutLMModel"),l(Zt,"href","https://github.com/tesseract-ocr/tesseract"),l(Zt,"rel","nofollow"),l(Jt,"href","https://pypi.org/project/pytesseract/"),l(Jt,"rel","nofollow"),l(Pn,"href","/docs/transformers/v4.29.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Processor"),l(jn,"href","/docs/transformers/v4.29.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Model"),l(In,"href","/docs/transformers/v4.29.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Config"),l(Cn,"href","/docs/transformers/v4.29.0/en/main_classes/model#transformers.PreTrainedModel.from_pretrained"),l(An,"href","layoutxlm"),l(Ze,"id","resources"),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","#resources"),l(ze,"class","relative group"),l(io,"href","https://colab.research.google.com/github/NielsRogge/Transformers-Tutorials/blob/master/LayoutLMv2/RVL-CDIP/Fine_tuning_LayoutLMv2ForSequenceClassification_on_RVL_CDIP.ipynb"),l(io,"rel","nofollow"),l(Nn,"href","../tasks/sequence_classification"),l(po,"href","https://colab.research.google.com/github/NielsRogge/Transformers-Tutorials/blob/master/LayoutLMv2/DocVQA/Fine_tuning_LayoutLMv2ForQuestionAnswering_on_DocVQA.ipynb"),l(po,"rel","nofollow"),l(Rn,"href","../tasks/question_answering"),l(Un,"href","../tasks/document_question_answering"),l(ho,"href","https://colab.research.google.com/github/NielsRogge/Transformers-Tutorials/blob/master/LayoutLMv2/CORD/Fine_tuning_LayoutLMv2ForTokenClassification_on_CORD.ipynb"),l(ho,"rel","nofollow"),l(go,"href","https://colab.research.google.com/github/NielsRogge/Transformers-Tutorials/blob/master/LayoutLMv2/FUNSD/Fine_tuning_LayoutLMv2ForTokenClassification_on_FUNSD_using_HuggingFace_Trainer.ipynb"),l(go,"rel","nofollow"),l(Vn,"href","../tasks/token_classification"),l(et,"id","usage-layoutlmv2processor"),l(et,"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(et,"href","#usage-layoutlmv2processor"),l(qe,"class","relative group"),l(Qn,"href","/docs/transformers/v4.29.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Processor"),l(Gn,"href","/docs/transformers/v4.29.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2FeatureExtractor"),l(Hn,"href","/docs/transformers/v4.29.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Tokenizer"),l(Kn,"href","/docs/transformers/v4.29.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2TokenizerFast"),l(Xn,"href","/docs/transformers/v4.29.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Processor"),l(Yn,"href","/docs/transformers/v4.29.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2FeatureExtractor"),l(Zn,"href","/docs/transformers/v4.29.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Tokenizer"),l(Jn,"href","/docs/transformers/v4.29.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2TokenizerFast"),l(es,"href","/docs/transformers/v4.29.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Processor"),l(yo,"href","https://pypi.org/project/pytesseract/"),l(yo,"rel","nofollow"),l(ts,"href","/docs/transformers/v4.29.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2FeatureExtractor"),l(tt,"id","transformers.LayoutLMv2Config"),l(tt,"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(tt,"href","#transformers.LayoutLMv2Config"),l(Fe,"class","relative group"),l(ps,"href","/docs/transformers/v4.29.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Model"),l($o,"href","https://huggingface.co/microsoft/layoutlmv2-base-uncased"),l($o,"rel","nofollow"),l(us,"href","/docs/transformers/v4.29.0/en/main_classes/configuration#transformers.PretrainedConfig"),l(ms,"href","/docs/transformers/v4.29.0/en/main_classes/configuration#transformers.PretrainedConfig"),l(Z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(nt,"id","transformers.LayoutLMv2FeatureExtractor"),l(nt,"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(nt,"href","#transformers.LayoutLMv2FeatureExtractor"),l(Ie,"class","relative group"),l(st,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(Ce,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(at,"id","transformers.LayoutLMv2ImageProcessor"),l(at,"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(at,"href","#transformers.LayoutLMv2ImageProcessor"),l(Ae,"class","relative group"),l(rt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(ce,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(it,"id","transformers.LayoutLMv2Tokenizer"),l(it,"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(it,"href","#transformers.LayoutLMv2Tokenizer"),l(De,"class","relative group"),l(hs,"href","/docs/transformers/v4.29.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Tokenizer"),l(fs,"href","/docs/transformers/v4.29.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizer"),l(_s,"href","/docs/transformers/v4.29.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Tokenizer"),l(lt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(vs,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(N,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(ct,"id","transformers.LayoutLMv2TokenizerFast"),l(ct,"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(ct,"href","#transformers.LayoutLMv2TokenizerFast"),l(Oe,"class","relative group"),l(ys,"href","/docs/transformers/v4.29.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast"),l(dt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(J,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(pt,"id","transformers.LayoutLMv2Processor"),l(pt,"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(pt,"href","#transformers.LayoutLMv2Processor"),l(Ne,"class","relative group"),l(Ls,"href","/docs/transformers/v4.29.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Processor"),l(ks,"href","/docs/transformers/v4.29.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2ImageProcessor"),l(ws,"href","/docs/transformers/v4.29.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Tokenizer"),l(xs,"href","/docs/transformers/v4.29.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2TokenizerFast"),l(Go,"href","/docs/transformers/v4.29.0/en/model_doc/dpt#transformers.DPTFeatureExtractor.__call__"),l(Ts,"href","/docs/transformers/v4.29.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2ImageProcessor"),l(Ho,"href","/docs/transformers/v4.29.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Tokenizer.__call__"),l(Ms,"href","/docs/transformers/v4.29.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2ImageProcessor"),l(be,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(U,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(ut,"id","transformers.LayoutLMv2Model"),l(ut,"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(ut,"href","#transformers.LayoutLMv2Model"),l(Se,"class","relative group"),l(Zo,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),l(Zo,"rel","nofollow"),l($s,"href","/docs/transformers/v4.29.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Model"),l(ae,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(de,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(ft,"id","transformers.LayoutLMv2ForSequenceClassification"),l(ft,"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(ft,"href","#transformers.LayoutLMv2ForSequenceClassification"),l(We,"class","relative group"),l(nn,"href","https://www.cs.cmu.edu/~aharley/rvl-cdip/"),l(nn,"rel","nofollow"),l(an,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),l(an,"rel","nofollow"),l(Es,"href","/docs/transformers/v4.29.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2ForSequenceClassification"),l(re,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(ee,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(vt,"id","transformers.LayoutLMv2ForTokenClassification"),l(vt,"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(vt,"href","#transformers.LayoutLMv2ForTokenClassification"),l(Be,"class","relative group"),l(dn,"href","https://guillaumejaume.github.io/FUNSD/"),l(dn,"rel","nofollow"),l(pn,"href","https://rrc.cvc.uab.es/?ch=13"),l(pn,"rel","nofollow"),l(un,"href","https://github.com/clovaai/cord"),l(un,"rel","nofollow"),l(mn,"href","https://github.com/applicaai/kleister-nda"),l(mn,"rel","nofollow"),l(fn,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),l(fn,"rel","nofollow"),l(zs,"href","/docs/transformers/v4.29.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2ForTokenClassification"),l(ie,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(te,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(Lt,"id","transformers.LayoutLMv2ForQuestionAnswering"),l(Lt,"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(Lt,"href","#transformers.LayoutLMv2ForQuestionAnswering"),l(Qe,"class","relative group"),l(yn,"href","https://rrc.cvc.uab.es/?ch=17"),l(yn,"rel","nofollow"),l(Ln,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),l(Ln,"rel","nofollow"),l(qs,"href","/docs/transformers/v4.29.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2ForQuestionAnswering"),l(D,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(ne,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(t,c){e(document.head,h),u(t,x,c),u(t,f,c),e(f,k),e(k,T),v(m,T,null),e(f,w),e(f,O),e(O,Hl),u(t,Yr,c),u(t,$e,c),e($e,Ke),e(Ke,Ks),v(Ct,Ks,null),e($e,Kl),e($e,Xs),e(Xs,Xl),u(t,Zr,c),u(t,me,c),e(me,Yl),e(me,At),e(At,Zl),e(me,Jl),e(me,Tn),e(Tn,ec),e(me,tc),u(t,Jr,c),u(t,he,c),e(he,Y),e(Y,oc),e(Y,Dt),e(Dt,nc),e(Y,sc),e(Y,Ot),e(Ot,ac),e(Y,rc),e(Y,Nt),e(Nt,ic),e(Y,lc),e(Y,St),e(St,cc),e(Y,dc),e(he,pc),e(he,Rt),e(Rt,uc),e(Rt,Wt),e(Wt,mc),e(Rt,hc),e(he,fc),e(he,Ut),e(Ut,gc),e(Ut,Bt),e(Bt,_c),e(Ut,vc),u(t,ei,c),u(t,Mn,c),e(Mn,yc),u(t,ti,c),u(t,$n,c),e($n,Ys),e(Ys,bc),u(t,oi,c),u(t,se,c),e(se,Lc),e(se,Zs),e(Zs,kc),e(se,wc),e(se,Js),e(Js,xc),e(se,Tc),e(se,ea),e(ea,Mc),e(se,$c),u(t,ni,c),v(Vt,t,c),u(t,si,c),u(t,En,c),e(En,Ec),u(t,ai,c),u(t,zn,c),e(zn,zc),u(t,ri,c),u(t,V,c),e(V,ta),e(ta,qc),e(V,Fc),e(V,Qt),e(Qt,Pc),e(Qt,Gt),e(Gt,jc),e(Qt,Ic),e(V,Cc),e(V,Ht),e(Ht,Ac),e(Ht,Kt),e(Kt,Dc),e(Ht,Oc),e(V,Nc),e(V,Ee),e(Ee,Sc),e(Ee,Xt),e(Xt,Rc),e(Ee,Wc),e(Ee,Yt),e(Yt,Uc),e(Ee,Bc),e(V,Vc),e(V,M),e(M,Qc),e(M,oa),e(oa,Gc),e(M,Hc),e(M,qn),e(qn,Kc),e(M,Xc),e(M,na),e(na,Yc),e(M,Zc),e(M,sa),e(sa,Jc),e(M,ed),e(M,aa),e(aa,td),e(M,od),e(M,ra),e(ra,nd),e(M,sd),e(M,ia),e(ia,ad),e(M,rd),e(M,la),e(la,id),e(M,ld),e(M,ca),e(ca,cd),e(M,dd),e(M,Fn),e(Fn,pd),e(M,ud),e(M,Zt),e(Zt,md),e(M,hd),e(M,Jt),e(Jt,fd),e(M,gd),u(t,ii,c),v(eo,t,c),u(t,li,c),u(t,fe,c),e(fe,_d),e(fe,da),e(da,vd),e(fe,yd),e(fe,pa),e(pa,bd),e(fe,Ld),u(t,ci,c),v(to,t,c),u(t,di,c),u(t,Xe,c),e(Xe,kd),e(Xe,Pn),e(Pn,wd),e(Xe,xd),u(t,pi,c),u(t,ge,c),e(ge,A),e(A,Td),e(A,jn),e(jn,Md),e(A,$d),e(A,ua),e(ua,Ed),e(A,zd),e(A,ma),e(ma,qd),e(A,Fd),e(A,In),e(In,Pd),e(A,jd),e(A,ha),e(ha,Id),e(A,Cd),e(A,fa),e(fa,Ad),e(A,Dd),e(A,ga),e(ga,Od),e(A,Nd),e(ge,Sd),e(ge,oo),e(oo,Rd),e(oo,Cn),e(Cn,Wd),e(oo,Ud),e(ge,Bd),e(ge,no),e(no,Vd),e(no,_a),e(_a,Qd),e(no,Gd),u(t,ui,c),u(t,Ye,c),e(Ye,Hd),e(Ye,An),e(An,Kd),e(Ye,Xd),u(t,mi,c),u(t,ze,c),e(ze,Ze),e(Ze,va),v(so,va,null),e(ze,Yd),e(ze,ya),e(ya,Zd),u(t,hi,c),u(t,Dn,c),e(Dn,Jd),u(t,fi,c),v(ao,t,c),u(t,gi,c),u(t,Je,c),e(Je,ro),e(ro,ep),e(ro,io),e(io,tp),e(ro,op),e(Je,np),e(Je,On),e(On,sp),e(On,Nn),e(Nn,ap),u(t,_i,c),v(lo,t,c),u(t,vi,c),u(t,_e,c),e(_e,co),e(co,rp),e(co,po),e(po,ip),e(co,lp),e(_e,cp),e(_e,Sn),e(Sn,dp),e(Sn,Rn),e(Rn,pp),e(_e,up),e(_e,Wn),e(Wn,mp),e(Wn,Un),e(Un,hp),u(t,yi,c),v(uo,t,c),u(t,bi,c),u(t,ve,c),e(ve,mo),e(mo,fp),e(mo,ho),e(ho,gp),e(mo,_p),e(ve,vp),e(ve,fo),e(fo,yp),e(fo,go),e(go,bp),e(fo,Lp),e(ve,kp),e(ve,Bn),e(Bn,wp),e(Bn,Vn),e(Vn,xp),u(t,Li,c),u(t,qe,c),e(qe,et),e(et,ba),v(_o,ba,null),e(qe,Tp),e(qe,La),e(La,Mp),u(t,ki,c),u(t,Q,c),e(Q,$p),e(Q,Qn),e(Qn,Ep),e(Q,zp),e(Q,Gn),e(Gn,qp),e(Q,Fp),e(Q,Hn),e(Hn,Pp),e(Q,jp),e(Q,Kn),e(Kn,Ip),e(Q,Cp),u(t,wi,c),v(vo,t,c),u(t,xi,c),u(t,E,c),e(E,Ap),e(E,Xn),e(Xn,Dp),e(E,Op),e(E,Yn),e(Yn,Np),e(E,Sp),e(E,ka),e(ka,Rp),e(E,Wp),e(E,Zn),e(Zn,Up),e(E,Bp),e(E,Jn),e(Jn,Vp),e(E,Qp),e(E,wa),e(wa,Gp),e(E,Hp),e(E,xa),e(xa,Kp),e(E,Xp),e(E,Ta),e(Ta,Yp),e(E,Zp),e(E,Ma),e(Ma,Jp),e(E,eu),e(E,$a),e($a,tu),e(E,ou),u(t,Ti,c),u(t,W,c),e(W,es),e(es,nu),e(W,su),e(W,yo),e(yo,au),e(W,ru),e(W,ts),e(ts,iu),e(W,lu),e(W,Ea),e(Ea,cu),e(W,du),e(W,za),e(za,pu),e(W,uu),u(t,Mi,c),u(t,os,c),e(os,mu),u(t,$i,c),u(t,ns,c),e(ns,qa),e(qa,hu),u(t,Ei,c),u(t,ss,c),e(ss,fu),u(t,zi,c),v(bo,t,c),u(t,qi,c),u(t,as,c),e(as,Fa),e(Fa,gu),u(t,Fi,c),u(t,ye,c),e(ye,_u),e(ye,Pa),e(Pa,vu),e(ye,yu),e(ye,ja),e(ja,bu),e(ye,Lu),u(t,Pi,c),v(Lo,t,c),u(t,ji,c),u(t,rs,c),e(rs,Ia),e(Ia,ku),u(t,Ii,c),u(t,G,c),e(G,wu),e(G,Ca),e(Ca,xu),e(G,Tu),e(G,Aa),e(Aa,Mu),e(G,$u),e(G,Da),e(Da,Eu),e(G,zu),e(G,Oa),e(Oa,qu),e(G,Fu),u(t,Ci,c),v(ko,t,c),u(t,Ai,c),u(t,is,c),e(is,Na),e(Na,Pu),u(t,Di,c),u(t,ls,c),e(ls,ju),u(t,Oi,c),v(wo,t,c),u(t,Ni,c),u(t,cs,c),e(cs,Sa),e(Sa,Iu),u(t,Si,c),u(t,ds,c),e(ds,Cu),u(t,Ri,c),v(xo,t,c),u(t,Wi,c),u(t,Fe,c),e(Fe,tt),e(tt,Ra),v(To,Ra,null),e(Fe,Au),e(Fe,Wa),e(Wa,Du),u(t,Ui,c),u(t,Z,c),v(Mo,Z,null),e(Z,Ou),e(Z,Pe),e(Pe,Nu),e(Pe,ps),e(ps,Su),e(Pe,Ru),e(Pe,$o),e($o,Wu),e(Pe,Uu),e(Z,Bu),e(Z,je),e(je,Vu),e(je,us),e(us,Qu),e(je,Gu),e(je,ms),e(ms,Hu),e(je,Ku),e(Z,Xu),v(ot,Z,null),u(t,Bi,c),u(t,Ie,c),e(Ie,nt),e(nt,Ua),v(Eo,Ua,null),e(Ie,Yu),e(Ie,Ba),e(Ba,Zu),u(t,Vi,c),u(t,Ce,c),v(zo,Ce,null),e(Ce,Ju),e(Ce,st),v(qo,st,null),e(st,em),e(st,Va),e(Va,tm),u(t,Qi,c),u(t,Ae,c),e(Ae,at),e(at,Qa),v(Fo,Qa,null),e(Ae,om),e(Ae,Ga),e(Ga,nm),u(t,Gi,c),u(t,ce,c),v(Po,ce,null),e(ce,sm),e(ce,Ha),e(Ha,am),e(ce,rm),e(ce,rt),v(jo,rt,null),e(rt,im),e(rt,Ka),e(Ka,lm),u(t,Hi,c),u(t,De,c),e(De,it),e(it,Xa),v(Io,Xa,null),e(De,cm),e(De,Ya),e(Ya,dm),u(t,Ki,c),u(t,N,c),v(Co,N,null),e(N,pm),e(N,S),e(S,um),e(S,hs),e(hs,mm),e(S,hm),e(S,Za),e(Za,fm),e(S,gm),e(S,Ja),e(Ja,_m),e(S,vm),e(S,er),e(er,ym),e(S,bm),e(S,tr),e(tr,Lm),e(S,km),e(S,or),e(or,wm),e(S,xm),e(N,Tm),e(N,Ao),e(Ao,Mm),e(Ao,fs),e(fs,$m),e(Ao,Em),e(N,zm),e(N,gs),e(gs,_s),e(_s,qm),e(gs,Fm),e(N,Pm),e(N,lt),v(Do,lt,null),e(lt,jm),e(lt,nr),e(nr,Im),e(N,Cm),e(N,vs),v(Oo,vs,null),u(t,Xi,c),u(t,Oe,c),e(Oe,ct),e(ct,sr),v(No,sr,null),e(Oe,Am),e(Oe,ar),e(ar,Dm),u(t,Yi,c),u(t,J,c),v(So,J,null),e(J,Om),e(J,Ro),e(Ro,Nm),e(Ro,rr),e(rr,Sm),e(Ro,Rm),e(J,Wm),e(J,Wo),e(Wo,Um),e(Wo,ys),e(ys,Bm),e(Wo,Vm),e(J,Qm),e(J,dt),v(Uo,dt,null),e(dt,Gm),e(dt,ir),e(ir,Hm),u(t,Zi,c),u(t,Ne,c),e(Ne,pt),e(pt,lr),v(Bo,lr,null),e(Ne,Km),e(Ne,cr),e(cr,Xm),u(t,Ji,c),u(t,U,c),v(Vo,U,null),e(U,Ym),e(U,dr),e(dr,Zm),e(U,Jm),e(U,bs),e(bs,Ls),e(Ls,eh),e(bs,th),e(U,oh),e(U,F),e(F,nh),e(F,ks),e(ks,sh),e(F,ah),e(F,ws),e(ws,rh),e(F,ih),e(F,xs),e(xs,lh),e(F,ch),e(F,pr),e(pr,dh),e(F,ph),e(F,ur),e(ur,uh),e(F,mh),e(F,mr),e(mr,hh),e(F,fh),e(F,hr),e(hr,gh),e(F,_h),e(F,fr),e(fr,vh),e(F,yh),e(F,gr),e(gr,bh),e(F,Lh),e(U,kh),e(U,be),v(Qo,be,null),e(be,wh),e(be,$),e($,xh),e($,_r),e(_r,Th),e($,Mh),e($,Go),e(Go,vr),e(vr,$h),e(Go,Eh),e($,zh),e($,Ts),e(Ts,qh),e($,Fh),e($,yr),e(yr,Ph),e($,jh),e($,br),e(br,Ih),e($,Ch),e($,Ho),e(Ho,Lr),e(Lr,Ah),e(Ho,Dh),e($,Oh),e($,kr),e(kr,Nh),e($,Sh),e($,Ms),e(Ms,Rh),e($,Wh),e($,wr),e(wr,Uh),e($,Bh),e($,xr),e(xr,Vh),e($,Qh),e($,Tr),e(Tr,Gh),e($,Hh),e($,Mr),e(Mr,Kh),e($,Xh),e(be,Yh),e(be,$r),e($r,Zh),u(t,el,c),u(t,Se,c),e(Se,ut),e(ut,Er),v(Ko,Er,null),e(Se,Jh),e(Se,zr),e(zr,ef),u(t,tl,c),u(t,de,c),v(Xo,de,null),e(de,tf),e(de,Yo),e(Yo,of),e(Yo,Zo),e(Zo,nf),e(Yo,sf),e(de,af),e(de,ae),v(Jo,ae,null),e(ae,rf),e(ae,Re),e(Re,lf),e(Re,$s),e($s,cf),e(Re,df),e(Re,qr),e(qr,pf),e(Re,uf),e(ae,mf),v(mt,ae,null),e(ae,hf),v(ht,ae,null),u(t,ol,c),u(t,We,c),e(We,ft),e(ft,Fr),v(en,Fr,null),e(We,ff),e(We,Pr),e(Pr,gf),u(t,nl,c),u(t,ee,c),v(tn,ee,null),e(ee,_f),e(ee,on),e(on,vf),e(on,nn),e(nn,yf),e(on,bf),e(ee,Lf),e(ee,sn),e(sn,kf),e(sn,an),e(an,wf),e(sn,xf),e(ee,Tf),e(ee,re),v(rn,re,null),e(re,Mf),e(re,Ue),e(Ue,$f),e(Ue,Es),e(Es,Ef),e(Ue,zf),e(Ue,jr),e(jr,qf),e(Ue,Ff),e(re,Pf),v(gt,re,null),e(re,jf),v(_t,re,null),u(t,sl,c),u(t,Be,c),e(Be,vt),e(vt,Ir),v(ln,Ir,null),e(Be,If),e(Be,Cr),e(Cr,Cf),u(t,al,c),u(t,te,c),v(cn,te,null),e(te,Af),e(te,oe),e(oe,Df),e(oe,dn),e(dn,Of),e(oe,Nf),e(oe,pn),e(pn,Sf),e(oe,Rf),e(oe,un),e(un,Wf),e(oe,Uf),e(oe,mn),e(mn,Bf),e(oe,Vf),e(te,Qf),e(te,hn),e(hn,Gf),e(hn,fn),e(fn,Hf),e(hn,Kf),e(te,Xf),e(te,ie),v(gn,ie,null),e(ie,Yf),e(ie,Ve),e(Ve,Zf),e(Ve,zs),e(zs,Jf),e(Ve,eg),e(Ve,Ar),e(Ar,tg),e(Ve,og),e(ie,ng),v(yt,ie,null),e(ie,sg),v(bt,ie,null),u(t,rl,c),u(t,Qe,c),e(Qe,Lt),e(Lt,Dr),v(_n,Dr,null),e(Qe,ag),e(Qe,Or),e(Or,rg),u(t,il,c),u(t,ne,c),v(vn,ne,null),e(ne,ig),e(ne,pe),e(pe,lg),e(pe,yn),e(yn,cg),e(pe,dg),e(pe,Nr),e(Nr,pg),e(pe,ug),e(pe,Sr),e(Sr,mg),e(pe,hg),e(ne,fg),e(ne,bn),e(bn,gg),e(bn,Ln),e(Ln,_g),e(bn,vg),e(ne,yg),e(ne,D),v(kn,D,null),e(D,bg),e(D,Ge),e(Ge,Lg),e(Ge,qs),e(qs,kg),e(Ge,wg),e(Ge,Rr),e(Rr,xg),e(Ge,Tg),e(D,Mg),v(kt,D,null),e(D,$g),e(D,Wr),e(Wr,Eg),e(D,zg),e(D,Ur),e(Ur,qg),e(D,Fg),v(wt,D,null),e(D,Pg),v(xt,D,null),ll=!0},p(t,[c]){const wn={};c&2&&(wn.$$scope={dirty:c,ctx:t}),ot.$set(wn);const Br={};c&2&&(Br.$$scope={dirty:c,ctx:t}),mt.$set(Br);const Vr={};c&2&&(Vr.$$scope={dirty:c,ctx:t}),ht.$set(Vr);const Qr={};c&2&&(Qr.$$scope={dirty:c,ctx:t}),gt.$set(Qr);const xn={};c&2&&(xn.$$scope={dirty:c,ctx:t}),_t.$set(xn);const Gr={};c&2&&(Gr.$$scope={dirty:c,ctx:t}),yt.$set(Gr);const Hr={};c&2&&(Hr.$$scope={dirty:c,ctx:t}),bt.$set(Hr);const Kr={};c&2&&(Kr.$$scope={dirty:c,ctx:t}),kt.$set(Kr);const He={};c&2&&(He.$$scope={dirty:c,ctx:t}),wt.$set(He);const Xr={};c&2&&(Xr.$$scope={dirty:c,ctx:t}),xt.$set(Xr)},i(t){ll||(y(m.$$.fragment,t),y(Ct.$$.fragment,t),y(Vt.$$.fragment,t),y(eo.$$.fragment,t),y(to.$$.fragment,t),y(so.$$.fragment,t),y(ao.$$.fragment,t),y(lo.$$.fragment,t),y(uo.$$.fragment,t),y(_o.$$.fragment,t),y(vo.$$.fragment,t),y(bo.$$.fragment,t),y(Lo.$$.fragment,t),y(ko.$$.fragment,t),y(wo.$$.fragment,t),y(xo.$$.fragment,t),y(To.$$.fragment,t),y(Mo.$$.fragment,t),y(ot.$$.fragment,t),y(Eo.$$.fragment,t),y(zo.$$.fragment,t),y(qo.$$.fragment,t),y(Fo.$$.fragment,t),y(Po.$$.fragment,t),y(jo.$$.fragment,t),y(Io.$$.fragment,t),y(Co.$$.fragment,t),y(Do.$$.fragment,t),y(Oo.$$.fragment,t),y(No.$$.fragment,t),y(So.$$.fragment,t),y(Uo.$$.fragment,t),y(Bo.$$.fragment,t),y(Vo.$$.fragment,t),y(Qo.$$.fragment,t),y(Ko.$$.fragment,t),y(Xo.$$.fragment,t),y(Jo.$$.fragment,t),y(mt.$$.fragment,t),y(ht.$$.fragment,t),y(en.$$.fragment,t),y(tn.$$.fragment,t),y(rn.$$.fragment,t),y(gt.$$.fragment,t),y(_t.$$.fragment,t),y(ln.$$.fragment,t),y(cn.$$.fragment,t),y(gn.$$.fragment,t),y(yt.$$.fragment,t),y(bt.$$.fragment,t),y(_n.$$.fragment,t),y(vn.$$.fragment,t),y(kn.$$.fragment,t),y(kt.$$.fragment,t),y(wt.$$.fragment,t),y(xt.$$.fragment,t),ll=!0)},o(t){b(m.$$.fragment,t),b(Ct.$$.fragment,t),b(Vt.$$.fragment,t),b(eo.$$.fragment,t),b(to.$$.fragment,t),b(so.$$.fragment,t),b(ao.$$.fragment,t),b(lo.$$.fragment,t),b(uo.$$.fragment,t),b(_o.$$.fragment,t),b(vo.$$.fragment,t),b(bo.$$.fragment,t),b(Lo.$$.fragment,t),b(ko.$$.fragment,t),b(wo.$$.fragment,t),b(xo.$$.fragment,t),b(To.$$.fragment,t),b(Mo.$$.fragment,t),b(ot.$$.fragment,t),b(Eo.$$.fragment,t),b(zo.$$.fragment,t),b(qo.$$.fragment,t),b(Fo.$$.fragment,t),b(Po.$$.fragment,t),b(jo.$$.fragment,t),b(Io.$$.fragment,t),b(Co.$$.fragment,t),b(Do.$$.fragment,t),b(Oo.$$.fragment,t),b(No.$$.fragment,t),b(So.$$.fragment,t),b(Uo.$$.fragment,t),b(Bo.$$.fragment,t),b(Vo.$$.fragment,t),b(Qo.$$.fragment,t),b(Ko.$$.fragment,t),b(Xo.$$.fragment,t),b(Jo.$$.fragment,t),b(mt.$$.fragment,t),b(ht.$$.fragment,t),b(en.$$.fragment,t),b(tn.$$.fragment,t),b(rn.$$.fragment,t),b(gt.$$.fragment,t),b(_t.$$.fragment,t),b(ln.$$.fragment,t),b(cn.$$.fragment,t),b(gn.$$.fragment,t),b(yt.$$.fragment,t),b(bt.$$.fragment,t),b(_n.$$.fragment,t),b(vn.$$.fragment,t),b(kn.$$.fragment,t),b(kt.$$.fragment,t),b(wt.$$.fragment,t),b(xt.$$.fragment,t),ll=!1},d(t){o(h),t&&o(x),t&&o(f),L(m),t&&o(Yr),t&&o($e),L(Ct),t&&o(Zr),t&&o(me),t&&o(Jr),t&&o(he),t&&o(ei),t&&o(Mn),t&&o(ti),t&&o($n),t&&o(oi),t&&o(se),t&&o(ni),L(Vt,t),t&&o(si),t&&o(En),t&&o(ai),t&&o(zn),t&&o(ri),t&&o(V),t&&o(ii),L(eo,t),t&&o(li),t&&o(fe),t&&o(ci),L(to,t),t&&o(di),t&&o(Xe),t&&o(pi),t&&o(ge),t&&o(ui),t&&o(Ye),t&&o(mi),t&&o(ze),L(so),t&&o(hi),t&&o(Dn),t&&o(fi),L(ao,t),t&&o(gi),t&&o(Je),t&&o(_i),L(lo,t),t&&o(vi),t&&o(_e),t&&o(yi),L(uo,t),t&&o(bi),t&&o(ve),t&&o(Li),t&&o(qe),L(_o),t&&o(ki),t&&o(Q),t&&o(wi),L(vo,t),t&&o(xi),t&&o(E),t&&o(Ti),t&&o(W),t&&o(Mi),t&&o(os),t&&o($i),t&&o(ns),t&&o(Ei),t&&o(ss),t&&o(zi),L(bo,t),t&&o(qi),t&&o(as),t&&o(Fi),t&&o(ye),t&&o(Pi),L(Lo,t),t&&o(ji),t&&o(rs),t&&o(Ii),t&&o(G),t&&o(Ci),L(ko,t),t&&o(Ai),t&&o(is),t&&o(Di),t&&o(ls),t&&o(Oi),L(wo,t),t&&o(Ni),t&&o(cs),t&&o(Si),t&&o(ds),t&&o(Ri),L(xo,t),t&&o(Wi),t&&o(Fe),L(To),t&&o(Ui),t&&o(Z),L(Mo),L(ot),t&&o(Bi),t&&o(Ie),L(Eo),t&&o(Vi),t&&o(Ce),L(zo),L(qo),t&&o(Qi),t&&o(Ae),L(Fo),t&&o(Gi),t&&o(ce),L(Po),L(jo),t&&o(Hi),t&&o(De),L(Io),t&&o(Ki),t&&o(N),L(Co),L(Do),L(Oo),t&&o(Xi),t&&o(Oe),L(No),t&&o(Yi),t&&o(J),L(So),L(Uo),t&&o(Zi),t&&o(Ne),L(Bo),t&&o(Ji),t&&o(U),L(Vo),L(Qo),t&&o(el),t&&o(Se),L(Ko),t&&o(tl),t&&o(de),L(Xo),L(Jo),L(mt),L(ht),t&&o(ol),t&&o(We),L(en),t&&o(nl),t&&o(ee),L(tn),L(rn),L(gt),L(_t),t&&o(sl),t&&o(Be),L(ln),t&&o(al),t&&o(te),L(cn),L(gn),L(yt),L(bt),t&&o(rl),t&&o(Qe),L(_n),t&&o(il),t&&o(ne),L(vn),L(kn),L(kt),L(wt),L(xt)}}}const D2={local:"layoutlmv2",sections:[{local:"overview",title:"Overview"},{local:"resources",title:"Resources"},{local:"usage-layoutlmv2processor",title:"Usage: LayoutLMv2Processor"},{local:"transformers.LayoutLMv2Config",title:"LayoutLMv2Config"},{local:"transformers.LayoutLMv2FeatureExtractor",title:"LayoutLMv2FeatureExtractor"},{local:"transformers.LayoutLMv2ImageProcessor",title:"LayoutLMv2ImageProcessor"},{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 O2(P){return T2(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Q2 extends L2{constructor(h){super();k2(this,h,O2,A2,w2,{})}}export{Q2 as default,D2 as metadata};
