import{S as Mm,i as $m,s as Em,e as n,k as d,w as v,t as i,M as zm,c as r,d as t,m as c,a,x as y,h as l,b as p,G as e,g as _,y as w,q as T,o as R,B as M,v as xm,L as rt}from"../../chunks/vendor-hf-doc-builder.js";import{T as Mr}from"../../chunks/Tip-hf-doc-builder.js";import{D as z}from"../../chunks/Docstring-hf-doc-builder.js";import{C as at}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as Q}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as nt}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";function jm($){let m,k,u,f,b;return f=new at({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFJlYWxtQ29uZmlnJTJDJTIwUmVhbG1FbWJlZGRlciUwQSUwQSUyMyUyMEluaXRpYWxpemluZyUyMGElMjBSRUFMTSUyMHJlYWxtLWNjLW5ld3MtcHJldHJhaW5lZC0qJTIwc3R5bGUlMjBjb25maWd1cmF0aW9uJTBBY29uZmlndXJhdGlvbiUyMCUzRCUyMFJlYWxtQ29uZmlnKCklMEElMEElMjMlMjBJbml0aWFsaXppbmclMjBhJTIwbW9kZWwlMjAod2l0aCUyMHJhbmRvbSUyMHdlaWdodHMpJTIwZnJvbSUyMHRoZSUyMGdvb2dsZSUyRnJlYWxtLWNjLW5ld3MtcHJldHJhaW5lZC1lbWJlZGRlciUyMHN0eWxlJTIwY29uZmlndXJhdGlvbiUwQW1vZGVsJTIwJTNEJTIwUmVhbG1FbWJlZGRlcihjb25maWd1cmF0aW9uKSUwQSUwQSUyMyUyMEFjY2Vzc2luZyUyMHRoZSUyMG1vZGVsJTIwY29uZmlndXJhdGlvbiUwQWNvbmZpZ3VyYXRpb24lMjAlM0QlMjBtb2RlbC5jb25maWc=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> RealmConfig, RealmEmbedder

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a REALM realm-cc-news-pretrained-* style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = RealmConfig()

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a model (with random weights) from the google/realm-cc-news-pretrained-embedder style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = RealmEmbedder(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(){m=n("p"),k=i("Example:"),u=d(),v(f.$$.fragment)},l(s){m=r(s,"P",{});var h=a(m);k=l(h,"Example:"),h.forEach(t),u=c(s),y(f.$$.fragment,s)},m(s,h){_(s,m,h),e(m,k),_(s,u,h),w(f,s,h),b=!0},p:rt,i(s){b||(T(f.$$.fragment,s),b=!0)},o(s){R(f.$$.fragment,s),b=!1},d(s){s&&t(m),s&&t(u),M(f,s)}}}function Jm($){let m,k,u,f,b;return f=new at({props:{code:"MCUyMDAlMjAwJTIwMCUyMDAlMjAwJTIwMCUyMDAlMjAwJTIwMCUyMDAlMjAxJTIwMSUyMDElMjAxJTIwMSUyMDElMjAxJTIwMSUyMDElMEElN0MlMjBmaXJzdCUyMHNlcXVlbmNlJTIwJTIwJTIwJTIwJTdDJTIwc2Vjb25kJTIwc2VxdWVuY2UlMjAlN0M=",highlighted:`0<span class="hljs-number"> 0 </span>0<span class="hljs-number"> 0 </span>0<span class="hljs-number"> 0 </span>0<span class="hljs-number"> 0 </span>0<span class="hljs-number"> 0 </span>0<span class="hljs-number"> 1 </span>1<span class="hljs-number"> 1 </span>1<span class="hljs-number"> 1 </span>1<span class="hljs-number"> 1 </span>1 1
| first sequence    | second sequence |`}}),{c(){m=n("p"),k=i("pair mask has the following format:"),u=d(),v(f.$$.fragment)},l(s){m=r(s,"P",{});var h=a(m);k=l(h,"pair mask has the following format:"),h.forEach(t),u=c(s),y(f.$$.fragment,s)},m(s,h){_(s,m,h),e(m,k),_(s,u,h),w(f,s,h),b=!0},p:rt,i(s){b||(T(f.$$.fragment,s),b=!0)},o(s){R(f.$$.fragment,s),b=!1},d(s){s&&t(m),s&&t(u),M(f,s)}}}function Am($){let m,k,u,f,b;return f=new at({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFJlYWxtVG9rZW5pemVyJTBBJTBBJTIzJTIwYmF0Y2hfc2l6ZSUyMCUzRCUyMDIlMkMlMjBudW1fY2FuZGlkYXRlcyUyMCUzRCUyMDIlMEF0ZXh0JTIwJTNEJTIwJTVCJTVCJTIySGVsbG8lMjB3b3JsZCElMjIlMkMlMjAlMjJOaWNlJTIwdG8lMjBtZWV0JTIweW91ISUyMiU1RCUyQyUyMCU1QiUyMlRoZSUyMGN1dGUlMjBjYXQuJTIyJTJDJTIwJTIyVGhlJTIwYWRvcmFibGUlMjBkb2cuJTIyJTVEJTVEJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwUmVhbG1Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKCUyMmdvb2dsZSUyRnJlYWxtLWNjLW5ld3MtcHJldHJhaW5lZC1lbmNvZGVyJTIyKSUwQXRva2VuaXplZF90ZXh0JTIwJTNEJTIwdG9rZW5pemVyLmJhdGNoX2VuY29kZV9jYW5kaWRhdGVzKHRleHQlMkMlMjBtYXhfbGVuZ3RoJTNEMTAlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> RealmTokenizer

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># batch_size = 2, num_candidates = 2</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>text = [[<span class="hljs-string">&quot;Hello world!&quot;</span>, <span class="hljs-string">&quot;Nice to meet you!&quot;</span>], [<span class="hljs-string">&quot;The cute cat.&quot;</span>, <span class="hljs-string">&quot;The adorable dog.&quot;</span>]]

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = RealmTokenizer.from_pretrained(<span class="hljs-string">&quot;google/realm-cc-news-pretrained-encoder&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenized_text = tokenizer.batch_encode_candidates(text, max_length=<span class="hljs-number">10</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)`}}),{c(){m=n("p"),k=i("Example:"),u=d(),v(f.$$.fragment)},l(s){m=r(s,"P",{});var h=a(m);k=l(h,"Example:"),h.forEach(t),u=c(s),y(f.$$.fragment,s)},m(s,h){_(s,m,h),e(m,k),_(s,u,h),w(f,s,h),b=!0},p:rt,i(s){b||(T(f.$$.fragment,s),b=!0)},o(s){R(f.$$.fragment,s),b=!1},d(s){s&&t(m),s&&t(u),M(f,s)}}}function qm($){let m,k,u,f,b;return f=new at({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFJlYWxtVG9rZW5pemVyRmFzdCUwQSUwQSUyMyUyMGJhdGNoX3NpemUlMjAlM0QlMjAyJTJDJTIwbnVtX2NhbmRpZGF0ZXMlMjAlM0QlMjAyJTBBdGV4dCUyMCUzRCUyMCU1QiU1QiUyMkhlbGxvJTIwd29ybGQhJTIyJTJDJTIwJTIyTmljZSUyMHRvJTIwbWVldCUyMHlvdSElMjIlNUQlMkMlMjAlNUIlMjJUaGUlMjBjdXRlJTIwY2F0LiUyMiUyQyUyMCUyMlRoZSUyMGFkb3JhYmxlJTIwZG9nLiUyMiU1RCU1RCUwQSUwQXRva2VuaXplciUyMCUzRCUyMFJlYWxtVG9rZW5pemVyRmFzdC5mcm9tX3ByZXRyYWluZWQoJTIyZ29vZ2xlJTJGcmVhbG0tY2MtbmV3cy1wcmV0cmFpbmVkLWVuY29kZXIlMjIpJTBBdG9rZW5pemVkX3RleHQlMjAlM0QlMjB0b2tlbml6ZXIuYmF0Y2hfZW5jb2RlX2NhbmRpZGF0ZXModGV4dCUyQyUyMG1heF9sZW5ndGglM0QxMCUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> RealmTokenizerFast

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># batch_size = 2, num_candidates = 2</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>text = [[<span class="hljs-string">&quot;Hello world!&quot;</span>, <span class="hljs-string">&quot;Nice to meet you!&quot;</span>], [<span class="hljs-string">&quot;The cute cat.&quot;</span>, <span class="hljs-string">&quot;The adorable dog.&quot;</span>]]

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = RealmTokenizerFast.from_pretrained(<span class="hljs-string">&quot;google/realm-cc-news-pretrained-encoder&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenized_text = tokenizer.batch_encode_candidates(text, max_length=<span class="hljs-number">10</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)`}}),{c(){m=n("p"),k=i("Example:"),u=d(),v(f.$$.fragment)},l(s){m=r(s,"P",{});var h=a(m);k=l(h,"Example:"),h.forEach(t),u=c(s),y(f.$$.fragment,s)},m(s,h){_(s,m,h),e(m,k),_(s,u,h),w(f,s,h),b=!0},p:rt,i(s){b||(T(f.$$.fragment,s),b=!0)},o(s){R(f.$$.fragment,s),b=!1},d(s){s&&t(m),s&&t(u),M(f,s)}}}function Um($){let m,k,u,f,b;return{c(){m=n("p"),k=i("Although the recipe for forward pass needs to be defined within this function, one should call the "),u=n("code"),f=i("Module"),b=i(`
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(s){m=r(s,"P",{});var h=a(m);k=l(h,"Although the recipe for forward pass needs to be defined within this function, one should call the "),u=r(h,"CODE",{});var x=a(u);f=l(x,"Module"),x.forEach(t),b=l(h,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),h.forEach(t)},m(s,h){_(s,m,h),e(m,k),e(m,u),e(u,f),e(m,b)},d(s){s&&t(m)}}}function Im($){let m,k,u,f,b;return f=new at({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBSZWFsbUVtYmVkZGVyJTBBaW1wb3J0JTIwdG9yY2glMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJnb29nbGUlMkZyZWFsbS1jYy1uZXdzLXByZXRyYWluZWQtZW1iZWRkZXIlMjIpJTBBbW9kZWwlMjAlM0QlMjBSZWFsbUVtYmVkZGVyLmZyb21fcHJldHJhaW5lZCglMjJnb29nbGUlMkZyZWFsbS1jYy1uZXdzLXByZXRyYWluZWQtZW1iZWRkZXIlMjIpJTBBJTBBaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKCUyMkhlbGxvJTJDJTIwbXklMjBkb2clMjBpcyUyMGN1dGUlMjIlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQW91dHB1dHMlMjAlM0QlMjBtb2RlbCgqKmlucHV0cyklMEElMEFwcm9qZWN0ZWRfc2NvcmUlMjAlM0QlMjBvdXRwdXRzLnByb2plY3RlZF9zY29yZQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, RealmEmbedder
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;google/realm-cc-news-pretrained-embedder&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = RealmEmbedder.from_pretrained(<span class="hljs-string">&quot;google/realm-cc-news-pretrained-embedder&quot;</span>)

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

<span class="hljs-meta">&gt;&gt;&gt; </span>projected_score = outputs.projected_score`}}),{c(){m=n("p"),k=i("Example:"),u=d(),v(f.$$.fragment)},l(s){m=r(s,"P",{});var h=a(m);k=l(h,"Example:"),h.forEach(t),u=c(s),y(f.$$.fragment,s)},m(s,h){_(s,m,h),e(m,k),_(s,u,h),w(f,s,h),b=!0},p:rt,i(s){b||(T(f.$$.fragment,s),b=!0)},o(s){R(f.$$.fragment,s),b=!1},d(s){s&&t(m),s&&t(u),M(f,s)}}}function Zm($){let m,k,u,f,b;return{c(){m=n("p"),k=i("Although the recipe for forward pass needs to be defined within this function, one should call the "),u=n("code"),f=i("Module"),b=i(`
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(s){m=r(s,"P",{});var h=a(m);k=l(h,"Although the recipe for forward pass needs to be defined within this function, one should call the "),u=r(h,"CODE",{});var x=a(u);f=l(x,"Module"),x.forEach(t),b=l(h,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),h.forEach(t)},m(s,h){_(s,m,h),e(m,k),e(m,u),e(u,f),e(m,b)},d(s){s&&t(m)}}}function Fm($){let m,k,u,f,b;return f=new at({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b1Rva2VuaXplciUyQyUyMFJlYWxtU2NvcmVyJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIyZ29vZ2xlJTJGcmVhbG0tY2MtbmV3cy1wcmV0cmFpbmVkLXNjb3JlciUyMiklMEFtb2RlbCUyMCUzRCUyMFJlYWxtU2NvcmVyLmZyb21fcHJldHJhaW5lZCglMjJnb29nbGUlMkZyZWFsbS1jYy1uZXdzLXByZXRyYWluZWQtc2NvcmVyJTIyJTJDJTIwbnVtX2NhbmRpZGF0ZXMlM0QyKSUwQSUwQSUyMyUyMGJhdGNoX3NpemUlMjAlM0QlMjAyJTJDJTIwbnVtX2NhbmRpZGF0ZXMlMjAlM0QlMjAyJTBBaW5wdXRfdGV4dHMlMjAlM0QlMjAlNUIlMjJIb3clMjBhcmUlMjB5b3UlM0YlMjIlMkMlMjAlMjJXaGF0JTIwaXMlMjB0aGUlMjBpdGVtJTIwaW4lMjB0aGUlMjBwaWN0dXJlJTNGJTIyJTVEJTBBY2FuZGlkYXRlc190ZXh0cyUyMCUzRCUyMCU1QiU1QiUyMkhlbGxvJTIwd29ybGQhJTIyJTJDJTIwJTIyTmljZSUyMHRvJTIwbWVldCUyMHlvdSElMjIlNUQlMkMlMjAlNUIlMjJBJTIwY3V0ZSUyMGNhdC4lMjIlMkMlMjAlMjJBbiUyMGFkb3JhYmxlJTIwZG9nLiUyMiU1RCU1RCUwQSUwQWlucHV0cyUyMCUzRCUyMHRva2VuaXplcihpbnB1dF90ZXh0cyUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpJTBBY2FuZGlkYXRlc19pbnB1dHMlMjAlM0QlMjB0b2tlbml6ZXIuYmF0Y2hfZW5jb2RlX2NhbmRpZGF0ZXMoY2FuZGlkYXRlc190ZXh0cyUyQyUyMG1heF9sZW5ndGglM0QxMCUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpJTBBJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsKCUwQSUyMCUyMCUyMCUyMCoqaW5wdXRzJTJDJTBBJTIwJTIwJTIwJTIwY2FuZGlkYXRlX2lucHV0X2lkcyUzRGNhbmRpZGF0ZXNfaW5wdXRzLmlucHV0X2lkcyUyQyUwQSUyMCUyMCUyMCUyMGNhbmRpZGF0ZV9hdHRlbnRpb25fbWFzayUzRGNhbmRpZGF0ZXNfaW5wdXRzLmF0dGVudGlvbl9tYXNrJTJDJTBBJTIwJTIwJTIwJTIwY2FuZGlkYXRlX3Rva2VuX3R5cGVfaWRzJTNEY2FuZGlkYXRlc19pbnB1dHMudG9rZW5fdHlwZV9pZHMlMkMlMEEpJTBBcmVsZXZhbmNlX3Njb3JlJTIwJTNEJTIwb3V0cHV0cy5yZWxldmFuY2Vfc2NvcmU=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, RealmScorer

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;google/realm-cc-news-pretrained-scorer&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = RealmScorer.from_pretrained(<span class="hljs-string">&quot;google/realm-cc-news-pretrained-scorer&quot;</span>, num_candidates=<span class="hljs-number">2</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># batch_size = 2, num_candidates = 2</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>input_texts = [<span class="hljs-string">&quot;How are you?&quot;</span>, <span class="hljs-string">&quot;What is the item in the picture?&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>candidates_texts = [[<span class="hljs-string">&quot;Hello world!&quot;</span>, <span class="hljs-string">&quot;Nice to meet you!&quot;</span>], [<span class="hljs-string">&quot;A cute cat.&quot;</span>, <span class="hljs-string">&quot;An adorable dog.&quot;</span>]]

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(input_texts, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>candidates_inputs = tokenizer.batch_encode_candidates(candidates_texts, max_length=<span class="hljs-number">10</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(
<span class="hljs-meta">... </span>    **inputs,
<span class="hljs-meta">... </span>    candidate_input_ids=candidates_inputs.input_ids,
<span class="hljs-meta">... </span>    candidate_attention_mask=candidates_inputs.attention_mask,
<span class="hljs-meta">... </span>    candidate_token_type_ids=candidates_inputs.token_type_ids,
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>relevance_score = outputs.relevance_score`}}),{c(){m=n("p"),k=i("Example:"),u=d(),v(f.$$.fragment)},l(s){m=r(s,"P",{});var h=a(m);k=l(h,"Example:"),h.forEach(t),u=c(s),y(f.$$.fragment,s)},m(s,h){_(s,m,h),e(m,k),_(s,u,h),w(f,s,h),b=!0},p:rt,i(s){b||(T(f.$$.fragment,s),b=!0)},o(s){R(f.$$.fragment,s),b=!1},d(s){s&&t(m),s&&t(u),M(f,s)}}}function Wm($){let m,k,u,f,b;return{c(){m=n("p"),k=i("Although the recipe for forward pass needs to be defined within this function, one should call the "),u=n("code"),f=i("Module"),b=i(`
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(s){m=r(s,"P",{});var h=a(m);k=l(h,"Although the recipe for forward pass needs to be defined within this function, one should call the "),u=r(h,"CODE",{});var x=a(u);f=l(x,"Module"),x.forEach(t),b=l(h,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),h.forEach(t)},m(s,h){_(s,m,h),e(m,k),e(m,u),e(u,f),e(m,b)},d(s){s&&t(m)}}}function Cm($){let m,k,u,f,b;return f=new at({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b1Rva2VuaXplciUyQyUyMFJlYWxtS25vd2xlZGdlQXVnRW5jb2RlciUwQSUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKCUyMmdvb2dsZSUyRnJlYWxtLWNjLW5ld3MtcHJldHJhaW5lZC1lbmNvZGVyJTIyKSUwQW1vZGVsJTIwJTNEJTIwUmVhbG1Lbm93bGVkZ2VBdWdFbmNvZGVyLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJnb29nbGUlMkZyZWFsbS1jYy1uZXdzLXByZXRyYWluZWQtZW5jb2RlciUyMiUyQyUyMG51bV9jYW5kaWRhdGVzJTNEMiUwQSklMEElMEElMjMlMjBiYXRjaF9zaXplJTIwJTNEJTIwMiUyQyUyMG51bV9jYW5kaWRhdGVzJTIwJTNEJTIwMiUwQXRleHQlMjAlM0QlMjAlNUIlNUIlMjJIZWxsbyUyMHdvcmxkISUyMiUyQyUyMCUyMk5pY2UlMjB0byUyMG1lZXQlMjB5b3UhJTIyJTVEJTJDJTIwJTVCJTIyVGhlJTIwY3V0ZSUyMGNhdC4lMjIlMkMlMjAlMjJUaGUlMjBhZG9yYWJsZSUyMGRvZy4lMjIlNUQlNUQlMEElMEFpbnB1dHMlMjAlM0QlMjB0b2tlbml6ZXIuYmF0Y2hfZW5jb2RlX2NhbmRpZGF0ZXModGV4dCUyQyUyMG1heF9sZW5ndGglM0QxMCUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsKCoqaW5wdXRzKSUwQWxvZ2l0cyUyMCUzRCUyMG91dHB1dHMubG9naXRz",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, RealmKnowledgeAugEncoder

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;google/realm-cc-news-pretrained-encoder&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = RealmKnowledgeAugEncoder.from_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;google/realm-cc-news-pretrained-encoder&quot;</span>, num_candidates=<span class="hljs-number">2</span>
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># batch_size = 2, num_candidates = 2</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>text = [[<span class="hljs-string">&quot;Hello world!&quot;</span>, <span class="hljs-string">&quot;Nice to meet you!&quot;</span>], [<span class="hljs-string">&quot;The cute cat.&quot;</span>, <span class="hljs-string">&quot;The adorable dog.&quot;</span>]]

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer.batch_encode_candidates(text, max_length=<span class="hljs-number">10</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**inputs)
<span class="hljs-meta">&gt;&gt;&gt; </span>logits = outputs.logits`}}),{c(){m=n("p"),k=i("Example:"),u=d(),v(f.$$.fragment)},l(s){m=r(s,"P",{});var h=a(m);k=l(h,"Example:"),h.forEach(t),u=c(s),y(f.$$.fragment,s)},m(s,h){_(s,m,h),e(m,k),_(s,u,h),w(f,s,h),b=!0},p:rt,i(s){b||(T(f.$$.fragment,s),b=!0)},o(s){R(f.$$.fragment,s),b=!1},d(s){s&&t(m),s&&t(u),M(f,s)}}}function Lm($){let m,k,u,f,b;return{c(){m=n("p"),k=i("Although the recipe for forward pass needs to be defined within this function, one should call the "),u=n("code"),f=i("Module"),b=i(`
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(s){m=r(s,"P",{});var h=a(m);k=l(h,"Although the recipe for forward pass needs to be defined within this function, one should call the "),u=r(h,"CODE",{});var x=a(u);f=l(x,"Module"),x.forEach(t),b=l(h,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),h.forEach(t)},m(s,h){_(s,m,h),e(m,k),e(m,u),e(u,f),e(m,b)},d(s){s&&t(m)}}}function Sm($){let m,k,u,f,b;return{c(){m=n("p"),k=i("Although the recipe for forward pass needs to be defined within this function, one should call the "),u=n("code"),f=i("Module"),b=i(`
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(s){m=r(s,"P",{});var h=a(m);k=l(h,"Although the recipe for forward pass needs to be defined within this function, one should call the "),u=r(h,"CODE",{});var x=a(u);f=l(x,"Module"),x.forEach(t),b=l(h,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),h.forEach(t)},m(s,h){_(s,m,h),e(m,k),e(m,u),e(u,f),e(m,b)},d(s){s&&t(m)}}}function Nm($){let m,k,u,f,b;return f=new at({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwUmVhbG1Gb3JPcGVuUUElMkMlMjBSZWFsbVJldHJpZXZlciUyQyUyMEF1dG9Ub2tlbml6ZXIlMEElMEFyZXRyaWV2ZXIlMjAlM0QlMjBSZWFsbVJldHJpZXZlci5mcm9tX3ByZXRyYWluZWQoJTIyZ29vZ2xlJTJGcmVhbG0tb3JxYS1ucS1vcGVucWElMjIpJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIyZ29vZ2xlJTJGcmVhbG0tb3JxYS1ucS1vcGVucWElMjIpJTBBbW9kZWwlMjAlM0QlMjBSZWFsbUZvck9wZW5RQS5mcm9tX3ByZXRyYWluZWQoJTIyZ29vZ2xlJTJGcmVhbG0tb3JxYS1ucS1vcGVucWElMjIlMkMlMjByZXRyaWV2ZXIlM0RyZXRyaWV2ZXIpJTBBJTBBcXVlc3Rpb24lMjAlM0QlMjAlMjJXaG8lMjBpcyUyMHRoZSUyMHBpb25lZXIlMjBpbiUyMG1vZGVybiUyMGNvbXB1dGVyJTIwc2NpZW5jZSUzRiUyMiUwQXF1ZXN0aW9uX2lkcyUyMCUzRCUyMHRva2VuaXplciglNUJxdWVzdGlvbiU1RCUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpJTBBYW5zd2VyX2lkcyUyMCUzRCUyMHRva2VuaXplciglMEElMjAlMjAlMjAlMjAlNUIlMjJhbGFuJTIwbWF0aGlzb24lMjB0dXJpbmclMjIlNUQlMkMlMEElMjAlMjAlMjAlMjBhZGRfc3BlY2lhbF90b2tlbnMlM0RGYWxzZSUyQyUwQSUyMCUyMCUyMCUyMHJldHVybl90b2tlbl90eXBlX2lkcyUzREZhbHNlJTJDJTBBJTIwJTIwJTIwJTIwcmV0dXJuX2F0dGVudGlvbl9tYXNrJTNERmFsc2UlMkMlMEEpLmlucHV0X2lkcyUwQSUwQXJlYWRlcl9vdXRwdXQlMkMlMjBwcmVkaWN0ZWRfYW5zd2VyX2lkcyUyMCUzRCUyMG1vZGVsKCoqcXVlc3Rpb25faWRzJTJDJTIwYW5zd2VyX2lkcyUzRGFuc3dlcl9pZHMlMkMlMjByZXR1cm5fZGljdCUzREZhbHNlKSUwQXByZWRpY3RlZF9hbnN3ZXIlMjAlM0QlMjB0b2tlbml6ZXIuZGVjb2RlKHByZWRpY3RlZF9hbnN3ZXJfaWRzKSUwQWxvc3MlMjAlM0QlMjByZWFkZXJfb3V0cHV0Lmxvc3M=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> RealmForOpenQA, RealmRetriever, AutoTokenizer

<span class="hljs-meta">&gt;&gt;&gt; </span>retriever = RealmRetriever.from_pretrained(<span class="hljs-string">&quot;google/realm-orqa-nq-openqa&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;google/realm-orqa-nq-openqa&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = RealmForOpenQA.from_pretrained(<span class="hljs-string">&quot;google/realm-orqa-nq-openqa&quot;</span>, retriever=retriever)

<span class="hljs-meta">&gt;&gt;&gt; </span>question = <span class="hljs-string">&quot;Who is the pioneer in modern computer science?&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>question_ids = tokenizer([question], return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>answer_ids = tokenizer(
<span class="hljs-meta">... </span>    [<span class="hljs-string">&quot;alan mathison turing&quot;</span>],
<span class="hljs-meta">... </span>    add_special_tokens=<span class="hljs-literal">False</span>,
<span class="hljs-meta">... </span>    return_token_type_ids=<span class="hljs-literal">False</span>,
<span class="hljs-meta">... </span>    return_attention_mask=<span class="hljs-literal">False</span>,
<span class="hljs-meta">... </span>).input_ids

<span class="hljs-meta">&gt;&gt;&gt; </span>reader_output, predicted_answer_ids = model(**question_ids, answer_ids=answer_ids, return_dict=<span class="hljs-literal">False</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_answer = tokenizer.decode(predicted_answer_ids)
<span class="hljs-meta">&gt;&gt;&gt; </span>loss = reader_output.loss`}}),{c(){m=n("p"),k=i("Example:"),u=d(),v(f.$$.fragment)},l(s){m=r(s,"P",{});var h=a(m);k=l(h,"Example:"),h.forEach(t),u=c(s),y(f.$$.fragment,s)},m(s,h){_(s,m,h),e(m,k),_(s,u,h),w(f,s,h),b=!0},p:rt,i(s){b||(T(f.$$.fragment,s),b=!0)},o(s){R(f.$$.fragment,s),b=!1},d(s){s&&t(m),s&&t(u),M(f,s)}}}function Pm($){let m,k,u,f,b,s,h,x,Ea,$r,oe,ye,ln,st,za,dn,xa,Er,we,ja,it,Ja,Aa,zr,go,qa,xr,_o,cn,Ua,jr,D,Ia,lt,Za,Fa,dt,Wa,Ca,Jr,ne,Te,mn,ct,La,pn,Sa,Ar,J,mt,Na,hn,Pa,Va,A,fn,bo,Ba,Ga,un,ko,Xa,Oa,gn,vo,Qa,Da,_n,yo,Ha,Ya,bn,wo,Ka,es,kn,To,ts,os,pt,ns,ht,rs,as,ss,re,is,Ro,ls,ds,Mo,cs,ms,ps,Re,qr,ae,Me,vn,ft,hs,yn,fs,Ur,E,ut,us,wn,gs,_s,$e,$o,bs,ks,Eo,vs,ys,ws,gt,Ts,zo,Rs,Ms,$s,H,_t,Es,Tn,zs,xs,bt,xo,js,Rn,Js,As,jo,qs,Mn,Us,Is,Ee,kt,Zs,vt,Fs,$n,Ws,Cs,Ls,F,yt,Ss,En,Ns,Ps,ze,Vs,se,Bs,zn,Gs,Xs,xn,Os,Qs,Ds,Jo,wt,Hs,U,Tt,Ys,Rt,Ks,jn,ei,ti,oi,ie,Jn,ni,ri,Mt,ai,An,si,ii,li,$t,di,qn,ci,mi,pi,Et,Ao,hi,Un,fi,ui,qo,gi,In,_i,bi,xe,Ir,le,je,Zn,zt,ki,Fn,vi,Zr,q,xt,yi,jt,wi,Wn,Ti,Ri,Mi,Je,Uo,$i,Ei,Io,zi,xi,ji,Jt,Ji,Zo,Ai,qi,Ui,I,At,Ii,qt,Zi,Cn,Fi,Wi,Ci,de,Ln,Li,Si,Ut,Ni,Sn,Pi,Vi,Bi,It,Gi,Nn,Xi,Oi,Qi,Zt,Fo,Di,Pn,Hi,Yi,Wo,Ki,Vn,el,tl,Ae,Fr,ce,qe,Bn,Ft,ol,Gn,nl,Wr,V,Wt,rl,Xn,al,sl,Ue,Ct,il,On,ll,Cr,me,Ie,Qn,Lt,dl,Dn,cl,Lr,B,St,ml,Nt,pl,Pt,hl,fl,ul,W,Vt,gl,pe,_l,Co,bl,kl,Hn,vl,yl,wl,Ze,Tl,Fe,Sr,he,We,Yn,Bt,Rl,Kn,Ml,Nr,G,Gt,$l,Xt,El,Ot,zl,xl,jl,C,Qt,Jl,fe,Al,Lo,ql,Ul,er,Il,Zl,Fl,Ce,Wl,Le,Pr,ue,Se,tr,Dt,Cl,or,Ll,Vr,X,Ht,Sl,Yt,Nl,Kt,Pl,Vl,Bl,L,eo,Gl,ge,Xl,So,Ol,Ql,nr,Dl,Hl,Yl,Ne,Kl,Pe,Br,_e,Ve,rr,to,ed,ar,td,Gr,O,oo,od,no,nd,ro,rd,ad,sd,Y,ao,id,be,ld,No,dd,cd,sr,md,pd,hd,Be,Xr,ke,Ge,ir,so,fd,lr,ud,Or,Z,io,gd,Xe,dr,_d,bd,lo,kd,vd,yd,Oe,co,wd,mo,Td,cr,Rd,Md,$d,S,po,Ed,ve,zd,Po,xd,jd,mr,Jd,Ad,qd,Qe,Ud,De,Qr;return s=new Q({}),st=new Q({}),ct=new Q({}),mt=new z({props:{name:"class transformers.RealmConfig",anchor:"transformers.RealmConfig",parameters:[{name:"vocab_size",val:" = 30522"},{name:"hidden_size",val:" = 768"},{name:"retriever_proj_size",val:" = 128"},{name:"num_hidden_layers",val:" = 12"},{name:"num_attention_heads",val:" = 12"},{name:"num_candidates",val:" = 8"},{name:"intermediate_size",val:" = 3072"},{name:"hidden_act",val:" = 'gelu_new'"},{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:"span_hidden_size",val:" = 256"},{name:"max_span_width",val:" = 10"},{name:"reader_layer_norm_eps",val:" = 0.001"},{name:"reader_beam_size",val:" = 5"},{name:"reader_seq_len",val:" = 320"},{name:"num_block_records",val:" = 13353718"},{name:"searcher_beam_size",val:" = 5000"},{name:"pad_token_id",val:" = 1"},{name:"bos_token_id",val:" = 0"},{name:"eos_token_id",val:" = 2"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.RealmConfig.vocab_size",description:`<strong>vocab_size</strong> (<code>int</code>, <em>optional</em>, defaults to 30522) &#x2014;
Vocabulary size of the REALM 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/realm#transformers.RealmEmbedder">RealmEmbedder</a>, <a href="/docs/transformers/main/en/model_doc/realm#transformers.RealmScorer">RealmScorer</a>, <a href="/docs/transformers/main/en/model_doc/realm#transformers.RealmKnowledgeAugEncoder">RealmKnowledgeAugEncoder</a>, or
<a href="/docs/transformers/main/en/model_doc/realm#transformers.RealmReader">RealmReader</a>.`,name:"vocab_size"},{anchor:"transformers.RealmConfig.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.RealmConfig.retriever_proj_size",description:`<strong>retriever_proj_size</strong> (<code>int</code>, <em>optional</em>, defaults to 128) &#x2014;
Dimension of the retriever(embedder) projection.`,name:"retriever_proj_size"},{anchor:"transformers.RealmConfig.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.RealmConfig.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.RealmConfig.num_candidates",description:`<strong>num_candidates</strong> (<code>int</code>, <em>optional</em>, defaults to 8) &#x2014;
Number of candidates inputted to the RealmScorer or RealmKnowledgeAugEncoder.`,name:"num_candidates"},{anchor:"transformers.RealmConfig.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.RealmConfig.hidden_act",description:`<strong>hidden_act</strong> (<code>str</code> or <code>function</code>, <em>optional</em>, defaults to <code>&quot;gelu_new&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.RealmConfig.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.RealmConfig.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.RealmConfig.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.RealmConfig.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/realm#transformers.RealmEmbedder">RealmEmbedder</a>, <a href="/docs/transformers/main/en/model_doc/realm#transformers.RealmScorer">RealmScorer</a>,
<a href="/docs/transformers/main/en/model_doc/realm#transformers.RealmKnowledgeAugEncoder">RealmKnowledgeAugEncoder</a>, or <a href="/docs/transformers/main/en/model_doc/realm#transformers.RealmReader">RealmReader</a>.`,name:"type_vocab_size"},{anchor:"transformers.RealmConfig.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.RealmConfig.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.RealmConfig.span_hidden_size",description:`<strong>span_hidden_size</strong> (<code>int</code>, <em>optional</em>, defaults to 256) &#x2014;
Dimension of the reader&#x2019;s spans.`,name:"span_hidden_size"},{anchor:"transformers.RealmConfig.max_span_width",description:`<strong>max_span_width</strong> (<code>int</code>, <em>optional</em>, defaults to 10) &#x2014;
Max span width of the reader.`,name:"max_span_width"},{anchor:"transformers.RealmConfig.reader_layer_norm_eps",description:`<strong>reader_layer_norm_eps</strong> (<code>float</code>, <em>optional</em>, defaults to 1e-3) &#x2014;
The epsilon used by the reader&#x2019;s layer normalization layers.`,name:"reader_layer_norm_eps"},{anchor:"transformers.RealmConfig.reader_beam_size",description:`<strong>reader_beam_size</strong> (<code>int</code>, <em>optional</em>, defaults to 5) &#x2014;
Beam size of the reader.`,name:"reader_beam_size"},{anchor:"transformers.RealmConfig.reader_seq_len",description:`<strong>reader_seq_len</strong> (<code>int</code>, <em>optional</em>, defaults to 288+32) &#x2014;
Maximum sequence length of the reader.`,name:"reader_seq_len"},{anchor:"transformers.RealmConfig.num_block_records",description:`<strong>num_block_records</strong> (<code>int</code>, <em>optional</em>, defaults to 13353718) &#x2014;
Number of block records.`,name:"num_block_records"},{anchor:"transformers.RealmConfig.searcher_beam_size",description:`<strong>searcher_beam_size</strong> (<code>int</code>, <em>optional</em>, defaults to 5000) &#x2014;
Beam size of the searcher. Note that when eval mode is enabled, <em>searcher_beam_size</em> will be the same as
<em>reader_beam_size</em>.`,name:"searcher_beam_size"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/realm/configuration_realm.py#L44"}}),Re=new nt({props:{anchor:"transformers.RealmConfig.example",$$slots:{default:[jm]},$$scope:{ctx:$}}}),ft=new Q({}),ut=new z({props:{name:"class transformers.RealmTokenizer",anchor:"transformers.RealmTokenizer",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:"tokenize_chinese_chars",val:" = True"},{name:"strip_accents",val:" = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.RealmTokenizer.vocab_file",description:`<strong>vocab_file</strong> (<code>str</code>) &#x2014;
File containing the vocabulary.`,name:"vocab_file"},{anchor:"transformers.RealmTokenizer.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.RealmTokenizer.do_basic_tokenize",description:`<strong>do_basic_tokenize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to do basic tokenization before WordPiece.`,name:"do_basic_tokenize"},{anchor:"transformers.RealmTokenizer.never_split",description:`<strong>never_split</strong> (<code>Iterable</code>, <em>optional</em>) &#x2014;
Collection of tokens which will never be split during tokenization. Only has an effect when
<code>do_basic_tokenize=True</code>`,name:"never_split"},{anchor:"transformers.RealmTokenizer.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.RealmTokenizer.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.RealmTokenizer.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.RealmTokenizer.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.RealmTokenizer.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.RealmTokenizer.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.</p>
<p>This should likely be deactivated for Japanese (see this
<a href="https://github.com/huggingface/transformers/issues/328" rel="nofollow">issue</a>).`,name:"tokenize_chinese_chars"},{anchor:"transformers.RealmTokenizer.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 BERT).`,name:"strip_accents"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/realm/tokenization_realm.py#L95"}}),_t=new z({props:{name:"build_inputs_with_special_tokens",anchor:"transformers.RealmTokenizer.build_inputs_with_special_tokens",parameters:[{name:"token_ids_0",val:": typing.List[int]"},{name:"token_ids_1",val:": typing.Optional[typing.List[int]] = None"}],parametersDescription:[{anchor:"transformers.RealmTokenizer.build_inputs_with_special_tokens.token_ids_0",description:`<strong>token_ids_0</strong> (<code>List[int]</code>) &#x2014;
List of IDs to which the special tokens will be added.`,name:"token_ids_0"},{anchor:"transformers.RealmTokenizer.build_inputs_with_special_tokens.token_ids_1",description:`<strong>token_ids_1</strong> (<code>List[int]</code>, <em>optional</em>) &#x2014;
Optional second list of IDs for sequence pairs.`,name:"token_ids_1"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/realm/tokenization_realm.py#L301",returnDescription:`
<p>List of <a href="../glossary#input-ids">input IDs</a> with the appropriate special tokens.</p>
`,returnType:`
<p><code>List[int]</code></p>
`}}),kt=new z({props:{name:"get_special_tokens_mask",anchor:"transformers.RealmTokenizer.get_special_tokens_mask",parameters:[{name:"token_ids_0",val:": typing.List[int]"},{name:"token_ids_1",val:": typing.Optional[typing.List[int]] = None"},{name:"already_has_special_tokens",val:": bool = False"}],parametersDescription:[{anchor:"transformers.RealmTokenizer.get_special_tokens_mask.token_ids_0",description:`<strong>token_ids_0</strong> (<code>List[int]</code>) &#x2014;
List of IDs.`,name:"token_ids_0"},{anchor:"transformers.RealmTokenizer.get_special_tokens_mask.token_ids_1",description:`<strong>token_ids_1</strong> (<code>List[int]</code>, <em>optional</em>) &#x2014;
Optional second list of IDs for sequence pairs.`,name:"token_ids_1"},{anchor:"transformers.RealmTokenizer.get_special_tokens_mask.already_has_special_tokens",description:`<strong>already_has_special_tokens</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not the token list is already formatted with special tokens for the model.`,name:"already_has_special_tokens"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/realm/tokenization_realm.py#L326",returnDescription:`
<p>A list of integers in the range [0, 1]: 1 for a special token, 0 for a sequence token.</p>
`,returnType:`
<p><code>List[int]</code></p>
`}}),yt=new z({props:{name:"create_token_type_ids_from_sequences",anchor:"transformers.RealmTokenizer.create_token_type_ids_from_sequences",parameters:[{name:"token_ids_0",val:": typing.List[int]"},{name:"token_ids_1",val:": typing.Optional[typing.List[int]] = None"}],parametersDescription:[{anchor:"transformers.RealmTokenizer.create_token_type_ids_from_sequences.token_ids_0",description:`<strong>token_ids_0</strong> (<code>List[int]</code>) &#x2014;
List of IDs.`,name:"token_ids_0"},{anchor:"transformers.RealmTokenizer.create_token_type_ids_from_sequences.token_ids_1",description:`<strong>token_ids_1</strong> (<code>List[int]</code>, <em>optional</em>) &#x2014;
Optional second list of IDs for sequence pairs.`,name:"token_ids_1"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/realm/tokenization_realm.py#L354",returnDescription:`
<p>List of <a href="../glossary#token-type-ids">token type IDs</a> according to the given sequence(s).</p>
`,returnType:`
<p><code>List[int]</code></p>
`}}),ze=new nt({props:{anchor:"transformers.RealmTokenizer.create_token_type_ids_from_sequences.example",$$slots:{default:[Jm]},$$scope:{ctx:$}}}),wt=new z({props:{name:"save_vocabulary",anchor:"transformers.RealmTokenizer.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/realm/tokenization_realm.py#L383"}}),Tt=new z({props:{name:"batch_encode_candidates",anchor:"transformers.RealmTokenizer.batch_encode_candidates",parameters:[{name:"text",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.RealmTokenizer.batch_encode_candidates.text",description:`<strong>text</strong> (<code>List[List[str]]</code>) &#x2014;
The batch of sequences to be encoded. Each sequence must be in this format: (batch_size,
num_candidates, text).`,name:"text"},{anchor:"transformers.RealmTokenizer.batch_encode_candidates.text_pair",description:`<strong>text_pair</strong> (<code>List[List[str]]</code>, <em>optional</em>) &#x2014;
The batch of sequences to be encoded. Each sequence must be in this format: (batch_size,
num_candidates, text).
**kwargs &#x2014;
Keyword arguments of the <strong>call</strong> method.`,name:"text_pair"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/realm/tokenization_realm.py#L228",returnDescription:`
<p>Encoded text or text pair.</p>
`,returnType:`
<p><a
  href="/docs/transformers/main/en/main_classes/tokenizer#transformers.BatchEncoding"
>BatchEncoding</a></p>
`}}),xe=new nt({props:{anchor:"transformers.RealmTokenizer.batch_encode_candidates.example",$$slots:{default:[Am]},$$scope:{ctx:$}}}),zt=new Q({}),xt=new z({props:{name:"class transformers.RealmTokenizerFast",anchor:"transformers.RealmTokenizerFast",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:"tokenize_chinese_chars",val:" = True"},{name:"strip_accents",val:" = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.RealmTokenizerFast.vocab_file",description:`<strong>vocab_file</strong> (<code>str</code>) &#x2014;
File containing the vocabulary.`,name:"vocab_file"},{anchor:"transformers.RealmTokenizerFast.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.RealmTokenizerFast.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.RealmTokenizerFast.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.RealmTokenizerFast.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.RealmTokenizerFast.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.RealmTokenizerFast.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.RealmTokenizerFast.clean_text",description:`<strong>clean_text</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to clean the text before tokenization by removing any control characters and replacing all
whitespaces by the classic one.`,name:"clean_text"},{anchor:"transformers.RealmTokenizerFast.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.RealmTokenizerFast.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 BERT).`,name:"strip_accents"},{anchor:"transformers.RealmTokenizerFast.wordpieces_prefix",description:`<strong>wordpieces_prefix</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;##&quot;</code>) &#x2014;
The prefix for subwords.`,name:"wordpieces_prefix"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/realm/tokenization_realm_fast.py#L102"}}),At=new z({props:{name:"batch_encode_candidates",anchor:"transformers.RealmTokenizerFast.batch_encode_candidates",parameters:[{name:"text",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.RealmTokenizerFast.batch_encode_candidates.text",description:`<strong>text</strong> (<code>List[List[str]]</code>) &#x2014;
The batch of sequences to be encoded. Each sequence must be in this format: (batch_size,
num_candidates, text).`,name:"text"},{anchor:"transformers.RealmTokenizerFast.batch_encode_candidates.text_pair",description:`<strong>text_pair</strong> (<code>List[List[str]]</code>, <em>optional</em>) &#x2014;
The batch of sequences to be encoded. Each sequence must be in this format: (batch_size,
num_candidates, text).
**kwargs &#x2014;
Keyword arguments of the <strong>call</strong> method.`,name:"text_pair"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/realm/tokenization_realm_fast.py#L193",returnDescription:`
<p>Encoded text or text pair.</p>
`,returnType:`
<p><a
  href="/docs/transformers/main/en/main_classes/tokenizer#transformers.BatchEncoding"
>BatchEncoding</a></p>
`}}),Ae=new nt({props:{anchor:"transformers.RealmTokenizerFast.batch_encode_candidates.example",$$slots:{default:[qm]},$$scope:{ctx:$}}}),Ft=new Q({}),Wt=new z({props:{name:"class transformers.RealmRetriever",anchor:"transformers.RealmRetriever",parameters:[{name:"block_records",val:""},{name:"tokenizer",val:""}],parametersDescription:[{anchor:"transformers.RealmRetriever.block_records",description:`<strong>block_records</strong> (<code>np.ndarray</code>) &#x2014;
A numpy array which cantains evidence texts.`,name:"block_records"},{anchor:"transformers.RealmRetriever.tokenizer",description:`<strong>tokenizer</strong> (<a href="/docs/transformers/main/en/model_doc/realm#transformers.RealmTokenizer">RealmTokenizer</a>) &#x2014;
The tokenizer to encode retrieved texts.`,name:"tokenizer"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/realm/retrieval_realm.py#L72"}}),Ct=new z({props:{name:"block_has_answer",anchor:"transformers.RealmRetriever.block_has_answer",parameters:[{name:"concat_inputs",val:""},{name:"answer_ids",val:""}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/realm/retrieval_realm.py#L129"}}),Lt=new Q({}),St=new z({props:{name:"class transformers.RealmEmbedder",anchor:"transformers.RealmEmbedder",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.RealmEmbedder.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/realm#transformers.RealmConfig">RealmConfig</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/realm/modeling_realm.py#L1151"}}),Vt=new z({props:{name:"forward",anchor:"transformers.RealmEmbedder.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = 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.RealmEmbedder.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.RealmEmbedder.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.RealmEmbedder.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.RealmEmbedder.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.RealmEmbedder.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.RealmEmbedder.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.RealmEmbedder.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.RealmEmbedder.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.RealmEmbedder.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/realm/modeling_realm.py#L1167",returnDescription:`
<p>A <code>transformers.models.realm.modeling_realm.RealmEmbedderOutput</code> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/main/en/model_doc/realm#transformers.RealmConfig"
>RealmConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>projected_score</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, config.retriever_proj_size)</code>) \u2014 Projected score.</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings + one for the output of each layer) of
shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
</ul>
`,returnType:`
<p><code>transformers.models.realm.modeling_realm.RealmEmbedderOutput</code> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Ze=new Mr({props:{$$slots:{default:[Um]},$$scope:{ctx:$}}}),Fe=new nt({props:{anchor:"transformers.RealmEmbedder.forward.example",$$slots:{default:[Im]},$$scope:{ctx:$}}}),Bt=new Q({}),Gt=new z({props:{name:"class transformers.RealmScorer",anchor:"transformers.RealmScorer",parameters:[{name:"config",val:""},{name:"query_embedder",val:" = None"}],parametersDescription:[{anchor:"transformers.RealmScorer.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/realm#transformers.RealmConfig">RealmConfig</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"},{anchor:"transformers.RealmScorer.query_embedder",description:`<strong>query_embedder</strong> (<a href="/docs/transformers/main/en/model_doc/realm#transformers.RealmEmbedder">RealmEmbedder</a>) &#x2014;
Embedder for input sequences. If not specified, it will use the same embedder as candidate sequences.`,name:"query_embedder"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/realm/modeling_realm.py#L1233"}}),Qt=new z({props:{name:"forward",anchor:"transformers.RealmScorer.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = 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:"candidate_input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"candidate_attention_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"candidate_token_type_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"candidate_inputs_embeds",val:": typing.Optional[torch.FloatTensor] = 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.RealmScorer.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.RealmScorer.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.RealmScorer.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.RealmScorer.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.RealmScorer.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.RealmScorer.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.RealmScorer.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.RealmScorer.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.RealmScorer.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.RealmScorer.forward.candidate_input_ids",description:`<strong>candidate_input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, num_candidates, sequence_length)</code>) &#x2014;
Indices of candidate 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:"candidate_input_ids"},{anchor:"transformers.RealmScorer.forward.candidate_attention_mask",description:`<strong>candidate_attention_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_candidates, 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:"candidate_attention_mask"},{anchor:"transformers.RealmScorer.forward.candidate_token_type_ids",description:`<strong>candidate_token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, num_candidates, 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:"candidate_token_type_ids"},{anchor:"transformers.RealmScorer.forward.candidate_inputs_embeds",description:`<strong>candidate_inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size * num_candidates, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>candidate_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>candidate_input_ids</em> indices
into associated vectors than the model&#x2019;s internal embedding lookup matrix.`,name:"candidate_inputs_embeds"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/realm/modeling_realm.py#L1249",returnDescription:`
<p>A <code>transformers.models.realm.modeling_realm.RealmScorerOutput</code> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/main/en/model_doc/realm#transformers.RealmConfig"
>RealmConfig</a>) and inputs.</p>
<ul>
<li><strong>relevance_score</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, config.num_candidates)</code>) \u2014 The relevance score of document candidates (before softmax).</li>
<li><strong>query_score</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, config.retriever_proj_size)</code>) \u2014 Query score derived from the query embedder.</li>
<li><strong>candidate_score</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, config.num_candidates, config.retriever_proj_size)</code>) \u2014 Candidate score derived from the embedder.</li>
</ul>
`,returnType:`
<p><code>transformers.models.realm.modeling_realm.RealmScorerOutput</code> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Ce=new Mr({props:{$$slots:{default:[Zm]},$$scope:{ctx:$}}}),Le=new nt({props:{anchor:"transformers.RealmScorer.forward.example",$$slots:{default:[Fm]},$$scope:{ctx:$}}}),Dt=new Q({}),Ht=new z({props:{name:"class transformers.RealmKnowledgeAugEncoder",anchor:"transformers.RealmKnowledgeAugEncoder",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.RealmKnowledgeAugEncoder.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/realm#transformers.RealmConfig">RealmConfig</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/realm/modeling_realm.py#L1381"}}),eo=new z({props:{name:"forward",anchor:"transformers.RealmKnowledgeAugEncoder.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = 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:"relevance_score",val:": typing.Optional[torch.FloatTensor] = None"},{name:"labels",val:": typing.Optional[torch.LongTensor] = None"},{name:"mlm_mask",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.RealmKnowledgeAugEncoder.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, num_candidates, 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.RealmKnowledgeAugEncoder.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_candidates, 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.RealmKnowledgeAugEncoder.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, num_candidates, 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.RealmKnowledgeAugEncoder.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, num_candidates, 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.RealmKnowledgeAugEncoder.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.RealmKnowledgeAugEncoder.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_candidates, 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.RealmKnowledgeAugEncoder.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.RealmKnowledgeAugEncoder.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.RealmKnowledgeAugEncoder.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.RealmKnowledgeAugEncoder.forward.relevance_score",description:`<strong>relevance_score</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_candidates)</code>, <em>optional</em>) &#x2014;
Relevance score derived from RealmScorer, must be specified if you want to compute the masked language
modeling loss.`,name:"relevance_score"},{anchor:"transformers.RealmKnowledgeAugEncoder.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 masked language modeling loss. Indices should be in <code>[-100, 0, ..., config.vocab_size]</code> (see <code>input_ids</code> docstring) Tokens with indices set to <code>-100</code> are ignored (masked), the
loss is only computed for the tokens with labels in <code>[0, ..., config.vocab_size]</code>`,name:"labels"},{anchor:"transformers.RealmKnowledgeAugEncoder.forward.mlm_mask",description:`<strong>mlm_mask</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid calculating joint loss on certain positions. If not specified, the loss will not be masked.
Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>`,name:"mlm_mask"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/realm/modeling_realm.py#L1402",returnDescription:`
<p>A <a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_outputs.MaskedLMOutput"
>transformers.modeling_outputs.MaskedLMOutput</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/realm#transformers.RealmConfig"
>RealmConfig</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 Masked language modeling (MLM) loss.</p>
</li>
<li>
<p><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, config.vocab_size)</code>) \u2014 Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, 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.MaskedLMOutput"
>transformers.modeling_outputs.MaskedLMOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Ne=new Mr({props:{$$slots:{default:[Wm]},$$scope:{ctx:$}}}),Pe=new nt({props:{anchor:"transformers.RealmKnowledgeAugEncoder.forward.example",$$slots:{default:[Cm]},$$scope:{ctx:$}}}),to=new Q({}),oo=new z({props:{name:"class transformers.RealmReader",anchor:"transformers.RealmReader",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.RealmReader.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/realm#transformers.RealmConfig">RealmConfig</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/realm/modeling_realm.py#L1531"}}),ao=new z({props:{name:"forward",anchor:"transformers.RealmReader.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = 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:"relevance_score",val:": typing.Optional[torch.FloatTensor] = None"},{name:"block_mask",val:": typing.Optional[torch.BoolTensor] = None"},{name:"start_positions",val:": typing.Optional[torch.LongTensor] = None"},{name:"end_positions",val:": typing.Optional[torch.LongTensor] = None"},{name:"has_answers",val:": typing.Optional[torch.BoolTensor] = 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.RealmReader.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(reader_beam_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.RealmReader.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(reader_beam_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.RealmReader.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(reader_beam_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.RealmReader.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(reader_beam_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.RealmReader.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.RealmReader.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(reader_beam_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.RealmReader.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.RealmReader.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.RealmReader.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.RealmReader.forward.relevance_score",description:`<strong>relevance_score</strong> (<code>torch.FloatTensor</code> of shape <code>(searcher_beam_size,)</code>, <em>optional</em>) &#x2014;
Relevance score, which must be specified if you want to compute the logits and marginal log loss.`,name:"relevance_score"},{anchor:"transformers.RealmReader.forward.block_mask",description:`<strong>block_mask</strong> (<code>torch.BoolTensor</code> of shape <code>(searcher_beam_size, sequence_length)</code>, <em>optional</em>) &#x2014;
The mask of the evidence block, which must be specified if you want to compute the logits and marginal log
loss.`,name:"block_mask"},{anchor:"transformers.RealmReader.forward.start_positions",description:`<strong>start_positions</strong> (<code>torch.LongTensor</code> of shape <code>(searcher_beam_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.RealmReader.forward.end_positions",description:`<strong>end_positions</strong> (<code>torch.LongTensor</code> of shape <code>(searcher_beam_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"},{anchor:"transformers.RealmReader.forward.has_answers",description:`<strong>has_answers</strong> (<code>torch.BoolTensor</code> of shape <code>(searcher_beam_size,)</code>, <em>optional</em>) &#x2014;
Whether or not the evidence block has answer(s).`,name:"has_answers"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/realm/modeling_realm.py#L1542",returnDescription:`
<p>A <code>transformers.models.realm.modeling_realm.RealmReaderOutput</code> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/main/en/model_doc/realm#transformers.RealmConfig"
>RealmConfig</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>start_positions</code>, <code>end_positions</code>, <code>has_answers</code> are provided) \u2014 Total loss.</p>
</li>
<li>
<p><strong>retriever_loss</strong> (<code>torch.FloatTensor</code> of shape <code>(1,)</code>, <em>optional</em>, returned when <code>start_positions</code>, <code>end_positions</code>, <code>has_answers</code> are provided) \u2014 Retriever loss.</p>
</li>
<li>
<p><strong>reader_loss</strong> (<code>torch.FloatTensor</code> of shape <code>(1,)</code>, <em>optional</em>, returned when <code>start_positions</code>, <code>end_positions</code>, <code>has_answers</code> are provided) \u2014 Reader loss.</p>
</li>
<li>
<p><strong>retriever_correct</strong> (<code>torch.BoolTensor</code> of shape <code>(config.searcher_beam_size,)</code>, <em>optional</em>) \u2014 Whether or not an evidence block contains answer.</p>
</li>
<li>
<p><strong>reader_correct</strong> (<code>torch.BoolTensor</code> of shape <code>(config.reader_beam_size, num_candidates)</code>, <em>optional</em>) \u2014 Whether or not a span candidate contains answer.</p>
</li>
<li>
<p><strong>block_idx</strong> (<code>torch.LongTensor</code> of shape <code>()</code>) \u2014 The index of the retrieved evidence block in which the predicted answer is most likely.</p>
</li>
<li>
<p><strong>candidate</strong> (<code>torch.LongTensor</code> of shape <code>()</code>) \u2014 The index of the retrieved span candidates in which the predicted answer is most likely.</p>
</li>
<li>
<p><strong>start_pos</strong> (<code>torch.IntTensor</code> of shape <code>()</code>) \u2014 Predicted answer starting position in <em>RealmReader</em>\u2019s inputs.</p>
</li>
<li>
<p><strong>end_pos</strong> (<code>torch.IntTensor</code> of shape <code>()</code>) \u2014 Predicted answer ending position in <em>RealmReader</em>\u2019s inputs.</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings + one for the output of each layer) of
shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
</ul>
`,returnType:`
<p><code>transformers.models.realm.modeling_realm.RealmReaderOutput</code> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Be=new Mr({props:{$$slots:{default:[Lm]},$$scope:{ctx:$}}}),so=new Q({}),io=new z({props:{name:"class transformers.RealmForOpenQA",anchor:"transformers.RealmForOpenQA",parameters:[{name:"config",val:""},{name:"retriever",val:" = None"}],parametersDescription:[{anchor:"transformers.RealmForOpenQA.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/realm#transformers.RealmConfig">RealmConfig</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/realm/modeling_realm.py#L1735"}}),co=new z({props:{name:"block_embedding_to",anchor:"transformers.RealmForOpenQA.block_embedding_to",parameters:[{name:"device",val:""}],parametersDescription:[{anchor:"transformers.RealmForOpenQA.block_embedding_to.device",description:`<strong>device</strong> (<code>str</code> or <code>torch.device</code>) &#x2014;
The device to which <code>self.block_emb</code> will be sent.`,name:"device"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/realm/modeling_realm.py#L1758"}}),po=new z({props:{name:"forward",anchor:"transformers.RealmForOpenQA.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor]"},{name:"attention_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"token_type_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"answer_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.RealmForOpenQA.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(1, 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.RealmForOpenQA.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(1, 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.RealmForOpenQA.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(1, 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 (should not be used in this model by design).</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.RealmForOpenQA.forward.answer_ids",description:`<strong>answer_ids</strong> (<code>list</code> of shape <code>(num_answers, answer_length)</code>, <em>optional</em>) &#x2014;
Answer ids for computing the marginal log-likelihood loss. Indices should be in <code>[-1, 0, ..., config.vocab_size]</code> (see <code>input_ids</code> docstring) Tokens with indices set to <code>-1</code> are ignored (masked), the
loss is only computed for the tokens with labels in <code>[0, ..., config.vocab_size]</code>`,name:"answer_ids"},{anchor:"transformers.RealmForOpenQA.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/realm/modeling_realm.py#L1768",returnDescription:`
<p>A <code>transformers.models.realm.modeling_realm.RealmForOpenQAOutput</code> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/main/en/model_doc/realm#transformers.RealmConfig"
>RealmConfig</a>) and inputs.</p>
<ul>
<li><strong>reader_output</strong> (<code>dict</code>) \u2014 Reader output.</li>
<li><strong>predicted_answer_ids</strong> (<code>torch.LongTensor</code> of shape <code>(answer_sequence_length)</code>) \u2014 Predicted answer ids.</li>
</ul>
`,returnType:`
<p><code>transformers.models.realm.modeling_realm.RealmForOpenQAOutput</code> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Qe=new Mr({props:{$$slots:{default:[Sm]},$$scope:{ctx:$}}}),De=new nt({props:{anchor:"transformers.RealmForOpenQA.forward.example",$$slots:{default:[Nm]},$$scope:{ctx:$}}}),{c(){m=n("meta"),k=d(),u=n("h1"),f=n("a"),b=n("span"),v(s.$$.fragment),h=d(),x=n("span"),Ea=i("REALM"),$r=d(),oe=n("h2"),ye=n("a"),ln=n("span"),v(st.$$.fragment),za=d(),dn=n("span"),xa=i("Overview"),Er=d(),we=n("p"),ja=i("The REALM model was proposed in "),it=n("a"),Ja=i("REALM: Retrieval-Augmented Language Model Pre-Training"),Aa=i(` by Kelvin Guu, Kenton Lee, Zora Tung, Panupong Pasupat and Ming-Wei Chang. It\u2019s a
retrieval-augmented language model that firstly retrieves documents from a textual knowledge corpus and then
utilizes retrieved documents to process question answering tasks.`),zr=d(),go=n("p"),qa=i("The abstract from the paper is the following:"),xr=d(),_o=n("p"),cn=n("em"),Ua=i(`Language model pre-training has been shown to capture a surprising amount of world knowledge, crucial for NLP tasks
such as question answering. However, this knowledge is stored implicitly in the parameters of a neural network,
requiring ever-larger networks to cover more facts. To capture knowledge in a more modular and interpretable way, we
augment language model pre-training with a latent knowledge retriever, which allows the model to retrieve and attend
over documents from a large corpus such as Wikipedia, used during pre-training, fine-tuning and inference. For the
first time, we show how to pre-train such a knowledge retriever in an unsupervised manner, using masked language
modeling as the learning signal and backpropagating through a retrieval step that considers millions of documents. We
demonstrate the effectiveness of Retrieval-Augmented Language Model pre-training (REALM) by fine-tuning on the
challenging task of Open-domain Question Answering (Open-QA). We compare against state-of-the-art models for both
explicit and implicit knowledge storage on three popular Open-QA benchmarks, and find that we outperform all previous
methods by a significant margin (4-16% absolute accuracy), while also providing qualitative benefits such as
interpretability and modularity.`),jr=d(),D=n("p"),Ia=i("This model was contributed by "),lt=n("a"),Za=i("qqaatw"),Fa=i(`. The original code can be found
`),dt=n("a"),Wa=i("here"),Ca=i("."),Jr=d(),ne=n("h2"),Te=n("a"),mn=n("span"),v(ct.$$.fragment),La=d(),pn=n("span"),Sa=i("RealmConfig"),Ar=d(),J=n("div"),v(mt.$$.fragment),Na=d(),hn=n("p"),Pa=i("This is the configuration class to store the configuration of"),Va=d(),A=n("ol"),fn=n("li"),bo=n("a"),Ba=i("RealmEmbedder"),Ga=d(),un=n("li"),ko=n("a"),Xa=i("RealmScorer"),Oa=d(),gn=n("li"),vo=n("a"),Qa=i("RealmKnowledgeAugEncoder"),Da=d(),_n=n("li"),yo=n("a"),Ha=i("RealmRetriever"),Ya=d(),bn=n("li"),wo=n("a"),Ka=i("RealmReader"),es=d(),kn=n("li"),To=n("a"),ts=i("RealmForOpenQA"),os=d(),pt=n("p"),ns=i(`It is used to instantiate an REALM 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 REALM
`),ht=n("a"),rs=i("google/realm-cc-news-pretrained-embedder"),as=i(`
architecture.`),ss=d(),re=n("p"),is=i("Configuration objects inherit from "),Ro=n("a"),ls=i("PretrainedConfig"),ds=i(` and can be used to control the model outputs. Read the
documentation from `),Mo=n("a"),cs=i("PretrainedConfig"),ms=i(" for more information."),ps=d(),v(Re.$$.fragment),qr=d(),ae=n("h2"),Me=n("a"),vn=n("span"),v(ft.$$.fragment),hs=d(),yn=n("span"),fs=i("RealmTokenizer"),Ur=d(),E=n("div"),v(ut.$$.fragment),us=d(),wn=n("p"),gs=i("Construct a REALM tokenizer."),_s=d(),$e=n("p"),$o=n("a"),bs=i("RealmTokenizer"),ks=i(" is identical to "),Eo=n("a"),vs=i("BertTokenizer"),ys=i(` and runs end-to-end tokenization: punctuation splitting and
wordpiece.`),ws=d(),gt=n("p"),Ts=i("This tokenizer inherits from "),zo=n("a"),Rs=i("PreTrainedTokenizer"),Ms=i(` which contains most of the main methods. Users should refer to
this superclass for more information regarding those methods.`),$s=d(),H=n("div"),v(_t.$$.fragment),Es=d(),Tn=n("p"),zs=i(`Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and
adding special tokens. A REALM sequence has the following format:`),xs=d(),bt=n("ul"),xo=n("li"),js=i("single sequence: "),Rn=n("code"),Js=i("[CLS] X [SEP]"),As=d(),jo=n("li"),qs=i("pair of sequences: "),Mn=n("code"),Us=i("[CLS] A [SEP] B [SEP]"),Is=d(),Ee=n("div"),v(kt.$$.fragment),Zs=d(),vt=n("p"),Fs=i(`Retrieve sequence ids from a token list that has no special tokens added. This method is called when adding
special tokens using the tokenizer `),$n=n("code"),Ws=i("prepare_for_model"),Cs=i(" method."),Ls=d(),F=n("div"),v(yt.$$.fragment),Ss=d(),En=n("p"),Ns=i("Create a mask from the two sequences passed to be used in a sequence-pair classification task. A REALM sequence"),Ps=d(),v(ze.$$.fragment),Vs=d(),se=n("p"),Bs=i("If "),zn=n("code"),Gs=i("token_ids_1"),Xs=i(" is "),xn=n("code"),Os=i("None"),Qs=i(", this method only returns the first portion of the mask (0s)."),Ds=d(),Jo=n("div"),v(wt.$$.fragment),Hs=d(),U=n("div"),v(Tt.$$.fragment),Ys=d(),Rt=n("p"),Ks=i("Encode a batch of text or text pair. This method is similar to regular "),jn=n("strong"),ei=i("call"),ti=i(` method but has the following
differences:`),oi=d(),ie=n("ol"),Jn=n("li"),ni=i("Handle additional num_candidate axis. (batch_size, num_candidates, text)"),ri=d(),Mt=n("li"),ai=i("Always pad the sequences to "),An=n("em"),si=i("max_length"),ii=i("."),li=d(),$t=n("li"),di=i("Must specify "),qn=n("em"),ci=i("max_length"),mi=i(" in order to stack packs of candidates into a batch."),pi=d(),Et=n("ul"),Ao=n("li"),hi=i("single sequence: "),Un=n("code"),fi=i("[CLS] X [SEP]"),ui=d(),qo=n("li"),gi=i("pair of sequences: "),In=n("code"),_i=i("[CLS] A [SEP] B [SEP]"),bi=d(),v(xe.$$.fragment),Ir=d(),le=n("h2"),je=n("a"),Zn=n("span"),v(zt.$$.fragment),ki=d(),Fn=n("span"),vi=i("RealmTokenizerFast"),Zr=d(),q=n("div"),v(xt.$$.fragment),yi=d(),jt=n("p"),wi=i("Construct a \u201Cfast\u201D REALM tokenizer (backed by HuggingFace\u2019s "),Wn=n("em"),Ti=i("tokenizers"),Ri=i(" library). Based on WordPiece."),Mi=d(),Je=n("p"),Uo=n("a"),$i=i("RealmTokenizerFast"),Ei=i(" is identical to "),Io=n("a"),zi=i("BertTokenizerFast"),xi=i(` and runs end-to-end tokenization: punctuation
splitting and wordpiece.`),ji=d(),Jt=n("p"),Ji=i("This tokenizer inherits from "),Zo=n("a"),Ai=i("PreTrainedTokenizerFast"),qi=i(` which contains most of the main methods. Users should
refer to this superclass for more information regarding those methods.`),Ui=d(),I=n("div"),v(At.$$.fragment),Ii=d(),qt=n("p"),Zi=i("Encode a batch of text or text pair. This method is similar to regular "),Cn=n("strong"),Fi=i("call"),Wi=i(` method but has the following
differences:`),Ci=d(),de=n("ol"),Ln=n("li"),Li=i("Handle additional num_candidate axis. (batch_size, num_candidates, text)"),Si=d(),Ut=n("li"),Ni=i("Always pad the sequences to "),Sn=n("em"),Pi=i("max_length"),Vi=i("."),Bi=d(),It=n("li"),Gi=i("Must specify "),Nn=n("em"),Xi=i("max_length"),Oi=i(" in order to stack packs of candidates into a batch."),Qi=d(),Zt=n("ul"),Fo=n("li"),Di=i("single sequence: "),Pn=n("code"),Hi=i("[CLS] X [SEP]"),Yi=d(),Wo=n("li"),Ki=i("pair of sequences: "),Vn=n("code"),el=i("[CLS] A [SEP] B [SEP]"),tl=d(),v(Ae.$$.fragment),Fr=d(),ce=n("h2"),qe=n("a"),Bn=n("span"),v(Ft.$$.fragment),ol=d(),Gn=n("span"),nl=i("RealmRetriever"),Wr=d(),V=n("div"),v(Wt.$$.fragment),rl=d(),Xn=n("p"),al=i(`The retriever of REALM outputting the retrieved evidence block and whether the block has answers as well as answer
positions.\u201D`),sl=d(),Ue=n("div"),v(Ct.$$.fragment),il=d(),On=n("p"),ll=i("check if retrieved_blocks has answers."),Cr=d(),me=n("h2"),Ie=n("a"),Qn=n("span"),v(Lt.$$.fragment),dl=d(),Dn=n("span"),cl=i("RealmEmbedder"),Lr=d(),B=n("div"),v(St.$$.fragment),ml=d(),Nt=n("p"),pl=i(`The embedder of REALM outputting projected score that will be used to calculate relevance score.
This model is a PyTorch `),Pt=n("a"),hl=i("torch.nn.Module"),fl=i(` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),ul=d(),W=n("div"),v(Vt.$$.fragment),gl=d(),pe=n("p"),_l=i("The "),Co=n("a"),bl=i("RealmEmbedder"),kl=i(" forward method, overrides the "),Hn=n("code"),vl=i("__call__"),yl=i(" special method."),wl=d(),v(Ze.$$.fragment),Tl=d(),v(Fe.$$.fragment),Sr=d(),he=n("h2"),We=n("a"),Yn=n("span"),v(Bt.$$.fragment),Rl=d(),Kn=n("span"),Ml=i("RealmScorer"),Nr=d(),G=n("div"),v(Gt.$$.fragment),$l=d(),Xt=n("p"),El=i(`The scorer of REALM outputting relevance scores representing the score of document candidates (before softmax).
This model is a PyTorch `),Ot=n("a"),zl=i("torch.nn.Module"),xl=i(` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),jl=d(),C=n("div"),v(Qt.$$.fragment),Jl=d(),fe=n("p"),Al=i("The "),Lo=n("a"),ql=i("RealmScorer"),Ul=i(" forward method, overrides the "),er=n("code"),Il=i("__call__"),Zl=i(" special method."),Fl=d(),v(Ce.$$.fragment),Wl=d(),v(Le.$$.fragment),Pr=d(),ue=n("h2"),Se=n("a"),tr=n("span"),v(Dt.$$.fragment),Cl=d(),or=n("span"),Ll=i("RealmKnowledgeAugEncoder"),Vr=d(),X=n("div"),v(Ht.$$.fragment),Sl=d(),Yt=n("p"),Nl=i(`The knowledge-augmented encoder of REALM outputting masked language model logits and marginal log-likelihood loss.
This model is a PyTorch `),Kt=n("a"),Pl=i("torch.nn.Module"),Vl=i(` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Bl=d(),L=n("div"),v(eo.$$.fragment),Gl=d(),ge=n("p"),Xl=i("The "),So=n("a"),Ol=i("RealmKnowledgeAugEncoder"),Ql=i(" forward method, overrides the "),nr=n("code"),Dl=i("__call__"),Hl=i(" special method."),Yl=d(),v(Ne.$$.fragment),Kl=d(),v(Pe.$$.fragment),Br=d(),_e=n("h2"),Ve=n("a"),rr=n("span"),v(to.$$.fragment),ed=d(),ar=n("span"),td=i("RealmReader"),Gr=d(),O=n("div"),v(oo.$$.fragment),od=d(),no=n("p"),nd=i(`The reader of REALM.
This model is a PyTorch `),ro=n("a"),rd=i("torch.nn.Module"),ad=i(` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),sd=d(),Y=n("div"),v(ao.$$.fragment),id=d(),be=n("p"),ld=i("The "),No=n("a"),dd=i("RealmReader"),cd=i(" forward method, overrides the "),sr=n("code"),md=i("__call__"),pd=i(" special method."),hd=d(),v(Be.$$.fragment),Xr=d(),ke=n("h2"),Ge=n("a"),ir=n("span"),v(so.$$.fragment),fd=d(),lr=n("span"),ud=i("RealmForOpenQA"),Or=d(),Z=n("div"),v(io.$$.fragment),gd=d(),Xe=n("p"),dr=n("code"),_d=i("RealmForOpenQA"),bd=i(` for end-to-end open domain question answering.
This model is a PyTorch `),lo=n("a"),kd=i("torch.nn.Module"),vd=i(` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),yd=d(),Oe=n("div"),v(co.$$.fragment),wd=d(),mo=n("p"),Td=i("Send "),cr=n("code"),Rd=i("self.block_emb"),Md=i(" to a specific device."),$d=d(),S=n("div"),v(po.$$.fragment),Ed=d(),ve=n("p"),zd=i("The "),Po=n("a"),xd=i("RealmForOpenQA"),jd=i(" forward method, overrides the "),mr=n("code"),Jd=i("__call__"),Ad=i(" special method."),qd=d(),v(Qe.$$.fragment),Ud=d(),v(De.$$.fragment),this.h()},l(o){const g=zm('[data-svelte="svelte-1phssyn"]',document.head);m=r(g,"META",{name:!0,content:!0}),g.forEach(t),k=c(o),u=r(o,"H1",{class:!0});var ho=a(u);f=r(ho,"A",{id:!0,class:!0,href:!0});var pr=a(f);b=r(pr,"SPAN",{});var hr=a(b);y(s.$$.fragment,hr),hr.forEach(t),pr.forEach(t),h=c(ho),x=r(ho,"SPAN",{});var fr=a(x);Ea=l(fr,"REALM"),fr.forEach(t),ho.forEach(t),$r=c(o),oe=r(o,"H2",{class:!0});var fo=a(oe);ye=r(fo,"A",{id:!0,class:!0,href:!0});var ur=a(ye);ln=r(ur,"SPAN",{});var gr=a(ln);y(st.$$.fragment,gr),gr.forEach(t),ur.forEach(t),za=c(fo),dn=r(fo,"SPAN",{});var _r=a(dn);xa=l(_r,"Overview"),_r.forEach(t),fo.forEach(t),Er=c(o),we=r(o,"P",{});var uo=a(we);ja=l(uo,"The REALM model was proposed in "),it=r(uo,"A",{href:!0,rel:!0});var br=a(it);Ja=l(br,"REALM: Retrieval-Augmented Language Model Pre-Training"),br.forEach(t),Aa=l(uo,` by Kelvin Guu, Kenton Lee, Zora Tung, Panupong Pasupat and Ming-Wei Chang. It\u2019s a
retrieval-augmented language model that firstly retrieves documents from a textual knowledge corpus and then
utilizes retrieved documents to process question answering tasks.`),uo.forEach(t),zr=c(o),go=r(o,"P",{});var kr=a(go);qa=l(kr,"The abstract from the paper is the following:"),kr.forEach(t),xr=c(o),_o=r(o,"P",{});var vr=a(_o);cn=r(vr,"EM",{});var yr=a(cn);Ua=l(yr,`Language model pre-training has been shown to capture a surprising amount of world knowledge, crucial for NLP tasks
such as question answering. However, this knowledge is stored implicitly in the parameters of a neural network,
requiring ever-larger networks to cover more facts. To capture knowledge in a more modular and interpretable way, we
augment language model pre-training with a latent knowledge retriever, which allows the model to retrieve and attend
over documents from a large corpus such as Wikipedia, used during pre-training, fine-tuning and inference. For the
first time, we show how to pre-train such a knowledge retriever in an unsupervised manner, using masked language
modeling as the learning signal and backpropagating through a retrieval step that considers millions of documents. We
demonstrate the effectiveness of Retrieval-Augmented Language Model pre-training (REALM) by fine-tuning on the
challenging task of Open-domain Question Answering (Open-QA). We compare against state-of-the-art models for both
explicit and implicit knowledge storage on three popular Open-QA benchmarks, and find that we outperform all previous
methods by a significant margin (4-16% absolute accuracy), while also providing qualitative benefits such as
interpretability and modularity.`),yr.forEach(t),vr.forEach(t),jr=c(o),D=r(o,"P",{});var Vo=a(D);Ia=l(Vo,"This model was contributed by "),lt=r(Vo,"A",{href:!0,rel:!0});var Sd=a(lt);Za=l(Sd,"qqaatw"),Sd.forEach(t),Fa=l(Vo,`. The original code can be found
`),dt=r(Vo,"A",{href:!0,rel:!0});var Nd=a(dt);Wa=l(Nd,"here"),Nd.forEach(t),Ca=l(Vo,"."),Vo.forEach(t),Jr=c(o),ne=r(o,"H2",{class:!0});var Dr=a(ne);Te=r(Dr,"A",{id:!0,class:!0,href:!0});var Pd=a(Te);mn=r(Pd,"SPAN",{});var Vd=a(mn);y(ct.$$.fragment,Vd),Vd.forEach(t),Pd.forEach(t),La=c(Dr),pn=r(Dr,"SPAN",{});var Bd=a(pn);Sa=l(Bd,"RealmConfig"),Bd.forEach(t),Dr.forEach(t),Ar=c(o),J=r(o,"DIV",{class:!0});var N=a(J);y(mt.$$.fragment,N),Na=c(N),hn=r(N,"P",{});var Gd=a(hn);Pa=l(Gd,"This is the configuration class to store the configuration of"),Gd.forEach(t),Va=c(N),A=r(N,"OL",{});var P=a(A);fn=r(P,"LI",{});var Xd=a(fn);bo=r(Xd,"A",{href:!0});var Od=a(bo);Ba=l(Od,"RealmEmbedder"),Od.forEach(t),Xd.forEach(t),Ga=c(P),un=r(P,"LI",{});var Qd=a(un);ko=r(Qd,"A",{href:!0});var Dd=a(ko);Xa=l(Dd,"RealmScorer"),Dd.forEach(t),Qd.forEach(t),Oa=c(P),gn=r(P,"LI",{});var Hd=a(gn);vo=r(Hd,"A",{href:!0});var Yd=a(vo);Qa=l(Yd,"RealmKnowledgeAugEncoder"),Yd.forEach(t),Hd.forEach(t),Da=c(P),_n=r(P,"LI",{});var Kd=a(_n);yo=r(Kd,"A",{href:!0});var ec=a(yo);Ha=l(ec,"RealmRetriever"),ec.forEach(t),Kd.forEach(t),Ya=c(P),bn=r(P,"LI",{});var tc=a(bn);wo=r(tc,"A",{href:!0});var oc=a(wo);Ka=l(oc,"RealmReader"),oc.forEach(t),tc.forEach(t),es=c(P),kn=r(P,"LI",{});var nc=a(kn);To=r(nc,"A",{href:!0});var rc=a(To);ts=l(rc,"RealmForOpenQA"),rc.forEach(t),nc.forEach(t),P.forEach(t),os=c(N),pt=r(N,"P",{});var Hr=a(pt);ns=l(Hr,`It is used to instantiate an REALM 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 REALM
`),ht=r(Hr,"A",{href:!0,rel:!0});var ac=a(ht);rs=l(ac,"google/realm-cc-news-pretrained-embedder"),ac.forEach(t),as=l(Hr,`
architecture.`),Hr.forEach(t),ss=c(N),re=r(N,"P",{});var Bo=a(re);is=l(Bo,"Configuration objects inherit from "),Ro=r(Bo,"A",{href:!0});var sc=a(Ro);ls=l(sc,"PretrainedConfig"),sc.forEach(t),ds=l(Bo,` and can be used to control the model outputs. Read the
documentation from `),Mo=r(Bo,"A",{href:!0});var ic=a(Mo);cs=l(ic,"PretrainedConfig"),ic.forEach(t),ms=l(Bo," for more information."),Bo.forEach(t),ps=c(N),y(Re.$$.fragment,N),N.forEach(t),qr=c(o),ae=r(o,"H2",{class:!0});var Yr=a(ae);Me=r(Yr,"A",{id:!0,class:!0,href:!0});var lc=a(Me);vn=r(lc,"SPAN",{});var dc=a(vn);y(ft.$$.fragment,dc),dc.forEach(t),lc.forEach(t),hs=c(Yr),yn=r(Yr,"SPAN",{});var cc=a(yn);fs=l(cc,"RealmTokenizer"),cc.forEach(t),Yr.forEach(t),Ur=c(o),E=r(o,"DIV",{class:!0});var j=a(E);y(ut.$$.fragment,j),us=c(j),wn=r(j,"P",{});var mc=a(wn);gs=l(mc,"Construct a REALM tokenizer."),mc.forEach(t),_s=c(j),$e=r(j,"P",{});var wr=a($e);$o=r(wr,"A",{href:!0});var pc=a($o);bs=l(pc,"RealmTokenizer"),pc.forEach(t),ks=l(wr," is identical to "),Eo=r(wr,"A",{href:!0});var hc=a(Eo);vs=l(hc,"BertTokenizer"),hc.forEach(t),ys=l(wr,` and runs end-to-end tokenization: punctuation splitting and
wordpiece.`),wr.forEach(t),ws=c(j),gt=r(j,"P",{});var Kr=a(gt);Ts=l(Kr,"This tokenizer inherits from "),zo=r(Kr,"A",{href:!0});var fc=a(zo);Rs=l(fc,"PreTrainedTokenizer"),fc.forEach(t),Ms=l(Kr,` which contains most of the main methods. Users should refer to
this superclass for more information regarding those methods.`),Kr.forEach(t),$s=c(j),H=r(j,"DIV",{class:!0});var Go=a(H);y(_t.$$.fragment,Go),Es=c(Go),Tn=r(Go,"P",{});var uc=a(Tn);zs=l(uc,`Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and
adding special tokens. A REALM sequence has the following format:`),uc.forEach(t),xs=c(Go),bt=r(Go,"UL",{});var ea=a(bt);xo=r(ea,"LI",{});var Id=a(xo);js=l(Id,"single sequence: "),Rn=r(Id,"CODE",{});var gc=a(Rn);Js=l(gc,"[CLS] X [SEP]"),gc.forEach(t),Id.forEach(t),As=c(ea),jo=r(ea,"LI",{});var Zd=a(jo);qs=l(Zd,"pair of sequences: "),Mn=r(Zd,"CODE",{});var _c=a(Mn);Us=l(_c,"[CLS] A [SEP] B [SEP]"),_c.forEach(t),Zd.forEach(t),ea.forEach(t),Go.forEach(t),Is=c(j),Ee=r(j,"DIV",{class:!0});var ta=a(Ee);y(kt.$$.fragment,ta),Zs=c(ta),vt=r(ta,"P",{});var oa=a(vt);Fs=l(oa,`Retrieve sequence ids from a token list that has no special tokens added. This method is called when adding
special tokens using the tokenizer `),$n=r(oa,"CODE",{});var bc=a($n);Ws=l(bc,"prepare_for_model"),bc.forEach(t),Cs=l(oa," method."),oa.forEach(t),ta.forEach(t),Ls=c(j),F=r(j,"DIV",{class:!0});var He=a(F);y(yt.$$.fragment,He),Ss=c(He),En=r(He,"P",{});var kc=a(En);Ns=l(kc,"Create a mask from the two sequences passed to be used in a sequence-pair classification task. A REALM sequence"),kc.forEach(t),Ps=c(He),y(ze.$$.fragment,He),Vs=c(He),se=r(He,"P",{});var Xo=a(se);Bs=l(Xo,"If "),zn=r(Xo,"CODE",{});var vc=a(zn);Gs=l(vc,"token_ids_1"),vc.forEach(t),Xs=l(Xo," is "),xn=r(Xo,"CODE",{});var yc=a(xn);Os=l(yc,"None"),yc.forEach(t),Qs=l(Xo,", this method only returns the first portion of the mask (0s)."),Xo.forEach(t),He.forEach(t),Ds=c(j),Jo=r(j,"DIV",{class:!0});var wc=a(Jo);y(wt.$$.fragment,wc),wc.forEach(t),Hs=c(j),U=r(j,"DIV",{class:!0});var K=a(U);y(Tt.$$.fragment,K),Ys=c(K),Rt=r(K,"P",{});var na=a(Rt);Ks=l(na,"Encode a batch of text or text pair. This method is similar to regular "),jn=r(na,"STRONG",{});var Tc=a(jn);ei=l(Tc,"call"),Tc.forEach(t),ti=l(na,` method but has the following
differences:`),na.forEach(t),oi=c(K),ie=r(K,"OL",{});var Oo=a(ie);Jn=r(Oo,"LI",{});var Rc=a(Jn);ni=l(Rc,"Handle additional num_candidate axis. (batch_size, num_candidates, text)"),Rc.forEach(t),ri=c(Oo),Mt=r(Oo,"LI",{});var ra=a(Mt);ai=l(ra,"Always pad the sequences to "),An=r(ra,"EM",{});var Mc=a(An);si=l(Mc,"max_length"),Mc.forEach(t),ii=l(ra,"."),ra.forEach(t),li=c(Oo),$t=r(Oo,"LI",{});var aa=a($t);di=l(aa,"Must specify "),qn=r(aa,"EM",{});var $c=a(qn);ci=l($c,"max_length"),$c.forEach(t),mi=l(aa," in order to stack packs of candidates into a batch."),aa.forEach(t),Oo.forEach(t),pi=c(K),Et=r(K,"UL",{});var sa=a(Et);Ao=r(sa,"LI",{});var Fd=a(Ao);hi=l(Fd,"single sequence: "),Un=r(Fd,"CODE",{});var Ec=a(Un);fi=l(Ec,"[CLS] X [SEP]"),Ec.forEach(t),Fd.forEach(t),ui=c(sa),qo=r(sa,"LI",{});var Wd=a(qo);gi=l(Wd,"pair of sequences: "),In=r(Wd,"CODE",{});var zc=a(In);_i=l(zc,"[CLS] A [SEP] B [SEP]"),zc.forEach(t),Wd.forEach(t),sa.forEach(t),bi=c(K),y(xe.$$.fragment,K),K.forEach(t),j.forEach(t),Ir=c(o),le=r(o,"H2",{class:!0});var ia=a(le);je=r(ia,"A",{id:!0,class:!0,href:!0});var xc=a(je);Zn=r(xc,"SPAN",{});var jc=a(Zn);y(zt.$$.fragment,jc),jc.forEach(t),xc.forEach(t),ki=c(ia),Fn=r(ia,"SPAN",{});var Jc=a(Fn);vi=l(Jc,"RealmTokenizerFast"),Jc.forEach(t),ia.forEach(t),Zr=c(o),q=r(o,"DIV",{class:!0});var ee=a(q);y(xt.$$.fragment,ee),yi=c(ee),jt=r(ee,"P",{});var la=a(jt);wi=l(la,"Construct a \u201Cfast\u201D REALM tokenizer (backed by HuggingFace\u2019s "),Wn=r(la,"EM",{});var Ac=a(Wn);Ti=l(Ac,"tokenizers"),Ac.forEach(t),Ri=l(la," library). Based on WordPiece."),la.forEach(t),Mi=c(ee),Je=r(ee,"P",{});var Tr=a(Je);Uo=r(Tr,"A",{href:!0});var qc=a(Uo);$i=l(qc,"RealmTokenizerFast"),qc.forEach(t),Ei=l(Tr," is identical to "),Io=r(Tr,"A",{href:!0});var Uc=a(Io);zi=l(Uc,"BertTokenizerFast"),Uc.forEach(t),xi=l(Tr,` and runs end-to-end tokenization: punctuation
splitting and wordpiece.`),Tr.forEach(t),ji=c(ee),Jt=r(ee,"P",{});var da=a(Jt);Ji=l(da,"This tokenizer inherits from "),Zo=r(da,"A",{href:!0});var Ic=a(Zo);Ai=l(Ic,"PreTrainedTokenizerFast"),Ic.forEach(t),qi=l(da,` which contains most of the main methods. Users should
refer to this superclass for more information regarding those methods.`),da.forEach(t),Ui=c(ee),I=r(ee,"DIV",{class:!0});var te=a(I);y(At.$$.fragment,te),Ii=c(te),qt=r(te,"P",{});var ca=a(qt);Zi=l(ca,"Encode a batch of text or text pair. This method is similar to regular "),Cn=r(ca,"STRONG",{});var Zc=a(Cn);Fi=l(Zc,"call"),Zc.forEach(t),Wi=l(ca,` method but has the following
differences:`),ca.forEach(t),Ci=c(te),de=r(te,"OL",{});var Qo=a(de);Ln=r(Qo,"LI",{});var Fc=a(Ln);Li=l(Fc,"Handle additional num_candidate axis. (batch_size, num_candidates, text)"),Fc.forEach(t),Si=c(Qo),Ut=r(Qo,"LI",{});var ma=a(Ut);Ni=l(ma,"Always pad the sequences to "),Sn=r(ma,"EM",{});var Wc=a(Sn);Pi=l(Wc,"max_length"),Wc.forEach(t),Vi=l(ma,"."),ma.forEach(t),Bi=c(Qo),It=r(Qo,"LI",{});var pa=a(It);Gi=l(pa,"Must specify "),Nn=r(pa,"EM",{});var Cc=a(Nn);Xi=l(Cc,"max_length"),Cc.forEach(t),Oi=l(pa," in order to stack packs of candidates into a batch."),pa.forEach(t),Qo.forEach(t),Qi=c(te),Zt=r(te,"UL",{});var ha=a(Zt);Fo=r(ha,"LI",{});var Cd=a(Fo);Di=l(Cd,"single sequence: "),Pn=r(Cd,"CODE",{});var Lc=a(Pn);Hi=l(Lc,"[CLS] X [SEP]"),Lc.forEach(t),Cd.forEach(t),Yi=c(ha),Wo=r(ha,"LI",{});var Ld=a(Wo);Ki=l(Ld,"pair of sequences: "),Vn=r(Ld,"CODE",{});var Sc=a(Vn);el=l(Sc,"[CLS] A [SEP] B [SEP]"),Sc.forEach(t),Ld.forEach(t),ha.forEach(t),tl=c(te),y(Ae.$$.fragment,te),te.forEach(t),ee.forEach(t),Fr=c(o),ce=r(o,"H2",{class:!0});var fa=a(ce);qe=r(fa,"A",{id:!0,class:!0,href:!0});var Nc=a(qe);Bn=r(Nc,"SPAN",{});var Pc=a(Bn);y(Ft.$$.fragment,Pc),Pc.forEach(t),Nc.forEach(t),ol=c(fa),Gn=r(fa,"SPAN",{});var Vc=a(Gn);nl=l(Vc,"RealmRetriever"),Vc.forEach(t),fa.forEach(t),Wr=c(o),V=r(o,"DIV",{class:!0});var Do=a(V);y(Wt.$$.fragment,Do),rl=c(Do),Xn=r(Do,"P",{});var Bc=a(Xn);al=l(Bc,`The retriever of REALM outputting the retrieved evidence block and whether the block has answers as well as answer
positions.\u201D`),Bc.forEach(t),sl=c(Do),Ue=r(Do,"DIV",{class:!0});var ua=a(Ue);y(Ct.$$.fragment,ua),il=c(ua),On=r(ua,"P",{});var Gc=a(On);ll=l(Gc,"check if retrieved_blocks has answers."),Gc.forEach(t),ua.forEach(t),Do.forEach(t),Cr=c(o),me=r(o,"H2",{class:!0});var ga=a(me);Ie=r(ga,"A",{id:!0,class:!0,href:!0});var Xc=a(Ie);Qn=r(Xc,"SPAN",{});var Oc=a(Qn);y(Lt.$$.fragment,Oc),Oc.forEach(t),Xc.forEach(t),dl=c(ga),Dn=r(ga,"SPAN",{});var Qc=a(Dn);cl=l(Qc,"RealmEmbedder"),Qc.forEach(t),ga.forEach(t),Lr=c(o),B=r(o,"DIV",{class:!0});var Ho=a(B);y(St.$$.fragment,Ho),ml=c(Ho),Nt=r(Ho,"P",{});var _a=a(Nt);pl=l(_a,`The embedder of REALM outputting projected score that will be used to calculate relevance score.
This model is a PyTorch `),Pt=r(_a,"A",{href:!0,rel:!0});var Dc=a(Pt);hl=l(Dc,"torch.nn.Module"),Dc.forEach(t),fl=l(_a,` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),_a.forEach(t),ul=c(Ho),W=r(Ho,"DIV",{class:!0});var Ye=a(W);y(Vt.$$.fragment,Ye),gl=c(Ye),pe=r(Ye,"P",{});var Yo=a(pe);_l=l(Yo,"The "),Co=r(Yo,"A",{href:!0});var Hc=a(Co);bl=l(Hc,"RealmEmbedder"),Hc.forEach(t),kl=l(Yo," forward method, overrides the "),Hn=r(Yo,"CODE",{});var Yc=a(Hn);vl=l(Yc,"__call__"),Yc.forEach(t),yl=l(Yo," special method."),Yo.forEach(t),wl=c(Ye),y(Ze.$$.fragment,Ye),Tl=c(Ye),y(Fe.$$.fragment,Ye),Ye.forEach(t),Ho.forEach(t),Sr=c(o),he=r(o,"H2",{class:!0});var ba=a(he);We=r(ba,"A",{id:!0,class:!0,href:!0});var Kc=a(We);Yn=r(Kc,"SPAN",{});var em=a(Yn);y(Bt.$$.fragment,em),em.forEach(t),Kc.forEach(t),Rl=c(ba),Kn=r(ba,"SPAN",{});var tm=a(Kn);Ml=l(tm,"RealmScorer"),tm.forEach(t),ba.forEach(t),Nr=c(o),G=r(o,"DIV",{class:!0});var Ko=a(G);y(Gt.$$.fragment,Ko),$l=c(Ko),Xt=r(Ko,"P",{});var ka=a(Xt);El=l(ka,`The scorer of REALM outputting relevance scores representing the score of document candidates (before softmax).
This model is a PyTorch `),Ot=r(ka,"A",{href:!0,rel:!0});var om=a(Ot);zl=l(om,"torch.nn.Module"),om.forEach(t),xl=l(ka,` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),ka.forEach(t),jl=c(Ko),C=r(Ko,"DIV",{class:!0});var Ke=a(C);y(Qt.$$.fragment,Ke),Jl=c(Ke),fe=r(Ke,"P",{});var en=a(fe);Al=l(en,"The "),Lo=r(en,"A",{href:!0});var nm=a(Lo);ql=l(nm,"RealmScorer"),nm.forEach(t),Ul=l(en," forward method, overrides the "),er=r(en,"CODE",{});var rm=a(er);Il=l(rm,"__call__"),rm.forEach(t),Zl=l(en," special method."),en.forEach(t),Fl=c(Ke),y(Ce.$$.fragment,Ke),Wl=c(Ke),y(Le.$$.fragment,Ke),Ke.forEach(t),Ko.forEach(t),Pr=c(o),ue=r(o,"H2",{class:!0});var va=a(ue);Se=r(va,"A",{id:!0,class:!0,href:!0});var am=a(Se);tr=r(am,"SPAN",{});var sm=a(tr);y(Dt.$$.fragment,sm),sm.forEach(t),am.forEach(t),Cl=c(va),or=r(va,"SPAN",{});var im=a(or);Ll=l(im,"RealmKnowledgeAugEncoder"),im.forEach(t),va.forEach(t),Vr=c(o),X=r(o,"DIV",{class:!0});var tn=a(X);y(Ht.$$.fragment,tn),Sl=c(tn),Yt=r(tn,"P",{});var ya=a(Yt);Nl=l(ya,`The knowledge-augmented encoder of REALM outputting masked language model logits and marginal log-likelihood loss.
This model is a PyTorch `),Kt=r(ya,"A",{href:!0,rel:!0});var lm=a(Kt);Pl=l(lm,"torch.nn.Module"),lm.forEach(t),Vl=l(ya,` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),ya.forEach(t),Bl=c(tn),L=r(tn,"DIV",{class:!0});var et=a(L);y(eo.$$.fragment,et),Gl=c(et),ge=r(et,"P",{});var on=a(ge);Xl=l(on,"The "),So=r(on,"A",{href:!0});var dm=a(So);Ol=l(dm,"RealmKnowledgeAugEncoder"),dm.forEach(t),Ql=l(on," forward method, overrides the "),nr=r(on,"CODE",{});var cm=a(nr);Dl=l(cm,"__call__"),cm.forEach(t),Hl=l(on," special method."),on.forEach(t),Yl=c(et),y(Ne.$$.fragment,et),Kl=c(et),y(Pe.$$.fragment,et),et.forEach(t),tn.forEach(t),Br=c(o),_e=r(o,"H2",{class:!0});var wa=a(_e);Ve=r(wa,"A",{id:!0,class:!0,href:!0});var mm=a(Ve);rr=r(mm,"SPAN",{});var pm=a(rr);y(to.$$.fragment,pm),pm.forEach(t),mm.forEach(t),ed=c(wa),ar=r(wa,"SPAN",{});var hm=a(ar);td=l(hm,"RealmReader"),hm.forEach(t),wa.forEach(t),Gr=c(o),O=r(o,"DIV",{class:!0});var nn=a(O);y(oo.$$.fragment,nn),od=c(nn),no=r(nn,"P",{});var Ta=a(no);nd=l(Ta,`The reader of REALM.
This model is a PyTorch `),ro=r(Ta,"A",{href:!0,rel:!0});var fm=a(ro);rd=l(fm,"torch.nn.Module"),fm.forEach(t),ad=l(Ta,` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Ta.forEach(t),sd=c(nn),Y=r(nn,"DIV",{class:!0});var rn=a(Y);y(ao.$$.fragment,rn),id=c(rn),be=r(rn,"P",{});var an=a(be);ld=l(an,"The "),No=r(an,"A",{href:!0});var um=a(No);dd=l(um,"RealmReader"),um.forEach(t),cd=l(an," forward method, overrides the "),sr=r(an,"CODE",{});var gm=a(sr);md=l(gm,"__call__"),gm.forEach(t),pd=l(an," special method."),an.forEach(t),hd=c(rn),y(Be.$$.fragment,rn),rn.forEach(t),nn.forEach(t),Xr=c(o),ke=r(o,"H2",{class:!0});var Ra=a(ke);Ge=r(Ra,"A",{id:!0,class:!0,href:!0});var _m=a(Ge);ir=r(_m,"SPAN",{});var bm=a(ir);y(so.$$.fragment,bm),bm.forEach(t),_m.forEach(t),fd=c(Ra),lr=r(Ra,"SPAN",{});var km=a(lr);ud=l(km,"RealmForOpenQA"),km.forEach(t),Ra.forEach(t),Or=c(o),Z=r(o,"DIV",{class:!0});var tt=a(Z);y(io.$$.fragment,tt),gd=c(tt),Xe=r(tt,"P",{});var Rr=a(Xe);dr=r(Rr,"CODE",{});var vm=a(dr);_d=l(vm,"RealmForOpenQA"),vm.forEach(t),bd=l(Rr,` for end-to-end open domain question answering.
This model is a PyTorch `),lo=r(Rr,"A",{href:!0,rel:!0});var ym=a(lo);kd=l(ym,"torch.nn.Module"),ym.forEach(t),vd=l(Rr,` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Rr.forEach(t),yd=c(tt),Oe=r(tt,"DIV",{class:!0});var Ma=a(Oe);y(co.$$.fragment,Ma),wd=c(Ma),mo=r(Ma,"P",{});var $a=a(mo);Td=l($a,"Send "),cr=r($a,"CODE",{});var wm=a(cr);Rd=l(wm,"self.block_emb"),wm.forEach(t),Md=l($a," to a specific device."),$a.forEach(t),Ma.forEach(t),$d=c(tt),S=r(tt,"DIV",{class:!0});var ot=a(S);y(po.$$.fragment,ot),Ed=c(ot),ve=r(ot,"P",{});var sn=a(ve);zd=l(sn,"The "),Po=r(sn,"A",{href:!0});var Tm=a(Po);xd=l(Tm,"RealmForOpenQA"),Tm.forEach(t),jd=l(sn," forward method, overrides the "),mr=r(sn,"CODE",{});var Rm=a(mr);Jd=l(Rm,"__call__"),Rm.forEach(t),Ad=l(sn," special method."),sn.forEach(t),qd=c(ot),y(Qe.$$.fragment,ot),Ud=c(ot),y(De.$$.fragment,ot),ot.forEach(t),tt.forEach(t),this.h()},h(){p(m,"name","hf:doc:metadata"),p(m,"content",JSON.stringify(Vm)),p(f,"id","realm"),p(f,"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"),p(f,"href","#realm"),p(u,"class","relative group"),p(ye,"id","overview"),p(ye,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),p(ye,"href","#overview"),p(oe,"class","relative group"),p(it,"href","https://arxiv.org/abs/2002.08909"),p(it,"rel","nofollow"),p(lt,"href","https://huggingface.co/qqaatw"),p(lt,"rel","nofollow"),p(dt,"href","https://github.com/google-research/language/tree/master/language/realm"),p(dt,"rel","nofollow"),p(Te,"id","transformers.RealmConfig"),p(Te,"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"),p(Te,"href","#transformers.RealmConfig"),p(ne,"class","relative group"),p(bo,"href","/docs/transformers/main/en/model_doc/realm#transformers.RealmEmbedder"),p(ko,"href","/docs/transformers/main/en/model_doc/realm#transformers.RealmScorer"),p(vo,"href","/docs/transformers/main/en/model_doc/realm#transformers.RealmKnowledgeAugEncoder"),p(yo,"href","/docs/transformers/main/en/model_doc/realm#transformers.RealmRetriever"),p(wo,"href","/docs/transformers/main/en/model_doc/realm#transformers.RealmReader"),p(To,"href","/docs/transformers/main/en/model_doc/realm#transformers.RealmForOpenQA"),p(ht,"href","https://huggingface.co/google/realm-cc-news-pretrained-embedder"),p(ht,"rel","nofollow"),p(Ro,"href","/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig"),p(Mo,"href","/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig"),p(J,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(Me,"id","transformers.RealmTokenizer"),p(Me,"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"),p(Me,"href","#transformers.RealmTokenizer"),p(ae,"class","relative group"),p($o,"href","/docs/transformers/main/en/model_doc/realm#transformers.RealmTokenizer"),p(Eo,"href","/docs/transformers/main/en/model_doc/bert#transformers.BertTokenizer"),p(zo,"href","/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizer"),p(H,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(Ee,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(F,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(Jo,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(U,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(E,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(je,"id","transformers.RealmTokenizerFast"),p(je,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),p(je,"href","#transformers.RealmTokenizerFast"),p(le,"class","relative group"),p(Uo,"href","/docs/transformers/main/en/model_doc/realm#transformers.RealmTokenizerFast"),p(Io,"href","/docs/transformers/main/en/model_doc/bert#transformers.BertTokenizerFast"),p(Zo,"href","/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast"),p(I,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(q,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(qe,"id","transformers.RealmRetriever"),p(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"),p(qe,"href","#transformers.RealmRetriever"),p(ce,"class","relative group"),p(Ue,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(V,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(Ie,"id","transformers.RealmEmbedder"),p(Ie,"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"),p(Ie,"href","#transformers.RealmEmbedder"),p(me,"class","relative group"),p(Pt,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),p(Pt,"rel","nofollow"),p(Co,"href","/docs/transformers/main/en/model_doc/realm#transformers.RealmEmbedder"),p(W,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(B,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(We,"id","transformers.RealmScorer"),p(We,"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"),p(We,"href","#transformers.RealmScorer"),p(he,"class","relative group"),p(Ot,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),p(Ot,"rel","nofollow"),p(Lo,"href","/docs/transformers/main/en/model_doc/realm#transformers.RealmScorer"),p(C,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(G,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(Se,"id","transformers.RealmKnowledgeAugEncoder"),p(Se,"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"),p(Se,"href","#transformers.RealmKnowledgeAugEncoder"),p(ue,"class","relative group"),p(Kt,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),p(Kt,"rel","nofollow"),p(So,"href","/docs/transformers/main/en/model_doc/realm#transformers.RealmKnowledgeAugEncoder"),p(L,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(X,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(Ve,"id","transformers.RealmReader"),p(Ve,"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"),p(Ve,"href","#transformers.RealmReader"),p(_e,"class","relative group"),p(ro,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),p(ro,"rel","nofollow"),p(No,"href","/docs/transformers/main/en/model_doc/realm#transformers.RealmReader"),p(Y,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(O,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(Ge,"id","transformers.RealmForOpenQA"),p(Ge,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),p(Ge,"href","#transformers.RealmForOpenQA"),p(ke,"class","relative group"),p(lo,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),p(lo,"rel","nofollow"),p(Oe,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(Po,"href","/docs/transformers/main/en/model_doc/realm#transformers.RealmForOpenQA"),p(S,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(Z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(o,g){e(document.head,m),_(o,k,g),_(o,u,g),e(u,f),e(f,b),w(s,b,null),e(u,h),e(u,x),e(x,Ea),_(o,$r,g),_(o,oe,g),e(oe,ye),e(ye,ln),w(st,ln,null),e(oe,za),e(oe,dn),e(dn,xa),_(o,Er,g),_(o,we,g),e(we,ja),e(we,it),e(it,Ja),e(we,Aa),_(o,zr,g),_(o,go,g),e(go,qa),_(o,xr,g),_(o,_o,g),e(_o,cn),e(cn,Ua),_(o,jr,g),_(o,D,g),e(D,Ia),e(D,lt),e(lt,Za),e(D,Fa),e(D,dt),e(dt,Wa),e(D,Ca),_(o,Jr,g),_(o,ne,g),e(ne,Te),e(Te,mn),w(ct,mn,null),e(ne,La),e(ne,pn),e(pn,Sa),_(o,Ar,g),_(o,J,g),w(mt,J,null),e(J,Na),e(J,hn),e(hn,Pa),e(J,Va),e(J,A),e(A,fn),e(fn,bo),e(bo,Ba),e(A,Ga),e(A,un),e(un,ko),e(ko,Xa),e(A,Oa),e(A,gn),e(gn,vo),e(vo,Qa),e(A,Da),e(A,_n),e(_n,yo),e(yo,Ha),e(A,Ya),e(A,bn),e(bn,wo),e(wo,Ka),e(A,es),e(A,kn),e(kn,To),e(To,ts),e(J,os),e(J,pt),e(pt,ns),e(pt,ht),e(ht,rs),e(pt,as),e(J,ss),e(J,re),e(re,is),e(re,Ro),e(Ro,ls),e(re,ds),e(re,Mo),e(Mo,cs),e(re,ms),e(J,ps),w(Re,J,null),_(o,qr,g),_(o,ae,g),e(ae,Me),e(Me,vn),w(ft,vn,null),e(ae,hs),e(ae,yn),e(yn,fs),_(o,Ur,g),_(o,E,g),w(ut,E,null),e(E,us),e(E,wn),e(wn,gs),e(E,_s),e(E,$e),e($e,$o),e($o,bs),e($e,ks),e($e,Eo),e(Eo,vs),e($e,ys),e(E,ws),e(E,gt),e(gt,Ts),e(gt,zo),e(zo,Rs),e(gt,Ms),e(E,$s),e(E,H),w(_t,H,null),e(H,Es),e(H,Tn),e(Tn,zs),e(H,xs),e(H,bt),e(bt,xo),e(xo,js),e(xo,Rn),e(Rn,Js),e(bt,As),e(bt,jo),e(jo,qs),e(jo,Mn),e(Mn,Us),e(E,Is),e(E,Ee),w(kt,Ee,null),e(Ee,Zs),e(Ee,vt),e(vt,Fs),e(vt,$n),e($n,Ws),e(vt,Cs),e(E,Ls),e(E,F),w(yt,F,null),e(F,Ss),e(F,En),e(En,Ns),e(F,Ps),w(ze,F,null),e(F,Vs),e(F,se),e(se,Bs),e(se,zn),e(zn,Gs),e(se,Xs),e(se,xn),e(xn,Os),e(se,Qs),e(E,Ds),e(E,Jo),w(wt,Jo,null),e(E,Hs),e(E,U),w(Tt,U,null),e(U,Ys),e(U,Rt),e(Rt,Ks),e(Rt,jn),e(jn,ei),e(Rt,ti),e(U,oi),e(U,ie),e(ie,Jn),e(Jn,ni),e(ie,ri),e(ie,Mt),e(Mt,ai),e(Mt,An),e(An,si),e(Mt,ii),e(ie,li),e(ie,$t),e($t,di),e($t,qn),e(qn,ci),e($t,mi),e(U,pi),e(U,Et),e(Et,Ao),e(Ao,hi),e(Ao,Un),e(Un,fi),e(Et,ui),e(Et,qo),e(qo,gi),e(qo,In),e(In,_i),e(U,bi),w(xe,U,null),_(o,Ir,g),_(o,le,g),e(le,je),e(je,Zn),w(zt,Zn,null),e(le,ki),e(le,Fn),e(Fn,vi),_(o,Zr,g),_(o,q,g),w(xt,q,null),e(q,yi),e(q,jt),e(jt,wi),e(jt,Wn),e(Wn,Ti),e(jt,Ri),e(q,Mi),e(q,Je),e(Je,Uo),e(Uo,$i),e(Je,Ei),e(Je,Io),e(Io,zi),e(Je,xi),e(q,ji),e(q,Jt),e(Jt,Ji),e(Jt,Zo),e(Zo,Ai),e(Jt,qi),e(q,Ui),e(q,I),w(At,I,null),e(I,Ii),e(I,qt),e(qt,Zi),e(qt,Cn),e(Cn,Fi),e(qt,Wi),e(I,Ci),e(I,de),e(de,Ln),e(Ln,Li),e(de,Si),e(de,Ut),e(Ut,Ni),e(Ut,Sn),e(Sn,Pi),e(Ut,Vi),e(de,Bi),e(de,It),e(It,Gi),e(It,Nn),e(Nn,Xi),e(It,Oi),e(I,Qi),e(I,Zt),e(Zt,Fo),e(Fo,Di),e(Fo,Pn),e(Pn,Hi),e(Zt,Yi),e(Zt,Wo),e(Wo,Ki),e(Wo,Vn),e(Vn,el),e(I,tl),w(Ae,I,null),_(o,Fr,g),_(o,ce,g),e(ce,qe),e(qe,Bn),w(Ft,Bn,null),e(ce,ol),e(ce,Gn),e(Gn,nl),_(o,Wr,g),_(o,V,g),w(Wt,V,null),e(V,rl),e(V,Xn),e(Xn,al),e(V,sl),e(V,Ue),w(Ct,Ue,null),e(Ue,il),e(Ue,On),e(On,ll),_(o,Cr,g),_(o,me,g),e(me,Ie),e(Ie,Qn),w(Lt,Qn,null),e(me,dl),e(me,Dn),e(Dn,cl),_(o,Lr,g),_(o,B,g),w(St,B,null),e(B,ml),e(B,Nt),e(Nt,pl),e(Nt,Pt),e(Pt,hl),e(Nt,fl),e(B,ul),e(B,W),w(Vt,W,null),e(W,gl),e(W,pe),e(pe,_l),e(pe,Co),e(Co,bl),e(pe,kl),e(pe,Hn),e(Hn,vl),e(pe,yl),e(W,wl),w(Ze,W,null),e(W,Tl),w(Fe,W,null),_(o,Sr,g),_(o,he,g),e(he,We),e(We,Yn),w(Bt,Yn,null),e(he,Rl),e(he,Kn),e(Kn,Ml),_(o,Nr,g),_(o,G,g),w(Gt,G,null),e(G,$l),e(G,Xt),e(Xt,El),e(Xt,Ot),e(Ot,zl),e(Xt,xl),e(G,jl),e(G,C),w(Qt,C,null),e(C,Jl),e(C,fe),e(fe,Al),e(fe,Lo),e(Lo,ql),e(fe,Ul),e(fe,er),e(er,Il),e(fe,Zl),e(C,Fl),w(Ce,C,null),e(C,Wl),w(Le,C,null),_(o,Pr,g),_(o,ue,g),e(ue,Se),e(Se,tr),w(Dt,tr,null),e(ue,Cl),e(ue,or),e(or,Ll),_(o,Vr,g),_(o,X,g),w(Ht,X,null),e(X,Sl),e(X,Yt),e(Yt,Nl),e(Yt,Kt),e(Kt,Pl),e(Yt,Vl),e(X,Bl),e(X,L),w(eo,L,null),e(L,Gl),e(L,ge),e(ge,Xl),e(ge,So),e(So,Ol),e(ge,Ql),e(ge,nr),e(nr,Dl),e(ge,Hl),e(L,Yl),w(Ne,L,null),e(L,Kl),w(Pe,L,null),_(o,Br,g),_(o,_e,g),e(_e,Ve),e(Ve,rr),w(to,rr,null),e(_e,ed),e(_e,ar),e(ar,td),_(o,Gr,g),_(o,O,g),w(oo,O,null),e(O,od),e(O,no),e(no,nd),e(no,ro),e(ro,rd),e(no,ad),e(O,sd),e(O,Y),w(ao,Y,null),e(Y,id),e(Y,be),e(be,ld),e(be,No),e(No,dd),e(be,cd),e(be,sr),e(sr,md),e(be,pd),e(Y,hd),w(Be,Y,null),_(o,Xr,g),_(o,ke,g),e(ke,Ge),e(Ge,ir),w(so,ir,null),e(ke,fd),e(ke,lr),e(lr,ud),_(o,Or,g),_(o,Z,g),w(io,Z,null),e(Z,gd),e(Z,Xe),e(Xe,dr),e(dr,_d),e(Xe,bd),e(Xe,lo),e(lo,kd),e(Xe,vd),e(Z,yd),e(Z,Oe),w(co,Oe,null),e(Oe,wd),e(Oe,mo),e(mo,Td),e(mo,cr),e(cr,Rd),e(mo,Md),e(Z,$d),e(Z,S),w(po,S,null),e(S,Ed),e(S,ve),e(ve,zd),e(ve,Po),e(Po,xd),e(ve,jd),e(ve,mr),e(mr,Jd),e(ve,Ad),e(S,qd),w(Qe,S,null),e(S,Ud),w(De,S,null),Qr=!0},p(o,[g]){const ho={};g&2&&(ho.$$scope={dirty:g,ctx:o}),Re.$set(ho);const pr={};g&2&&(pr.$$scope={dirty:g,ctx:o}),ze.$set(pr);const hr={};g&2&&(hr.$$scope={dirty:g,ctx:o}),xe.$set(hr);const fr={};g&2&&(fr.$$scope={dirty:g,ctx:o}),Ae.$set(fr);const fo={};g&2&&(fo.$$scope={dirty:g,ctx:o}),Ze.$set(fo);const ur={};g&2&&(ur.$$scope={dirty:g,ctx:o}),Fe.$set(ur);const gr={};g&2&&(gr.$$scope={dirty:g,ctx:o}),Ce.$set(gr);const _r={};g&2&&(_r.$$scope={dirty:g,ctx:o}),Le.$set(_r);const uo={};g&2&&(uo.$$scope={dirty:g,ctx:o}),Ne.$set(uo);const br={};g&2&&(br.$$scope={dirty:g,ctx:o}),Pe.$set(br);const kr={};g&2&&(kr.$$scope={dirty:g,ctx:o}),Be.$set(kr);const vr={};g&2&&(vr.$$scope={dirty:g,ctx:o}),Qe.$set(vr);const yr={};g&2&&(yr.$$scope={dirty:g,ctx:o}),De.$set(yr)},i(o){Qr||(T(s.$$.fragment,o),T(st.$$.fragment,o),T(ct.$$.fragment,o),T(mt.$$.fragment,o),T(Re.$$.fragment,o),T(ft.$$.fragment,o),T(ut.$$.fragment,o),T(_t.$$.fragment,o),T(kt.$$.fragment,o),T(yt.$$.fragment,o),T(ze.$$.fragment,o),T(wt.$$.fragment,o),T(Tt.$$.fragment,o),T(xe.$$.fragment,o),T(zt.$$.fragment,o),T(xt.$$.fragment,o),T(At.$$.fragment,o),T(Ae.$$.fragment,o),T(Ft.$$.fragment,o),T(Wt.$$.fragment,o),T(Ct.$$.fragment,o),T(Lt.$$.fragment,o),T(St.$$.fragment,o),T(Vt.$$.fragment,o),T(Ze.$$.fragment,o),T(Fe.$$.fragment,o),T(Bt.$$.fragment,o),T(Gt.$$.fragment,o),T(Qt.$$.fragment,o),T(Ce.$$.fragment,o),T(Le.$$.fragment,o),T(Dt.$$.fragment,o),T(Ht.$$.fragment,o),T(eo.$$.fragment,o),T(Ne.$$.fragment,o),T(Pe.$$.fragment,o),T(to.$$.fragment,o),T(oo.$$.fragment,o),T(ao.$$.fragment,o),T(Be.$$.fragment,o),T(so.$$.fragment,o),T(io.$$.fragment,o),T(co.$$.fragment,o),T(po.$$.fragment,o),T(Qe.$$.fragment,o),T(De.$$.fragment,o),Qr=!0)},o(o){R(s.$$.fragment,o),R(st.$$.fragment,o),R(ct.$$.fragment,o),R(mt.$$.fragment,o),R(Re.$$.fragment,o),R(ft.$$.fragment,o),R(ut.$$.fragment,o),R(_t.$$.fragment,o),R(kt.$$.fragment,o),R(yt.$$.fragment,o),R(ze.$$.fragment,o),R(wt.$$.fragment,o),R(Tt.$$.fragment,o),R(xe.$$.fragment,o),R(zt.$$.fragment,o),R(xt.$$.fragment,o),R(At.$$.fragment,o),R(Ae.$$.fragment,o),R(Ft.$$.fragment,o),R(Wt.$$.fragment,o),R(Ct.$$.fragment,o),R(Lt.$$.fragment,o),R(St.$$.fragment,o),R(Vt.$$.fragment,o),R(Ze.$$.fragment,o),R(Fe.$$.fragment,o),R(Bt.$$.fragment,o),R(Gt.$$.fragment,o),R(Qt.$$.fragment,o),R(Ce.$$.fragment,o),R(Le.$$.fragment,o),R(Dt.$$.fragment,o),R(Ht.$$.fragment,o),R(eo.$$.fragment,o),R(Ne.$$.fragment,o),R(Pe.$$.fragment,o),R(to.$$.fragment,o),R(oo.$$.fragment,o),R(ao.$$.fragment,o),R(Be.$$.fragment,o),R(so.$$.fragment,o),R(io.$$.fragment,o),R(co.$$.fragment,o),R(po.$$.fragment,o),R(Qe.$$.fragment,o),R(De.$$.fragment,o),Qr=!1},d(o){t(m),o&&t(k),o&&t(u),M(s),o&&t($r),o&&t(oe),M(st),o&&t(Er),o&&t(we),o&&t(zr),o&&t(go),o&&t(xr),o&&t(_o),o&&t(jr),o&&t(D),o&&t(Jr),o&&t(ne),M(ct),o&&t(Ar),o&&t(J),M(mt),M(Re),o&&t(qr),o&&t(ae),M(ft),o&&t(Ur),o&&t(E),M(ut),M(_t),M(kt),M(yt),M(ze),M(wt),M(Tt),M(xe),o&&t(Ir),o&&t(le),M(zt),o&&t(Zr),o&&t(q),M(xt),M(At),M(Ae),o&&t(Fr),o&&t(ce),M(Ft),o&&t(Wr),o&&t(V),M(Wt),M(Ct),o&&t(Cr),o&&t(me),M(Lt),o&&t(Lr),o&&t(B),M(St),M(Vt),M(Ze),M(Fe),o&&t(Sr),o&&t(he),M(Bt),o&&t(Nr),o&&t(G),M(Gt),M(Qt),M(Ce),M(Le),o&&t(Pr),o&&t(ue),M(Dt),o&&t(Vr),o&&t(X),M(Ht),M(eo),M(Ne),M(Pe),o&&t(Br),o&&t(_e),M(to),o&&t(Gr),o&&t(O),M(oo),M(ao),M(Be),o&&t(Xr),o&&t(ke),M(so),o&&t(Or),o&&t(Z),M(io),M(co),M(po),M(Qe),M(De)}}}const Vm={local:"realm",sections:[{local:"overview",title:"Overview"},{local:"transformers.RealmConfig",title:"RealmConfig"},{local:"transformers.RealmTokenizer",title:"RealmTokenizer"},{local:"transformers.RealmTokenizerFast",title:"RealmTokenizerFast"},{local:"transformers.RealmRetriever",title:"RealmRetriever"},{local:"transformers.RealmEmbedder",title:"RealmEmbedder"},{local:"transformers.RealmScorer",title:"RealmScorer"},{local:"transformers.RealmKnowledgeAugEncoder",title:"RealmKnowledgeAugEncoder"},{local:"transformers.RealmReader",title:"RealmReader"},{local:"transformers.RealmForOpenQA",title:"RealmForOpenQA"}],title:"REALM"};function Bm($){return xm(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ym extends Mm{constructor(m){super();$m(this,m,Bm,Pm,Em,{})}}export{Ym as default,Vm as metadata};
