import{S as Mm,i as $m,s as Em,e as n,k as d,w as k,t as l,M as zm,c as r,d as t,m as c,a,x as y,h as i,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,v,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"),v=l("Example:"),u=d(),k(f.$$.fragment)},l(s){m=r(s,"P",{});var h=a(m);v=i(h,"Example:"),h.forEach(t),u=c(s),y(f.$$.fragment,s)},m(s,h){_(s,m,h),e(m,v),_(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,v,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"),v=l("pair mask has the following format:"),u=d(),k(f.$$.fragment)},l(s){m=r(s,"P",{});var h=a(m);v=i(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,v),_(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,v,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"),v=l("Example:"),u=d(),k(f.$$.fragment)},l(s){m=r(s,"P",{});var h=a(m);v=i(h,"Example:"),h.forEach(t),u=c(s),y(f.$$.fragment,s)},m(s,h){_(s,m,h),e(m,v),_(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,v,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"),v=l("Example:"),u=d(),k(f.$$.fragment)},l(s){m=r(s,"P",{});var h=a(m);v=i(h,"Example:"),h.forEach(t),u=c(s),y(f.$$.fragment,s)},m(s,h){_(s,m,h),e(m,v),_(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,v,u,f,b;return{c(){m=n("p"),v=l("Although the recipe for forward pass needs to be defined within this function, one should call the "),u=n("code"),f=l("Module"),b=l(`
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);v=i(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=i(x,"Module"),x.forEach(t),b=i(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,v),e(m,u),e(u,f),e(m,b)},d(s){s&&t(m)}}}function Im($){let m,v,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"),v=l("Example:"),u=d(),k(f.$$.fragment)},l(s){m=r(s,"P",{});var h=a(m);v=i(h,"Example:"),h.forEach(t),u=c(s),y(f.$$.fragment,s)},m(s,h){_(s,m,h),e(m,v),_(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,v,u,f,b;return{c(){m=n("p"),v=l("Although the recipe for forward pass needs to be defined within this function, one should call the "),u=n("code"),f=l("Module"),b=l(`
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);v=i(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=i(x,"Module"),x.forEach(t),b=i(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,v),e(m,u),e(u,f),e(m,b)},d(s){s&&t(m)}}}function Fm($){let m,v,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"),v=l("Example:"),u=d(),k(f.$$.fragment)},l(s){m=r(s,"P",{});var h=a(m);v=i(h,"Example:"),h.forEach(t),u=c(s),y(f.$$.fragment,s)},m(s,h){_(s,m,h),e(m,v),_(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,v,u,f,b;return{c(){m=n("p"),v=l("Although the recipe for forward pass needs to be defined within this function, one should call the "),u=n("code"),f=l("Module"),b=l(`
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);v=i(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=i(x,"Module"),x.forEach(t),b=i(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,v),e(m,u),e(u,f),e(m,b)},d(s){s&&t(m)}}}function Cm($){let m,v,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"),v=l("Example:"),u=d(),k(f.$$.fragment)},l(s){m=r(s,"P",{});var h=a(m);v=i(h,"Example:"),h.forEach(t),u=c(s),y(f.$$.fragment,s)},m(s,h){_(s,m,h),e(m,v),_(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 Sm($){let m,v,u,f,b;return{c(){m=n("p"),v=l("Although the recipe for forward pass needs to be defined within this function, one should call the "),u=n("code"),f=l("Module"),b=l(`
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);v=i(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=i(x,"Module"),x.forEach(t),b=i(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,v),e(m,u),e(u,f),e(m,b)},d(s){s&&t(m)}}}function Lm($){let m,v,u,f,b;return{c(){m=n("p"),v=l("Although the recipe for forward pass needs to be defined within this function, one should call the "),u=n("code"),f=l("Module"),b=l(`
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);v=i(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=i(x,"Module"),x.forEach(t),b=i(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,v),e(m,u),e(u,f),e(m,b)},d(s){s&&t(m)}}}function Nm($){let m,v,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"),v=l("Example:"),u=d(),k(f.$$.fragment)},l(s){m=r(s,"P",{});var h=a(m);v=i(h,"Example:"),h.forEach(t),u=c(s),y(f.$$.fragment,s)},m(s,h){_(s,m,h),e(m,v),_(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 Vm($){let m,v,u,f,b,s,h,x,Ea,$r,oe,ye,ln,st,za,dn,xa,Er,we,ja,lt,Ja,Aa,zr,go,qa,xr,_o,cn,Ua,jr,D,Ia,it,Za,Fa,dt,Wa,Ca,Jr,ne,Te,mn,ct,Sa,pn,La,Ar,J,mt,Na,hn,Va,Pa,A,fn,bo,Ba,Ga,un,vo,Xa,Oa,gn,ko,Qa,Da,_n,yo,Ha,Ya,bn,wo,Ka,es,vn,To,ts,os,pt,ns,ht,rs,as,ss,re,ls,Ro,is,ds,Mo,cs,ms,ps,Re,qr,ae,Me,kn,ft,hs,yn,fs,Ur,E,ut,us,wn,gs,_s,$e,$o,bs,vs,Eo,ks,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,vt,Zs,kt,Fs,$n,Ws,Cs,Ss,F,yt,Ls,En,Ns,Vs,ze,Ps,se,Bs,zn,Gs,Xs,xn,Os,Qs,Ds,Jo,wt,Hs,U,Tt,Ys,Rt,Ks,jn,el,tl,ol,le,Jn,nl,rl,Mt,al,An,sl,ll,il,$t,dl,qn,cl,ml,pl,Et,Ao,hl,Un,fl,ul,qo,gl,In,_l,bl,xe,Ir,ie,je,Zn,zt,vl,Fn,kl,Zr,q,xt,yl,jt,wl,Wn,Tl,Rl,Ml,Je,Uo,$l,El,Io,zl,xl,jl,Jt,Jl,Zo,Al,ql,Ul,I,At,Il,qt,Zl,Cn,Fl,Wl,Cl,de,Sn,Sl,Ll,Ut,Nl,Ln,Vl,Pl,Bl,It,Gl,Nn,Xl,Ol,Ql,Zt,Fo,Dl,Vn,Hl,Yl,Wo,Kl,Pn,ei,ti,Ae,Fr,ce,qe,Bn,Ft,oi,Gn,ni,Wr,P,Wt,ri,Xn,ai,si,Ue,Ct,li,On,ii,Cr,me,Ie,Qn,St,di,Dn,ci,Sr,B,Lt,mi,Nt,pi,Vt,hi,fi,ui,W,Pt,gi,pe,_i,Co,bi,vi,Hn,ki,yi,wi,Ze,Ti,Fe,Lr,he,We,Yn,Bt,Ri,Kn,Mi,Nr,G,Gt,$i,Xt,Ei,Ot,zi,xi,ji,C,Qt,Ji,fe,Ai,So,qi,Ui,er,Ii,Zi,Fi,Ce,Wi,Se,Vr,ue,Le,tr,Dt,Ci,or,Si,Pr,X,Ht,Li,Yt,Ni,Kt,Vi,Pi,Bi,S,eo,Gi,ge,Xi,Lo,Oi,Qi,nr,Di,Hi,Yi,Ne,Ki,Ve,Br,_e,Pe,rr,to,ed,ar,td,Gr,O,oo,od,no,nd,ro,rd,ad,sd,Y,ao,ld,be,id,No,dd,cd,sr,md,pd,hd,Be,Xr,ve,Ge,lr,so,fd,ir,ud,Or,Z,lo,gd,Xe,dr,_d,bd,io,vd,kd,yd,Oe,co,wd,mo,Td,cr,Rd,Md,$d,L,po,Ed,ke,zd,Vo,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/v4.30.0/en/model_doc/realm#transformers.RealmEmbedder">RealmEmbedder</a>, <a href="/docs/transformers/v4.30.0/en/model_doc/realm#transformers.RealmScorer">RealmScorer</a>, <a href="/docs/transformers/v4.30.0/en/model_doc/realm#transformers.RealmKnowledgeAugEncoder">RealmKnowledgeAugEncoder</a>, or
<a href="/docs/transformers/v4.30.0/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/v4.30.0/en/model_doc/realm#transformers.RealmEmbedder">RealmEmbedder</a>, <a href="/docs/transformers/v4.30.0/en/model_doc/realm#transformers.RealmScorer">RealmScorer</a>,
<a href="/docs/transformers/v4.30.0/en/model_doc/realm#transformers.RealmKnowledgeAugEncoder">RealmKnowledgeAugEncoder</a>, or <a href="/docs/transformers/v4.30.0/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/v4.30.0/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/v4.30.0/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/v4.30.0/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>
`}}),vt=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/v4.30.0/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/v4.30.0/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/v4.30.0/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/v4.30.0/src/transformers/models/realm/tokenization_realm.py#L228",returnDescription:`
<p>Encoded text or text pair.</p>
`,returnType:`
<p><a
  href="/docs/transformers/v4.30.0/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/v4.30.0/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/v4.30.0/src/transformers/models/realm/tokenization_realm_fast.py#L193",returnDescription:`
<p>Encoded text or text pair.</p>
`,returnType:`
<p><a
  href="/docs/transformers/v4.30.0/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/v4.30.0/en/model_doc/realm#transformers.RealmTokenizer">RealmTokenizer</a>) &#x2014;
The tokenizer to encode retrieved texts.`,name:"tokenizer"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/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/v4.30.0/src/transformers/models/realm/retrieval_realm.py#L129"}}),St=new Q({}),Lt=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/v4.30.0/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/v4.30.0/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/realm/modeling_realm.py#L1149"}}),Pt=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/v4.30.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.30.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.30.0/en/model_doc/speecht5#transformers.SpeechT5Tokenizer.__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/v4.30.0/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/realm/modeling_realm.py#L1165",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/v4.30.0/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/v4.30.0/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/v4.30.0/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/v4.30.0/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/v4.30.0/src/transformers/models/realm/modeling_realm.py#L1231"}}),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/v4.30.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.30.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.30.0/en/model_doc/speecht5#transformers.SpeechT5Tokenizer.__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/v4.30.0/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/v4.30.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.30.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.30.0/en/model_doc/speecht5#transformers.SpeechT5Tokenizer.__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/v4.30.0/src/transformers/models/realm/modeling_realm.py#L1247",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/v4.30.0/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:$}}}),Se=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/v4.30.0/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/v4.30.0/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/realm/modeling_realm.py#L1379"}}),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/v4.30.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.30.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.30.0/en/model_doc/speecht5#transformers.SpeechT5Tokenizer.__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/v4.30.0/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/v4.30.0/src/transformers/models/realm/modeling_realm.py#L1400",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.30.0/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/v4.30.0/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/v4.30.0/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:$}}}),Ve=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/v4.30.0/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/v4.30.0/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/realm/modeling_realm.py#L1529"}}),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/v4.30.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.30.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.30.0/en/model_doc/speecht5#transformers.SpeechT5Tokenizer.__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/v4.30.0/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/v4.30.0/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/v4.30.0/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:[Sm]},$$scope:{ctx:$}}}),so=new Q({}),lo=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/v4.30.0/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/v4.30.0/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/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/v4.30.0/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/v4.30.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.30.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.30.0/en/model_doc/speecht5#transformers.SpeechT5Tokenizer.__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/v4.30.0/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/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/v4.30.0/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:[Lm]},$$scope:{ctx:$}}}),De=new nt({props:{anchor:"transformers.RealmForOpenQA.forward.example",$$slots:{default:[Nm]},$$scope:{ctx:$}}}),{c(){m=n("meta"),v=d(),u=n("h1"),f=n("a"),b=n("span"),k(s.$$.fragment),h=d(),x=n("span"),Ea=l("REALM"),$r=d(),oe=n("h2"),ye=n("a"),ln=n("span"),k(st.$$.fragment),za=d(),dn=n("span"),xa=l("Overview"),Er=d(),we=n("p"),ja=l("The REALM model was proposed in "),lt=n("a"),Ja=l("REALM: Retrieval-Augmented Language Model Pre-Training"),Aa=l(` 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=l("The abstract from the paper is the following:"),xr=d(),_o=n("p"),cn=n("em"),Ua=l(`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=l("This model was contributed by "),it=n("a"),Za=l("qqaatw"),Fa=l(`. The original code can be found
`),dt=n("a"),Wa=l("here"),Ca=l("."),Jr=d(),ne=n("h2"),Te=n("a"),mn=n("span"),k(ct.$$.fragment),Sa=d(),pn=n("span"),La=l("RealmConfig"),Ar=d(),J=n("div"),k(mt.$$.fragment),Na=d(),hn=n("p"),Va=l("This is the configuration class to store the configuration of"),Pa=d(),A=n("ol"),fn=n("li"),bo=n("a"),Ba=l("RealmEmbedder"),Ga=d(),un=n("li"),vo=n("a"),Xa=l("RealmScorer"),Oa=d(),gn=n("li"),ko=n("a"),Qa=l("RealmKnowledgeAugEncoder"),Da=d(),_n=n("li"),yo=n("a"),Ha=l("RealmRetriever"),Ya=d(),bn=n("li"),wo=n("a"),Ka=l("RealmReader"),es=d(),vn=n("li"),To=n("a"),ts=l("RealmForOpenQA"),os=d(),pt=n("p"),ns=l(`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=l("google/realm-cc-news-pretrained-embedder"),as=l(`
architecture.`),ss=d(),re=n("p"),ls=l("Configuration objects inherit from "),Ro=n("a"),is=l("PretrainedConfig"),ds=l(` and can be used to control the model outputs. Read the
documentation from `),Mo=n("a"),cs=l("PretrainedConfig"),ms=l(" for more information."),ps=d(),k(Re.$$.fragment),qr=d(),ae=n("h2"),Me=n("a"),kn=n("span"),k(ft.$$.fragment),hs=d(),yn=n("span"),fs=l("RealmTokenizer"),Ur=d(),E=n("div"),k(ut.$$.fragment),us=d(),wn=n("p"),gs=l("Construct a REALM tokenizer."),_s=d(),$e=n("p"),$o=n("a"),bs=l("RealmTokenizer"),vs=l(" is identical to "),Eo=n("a"),ks=l("BertTokenizer"),ys=l(` and runs end-to-end tokenization: punctuation splitting and
wordpiece.`),ws=d(),gt=n("p"),Ts=l("This tokenizer inherits from "),zo=n("a"),Rs=l("PreTrainedTokenizer"),Ms=l(` which contains most of the main methods. Users should refer to
this superclass for more information regarding those methods.`),$s=d(),H=n("div"),k(_t.$$.fragment),Es=d(),Tn=n("p"),zs=l(`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=l("single sequence: "),Rn=n("code"),Js=l("[CLS] X [SEP]"),As=d(),jo=n("li"),qs=l("pair of sequences: "),Mn=n("code"),Us=l("[CLS] A [SEP] B [SEP]"),Is=d(),Ee=n("div"),k(vt.$$.fragment),Zs=d(),kt=n("p"),Fs=l(`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=l("prepare_for_model"),Cs=l(" method."),Ss=d(),F=n("div"),k(yt.$$.fragment),Ls=d(),En=n("p"),Ns=l("Create a mask from the two sequences passed to be used in a sequence-pair classification task. A REALM sequence"),Vs=d(),k(ze.$$.fragment),Ps=d(),se=n("p"),Bs=l("If "),zn=n("code"),Gs=l("token_ids_1"),Xs=l(" is "),xn=n("code"),Os=l("None"),Qs=l(", this method only returns the first portion of the mask (0s)."),Ds=d(),Jo=n("div"),k(wt.$$.fragment),Hs=d(),U=n("div"),k(Tt.$$.fragment),Ys=d(),Rt=n("p"),Ks=l("Encode a batch of text or text pair. This method is similar to regular "),jn=n("strong"),el=l("call"),tl=l(` method but has the following
differences:`),ol=d(),le=n("ol"),Jn=n("li"),nl=l("Handle additional num_candidate axis. (batch_size, num_candidates, text)"),rl=d(),Mt=n("li"),al=l("Always pad the sequences to "),An=n("em"),sl=l("max_length"),ll=l("."),il=d(),$t=n("li"),dl=l("Must specify "),qn=n("em"),cl=l("max_length"),ml=l(" in order to stack packs of candidates into a batch."),pl=d(),Et=n("ul"),Ao=n("li"),hl=l("single sequence: "),Un=n("code"),fl=l("[CLS] X [SEP]"),ul=d(),qo=n("li"),gl=l("pair of sequences: "),In=n("code"),_l=l("[CLS] A [SEP] B [SEP]"),bl=d(),k(xe.$$.fragment),Ir=d(),ie=n("h2"),je=n("a"),Zn=n("span"),k(zt.$$.fragment),vl=d(),Fn=n("span"),kl=l("RealmTokenizerFast"),Zr=d(),q=n("div"),k(xt.$$.fragment),yl=d(),jt=n("p"),wl=l("Construct a \u201Cfast\u201D REALM tokenizer (backed by HuggingFace\u2019s "),Wn=n("em"),Tl=l("tokenizers"),Rl=l(" library). Based on WordPiece."),Ml=d(),Je=n("p"),Uo=n("a"),$l=l("RealmTokenizerFast"),El=l(" is identical to "),Io=n("a"),zl=l("BertTokenizerFast"),xl=l(` and runs end-to-end tokenization: punctuation
splitting and wordpiece.`),jl=d(),Jt=n("p"),Jl=l("This tokenizer inherits from "),Zo=n("a"),Al=l("PreTrainedTokenizerFast"),ql=l(` which contains most of the main methods. Users should
refer to this superclass for more information regarding those methods.`),Ul=d(),I=n("div"),k(At.$$.fragment),Il=d(),qt=n("p"),Zl=l("Encode a batch of text or text pair. This method is similar to regular "),Cn=n("strong"),Fl=l("call"),Wl=l(` method but has the following
differences:`),Cl=d(),de=n("ol"),Sn=n("li"),Sl=l("Handle additional num_candidate axis. (batch_size, num_candidates, text)"),Ll=d(),Ut=n("li"),Nl=l("Always pad the sequences to "),Ln=n("em"),Vl=l("max_length"),Pl=l("."),Bl=d(),It=n("li"),Gl=l("Must specify "),Nn=n("em"),Xl=l("max_length"),Ol=l(" in order to stack packs of candidates into a batch."),Ql=d(),Zt=n("ul"),Fo=n("li"),Dl=l("single sequence: "),Vn=n("code"),Hl=l("[CLS] X [SEP]"),Yl=d(),Wo=n("li"),Kl=l("pair of sequences: "),Pn=n("code"),ei=l("[CLS] A [SEP] B [SEP]"),ti=d(),k(Ae.$$.fragment),Fr=d(),ce=n("h2"),qe=n("a"),Bn=n("span"),k(Ft.$$.fragment),oi=d(),Gn=n("span"),ni=l("RealmRetriever"),Wr=d(),P=n("div"),k(Wt.$$.fragment),ri=d(),Xn=n("p"),ai=l(`The retriever of REALM outputting the retrieved evidence block and whether the block has answers as well as answer
positions.\u201D`),si=d(),Ue=n("div"),k(Ct.$$.fragment),li=d(),On=n("p"),ii=l("check if retrieved_blocks has answers."),Cr=d(),me=n("h2"),Ie=n("a"),Qn=n("span"),k(St.$$.fragment),di=d(),Dn=n("span"),ci=l("RealmEmbedder"),Sr=d(),B=n("div"),k(Lt.$$.fragment),mi=d(),Nt=n("p"),pi=l(`The embedder of REALM outputting projected score that will be used to calculate relevance score.
This model is a PyTorch `),Vt=n("a"),hi=l("torch.nn.Module"),fi=l(` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),ui=d(),W=n("div"),k(Pt.$$.fragment),gi=d(),pe=n("p"),_i=l("The "),Co=n("a"),bi=l("RealmEmbedder"),vi=l(" forward method, overrides the "),Hn=n("code"),ki=l("__call__"),yi=l(" special method."),wi=d(),k(Ze.$$.fragment),Ti=d(),k(Fe.$$.fragment),Lr=d(),he=n("h2"),We=n("a"),Yn=n("span"),k(Bt.$$.fragment),Ri=d(),Kn=n("span"),Mi=l("RealmScorer"),Nr=d(),G=n("div"),k(Gt.$$.fragment),$i=d(),Xt=n("p"),Ei=l(`The scorer of REALM outputting relevance scores representing the score of document candidates (before softmax).
This model is a PyTorch `),Ot=n("a"),zi=l("torch.nn.Module"),xi=l(` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),ji=d(),C=n("div"),k(Qt.$$.fragment),Ji=d(),fe=n("p"),Ai=l("The "),So=n("a"),qi=l("RealmScorer"),Ui=l(" forward method, overrides the "),er=n("code"),Ii=l("__call__"),Zi=l(" special method."),Fi=d(),k(Ce.$$.fragment),Wi=d(),k(Se.$$.fragment),Vr=d(),ue=n("h2"),Le=n("a"),tr=n("span"),k(Dt.$$.fragment),Ci=d(),or=n("span"),Si=l("RealmKnowledgeAugEncoder"),Pr=d(),X=n("div"),k(Ht.$$.fragment),Li=d(),Yt=n("p"),Ni=l(`The knowledge-augmented encoder of REALM outputting masked language model logits and marginal log-likelihood loss.
This model is a PyTorch `),Kt=n("a"),Vi=l("torch.nn.Module"),Pi=l(` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Bi=d(),S=n("div"),k(eo.$$.fragment),Gi=d(),ge=n("p"),Xi=l("The "),Lo=n("a"),Oi=l("RealmKnowledgeAugEncoder"),Qi=l(" forward method, overrides the "),nr=n("code"),Di=l("__call__"),Hi=l(" special method."),Yi=d(),k(Ne.$$.fragment),Ki=d(),k(Ve.$$.fragment),Br=d(),_e=n("h2"),Pe=n("a"),rr=n("span"),k(to.$$.fragment),ed=d(),ar=n("span"),td=l("RealmReader"),Gr=d(),O=n("div"),k(oo.$$.fragment),od=d(),no=n("p"),nd=l(`The reader of REALM.
This model is a PyTorch `),ro=n("a"),rd=l("torch.nn.Module"),ad=l(` 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"),k(ao.$$.fragment),ld=d(),be=n("p"),id=l("The "),No=n("a"),dd=l("RealmReader"),cd=l(" forward method, overrides the "),sr=n("code"),md=l("__call__"),pd=l(" special method."),hd=d(),k(Be.$$.fragment),Xr=d(),ve=n("h2"),Ge=n("a"),lr=n("span"),k(so.$$.fragment),fd=d(),ir=n("span"),ud=l("RealmForOpenQA"),Or=d(),Z=n("div"),k(lo.$$.fragment),gd=d(),Xe=n("p"),dr=n("code"),_d=l("RealmForOpenQA"),bd=l(` for end-to-end open domain question answering.
This model is a PyTorch `),io=n("a"),vd=l("torch.nn.Module"),kd=l(` 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"),k(co.$$.fragment),wd=d(),mo=n("p"),Td=l("Send "),cr=n("code"),Rd=l("self.block_emb"),Md=l(" to a specific device."),$d=d(),L=n("div"),k(po.$$.fragment),Ed=d(),ke=n("p"),zd=l("The "),Vo=n("a"),xd=l("RealmForOpenQA"),jd=l(" forward method, overrides the "),mr=n("code"),Jd=l("__call__"),Ad=l(" special method."),qd=d(),k(Qe.$$.fragment),Ud=d(),k(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),v=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=i(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=i(_r,"Overview"),_r.forEach(t),fo.forEach(t),Er=c(o),we=r(o,"P",{});var uo=a(we);ja=i(uo,"The REALM model was proposed in "),lt=r(uo,"A",{href:!0,rel:!0});var br=a(lt);Ja=i(br,"REALM: Retrieval-Augmented Language Model Pre-Training"),br.forEach(t),Aa=i(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 vr=a(go);qa=i(vr,"The abstract from the paper is the following:"),vr.forEach(t),xr=c(o),_o=r(o,"P",{});var kr=a(_o);cn=r(kr,"EM",{});var yr=a(cn);Ua=i(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),kr.forEach(t),jr=c(o),D=r(o,"P",{});var Po=a(D);Ia=i(Po,"This model was contributed by "),it=r(Po,"A",{href:!0,rel:!0});var Ld=a(it);Za=i(Ld,"qqaatw"),Ld.forEach(t),Fa=i(Po,`. The original code can be found
`),dt=r(Po,"A",{href:!0,rel:!0});var Nd=a(dt);Wa=i(Nd,"here"),Nd.forEach(t),Ca=i(Po,"."),Po.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 Vd=a(Te);mn=r(Vd,"SPAN",{});var Pd=a(mn);y(ct.$$.fragment,Pd),Pd.forEach(t),Vd.forEach(t),Sa=c(Dr),pn=r(Dr,"SPAN",{});var Bd=a(pn);La=i(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);Va=i(Gd,"This is the configuration class to store the configuration of"),Gd.forEach(t),Pa=c(N),A=r(N,"OL",{});var V=a(A);fn=r(V,"LI",{});var Xd=a(fn);bo=r(Xd,"A",{href:!0});var Od=a(bo);Ba=i(Od,"RealmEmbedder"),Od.forEach(t),Xd.forEach(t),Ga=c(V),un=r(V,"LI",{});var Qd=a(un);vo=r(Qd,"A",{href:!0});var Dd=a(vo);Xa=i(Dd,"RealmScorer"),Dd.forEach(t),Qd.forEach(t),Oa=c(V),gn=r(V,"LI",{});var Hd=a(gn);ko=r(Hd,"A",{href:!0});var Yd=a(ko);Qa=i(Yd,"RealmKnowledgeAugEncoder"),Yd.forEach(t),Hd.forEach(t),Da=c(V),_n=r(V,"LI",{});var Kd=a(_n);yo=r(Kd,"A",{href:!0});var ec=a(yo);Ha=i(ec,"RealmRetriever"),ec.forEach(t),Kd.forEach(t),Ya=c(V),bn=r(V,"LI",{});var tc=a(bn);wo=r(tc,"A",{href:!0});var oc=a(wo);Ka=i(oc,"RealmReader"),oc.forEach(t),tc.forEach(t),es=c(V),vn=r(V,"LI",{});var nc=a(vn);To=r(nc,"A",{href:!0});var rc=a(To);ts=i(rc,"RealmForOpenQA"),rc.forEach(t),nc.forEach(t),V.forEach(t),os=c(N),pt=r(N,"P",{});var Hr=a(pt);ns=i(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=i(ac,"google/realm-cc-news-pretrained-embedder"),ac.forEach(t),as=i(Hr,`
architecture.`),Hr.forEach(t),ss=c(N),re=r(N,"P",{});var Bo=a(re);ls=i(Bo,"Configuration objects inherit from "),Ro=r(Bo,"A",{href:!0});var sc=a(Ro);is=i(sc,"PretrainedConfig"),sc.forEach(t),ds=i(Bo,` and can be used to control the model outputs. Read the
documentation from `),Mo=r(Bo,"A",{href:!0});var lc=a(Mo);cs=i(lc,"PretrainedConfig"),lc.forEach(t),ms=i(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 ic=a(Me);kn=r(ic,"SPAN",{});var dc=a(kn);y(ft.$$.fragment,dc),dc.forEach(t),ic.forEach(t),hs=c(Yr),yn=r(Yr,"SPAN",{});var cc=a(yn);fs=i(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=i(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=i(pc,"RealmTokenizer"),pc.forEach(t),vs=i(wr," is identical to "),Eo=r(wr,"A",{href:!0});var hc=a(Eo);ks=i(hc,"BertTokenizer"),hc.forEach(t),ys=i(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=i(Kr,"This tokenizer inherits from "),zo=r(Kr,"A",{href:!0});var fc=a(zo);Rs=i(fc,"PreTrainedTokenizer"),fc.forEach(t),Ms=i(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=i(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=i(Id,"single sequence: "),Rn=r(Id,"CODE",{});var gc=a(Rn);Js=i(gc,"[CLS] X [SEP]"),gc.forEach(t),Id.forEach(t),As=c(ea),jo=r(ea,"LI",{});var Zd=a(jo);qs=i(Zd,"pair of sequences: "),Mn=r(Zd,"CODE",{});var _c=a(Mn);Us=i(_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(vt.$$.fragment,ta),Zs=c(ta),kt=r(ta,"P",{});var oa=a(kt);Fs=i(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=i(bc,"prepare_for_model"),bc.forEach(t),Cs=i(oa," method."),oa.forEach(t),ta.forEach(t),Ss=c(j),F=r(j,"DIV",{class:!0});var He=a(F);y(yt.$$.fragment,He),Ls=c(He),En=r(He,"P",{});var vc=a(En);Ns=i(vc,"Create a mask from the two sequences passed to be used in a sequence-pair classification task. A REALM sequence"),vc.forEach(t),Vs=c(He),y(ze.$$.fragment,He),Ps=c(He),se=r(He,"P",{});var Xo=a(se);Bs=i(Xo,"If "),zn=r(Xo,"CODE",{});var kc=a(zn);Gs=i(kc,"token_ids_1"),kc.forEach(t),Xs=i(Xo," is "),xn=r(Xo,"CODE",{});var yc=a(xn);Os=i(yc,"None"),yc.forEach(t),Qs=i(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=i(na,"Encode a batch of text or text pair. This method is similar to regular "),jn=r(na,"STRONG",{});var Tc=a(jn);el=i(Tc,"call"),Tc.forEach(t),tl=i(na,` method but has the following
differences:`),na.forEach(t),ol=c(K),le=r(K,"OL",{});var Oo=a(le);Jn=r(Oo,"LI",{});var Rc=a(Jn);nl=i(Rc,"Handle additional num_candidate axis. (batch_size, num_candidates, text)"),Rc.forEach(t),rl=c(Oo),Mt=r(Oo,"LI",{});var ra=a(Mt);al=i(ra,"Always pad the sequences to "),An=r(ra,"EM",{});var Mc=a(An);sl=i(Mc,"max_length"),Mc.forEach(t),ll=i(ra,"."),ra.forEach(t),il=c(Oo),$t=r(Oo,"LI",{});var aa=a($t);dl=i(aa,"Must specify "),qn=r(aa,"EM",{});var $c=a(qn);cl=i($c,"max_length"),$c.forEach(t),ml=i(aa," in order to stack packs of candidates into a batch."),aa.forEach(t),Oo.forEach(t),pl=c(K),Et=r(K,"UL",{});var sa=a(Et);Ao=r(sa,"LI",{});var Fd=a(Ao);hl=i(Fd,"single sequence: "),Un=r(Fd,"CODE",{});var Ec=a(Un);fl=i(Ec,"[CLS] X [SEP]"),Ec.forEach(t),Fd.forEach(t),ul=c(sa),qo=r(sa,"LI",{});var Wd=a(qo);gl=i(Wd,"pair of sequences: "),In=r(Wd,"CODE",{});var zc=a(In);_l=i(zc,"[CLS] A [SEP] B [SEP]"),zc.forEach(t),Wd.forEach(t),sa.forEach(t),bl=c(K),y(xe.$$.fragment,K),K.forEach(t),j.forEach(t),Ir=c(o),ie=r(o,"H2",{class:!0});var la=a(ie);je=r(la,"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),vl=c(la),Fn=r(la,"SPAN",{});var Jc=a(Fn);kl=i(Jc,"RealmTokenizerFast"),Jc.forEach(t),la.forEach(t),Zr=c(o),q=r(o,"DIV",{class:!0});var ee=a(q);y(xt.$$.fragment,ee),yl=c(ee),jt=r(ee,"P",{});var ia=a(jt);wl=i(ia,"Construct a \u201Cfast\u201D REALM tokenizer (backed by HuggingFace\u2019s "),Wn=r(ia,"EM",{});var Ac=a(Wn);Tl=i(Ac,"tokenizers"),Ac.forEach(t),Rl=i(ia," library). Based on WordPiece."),ia.forEach(t),Ml=c(ee),Je=r(ee,"P",{});var Tr=a(Je);Uo=r(Tr,"A",{href:!0});var qc=a(Uo);$l=i(qc,"RealmTokenizerFast"),qc.forEach(t),El=i(Tr," is identical to "),Io=r(Tr,"A",{href:!0});var Uc=a(Io);zl=i(Uc,"BertTokenizerFast"),Uc.forEach(t),xl=i(Tr,` and runs end-to-end tokenization: punctuation
splitting and wordpiece.`),Tr.forEach(t),jl=c(ee),Jt=r(ee,"P",{});var da=a(Jt);Jl=i(da,"This tokenizer inherits from "),Zo=r(da,"A",{href:!0});var Ic=a(Zo);Al=i(Ic,"PreTrainedTokenizerFast"),Ic.forEach(t),ql=i(da,` which contains most of the main methods. Users should
refer to this superclass for more information regarding those methods.`),da.forEach(t),Ul=c(ee),I=r(ee,"DIV",{class:!0});var te=a(I);y(At.$$.fragment,te),Il=c(te),qt=r(te,"P",{});var ca=a(qt);Zl=i(ca,"Encode a batch of text or text pair. This method is similar to regular "),Cn=r(ca,"STRONG",{});var Zc=a(Cn);Fl=i(Zc,"call"),Zc.forEach(t),Wl=i(ca,` method but has the following
differences:`),ca.forEach(t),Cl=c(te),de=r(te,"OL",{});var Qo=a(de);Sn=r(Qo,"LI",{});var Fc=a(Sn);Sl=i(Fc,"Handle additional num_candidate axis. (batch_size, num_candidates, text)"),Fc.forEach(t),Ll=c(Qo),Ut=r(Qo,"LI",{});var ma=a(Ut);Nl=i(ma,"Always pad the sequences to "),Ln=r(ma,"EM",{});var Wc=a(Ln);Vl=i(Wc,"max_length"),Wc.forEach(t),Pl=i(ma,"."),ma.forEach(t),Bl=c(Qo),It=r(Qo,"LI",{});var pa=a(It);Gl=i(pa,"Must specify "),Nn=r(pa,"EM",{});var Cc=a(Nn);Xl=i(Cc,"max_length"),Cc.forEach(t),Ol=i(pa," in order to stack packs of candidates into a batch."),pa.forEach(t),Qo.forEach(t),Ql=c(te),Zt=r(te,"UL",{});var ha=a(Zt);Fo=r(ha,"LI",{});var Cd=a(Fo);Dl=i(Cd,"single sequence: "),Vn=r(Cd,"CODE",{});var Sc=a(Vn);Hl=i(Sc,"[CLS] X [SEP]"),Sc.forEach(t),Cd.forEach(t),Yl=c(ha),Wo=r(ha,"LI",{});var Sd=a(Wo);Kl=i(Sd,"pair of sequences: "),Pn=r(Sd,"CODE",{});var Lc=a(Pn);ei=i(Lc,"[CLS] A [SEP] B [SEP]"),Lc.forEach(t),Sd.forEach(t),ha.forEach(t),ti=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 Vc=a(Bn);y(Ft.$$.fragment,Vc),Vc.forEach(t),Nc.forEach(t),oi=c(fa),Gn=r(fa,"SPAN",{});var Pc=a(Gn);ni=i(Pc,"RealmRetriever"),Pc.forEach(t),fa.forEach(t),Wr=c(o),P=r(o,"DIV",{class:!0});var Do=a(P);y(Wt.$$.fragment,Do),ri=c(Do),Xn=r(Do,"P",{});var Bc=a(Xn);ai=i(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),si=c(Do),Ue=r(Do,"DIV",{class:!0});var ua=a(Ue);y(Ct.$$.fragment,ua),li=c(ua),On=r(ua,"P",{});var Gc=a(On);ii=i(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(St.$$.fragment,Oc),Oc.forEach(t),Xc.forEach(t),di=c(ga),Dn=r(ga,"SPAN",{});var Qc=a(Dn);ci=i(Qc,"RealmEmbedder"),Qc.forEach(t),ga.forEach(t),Sr=c(o),B=r(o,"DIV",{class:!0});var Ho=a(B);y(Lt.$$.fragment,Ho),mi=c(Ho),Nt=r(Ho,"P",{});var _a=a(Nt);pi=i(_a,`The embedder of REALM outputting projected score that will be used to calculate relevance score.
This model is a PyTorch `),Vt=r(_a,"A",{href:!0,rel:!0});var Dc=a(Vt);hi=i(Dc,"torch.nn.Module"),Dc.forEach(t),fi=i(_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),ui=c(Ho),W=r(Ho,"DIV",{class:!0});var Ye=a(W);y(Pt.$$.fragment,Ye),gi=c(Ye),pe=r(Ye,"P",{});var Yo=a(pe);_i=i(Yo,"The "),Co=r(Yo,"A",{href:!0});var Hc=a(Co);bi=i(Hc,"RealmEmbedder"),Hc.forEach(t),vi=i(Yo," forward method, overrides the "),Hn=r(Yo,"CODE",{});var Yc=a(Hn);ki=i(Yc,"__call__"),Yc.forEach(t),yi=i(Yo," special method."),Yo.forEach(t),wi=c(Ye),y(Ze.$$.fragment,Ye),Ti=c(Ye),y(Fe.$$.fragment,Ye),Ye.forEach(t),Ho.forEach(t),Lr=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),Ri=c(ba),Kn=r(ba,"SPAN",{});var tm=a(Kn);Mi=i(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),$i=c(Ko),Xt=r(Ko,"P",{});var va=a(Xt);Ei=i(va,`The scorer of REALM outputting relevance scores representing the score of document candidates (before softmax).
This model is a PyTorch `),Ot=r(va,"A",{href:!0,rel:!0});var om=a(Ot);zi=i(om,"torch.nn.Module"),om.forEach(t),xi=i(va,` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),va.forEach(t),ji=c(Ko),C=r(Ko,"DIV",{class:!0});var Ke=a(C);y(Qt.$$.fragment,Ke),Ji=c(Ke),fe=r(Ke,"P",{});var en=a(fe);Ai=i(en,"The "),So=r(en,"A",{href:!0});var nm=a(So);qi=i(nm,"RealmScorer"),nm.forEach(t),Ui=i(en," forward method, overrides the "),er=r(en,"CODE",{});var rm=a(er);Ii=i(rm,"__call__"),rm.forEach(t),Zi=i(en," special method."),en.forEach(t),Fi=c(Ke),y(Ce.$$.fragment,Ke),Wi=c(Ke),y(Se.$$.fragment,Ke),Ke.forEach(t),Ko.forEach(t),Vr=c(o),ue=r(o,"H2",{class:!0});var ka=a(ue);Le=r(ka,"A",{id:!0,class:!0,href:!0});var am=a(Le);tr=r(am,"SPAN",{});var sm=a(tr);y(Dt.$$.fragment,sm),sm.forEach(t),am.forEach(t),Ci=c(ka),or=r(ka,"SPAN",{});var lm=a(or);Si=i(lm,"RealmKnowledgeAugEncoder"),lm.forEach(t),ka.forEach(t),Pr=c(o),X=r(o,"DIV",{class:!0});var tn=a(X);y(Ht.$$.fragment,tn),Li=c(tn),Yt=r(tn,"P",{});var ya=a(Yt);Ni=i(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 im=a(Kt);Vi=i(im,"torch.nn.Module"),im.forEach(t),Pi=i(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),Bi=c(tn),S=r(tn,"DIV",{class:!0});var et=a(S);y(eo.$$.fragment,et),Gi=c(et),ge=r(et,"P",{});var on=a(ge);Xi=i(on,"The "),Lo=r(on,"A",{href:!0});var dm=a(Lo);Oi=i(dm,"RealmKnowledgeAugEncoder"),dm.forEach(t),Qi=i(on," forward method, overrides the "),nr=r(on,"CODE",{});var cm=a(nr);Di=i(cm,"__call__"),cm.forEach(t),Hi=i(on," special method."),on.forEach(t),Yi=c(et),y(Ne.$$.fragment,et),Ki=c(et),y(Ve.$$.fragment,et),et.forEach(t),tn.forEach(t),Br=c(o),_e=r(o,"H2",{class:!0});var wa=a(_e);Pe=r(wa,"A",{id:!0,class:!0,href:!0});var mm=a(Pe);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=i(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=i(Ta,`The reader of REALM.
This model is a PyTorch `),ro=r(Ta,"A",{href:!0,rel:!0});var fm=a(ro);rd=i(fm,"torch.nn.Module"),fm.forEach(t),ad=i(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),ld=c(rn),be=r(rn,"P",{});var an=a(be);id=i(an,"The "),No=r(an,"A",{href:!0});var um=a(No);dd=i(um,"RealmReader"),um.forEach(t),cd=i(an," forward method, overrides the "),sr=r(an,"CODE",{});var gm=a(sr);md=i(gm,"__call__"),gm.forEach(t),pd=i(an," special method."),an.forEach(t),hd=c(rn),y(Be.$$.fragment,rn),rn.forEach(t),nn.forEach(t),Xr=c(o),ve=r(o,"H2",{class:!0});var Ra=a(ve);Ge=r(Ra,"A",{id:!0,class:!0,href:!0});var _m=a(Ge);lr=r(_m,"SPAN",{});var bm=a(lr);y(so.$$.fragment,bm),bm.forEach(t),_m.forEach(t),fd=c(Ra),ir=r(Ra,"SPAN",{});var vm=a(ir);ud=i(vm,"RealmForOpenQA"),vm.forEach(t),Ra.forEach(t),Or=c(o),Z=r(o,"DIV",{class:!0});var tt=a(Z);y(lo.$$.fragment,tt),gd=c(tt),Xe=r(tt,"P",{});var Rr=a(Xe);dr=r(Rr,"CODE",{});var km=a(dr);_d=i(km,"RealmForOpenQA"),km.forEach(t),bd=i(Rr,` for end-to-end open domain question answering.
This model is a PyTorch `),io=r(Rr,"A",{href:!0,rel:!0});var ym=a(io);vd=i(ym,"torch.nn.Module"),ym.forEach(t),kd=i(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=i($a,"Send "),cr=r($a,"CODE",{});var wm=a(cr);Rd=i(wm,"self.block_emb"),wm.forEach(t),Md=i($a," to a specific device."),$a.forEach(t),Ma.forEach(t),$d=c(tt),L=r(tt,"DIV",{class:!0});var ot=a(L);y(po.$$.fragment,ot),Ed=c(ot),ke=r(ot,"P",{});var sn=a(ke);zd=i(sn,"The "),Vo=r(sn,"A",{href:!0});var Tm=a(Vo);xd=i(Tm,"RealmForOpenQA"),Tm.forEach(t),jd=i(sn," forward method, overrides the "),mr=r(sn,"CODE",{});var Rm=a(mr);Jd=i(Rm,"__call__"),Rm.forEach(t),Ad=i(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(Pm)),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(lt,"href","https://arxiv.org/abs/2002.08909"),p(lt,"rel","nofollow"),p(it,"href","https://huggingface.co/qqaatw"),p(it,"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/v4.30.0/en/model_doc/realm#transformers.RealmEmbedder"),p(vo,"href","/docs/transformers/v4.30.0/en/model_doc/realm#transformers.RealmScorer"),p(ko,"href","/docs/transformers/v4.30.0/en/model_doc/realm#transformers.RealmKnowledgeAugEncoder"),p(yo,"href","/docs/transformers/v4.30.0/en/model_doc/realm#transformers.RealmRetriever"),p(wo,"href","/docs/transformers/v4.30.0/en/model_doc/realm#transformers.RealmReader"),p(To,"href","/docs/transformers/v4.30.0/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/v4.30.0/en/main_classes/configuration#transformers.PretrainedConfig"),p(Mo,"href","/docs/transformers/v4.30.0/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/v4.30.0/en/model_doc/realm#transformers.RealmTokenizer"),p(Eo,"href","/docs/transformers/v4.30.0/en/model_doc/bert#transformers.BertTokenizer"),p(zo,"href","/docs/transformers/v4.30.0/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(ie,"class","relative group"),p(Uo,"href","/docs/transformers/v4.30.0/en/model_doc/realm#transformers.RealmTokenizerFast"),p(Io,"href","/docs/transformers/v4.30.0/en/model_doc/bert#transformers.BertTokenizerFast"),p(Zo,"href","/docs/transformers/v4.30.0/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(P,"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(Vt,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),p(Vt,"rel","nofollow"),p(Co,"href","/docs/transformers/v4.30.0/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(So,"href","/docs/transformers/v4.30.0/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(Le,"id","transformers.RealmKnowledgeAugEncoder"),p(Le,"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(Le,"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(Lo,"href","/docs/transformers/v4.30.0/en/model_doc/realm#transformers.RealmKnowledgeAugEncoder"),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(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(Pe,"id","transformers.RealmReader"),p(Pe,"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(Pe,"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/v4.30.0/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(ve,"class","relative group"),p(io,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),p(io,"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(Vo,"href","/docs/transformers/v4.30.0/en/model_doc/realm#transformers.RealmForOpenQA"),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(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,v,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,lt),e(lt,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,it),e(it,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,Sa),e(ne,pn),e(pn,La),_(o,Ar,g),_(o,J,g),w(mt,J,null),e(J,Na),e(J,hn),e(hn,Va),e(J,Pa),e(J,A),e(A,fn),e(fn,bo),e(bo,Ba),e(A,Ga),e(A,un),e(un,vo),e(vo,Xa),e(A,Oa),e(A,gn),e(gn,ko),e(ko,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,vn),e(vn,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,ls),e(re,Ro),e(Ro,is),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,kn),w(ft,kn,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,vs),e($e,Eo),e(Eo,ks),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(vt,Ee,null),e(Ee,Zs),e(Ee,kt),e(kt,Fs),e(kt,$n),e($n,Ws),e(kt,Cs),e(E,Ss),e(E,F),w(yt,F,null),e(F,Ls),e(F,En),e(En,Ns),e(F,Vs),w(ze,F,null),e(F,Ps),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,el),e(Rt,tl),e(U,ol),e(U,le),e(le,Jn),e(Jn,nl),e(le,rl),e(le,Mt),e(Mt,al),e(Mt,An),e(An,sl),e(Mt,ll),e(le,il),e(le,$t),e($t,dl),e($t,qn),e(qn,cl),e($t,ml),e(U,pl),e(U,Et),e(Et,Ao),e(Ao,hl),e(Ao,Un),e(Un,fl),e(Et,ul),e(Et,qo),e(qo,gl),e(qo,In),e(In,_l),e(U,bl),w(xe,U,null),_(o,Ir,g),_(o,ie,g),e(ie,je),e(je,Zn),w(zt,Zn,null),e(ie,vl),e(ie,Fn),e(Fn,kl),_(o,Zr,g),_(o,q,g),w(xt,q,null),e(q,yl),e(q,jt),e(jt,wl),e(jt,Wn),e(Wn,Tl),e(jt,Rl),e(q,Ml),e(q,Je),e(Je,Uo),e(Uo,$l),e(Je,El),e(Je,Io),e(Io,zl),e(Je,xl),e(q,jl),e(q,Jt),e(Jt,Jl),e(Jt,Zo),e(Zo,Al),e(Jt,ql),e(q,Ul),e(q,I),w(At,I,null),e(I,Il),e(I,qt),e(qt,Zl),e(qt,Cn),e(Cn,Fl),e(qt,Wl),e(I,Cl),e(I,de),e(de,Sn),e(Sn,Sl),e(de,Ll),e(de,Ut),e(Ut,Nl),e(Ut,Ln),e(Ln,Vl),e(Ut,Pl),e(de,Bl),e(de,It),e(It,Gl),e(It,Nn),e(Nn,Xl),e(It,Ol),e(I,Ql),e(I,Zt),e(Zt,Fo),e(Fo,Dl),e(Fo,Vn),e(Vn,Hl),e(Zt,Yl),e(Zt,Wo),e(Wo,Kl),e(Wo,Pn),e(Pn,ei),e(I,ti),w(Ae,I,null),_(o,Fr,g),_(o,ce,g),e(ce,qe),e(qe,Bn),w(Ft,Bn,null),e(ce,oi),e(ce,Gn),e(Gn,ni),_(o,Wr,g),_(o,P,g),w(Wt,P,null),e(P,ri),e(P,Xn),e(Xn,ai),e(P,si),e(P,Ue),w(Ct,Ue,null),e(Ue,li),e(Ue,On),e(On,ii),_(o,Cr,g),_(o,me,g),e(me,Ie),e(Ie,Qn),w(St,Qn,null),e(me,di),e(me,Dn),e(Dn,ci),_(o,Sr,g),_(o,B,g),w(Lt,B,null),e(B,mi),e(B,Nt),e(Nt,pi),e(Nt,Vt),e(Vt,hi),e(Nt,fi),e(B,ui),e(B,W),w(Pt,W,null),e(W,gi),e(W,pe),e(pe,_i),e(pe,Co),e(Co,bi),e(pe,vi),e(pe,Hn),e(Hn,ki),e(pe,yi),e(W,wi),w(Ze,W,null),e(W,Ti),w(Fe,W,null),_(o,Lr,g),_(o,he,g),e(he,We),e(We,Yn),w(Bt,Yn,null),e(he,Ri),e(he,Kn),e(Kn,Mi),_(o,Nr,g),_(o,G,g),w(Gt,G,null),e(G,$i),e(G,Xt),e(Xt,Ei),e(Xt,Ot),e(Ot,zi),e(Xt,xi),e(G,ji),e(G,C),w(Qt,C,null),e(C,Ji),e(C,fe),e(fe,Ai),e(fe,So),e(So,qi),e(fe,Ui),e(fe,er),e(er,Ii),e(fe,Zi),e(C,Fi),w(Ce,C,null),e(C,Wi),w(Se,C,null),_(o,Vr,g),_(o,ue,g),e(ue,Le),e(Le,tr),w(Dt,tr,null),e(ue,Ci),e(ue,or),e(or,Si),_(o,Pr,g),_(o,X,g),w(Ht,X,null),e(X,Li),e(X,Yt),e(Yt,Ni),e(Yt,Kt),e(Kt,Vi),e(Yt,Pi),e(X,Bi),e(X,S),w(eo,S,null),e(S,Gi),e(S,ge),e(ge,Xi),e(ge,Lo),e(Lo,Oi),e(ge,Qi),e(ge,nr),e(nr,Di),e(ge,Hi),e(S,Yi),w(Ne,S,null),e(S,Ki),w(Ve,S,null),_(o,Br,g),_(o,_e,g),e(_e,Pe),e(Pe,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,ld),e(Y,be),e(be,id),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,ve,g),e(ve,Ge),e(Ge,lr),w(so,lr,null),e(ve,fd),e(ve,ir),e(ir,ud),_(o,Or,g),_(o,Z,g),w(lo,Z,null),e(Z,gd),e(Z,Xe),e(Xe,dr),e(dr,_d),e(Xe,bd),e(Xe,io),e(io,vd),e(Xe,kd),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,L),w(po,L,null),e(L,Ed),e(L,ke),e(ke,zd),e(ke,Vo),e(Vo,xd),e(ke,jd),e(ke,mr),e(mr,Jd),e(ke,Ad),e(L,qd),w(Qe,L,null),e(L,Ud),w(De,L,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}),Se.$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}),Ve.$set(br);const vr={};g&2&&(vr.$$scope={dirty:g,ctx:o}),Be.$set(vr);const kr={};g&2&&(kr.$$scope={dirty:g,ctx:o}),Qe.$set(kr);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(vt.$$.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(St.$$.fragment,o),T(Lt.$$.fragment,o),T(Pt.$$.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(Se.$$.fragment,o),T(Dt.$$.fragment,o),T(Ht.$$.fragment,o),T(eo.$$.fragment,o),T(Ne.$$.fragment,o),T(Ve.$$.fragment,o),T(to.$$.fragment,o),T(oo.$$.fragment,o),T(ao.$$.fragment,o),T(Be.$$.fragment,o),T(so.$$.fragment,o),T(lo.$$.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(vt.$$.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(St.$$.fragment,o),R(Lt.$$.fragment,o),R(Pt.$$.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(Se.$$.fragment,o),R(Dt.$$.fragment,o),R(Ht.$$.fragment,o),R(eo.$$.fragment,o),R(Ne.$$.fragment,o),R(Ve.$$.fragment,o),R(to.$$.fragment,o),R(oo.$$.fragment,o),R(ao.$$.fragment,o),R(Be.$$.fragment,o),R(so.$$.fragment,o),R(lo.$$.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(v),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(vt),M(yt),M(ze),M(wt),M(Tt),M(xe),o&&t(Ir),o&&t(ie),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(P),M(Wt),M(Ct),o&&t(Cr),o&&t(me),M(St),o&&t(Sr),o&&t(B),M(Lt),M(Pt),M(Ze),M(Fe),o&&t(Lr),o&&t(he),M(Bt),o&&t(Nr),o&&t(G),M(Gt),M(Qt),M(Ce),M(Se),o&&t(Vr),o&&t(ue),M(Dt),o&&t(Pr),o&&t(X),M(Ht),M(eo),M(Ne),M(Ve),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(ve),M(so),o&&t(Or),o&&t(Z),M(lo),M(co),M(po),M(Qe),M(De)}}}const Pm={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,Vm,Em,{})}}export{Ym as default,Pm as metadata};
