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