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