import{S as FT,i as xT,s as jT,e as s,k as p,w as b,t as o,M as JT,c as a,d as t,m as h,a as d,x as y,h as n,b as l,N as GT,G as e,g as v,y as w,q as M,o as R,B as k,v as zT,L as on}from"../../chunks/vendor-hf-doc-builder.js";import{T as ue}from"../../chunks/Tip-hf-doc-builder.js";import{D as Z}from"../../chunks/Docstring-hf-doc-builder.js";import{C as nn}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as ge}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as tn}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";function UT(F){let c,T,u,g,_;return g=new nn({props:{code:"JTIzJTIwVG8lMjBsb2FkJTIwdGhlJTIwZGVmYXVsdCUyMCUyMndpa2lfZHByJTIyJTIwZGF0YXNldCUyMHdpdGglMjAyMU0lMjBwYXNzYWdlcyUyMGZyb20lMjB3aWtpcGVkaWElMjAoaW5kZXglMjBuYW1lJTIwaXMlMjAnY29tcHJlc3NlZCclMjBvciUyMCdleGFjdCcpJTBBZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFJhZ1JldHJpZXZlciUwQSUwQXJldHJpZXZlciUyMCUzRCUyMFJhZ1JldHJpZXZlci5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyZmFjZWJvb2slMkZkcHItY3R4X2VuY29kZXItc2luZ2xlLW5xLWJhc2UlMjIlMkMlMjBkYXRhc2V0JTNEJTIyd2lraV9kcHIlMjIlMkMlMjBpbmRleF9uYW1lJTNEJTIyY29tcHJlc3NlZCUyMiUwQSklMEElMEElMjMlMjBUbyUyMGxvYWQlMjB5b3VyJTIwb3duJTIwaW5kZXhlZCUyMGRhdGFzZXQlMjBidWlsdCUyMHdpdGglMjB0aGUlMjBkYXRhc2V0cyUyMGxpYnJhcnkuJTIwTW9yZSUyMGluZm8lMjBvbiUyMGhvdyUyMHRvJTIwYnVpbGQlMjB0aGUlMjBpbmRleGVkJTIwZGF0YXNldCUyMGluJTIwZXhhbXBsZXMlMkZyYWclMkZ1c2Vfb3duX2tub3dsZWRnZV9kYXRhc2V0LnB5JTBBZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFJhZ1JldHJpZXZlciUwQSUwQWRhdGFzZXQlMjAlM0QlMjAoJTBBJTIwJTIwJTIwJTIwLi4uJTBBKSUyMCUyMCUyMyUyMGRhdGFzZXQlMjBtdXN0JTIwYmUlMjBhJTIwZGF0YXNldHMuRGF0YXNldHMlMjBvYmplY3QlMjB3aXRoJTIwY29sdW1ucyUyMCUyMnRpdGxlJTIyJTJDJTIwJTIydGV4dCUyMiUyMGFuZCUyMCUyMmVtYmVkZGluZ3MlMjIlMkMlMjBhbmQlMjBpdCUyMG11c3QlMjBoYXZlJTIwYSUyMGZhaXNzJTIwaW5kZXglMEFyZXRyaWV2ZXIlMjAlM0QlMjBSYWdSZXRyaWV2ZXIuZnJvbV9wcmV0cmFpbmVkKCUyMmZhY2Vib29rJTJGZHByLWN0eF9lbmNvZGVyLXNpbmdsZS1ucS1iYXNlJTIyJTJDJTIwaW5kZXhlZF9kYXRhc2V0JTNEZGF0YXNldCklMEElMEElMjMlMjBUbyUyMGxvYWQlMjB5b3VyJTIwb3duJTIwaW5kZXhlZCUyMGRhdGFzZXQlMjBidWlsdCUyMHdpdGglMjB0aGUlMjBkYXRhc2V0cyUyMGxpYnJhcnklMjB0aGF0JTIwd2FzJTIwc2F2ZWQlMjBvbiUyMGRpc2suJTIwTW9yZSUyMGluZm8lMjBpbiUyMGV4YW1wbGVzJTJGcmFnJTJGdXNlX293bl9rbm93bGVkZ2VfZGF0YXNldC5weSUwQWZyb20lMjB0cmFuc2Zvcm1lcnMlMjBpbXBvcnQlMjBSYWdSZXRyaWV2ZXIlMEElMEFkYXRhc2V0X3BhdGglMjAlM0QlMjAlMjJwYXRoJTJGdG8lMkZteSUyRmRhdGFzZXQlMjIlMjAlMjAlMjMlMjBkYXRhc2V0JTIwc2F2ZWQlMjB2aWElMjAqZGF0YXNldC5zYXZlX3RvX2Rpc2soLi4uKSolMEFpbmRleF9wYXRoJTIwJTNEJTIwJTIycGF0aCUyRnRvJTJGbXklMkZpbmRleC5mYWlzcyUyMiUyMCUyMCUyMyUyMGZhaXNzJTIwaW5kZXglMjBzYXZlZCUyMHZpYSUyMCpkYXRhc2V0LmdldF9pbmRleCglMjJlbWJlZGRpbmdzJTIyKS5zYXZlKC4uLikqJTBBcmV0cmlldmVyJTIwJTNEJTIwUmFnUmV0cmlldmVyLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJmYWNlYm9vayUyRmRwci1jdHhfZW5jb2Rlci1zaW5nbGUtbnEtYmFzZSUyMiUyQyUwQSUyMCUyMCUyMCUyMGluZGV4X25hbWUlM0QlMjJjdXN0b20lMjIlMkMlMEElMjAlMjAlMjAlMjBwYXNzYWdlc19wYXRoJTNEZGF0YXNldF9wYXRoJTJDJTBBJTIwJTIwJTIwJTIwaW5kZXhfcGF0aCUzRGluZGV4X3BhdGglMkMlMEEpJTBBJTBBJTIzJTIwVG8lMjBsb2FkJTIwdGhlJTIwbGVnYWN5JTIwaW5kZXglMjBidWlsdCUyMG9yaWdpbmFsbHklMjBmb3IlMjBSYWcncyUyMHBhcGVyJTBBZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFJhZ1JldHJpZXZlciUwQSUwQXJldHJpZXZlciUyMCUzRCUyMFJhZ1JldHJpZXZlci5mcm9tX3ByZXRyYWluZWQoJTIyZmFjZWJvb2slMkZkcHItY3R4X2VuY29kZXItc2luZ2xlLW5xLWJhc2UlMjIlMkMlMjBpbmRleF9uYW1lJTNEJTIybGVnYWN5JTIyKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># To load the default &quot;wiki_dpr&quot; dataset with 21M passages from wikipedia (index name is &#x27;compressed&#x27; or &#x27;exact&#x27;)</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> RagRetriever

<span class="hljs-meta">&gt;&gt;&gt; </span>retriever = RagRetriever.from_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;facebook/dpr-ctx_encoder-single-nq-base&quot;</span>, dataset=<span class="hljs-string">&quot;wiki_dpr&quot;</span>, index_name=<span class="hljs-string">&quot;compressed&quot;</span>
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># To load your own indexed dataset built with the datasets library. More info on how to build the indexed dataset in examples/rag/use_own_knowledge_dataset.py</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> RagRetriever

<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = (
<span class="hljs-meta">... </span>    ...
<span class="hljs-meta">... </span>)  <span class="hljs-comment"># dataset must be a datasets.Datasets object with columns &quot;title&quot;, &quot;text&quot; and &quot;embeddings&quot;, and it must have a faiss index</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>retriever = RagRetriever.from_pretrained(<span class="hljs-string">&quot;facebook/dpr-ctx_encoder-single-nq-base&quot;</span>, indexed_dataset=dataset)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># To load your own indexed dataset built with the datasets library that was saved on disk. More info in examples/rag/use_own_knowledge_dataset.py</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> RagRetriever

<span class="hljs-meta">&gt;&gt;&gt; </span>dataset_path = <span class="hljs-string">&quot;path/to/my/dataset&quot;</span>  <span class="hljs-comment"># dataset saved via *dataset.save_to_disk(...)*</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>index_path = <span class="hljs-string">&quot;path/to/my/index.faiss&quot;</span>  <span class="hljs-comment"># faiss index saved via *dataset.get_index(&quot;embeddings&quot;).save(...)*</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>retriever = RagRetriever.from_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;facebook/dpr-ctx_encoder-single-nq-base&quot;</span>,
<span class="hljs-meta">... </span>    index_name=<span class="hljs-string">&quot;custom&quot;</span>,
<span class="hljs-meta">... </span>    passages_path=dataset_path,
<span class="hljs-meta">... </span>    index_path=index_path,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># To load the legacy index built originally for Rag&#x27;s paper</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> RagRetriever

<span class="hljs-meta">&gt;&gt;&gt; </span>retriever = RagRetriever.from_pretrained(<span class="hljs-string">&quot;facebook/dpr-ctx_encoder-single-nq-base&quot;</span>, index_name=<span class="hljs-string">&quot;legacy&quot;</span>)`}}),{c(){c=s("p"),T=o("Examples:"),u=p(),b(g.$$.fragment)},l(i){c=a(i,"P",{});var m=d(c);T=n(m,"Examples:"),m.forEach(t),u=h(i),y(g.$$.fragment,i)},m(i,m){v(i,c,m),e(c,T),v(i,u,m),w(g,i,m),_=!0},p:on,i(i){_||(M(g.$$.fragment,i),_=!0)},o(i){R(g.$$.fragment,i),_=!1},d(i){i&&t(c),i&&t(u),k(g,i)}}}function ET(F){let c,T,u,g,_;return{c(){c=s("p"),T=o("Although the recipe for forward pass needs to be defined within this function, one should call the "),u=s("code"),g=o("Module"),_=o(`
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(i){c=a(i,"P",{});var m=d(c);T=n(m,"Although the recipe for forward pass needs to be defined within this function, one should call the "),u=a(m,"CODE",{});var q=d(u);g=n(q,"Module"),q.forEach(t),_=n(m,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),m.forEach(t)},m(i,m){v(i,c,m),e(c,T),e(c,u),e(u,g),e(c,_)},d(i){i&&t(c)}}}function $T(F){let c,T,u,g,_;return{c(){c=s("p"),T=o("Although the recipe for forward pass needs to be defined within this function, one should call the "),u=s("code"),g=o("Module"),_=o(`
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(i){c=a(i,"P",{});var m=d(c);T=n(m,"Although the recipe for forward pass needs to be defined within this function, one should call the "),u=a(m,"CODE",{});var q=d(u);g=n(q,"Module"),q.forEach(t),_=n(m,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),m.forEach(t)},m(i,m){v(i,c,m),e(c,T),e(c,u),e(u,g),e(c,_)},d(i){i&&t(c)}}}function ZT(F){let c,T,u,g,_;return g=new nn({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBSYWdSZXRyaWV2ZXIlMkMlMjBSYWdNb2RlbCUwQWltcG9ydCUyMHRvcmNoJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIyZmFjZWJvb2slMkZyYWctdG9rZW4tYmFzZSUyMiklMEFyZXRyaWV2ZXIlMjAlM0QlMjBSYWdSZXRyaWV2ZXIuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMmZhY2Vib29rJTJGcmFnLXRva2VuLWJhc2UlMjIlMkMlMjBpbmRleF9uYW1lJTNEJTIyZXhhY3QlMjIlMkMlMjB1c2VfZHVtbXlfZGF0YXNldCUzRFRydWUlMEEpJTBBJTIzJTIwaW5pdGlhbGl6ZSUyMHdpdGglMjBSYWdSZXRyaWV2ZXIlMjB0byUyMGRvJTIwZXZlcnl0aGluZyUyMGluJTIwb25lJTIwZm9yd2FyZCUyMGNhbGwlMEFtb2RlbCUyMCUzRCUyMFJhZ01vZGVsLmZyb21fcHJldHJhaW5lZCglMjJmYWNlYm9vayUyRnJhZy10b2tlbi1iYXNlJTIyJTJDJTIwcmV0cmlldmVyJTNEcmV0cmlldmVyKSUwQSUwQWlucHV0cyUyMCUzRCUyMHRva2VuaXplciglMjJIb3clMjBtYW55JTIwcGVvcGxlJTIwbGl2ZSUyMGluJTIwUGFyaXMlM0YlMjIlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQW91dHB1dHMlMjAlM0QlMjBtb2RlbChpbnB1dF9pZHMlM0RpbnB1dHMlNUIlMjJpbnB1dF9pZHMlMjIlNUQp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, RagRetriever, RagModel
<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;facebook/rag-token-base&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>retriever = RagRetriever.from_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;facebook/rag-token-base&quot;</span>, index_name=<span class="hljs-string">&quot;exact&quot;</span>, use_dummy_dataset=<span class="hljs-literal">True</span>
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># initialize with RagRetriever to do everything in one forward call</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = RagModel.from_pretrained(<span class="hljs-string">&quot;facebook/rag-token-base&quot;</span>, retriever=retriever)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(<span class="hljs-string">&quot;How many people live in Paris?&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(input_ids=inputs[<span class="hljs-string">&quot;input_ids&quot;</span>])`}}),{c(){c=s("p"),T=o("Example:"),u=p(),b(g.$$.fragment)},l(i){c=a(i,"P",{});var m=d(c);T=n(m,"Example:"),m.forEach(t),u=h(i),y(g.$$.fragment,i)},m(i,m){v(i,c,m),e(c,T),v(i,u,m),w(g,i,m),_=!0},p:on,i(i){_||(M(g.$$.fragment,i),_=!0)},o(i){R(g.$$.fragment,i),_=!1},d(i){i&&t(c),i&&t(u),k(g,i)}}}function IT(F){let c,T,u,g,_;return{c(){c=s("p"),T=o("Although the recipe for forward pass needs to be defined within this function, one should call the "),u=s("code"),g=o("Module"),_=o(`
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(i){c=a(i,"P",{});var m=d(c);T=n(m,"Although the recipe for forward pass needs to be defined within this function, one should call the "),u=a(m,"CODE",{});var q=d(u);g=n(q,"Module"),q.forEach(t),_=n(m,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),m.forEach(t)},m(i,m){v(i,c,m),e(c,T),e(c,u),e(u,g),e(c,_)},d(i){i&&t(c)}}}function CT(F){let c,T,u,g,_;return{c(){c=s("p"),T=o("Although the recipe for forward pass needs to be defined within this function, one should call the "),u=s("code"),g=o("Module"),_=o(`
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(i){c=a(i,"P",{});var m=d(c);T=n(m,"Although the recipe for forward pass needs to be defined within this function, one should call the "),u=a(m,"CODE",{});var q=d(u);g=n(q,"Module"),q.forEach(t),_=n(m,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),m.forEach(t)},m(i,m){v(i,c,m),e(c,T),e(c,u),e(u,g),e(c,_)},d(i){i&&t(c)}}}function NT(F){let c,T,u,g,_;return g=new nn({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBSYWdSZXRyaWV2ZXIlMkMlMjBSYWdTZXF1ZW5jZUZvckdlbmVyYXRpb24lMEFpbXBvcnQlMjB0b3JjaCUwQSUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKCUyMmZhY2Vib29rJTJGcmFnLXNlcXVlbmNlLW5xJTIyKSUwQXJldHJpZXZlciUyMCUzRCUyMFJhZ1JldHJpZXZlci5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyZmFjZWJvb2slMkZyYWctc2VxdWVuY2UtbnElMjIlMkMlMjBpbmRleF9uYW1lJTNEJTIyZXhhY3QlMjIlMkMlMjB1c2VfZHVtbXlfZGF0YXNldCUzRFRydWUlMEEpJTBBJTIzJTIwaW5pdGlhbGl6ZSUyMHdpdGglMjBSYWdSZXRyaWV2ZXIlMjB0byUyMGRvJTIwZXZlcnl0aGluZyUyMGluJTIwb25lJTIwZm9yd2FyZCUyMGNhbGwlMEFtb2RlbCUyMCUzRCUyMFJhZ1NlcXVlbmNlRm9yR2VuZXJhdGlvbi5mcm9tX3ByZXRyYWluZWQoJTIyZmFjZWJvb2slMkZyYWctdG9rZW4tbnElMjIlMkMlMjByZXRyaWV2ZXIlM0RyZXRyaWV2ZXIpJTBBJTBBaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKCUyMkhvdyUyMG1hbnklMjBwZW9wbGUlMjBsaXZlJTIwaW4lMjBQYXJpcyUzRiUyMiUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpJTBBdGFyZ2V0cyUyMCUzRCUyMHRva2VuaXplcih0ZXh0X3RhcmdldCUzRCUyMkluJTIwUGFyaXMlMkMlMjB0aGVyZSUyMGFyZSUyMDEwJTIwbWlsbGlvbiUyMHBlb3BsZS4lMjIlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQWlucHV0X2lkcyUyMCUzRCUyMGlucHV0cyU1QiUyMmlucHV0X2lkcyUyMiU1RCUwQWxhYmVscyUyMCUzRCUyMHRhcmdldHMlNUIlMjJpbnB1dF9pZHMlMjIlNUQlMEFvdXRwdXRzJTIwJTNEJTIwbW9kZWwoaW5wdXRfaWRzJTNEaW5wdXRfaWRzJTJDJTIwbGFiZWxzJTNEbGFiZWxzKSUwQSUwQSUyMyUyMG9yJTIwdXNlJTIwcmV0cmlldmVyJTIwc2VwYXJhdGVseSUwQW1vZGVsJTIwJTNEJTIwUmFnU2VxdWVuY2VGb3JHZW5lcmF0aW9uLmZyb21fcHJldHJhaW5lZCglMjJmYWNlYm9vayUyRnJhZy1zZXF1ZW5jZS1ucSUyMiUyQyUyMHVzZV9kdW1teV9kYXRhc2V0JTNEVHJ1ZSklMEElMjMlMjAxLiUyMEVuY29kZSUwQXF1ZXN0aW9uX2hpZGRlbl9zdGF0ZXMlMjAlM0QlMjBtb2RlbC5xdWVzdGlvbl9lbmNvZGVyKGlucHV0X2lkcyklNUIwJTVEJTBBJTIzJTIwMi4lMjBSZXRyaWV2ZSUwQWRvY3NfZGljdCUyMCUzRCUyMHJldHJpZXZlcihpbnB1dF9pZHMubnVtcHkoKSUyQyUyMHF1ZXN0aW9uX2hpZGRlbl9zdGF0ZXMuZGV0YWNoKCkubnVtcHkoKSUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpJTBBZG9jX3Njb3JlcyUyMCUzRCUyMHRvcmNoLmJtbSglMEElMjAlMjAlMjAlMjBxdWVzdGlvbl9oaWRkZW5fc3RhdGVzLnVuc3F1ZWV6ZSgxKSUyQyUyMGRvY3NfZGljdCU1QiUyMnJldHJpZXZlZF9kb2NfZW1iZWRzJTIyJTVELmZsb2F0KCkudHJhbnNwb3NlKDElMkMlMjAyKSUwQSkuc3F1ZWV6ZSgxKSUwQSUyMyUyMDMuJTIwRm9yd2FyZCUyMHRvJTIwZ2VuZXJhdG9yJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsKCUwQSUyMCUyMCUyMCUyMGNvbnRleHRfaW5wdXRfaWRzJTNEZG9jc19kaWN0JTVCJTIyY29udGV4dF9pbnB1dF9pZHMlMjIlNUQlMkMlMEElMjAlMjAlMjAlMjBjb250ZXh0X2F0dGVudGlvbl9tYXNrJTNEZG9jc19kaWN0JTVCJTIyY29udGV4dF9hdHRlbnRpb25fbWFzayUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMGRvY19zY29yZXMlM0Rkb2Nfc2NvcmVzJTJDJTBBJTIwJTIwJTIwJTIwZGVjb2Rlcl9pbnB1dF9pZHMlM0RsYWJlbHMlMkMlMEEp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, RagRetriever, RagSequenceForGeneration
<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;facebook/rag-sequence-nq&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>retriever = RagRetriever.from_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;facebook/rag-sequence-nq&quot;</span>, index_name=<span class="hljs-string">&quot;exact&quot;</span>, use_dummy_dataset=<span class="hljs-literal">True</span>
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># initialize with RagRetriever to do everything in one forward call</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = RagSequenceForGeneration.from_pretrained(<span class="hljs-string">&quot;facebook/rag-token-nq&quot;</span>, retriever=retriever)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(<span class="hljs-string">&quot;How many people live in Paris?&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>targets = tokenizer(text_target=<span class="hljs-string">&quot;In Paris, there are 10 million people.&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>input_ids = inputs[<span class="hljs-string">&quot;input_ids&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>labels = targets[<span class="hljs-string">&quot;input_ids&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(input_ids=input_ids, labels=labels)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># or use retriever separately</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = RagSequenceForGeneration.from_pretrained(<span class="hljs-string">&quot;facebook/rag-sequence-nq&quot;</span>, use_dummy_dataset=<span class="hljs-literal">True</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># 1. Encode</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>question_hidden_states = model.question_encoder(input_ids)[<span class="hljs-number">0</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># 2. Retrieve</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>docs_dict = retriever(input_ids.numpy(), question_hidden_states.detach().numpy(), return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>doc_scores = torch.bmm(
<span class="hljs-meta">... </span>    question_hidden_states.unsqueeze(<span class="hljs-number">1</span>), docs_dict[<span class="hljs-string">&quot;retrieved_doc_embeds&quot;</span>].<span class="hljs-built_in">float</span>().transpose(<span class="hljs-number">1</span>, <span class="hljs-number">2</span>)
<span class="hljs-meta">... </span>).squeeze(<span class="hljs-number">1</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># 3. Forward to generator</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(
<span class="hljs-meta">... </span>    context_input_ids=docs_dict[<span class="hljs-string">&quot;context_input_ids&quot;</span>],
<span class="hljs-meta">... </span>    context_attention_mask=docs_dict[<span class="hljs-string">&quot;context_attention_mask&quot;</span>],
<span class="hljs-meta">... </span>    doc_scores=doc_scores,
<span class="hljs-meta">... </span>    decoder_input_ids=labels,
<span class="hljs-meta">... </span>)`}}),{c(){c=s("p"),T=o("Example:"),u=p(),b(g.$$.fragment)},l(i){c=a(i,"P",{});var m=d(c);T=n(m,"Example:"),m.forEach(t),u=h(i),y(g.$$.fragment,i)},m(i,m){v(i,c,m),e(c,T),v(i,u,m),w(g,i,m),_=!0},p:on,i(i){_||(M(g.$$.fragment,i),_=!0)},o(i){R(g.$$.fragment,i),_=!1},d(i){i&&t(c),i&&t(u),k(g,i)}}}function AT(F){let c,T,u,g,_;return{c(){c=s("p"),T=o("Although the recipe for forward pass needs to be defined within this function, one should call the "),u=s("code"),g=o("Module"),_=o(`
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(i){c=a(i,"P",{});var m=d(c);T=n(m,"Although the recipe for forward pass needs to be defined within this function, one should call the "),u=a(m,"CODE",{});var q=d(u);g=n(q,"Module"),q.forEach(t),_=n(m,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),m.forEach(t)},m(i,m){v(i,c,m),e(c,T),e(c,u),e(u,g),e(c,_)},d(i){i&&t(c)}}}function WT(F){let c,T,u,g,_;return{c(){c=s("p"),T=o("Although the recipe for forward pass needs to be defined within this function, one should call the "),u=s("code"),g=o("Module"),_=o(`
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(i){c=a(i,"P",{});var m=d(c);T=n(m,"Although the recipe for forward pass needs to be defined within this function, one should call the "),u=a(m,"CODE",{});var q=d(u);g=n(q,"Module"),q.forEach(t),_=n(m,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),m.forEach(t)},m(i,m){v(i,c,m),e(c,T),e(c,u),e(u,g),e(c,_)},d(i){i&&t(c)}}}function XT(F){let c,T,u,g,_;return g=new nn({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBSYWdSZXRyaWV2ZXIlMkMlMjBSYWdUb2tlbkZvckdlbmVyYXRpb24lMEFpbXBvcnQlMjB0b3JjaCUwQSUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKCUyMmZhY2Vib29rJTJGcmFnLXRva2VuLW5xJTIyKSUwQXJldHJpZXZlciUyMCUzRCUyMFJhZ1JldHJpZXZlci5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyZmFjZWJvb2slMkZyYWctdG9rZW4tbnElMjIlMkMlMjBpbmRleF9uYW1lJTNEJTIyZXhhY3QlMjIlMkMlMjB1c2VfZHVtbXlfZGF0YXNldCUzRFRydWUlMEEpJTBBJTIzJTIwaW5pdGlhbGl6ZSUyMHdpdGglMjBSYWdSZXRyaWV2ZXIlMjB0byUyMGRvJTIwZXZlcnl0aGluZyUyMGluJTIwb25lJTIwZm9yd2FyZCUyMGNhbGwlMEFtb2RlbCUyMCUzRCUyMFJhZ1Rva2VuRm9yR2VuZXJhdGlvbi5mcm9tX3ByZXRyYWluZWQoJTIyZmFjZWJvb2slMkZyYWctdG9rZW4tbnElMjIlMkMlMjByZXRyaWV2ZXIlM0RyZXRyaWV2ZXIpJTBBJTBBaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKCUyMkhvdyUyMG1hbnklMjBwZW9wbGUlMjBsaXZlJTIwaW4lMjBQYXJpcyUzRiUyMiUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpJTBBdGFyZ2V0cyUyMCUzRCUyMHRva2VuaXplcih0ZXh0X3RhcmdldCUzRCUyMkluJTIwUGFyaXMlMkMlMjB0aGVyZSUyMGFyZSUyMDEwJTIwbWlsbGlvbiUyMHBlb3BsZS4lMjIlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQWlucHV0X2lkcyUyMCUzRCUyMGlucHV0cyU1QiUyMmlucHV0X2lkcyUyMiU1RCUwQWxhYmVscyUyMCUzRCUyMHRhcmdldHMlNUIlMjJpbnB1dF9pZHMlMjIlNUQlMEFvdXRwdXRzJTIwJTNEJTIwbW9kZWwoaW5wdXRfaWRzJTNEaW5wdXRfaWRzJTJDJTIwbGFiZWxzJTNEbGFiZWxzKSUwQSUwQSUyMyUyMG9yJTIwdXNlJTIwcmV0cmlldmVyJTIwc2VwYXJhdGVseSUwQW1vZGVsJTIwJTNEJTIwUmFnVG9rZW5Gb3JHZW5lcmF0aW9uLmZyb21fcHJldHJhaW5lZCglMjJmYWNlYm9vayUyRnJhZy10b2tlbi1ucSUyMiUyQyUyMHVzZV9kdW1teV9kYXRhc2V0JTNEVHJ1ZSklMEElMjMlMjAxLiUyMEVuY29kZSUwQXF1ZXN0aW9uX2hpZGRlbl9zdGF0ZXMlMjAlM0QlMjBtb2RlbC5xdWVzdGlvbl9lbmNvZGVyKGlucHV0X2lkcyklNUIwJTVEJTBBJTIzJTIwMi4lMjBSZXRyaWV2ZSUwQWRvY3NfZGljdCUyMCUzRCUyMHJldHJpZXZlcihpbnB1dF9pZHMubnVtcHkoKSUyQyUyMHF1ZXN0aW9uX2hpZGRlbl9zdGF0ZXMuZGV0YWNoKCkubnVtcHkoKSUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpJTBBZG9jX3Njb3JlcyUyMCUzRCUyMHRvcmNoLmJtbSglMEElMjAlMjAlMjAlMjBxdWVzdGlvbl9oaWRkZW5fc3RhdGVzLnVuc3F1ZWV6ZSgxKSUyQyUyMGRvY3NfZGljdCU1QiUyMnJldHJpZXZlZF9kb2NfZW1iZWRzJTIyJTVELmZsb2F0KCkudHJhbnNwb3NlKDElMkMlMjAyKSUwQSkuc3F1ZWV6ZSgxKSUwQSUyMyUyMDMuJTIwRm9yd2FyZCUyMHRvJTIwZ2VuZXJhdG9yJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsKCUwQSUyMCUyMCUyMCUyMGNvbnRleHRfaW5wdXRfaWRzJTNEZG9jc19kaWN0JTVCJTIyY29udGV4dF9pbnB1dF9pZHMlMjIlNUQlMkMlMEElMjAlMjAlMjAlMjBjb250ZXh0X2F0dGVudGlvbl9tYXNrJTNEZG9jc19kaWN0JTVCJTIyY29udGV4dF9hdHRlbnRpb25fbWFzayUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMGRvY19zY29yZXMlM0Rkb2Nfc2NvcmVzJTJDJTBBJTIwJTIwJTIwJTIwZGVjb2Rlcl9pbnB1dF9pZHMlM0RsYWJlbHMlMkMlMEEpJTBBJTBBJTIzJTIwb3IlMjBkaXJlY3RseSUyMGdlbmVyYXRlJTBBZ2VuZXJhdGVkJTIwJTNEJTIwbW9kZWwuZ2VuZXJhdGUoJTBBJTIwJTIwJTIwJTIwY29udGV4dF9pbnB1dF9pZHMlM0Rkb2NzX2RpY3QlNUIlMjJjb250ZXh0X2lucHV0X2lkcyUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMGNvbnRleHRfYXR0ZW50aW9uX21hc2slM0Rkb2NzX2RpY3QlNUIlMjJjb250ZXh0X2F0dGVudGlvbl9tYXNrJTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwZG9jX3Njb3JlcyUzRGRvY19zY29yZXMlMkMlMEEpJTBBZ2VuZXJhdGVkX3N0cmluZyUyMCUzRCUyMHRva2VuaXplci5iYXRjaF9kZWNvZGUoZ2VuZXJhdGVkJTJDJTIwc2tpcF9zcGVjaWFsX3Rva2VucyUzRFRydWUp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, RagRetriever, RagTokenForGeneration
<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;facebook/rag-token-nq&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>retriever = RagRetriever.from_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;facebook/rag-token-nq&quot;</span>, index_name=<span class="hljs-string">&quot;exact&quot;</span>, use_dummy_dataset=<span class="hljs-literal">True</span>
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># initialize with RagRetriever to do everything in one forward call</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = RagTokenForGeneration.from_pretrained(<span class="hljs-string">&quot;facebook/rag-token-nq&quot;</span>, retriever=retriever)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(<span class="hljs-string">&quot;How many people live in Paris?&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>targets = tokenizer(text_target=<span class="hljs-string">&quot;In Paris, there are 10 million people.&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>input_ids = inputs[<span class="hljs-string">&quot;input_ids&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>labels = targets[<span class="hljs-string">&quot;input_ids&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(input_ids=input_ids, labels=labels)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># or use retriever separately</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = RagTokenForGeneration.from_pretrained(<span class="hljs-string">&quot;facebook/rag-token-nq&quot;</span>, use_dummy_dataset=<span class="hljs-literal">True</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># 1. Encode</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>question_hidden_states = model.question_encoder(input_ids)[<span class="hljs-number">0</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># 2. Retrieve</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>docs_dict = retriever(input_ids.numpy(), question_hidden_states.detach().numpy(), return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>doc_scores = torch.bmm(
<span class="hljs-meta">... </span>    question_hidden_states.unsqueeze(<span class="hljs-number">1</span>), docs_dict[<span class="hljs-string">&quot;retrieved_doc_embeds&quot;</span>].<span class="hljs-built_in">float</span>().transpose(<span class="hljs-number">1</span>, <span class="hljs-number">2</span>)
<span class="hljs-meta">... </span>).squeeze(<span class="hljs-number">1</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># 3. Forward to generator</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(
<span class="hljs-meta">... </span>    context_input_ids=docs_dict[<span class="hljs-string">&quot;context_input_ids&quot;</span>],
<span class="hljs-meta">... </span>    context_attention_mask=docs_dict[<span class="hljs-string">&quot;context_attention_mask&quot;</span>],
<span class="hljs-meta">... </span>    doc_scores=doc_scores,
<span class="hljs-meta">... </span>    decoder_input_ids=labels,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># or directly generate</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>generated = model.generate(
<span class="hljs-meta">... </span>    context_input_ids=docs_dict[<span class="hljs-string">&quot;context_input_ids&quot;</span>],
<span class="hljs-meta">... </span>    context_attention_mask=docs_dict[<span class="hljs-string">&quot;context_attention_mask&quot;</span>],
<span class="hljs-meta">... </span>    doc_scores=doc_scores,
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>generated_string = tokenizer.batch_decode(generated, skip_special_tokens=<span class="hljs-literal">True</span>)`}}),{c(){c=s("p"),T=o("Example:"),u=p(),b(g.$$.fragment)},l(i){c=a(i,"P",{});var m=d(c);T=n(m,"Example:"),m.forEach(t),u=h(i),y(g.$$.fragment,i)},m(i,m){v(i,c,m),e(c,T),v(i,u,m),w(g,i,m),_=!0},p:on,i(i){_||(M(g.$$.fragment,i),_=!0)},o(i){R(g.$$.fragment,i),_=!1},d(i){i&&t(c),i&&t(u),k(g,i)}}}function VT(F){let c,T,u,g,_;return{c(){c=s("p"),T=o("Although the recipe for forward pass needs to be defined within this function, one should call the "),u=s("code"),g=o("Module"),_=o(`
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(i){c=a(i,"P",{});var m=d(c);T=n(m,"Although the recipe for forward pass needs to be defined within this function, one should call the "),u=a(m,"CODE",{});var q=d(u);g=n(q,"Module"),q.forEach(t),_=n(m,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),m.forEach(t)},m(i,m){v(i,c,m),e(c,T),e(c,u),e(u,g),e(c,_)},d(i){i&&t(c)}}}function ST(F){let c,T,u,g,_;return{c(){c=s("p"),T=o("Although the recipe for forward pass needs to be defined within this function, one should call the "),u=s("code"),g=o("Module"),_=o(`
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(i){c=a(i,"P",{});var m=d(c);T=n(m,"Although the recipe for forward pass needs to be defined within this function, one should call the "),u=a(m,"CODE",{});var q=d(u);g=n(q,"Module"),q.forEach(t),_=n(m,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),m.forEach(t)},m(i,m){v(i,c,m),e(c,T),e(c,u),e(u,g),e(c,_)},d(i){i&&t(c)}}}function BT(F){let c,T,u,g,_;return g=new nn({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBSYWdSZXRyaWV2ZXIlMkMlMjBURlJhZ01vZGVsJTBBaW1wb3J0JTIwdG9yY2glMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJmYWNlYm9vayUyRnJhZy10b2tlbi1iYXNlJTIyKSUwQXJldHJpZXZlciUyMCUzRCUyMFJhZ1JldHJpZXZlci5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyZmFjZWJvb2slMkZyYWctdG9rZW4tYmFzZSUyMiUyQyUyMGluZGV4X25hbWUlM0QlMjJleGFjdCUyMiUyQyUyMHVzZV9kdW1teV9kYXRhc2V0JTNEVHJ1ZSUwQSklMEElMjMlMjBpbml0aWFsaXplJTIwd2l0aCUyMFJhZ1JldHJpZXZlciUyMHRvJTIwZG8lMjBldmVyeXRoaW5nJTIwaW4lMjBvbmUlMjBmb3J3YXJkJTIwY2FsbCUwQW1vZGVsJTIwJTNEJTIwVEZSYWdNb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIyZmFjZWJvb2slMkZyYWctdG9rZW4tYmFzZSUyMiUyQyUyMHJldHJpZXZlciUzRHJldHJpZXZlciUyQyUyMGZyb21fcHQlM0RUcnVlKSUwQSUwQWlucHV0X2RpY3QlMjAlM0QlMjB0b2tlbml6ZXIucHJlcGFyZV9zZXEyc2VxX2JhdGNoKCUwQSUyMCUyMCUyMCUyMCUyMkhvdyUyMG1hbnklMjBwZW9wbGUlMjBsaXZlJTIwaW4lMjBQYXJpcyUzRiUyMiUyQyUyMCUyMkluJTIwUGFyaXMlMkMlMjB0aGVyZSUyMGFyZSUyMDEwJTIwbWlsbGlvbiUyMHBlb3BsZS4lMjIlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnRmJTIyJTBBKSUwQWlucHV0X2lkcyUyMCUzRCUyMGlucHV0X2RpY3QlNUIlMjJpbnB1dF9pZHMlMjIlNUQlMEFvdXRwdXRzJTIwJTNEJTIwbW9kZWwoaW5wdXRfaWRzKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, RagRetriever, TFRagModel
<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;facebook/rag-token-base&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>retriever = RagRetriever.from_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;facebook/rag-token-base&quot;</span>, index_name=<span class="hljs-string">&quot;exact&quot;</span>, use_dummy_dataset=<span class="hljs-literal">True</span>
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># initialize with RagRetriever to do everything in one forward call</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFRagModel.from_pretrained(<span class="hljs-string">&quot;facebook/rag-token-base&quot;</span>, retriever=retriever, from_pt=<span class="hljs-literal">True</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>input_dict = tokenizer.prepare_seq2seq_batch(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;How many people live in Paris?&quot;</span>, <span class="hljs-string">&quot;In Paris, there are 10 million people.&quot;</span>, return_tensors=<span class="hljs-string">&quot;tf&quot;</span>
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>input_ids = input_dict[<span class="hljs-string">&quot;input_ids&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(input_ids)`}}),{c(){c=s("p"),T=o("Example:"),u=p(),b(g.$$.fragment)},l(i){c=a(i,"P",{});var m=d(c);T=n(m,"Example:"),m.forEach(t),u=h(i),y(g.$$.fragment,i)},m(i,m){v(i,c,m),e(c,T),v(i,u,m),w(g,i,m),_=!0},p:on,i(i){_||(M(g.$$.fragment,i),_=!0)},o(i){R(g.$$.fragment,i),_=!1},d(i){i&&t(c),i&&t(u),k(g,i)}}}function PT(F){let c,T,u,g,_;return{c(){c=s("p"),T=o("Although the recipe for forward pass needs to be defined within this function, one should call the "),u=s("code"),g=o("Module"),_=o(`
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(i){c=a(i,"P",{});var m=d(c);T=n(m,"Although the recipe for forward pass needs to be defined within this function, one should call the "),u=a(m,"CODE",{});var q=d(u);g=n(q,"Module"),q.forEach(t),_=n(m,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),m.forEach(t)},m(i,m){v(i,c,m),e(c,T),e(c,u),e(u,g),e(c,_)},d(i){i&&t(c)}}}function HT(F){let c,T,u,g,_;return{c(){c=s("p"),T=o("Although the recipe for forward pass needs to be defined within this function, one should call the "),u=s("code"),g=o("Module"),_=o(`
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(i){c=a(i,"P",{});var m=d(c);T=n(m,"Although the recipe for forward pass needs to be defined within this function, one should call the "),u=a(m,"CODE",{});var q=d(u);g=n(q,"Module"),q.forEach(t),_=n(m,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),m.forEach(t)},m(i,m){v(i,c,m),e(c,T),e(c,u),e(u,g),e(c,_)},d(i){i&&t(c)}}}function LT(F){let c,T,u,g,_;return g=new nn({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBSYWdSZXRyaWV2ZXIlMkMlMjBURlJhZ1NlcXVlbmNlRm9yR2VuZXJhdGlvbiUwQSUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKCUyMmZhY2Vib29rJTJGcmFnLXNlcXVlbmNlLW5xJTIyKSUwQXJldHJpZXZlciUyMCUzRCUyMFJhZ1JldHJpZXZlci5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyZmFjZWJvb2slMkZyYWctc2VxdWVuY2UtbnElMjIlMkMlMjBpbmRleF9uYW1lJTNEJTIyZXhhY3QlMjIlMkMlMjB1c2VfZHVtbXlfZGF0YXNldCUzRFRydWUlMEEpJTBBJTIzJTIwaW5pdGlhbGl6ZSUyMHdpdGglMjBSYWdSZXRyaWV2ZXIlMjB0byUyMGRvJTIwZXZlcnl0aGluZyUyMGluJTIwb25lJTIwZm9yd2FyZCUyMGNhbGwlMEFtb2RlbCUyMCUzRCUyMFRGUmFnU2VxdWVuY2VGb3JHZW5lcmF0aW9uLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJmYWNlYm9vayUyRnJhZy1zZXF1ZW5jZS1ucSUyMiUyQyUyMHJldHJpZXZlciUzRHJldHJpZXZlciUyQyUyMGZyb21fcHQlM0RUcnVlJTBBKSUwQSUwQWlucHV0X2RpY3QlMjAlM0QlMjB0b2tlbml6ZXIucHJlcGFyZV9zZXEyc2VxX2JhdGNoKCUwQSUyMCUyMCUyMCUyMCUyMkhvdyUyMG1hbnklMjBwZW9wbGUlMjBsaXZlJTIwaW4lMjBQYXJpcyUzRiUyMiUyQyUyMCUyMkluJTIwUGFyaXMlMkMlMjB0aGVyZSUyMGFyZSUyMDEwJTIwbWlsbGlvbiUyMHBlb3BsZS4lMjIlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnRmJTIyJTBBKSUwQW91dHB1dHMlMjAlM0QlMjBtb2RlbChpbnB1dF9kaWN0JTJDJTIwb3V0cHV0X3JldHJpZXZlZCUzRFRydWUpJTBBJTBBJTIzJTIwb3IlMjB1c2UlMjByZXRyaWV2ZXIlMjBzZXBhcmF0ZWx5JTBBJTIzJTIwMS4lMjBFbmNvZGUlMEFpbnB1dF9pZHMlMjAlM0QlMjBpbnB1dF9kaWN0JTVCJTIyaW5wdXRfaWRzJTIyJTVEJTBBcXVlc3Rpb25faGlkZGVuX3N0YXRlcyUyMCUzRCUyMG1vZGVsLnF1ZXN0aW9uX2VuY29kZXIoaW5wdXRfaWRzKSU1QjAlNUQlMEElMjMlMjAyLiUyMFJldHJpZXZlJTBBZG9jc19kaWN0JTIwJTNEJTIwcmV0cmlldmVyKGlucHV0X2lkcy5udW1weSgpJTJDJTIwcXVlc3Rpb25faGlkZGVuX3N0YXRlcy5udW1weSgpJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJ0ZiUyMiklMEFkb2Nfc2NvcmVzJTIwJTNEJTIwdGYuc3F1ZWV6ZSglMEElMjAlMjAlMjAlMjB0Zi5tYXRtdWwoJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwdGYuZXhwYW5kX2RpbXMocXVlc3Rpb25faGlkZGVuX3N0YXRlcyUyQyUyMGF4aXMlM0QxKSUyQyUyMGRvY3NfZGljdCU1QiUyMnJldHJpZXZlZF9kb2NfZW1iZWRzJTIyJTVEJTJDJTIwdHJhbnNwb3NlX2IlM0RUcnVlJTBBJTIwJTIwJTIwJTIwKSUyQyUwQSUyMCUyMCUyMCUyMGF4aXMlM0QxJTJDJTBBKSUwQSUyMyUyMDMuJTIwRm9yd2FyZCUyMHRvJTIwZ2VuZXJhdG9yJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsKCUwQSUyMCUyMCUyMCUyMGlucHV0cyUzRE5vbmUlMkMlMEElMjAlMjAlMjAlMjBjb250ZXh0X2lucHV0X2lkcyUzRGRvY3NfZGljdCU1QiUyMmNvbnRleHRfaW5wdXRfaWRzJTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwY29udGV4dF9hdHRlbnRpb25fbWFzayUzRGRvY3NfZGljdCU1QiUyMmNvbnRleHRfYXR0ZW50aW9uX21hc2slMjIlNUQlMkMlMEElMjAlMjAlMjAlMjBkb2Nfc2NvcmVzJTNEZG9jX3Njb3JlcyUyQyUwQSUyMCUyMCUyMCUyMGRlY29kZXJfaW5wdXRfaWRzJTNEaW5wdXRfZGljdCU1QiUyMmxhYmVscyUyMiU1RCUyQyUwQSklMEElMEElMjMlMjBvciUyMGRpcmVjdGx5JTIwZ2VuZXJhdGUlMEFnZW5lcmF0ZWQlMjAlM0QlMjBtb2RlbC5nZW5lcmF0ZSglMEElMjAlMjAlMjAlMjBjb250ZXh0X2lucHV0X2lkcyUzRGRvY3NfZGljdCU1QiUyMmNvbnRleHRfaW5wdXRfaWRzJTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwY29udGV4dF9hdHRlbnRpb25fbWFzayUzRGRvY3NfZGljdCU1QiUyMmNvbnRleHRfYXR0ZW50aW9uX21hc2slMjIlNUQlMkMlMEElMjAlMjAlMjAlMjBkb2Nfc2NvcmVzJTNEZG9jX3Njb3JlcyUyQyUwQSklMEFnZW5lcmF0ZWRfc3RyaW5nJTIwJTNEJTIwdG9rZW5pemVyLmJhdGNoX2RlY29kZShnZW5lcmF0ZWQlMkMlMjBza2lwX3NwZWNpYWxfdG9rZW5zJTNEVHJ1ZSk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, RagRetriever, TFRagSequenceForGeneration

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;facebook/rag-sequence-nq&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>retriever = RagRetriever.from_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;facebook/rag-sequence-nq&quot;</span>, index_name=<span class="hljs-string">&quot;exact&quot;</span>, use_dummy_dataset=<span class="hljs-literal">True</span>
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># initialize with RagRetriever to do everything in one forward call</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFRagSequenceForGeneration.from_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;facebook/rag-sequence-nq&quot;</span>, retriever=retriever, from_pt=<span class="hljs-literal">True</span>
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>input_dict = tokenizer.prepare_seq2seq_batch(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;How many people live in Paris?&quot;</span>, <span class="hljs-string">&quot;In Paris, there are 10 million people.&quot;</span>, return_tensors=<span class="hljs-string">&quot;tf&quot;</span>
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(input_dict, output_retrieved=<span class="hljs-literal">True</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># or use retriever separately</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># 1. Encode</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>input_ids = input_dict[<span class="hljs-string">&quot;input_ids&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>question_hidden_states = model.question_encoder(input_ids)[<span class="hljs-number">0</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># 2. Retrieve</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>docs_dict = retriever(input_ids.numpy(), question_hidden_states.numpy(), return_tensors=<span class="hljs-string">&quot;tf&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>doc_scores = tf.squeeze(
<span class="hljs-meta">... </span>    tf.matmul(
<span class="hljs-meta">... </span>        tf.expand_dims(question_hidden_states, axis=<span class="hljs-number">1</span>), docs_dict[<span class="hljs-string">&quot;retrieved_doc_embeds&quot;</span>], transpose_b=<span class="hljs-literal">True</span>
<span class="hljs-meta">... </span>    ),
<span class="hljs-meta">... </span>    axis=<span class="hljs-number">1</span>,
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># 3. Forward to generator</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(
<span class="hljs-meta">... </span>    inputs=<span class="hljs-literal">None</span>,
<span class="hljs-meta">... </span>    context_input_ids=docs_dict[<span class="hljs-string">&quot;context_input_ids&quot;</span>],
<span class="hljs-meta">... </span>    context_attention_mask=docs_dict[<span class="hljs-string">&quot;context_attention_mask&quot;</span>],
<span class="hljs-meta">... </span>    doc_scores=doc_scores,
<span class="hljs-meta">... </span>    decoder_input_ids=input_dict[<span class="hljs-string">&quot;labels&quot;</span>],
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># or directly generate</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>generated = model.generate(
<span class="hljs-meta">... </span>    context_input_ids=docs_dict[<span class="hljs-string">&quot;context_input_ids&quot;</span>],
<span class="hljs-meta">... </span>    context_attention_mask=docs_dict[<span class="hljs-string">&quot;context_attention_mask&quot;</span>],
<span class="hljs-meta">... </span>    doc_scores=doc_scores,
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>generated_string = tokenizer.batch_decode(generated, skip_special_tokens=<span class="hljs-literal">True</span>)`}}),{c(){c=s("p"),T=o("Example:"),u=p(),b(g.$$.fragment)},l(i){c=a(i,"P",{});var m=d(c);T=n(m,"Example:"),m.forEach(t),u=h(i),y(g.$$.fragment,i)},m(i,m){v(i,c,m),e(c,T),v(i,u,m),w(g,i,m),_=!0},p:on,i(i){_||(M(g.$$.fragment,i),_=!0)},o(i){R(g.$$.fragment,i),_=!1},d(i){i&&t(c),i&&t(u),k(g,i)}}}function YT(F){let c,T,u,g,_;return{c(){c=s("p"),T=o("Although the recipe for forward pass needs to be defined within this function, one should call the "),u=s("code"),g=o("Module"),_=o(`
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(i){c=a(i,"P",{});var m=d(c);T=n(m,"Although the recipe for forward pass needs to be defined within this function, one should call the "),u=a(m,"CODE",{});var q=d(u);g=n(q,"Module"),q.forEach(t),_=n(m,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),m.forEach(t)},m(i,m){v(i,c,m),e(c,T),e(c,u),e(u,g),e(c,_)},d(i){i&&t(c)}}}function QT(F){let c,T,u,g,_;return{c(){c=s("p"),T=o("Although the recipe for forward pass needs to be defined within this function, one should call the "),u=s("code"),g=o("Module"),_=o(`
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(i){c=a(i,"P",{});var m=d(c);T=n(m,"Although the recipe for forward pass needs to be defined within this function, one should call the "),u=a(m,"CODE",{});var q=d(u);g=n(q,"Module"),q.forEach(t),_=n(m,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),m.forEach(t)},m(i,m){v(i,c,m),e(c,T),e(c,u),e(u,g),e(c,_)},d(i){i&&t(c)}}}function DT(F){let c,T,u,g,_;return g=new nn({props:{code:"aW1wb3J0JTIwdGVuc29yZmxvdyUyMGFzJTIwdGYlMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b1Rva2VuaXplciUyQyUyMFJhZ1JldHJpZXZlciUyQyUyMFRGUmFnVG9rZW5Gb3JHZW5lcmF0aW9uJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIyZmFjZWJvb2slMkZyYWctdG9rZW4tbnElMjIpJTBBcmV0cmlldmVyJTIwJTNEJTIwUmFnUmV0cmlldmVyLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJmYWNlYm9vayUyRnJhZy10b2tlbi1ucSUyMiUyQyUyMGluZGV4X25hbWUlM0QlMjJleGFjdCUyMiUyQyUyMHVzZV9kdW1teV9kYXRhc2V0JTNEVHJ1ZSUwQSklMEElMjMlMjBpbml0aWFsaXplJTIwd2l0aCUyMFJhZ1JldHJpZXZlciUyMHRvJTIwZG8lMjBldmVyeXRoaW5nJTIwaW4lMjBvbmUlMjBmb3J3YXJkJTIwY2FsbCUwQW1vZGVsJTIwJTNEJTIwVEZSYWdUb2tlbkZvckdlbmVyYXRpb24uZnJvbV9wcmV0cmFpbmVkKCUyMmZhY2Vib29rJTJGcmFnLXRva2VuLW5xJTIyJTJDJTIwcmV0cmlldmVyJTNEcmV0cmlldmVyJTJDJTIwZnJvbV9wdCUzRFRydWUpJTBBJTBBaW5wdXRfZGljdCUyMCUzRCUyMHRva2VuaXplci5wcmVwYXJlX3NlcTJzZXFfYmF0Y2goJTBBJTIwJTIwJTIwJTIwJTIySG93JTIwbWFueSUyMHBlb3BsZSUyMGxpdmUlMjBpbiUyMFBhcmlzJTNGJTIyJTJDJTIwJTIySW4lMjBQYXJpcyUyQyUyMHRoZXJlJTIwYXJlJTIwMTAlMjBtaWxsaW9uJTIwcGVvcGxlLiUyMiUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIydGYlMjIlMEEpJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsKGlucHV0X2RpY3QlMkMlMjBvdXRwdXRfcmV0cmlldmVkJTNEVHJ1ZSklMEElMEElMjMlMjBvciUyMHVzZSUyMHJldHJpZXZlciUyMHNlcGFyYXRlbHklMEElMjMlMjAxLiUyMEVuY29kZSUwQWlucHV0X2lkcyUyMCUzRCUyMGlucHV0X2RpY3QlNUIlMjJpbnB1dF9pZHMlMjIlNUQlMEFxdWVzdGlvbl9oaWRkZW5fc3RhdGVzJTIwJTNEJTIwbW9kZWwucXVlc3Rpb25fZW5jb2RlcihpbnB1dF9pZHMpJTVCMCU1RCUwQSUyMyUyMDIuJTIwUmV0cmlldmUlMEFkb2NzX2RpY3QlMjAlM0QlMjByZXRyaWV2ZXIoaW5wdXRfaWRzLm51bXB5KCklMkMlMjBxdWVzdGlvbl9oaWRkZW5fc3RhdGVzLm51bXB5KCklMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnRmJTIyKSUwQWRvY19zY29yZXMlMjAlM0QlMjB0Zi5zcXVlZXplKCUwQSUyMCUyMCUyMCUyMHRmLm1hdG11bCglMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjB0Zi5leHBhbmRfZGltcyhxdWVzdGlvbl9oaWRkZW5fc3RhdGVzJTJDJTIwYXhpcyUzRDEpJTJDJTIwZG9jc19kaWN0JTVCJTIycmV0cmlldmVkX2RvY19lbWJlZHMlMjIlNUQlMkMlMjB0cmFuc3Bvc2VfYiUzRFRydWUlMEElMjAlMjAlMjAlMjApJTJDJTBBJTIwJTIwJTIwJTIwYXhpcyUzRDElMkMlMEEpJTBBJTIzJTIwMy4lMjBGb3J3YXJkJTIwdG8lMjBnZW5lcmF0b3IlMEFvdXRwdXRzJTIwJTNEJTIwbW9kZWwoJTBBJTIwJTIwJTIwJTIwaW5wdXRzJTNETm9uZSUyQyUwQSUyMCUyMCUyMCUyMGNvbnRleHRfaW5wdXRfaWRzJTNEZG9jc19kaWN0JTVCJTIyY29udGV4dF9pbnB1dF9pZHMlMjIlNUQlMkMlMEElMjAlMjAlMjAlMjBjb250ZXh0X2F0dGVudGlvbl9tYXNrJTNEZG9jc19kaWN0JTVCJTIyY29udGV4dF9hdHRlbnRpb25fbWFzayUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMGRvY19zY29yZXMlM0Rkb2Nfc2NvcmVzJTJDJTBBJTIwJTIwJTIwJTIwZGVjb2Rlcl9pbnB1dF9pZHMlM0RpbnB1dF9kaWN0JTVCJTIybGFiZWxzJTIyJTVEJTJDJTBBKSUwQSUwQSUyMyUyMG9yJTIwZGlyZWN0bHklMjBnZW5lcmF0ZSUwQWdlbmVyYXRlZCUyMCUzRCUyMG1vZGVsLmdlbmVyYXRlKCUwQSUyMCUyMCUyMCUyMGNvbnRleHRfaW5wdXRfaWRzJTNEZG9jc19kaWN0JTVCJTIyY29udGV4dF9pbnB1dF9pZHMlMjIlNUQlMkMlMEElMjAlMjAlMjAlMjBjb250ZXh0X2F0dGVudGlvbl9tYXNrJTNEZG9jc19kaWN0JTVCJTIyY29udGV4dF9hdHRlbnRpb25fbWFzayUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMGRvY19zY29yZXMlM0Rkb2Nfc2NvcmVzJTJDJTBBKSUwQWdlbmVyYXRlZF9zdHJpbmclMjAlM0QlMjB0b2tlbml6ZXIuYmF0Y2hfZGVjb2RlKGdlbmVyYXRlZCUyQyUyMHNraXBfc3BlY2lhbF90b2tlbnMlM0RUcnVlKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, RagRetriever, TFRagTokenForGeneration

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;facebook/rag-token-nq&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>retriever = RagRetriever.from_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;facebook/rag-token-nq&quot;</span>, index_name=<span class="hljs-string">&quot;exact&quot;</span>, use_dummy_dataset=<span class="hljs-literal">True</span>
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># initialize with RagRetriever to do everything in one forward call</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFRagTokenForGeneration.from_pretrained(<span class="hljs-string">&quot;facebook/rag-token-nq&quot;</span>, retriever=retriever, from_pt=<span class="hljs-literal">True</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>input_dict = tokenizer.prepare_seq2seq_batch(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;How many people live in Paris?&quot;</span>, <span class="hljs-string">&quot;In Paris, there are 10 million people.&quot;</span>, return_tensors=<span class="hljs-string">&quot;tf&quot;</span>
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(input_dict, output_retrieved=<span class="hljs-literal">True</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># or use retriever separately</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># 1. Encode</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>input_ids = input_dict[<span class="hljs-string">&quot;input_ids&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>question_hidden_states = model.question_encoder(input_ids)[<span class="hljs-number">0</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># 2. Retrieve</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>docs_dict = retriever(input_ids.numpy(), question_hidden_states.numpy(), return_tensors=<span class="hljs-string">&quot;tf&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>doc_scores = tf.squeeze(
<span class="hljs-meta">... </span>    tf.matmul(
<span class="hljs-meta">... </span>        tf.expand_dims(question_hidden_states, axis=<span class="hljs-number">1</span>), docs_dict[<span class="hljs-string">&quot;retrieved_doc_embeds&quot;</span>], transpose_b=<span class="hljs-literal">True</span>
<span class="hljs-meta">... </span>    ),
<span class="hljs-meta">... </span>    axis=<span class="hljs-number">1</span>,
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># 3. Forward to generator</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(
<span class="hljs-meta">... </span>    inputs=<span class="hljs-literal">None</span>,
<span class="hljs-meta">... </span>    context_input_ids=docs_dict[<span class="hljs-string">&quot;context_input_ids&quot;</span>],
<span class="hljs-meta">... </span>    context_attention_mask=docs_dict[<span class="hljs-string">&quot;context_attention_mask&quot;</span>],
<span class="hljs-meta">... </span>    doc_scores=doc_scores,
<span class="hljs-meta">... </span>    decoder_input_ids=input_dict[<span class="hljs-string">&quot;labels&quot;</span>],
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># or directly generate</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>generated = model.generate(
<span class="hljs-meta">... </span>    context_input_ids=docs_dict[<span class="hljs-string">&quot;context_input_ids&quot;</span>],
<span class="hljs-meta">... </span>    context_attention_mask=docs_dict[<span class="hljs-string">&quot;context_attention_mask&quot;</span>],
<span class="hljs-meta">... </span>    doc_scores=doc_scores,
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>generated_string = tokenizer.batch_decode(generated, skip_special_tokens=<span class="hljs-literal">True</span>)`}}),{c(){c=s("p"),T=o("Example:"),u=p(),b(g.$$.fragment)},l(i){c=a(i,"P",{});var m=d(c);T=n(m,"Example:"),m.forEach(t),u=h(i),y(g.$$.fragment,i)},m(i,m){v(i,c,m),e(c,T),v(i,u,m),w(g,i,m),_=!0},p:on,i(i){_||(M(g.$$.fragment,i),_=!0)},o(i){R(g.$$.fragment,i),_=!1},d(i){i&&t(c),i&&t(u),k(g,i)}}}function OT(F){let c,T,u,g,_,i,m,q,ei,Xa,Wt,rn,sn,cf,Va,Me,Ye,jr,Xt,ti,Jr,oi,Sa,an,ni,Ba,Qe,ri,Vt,si,ai,Pa,dn,di,Ha,cn,Gr,ii,La,De,ci,St,li,pi,Ya,ln,hi,Qa,pn,zr,mi,Da,Re,Oe,Ur,Bt,ui,Er,gi,Oa,fe,Pt,fi,ae,hn,_i,vi,$r,Ti,bi,mn,yi,wi,un,Mi,Ri,ki,Ke,Ht,qi,Lt,Fi,gn,xi,ji,Ka,ke,et,Zr,Yt,Ji,Ir,Gi,ed,Qt,Dt,td,qe,tt,Cr,Ot,zi,Nr,Ui,od,Fe,Kt,Ei,Ar,$i,nd,eo,to,rd,xe,ot,Wr,oo,Zi,Xr,Ii,sd,K,no,Ci,Vr,Ni,Ai,nt,Wi,rt,ro,Xi,Sr,Vi,Si,st,so,Bi,je,Pi,Br,Hi,Li,Pr,Yi,Qi,Di,at,ao,Oi,io,Ki,Hr,ec,tc,ad,Je,dt,Lr,co,oc,Yr,nc,dd,N,lo,rc,Ge,sc,fn,ac,dc,Qr,ic,cc,lc,it,pc,Dr,hc,mc,ee,uc,Or,gc,fc,_n,_c,vc,Kr,Tc,bc,vn,yc,wc,Mc,z,Rc,Tn,kc,qc,es,Fc,xc,ts,jc,Jc,os,Gc,zc,ns,Uc,Ec,bn,$c,Zc,rs,Ic,Cc,yn,Nc,Ac,wn,Wc,Xc,ss,Vc,Sc,Bc,po,Pc,Mn,Hc,Lc,Yc,ho,Qc,mo,Dc,Oc,Kc,de,uo,el,ze,tl,Rn,ol,nl,as,rl,sl,al,ct,dl,lt,id,Ue,pt,ds,go,il,is,cl,cd,J,fo,ll,Ee,pl,kn,hl,ml,cs,ul,gl,fl,ht,_l,ls,vl,Tl,ps,bl,yl,te,wl,hs,Ml,Rl,qn,kl,ql,ms,Fl,xl,Fn,jl,Jl,Gl,U,zl,xn,Ul,El,us,$l,Zl,gs,Il,Cl,fs,Nl,Al,_s,Wl,Xl,jn,Vl,Sl,vs,Bl,Pl,Jn,Hl,Ll,Gn,Yl,Ql,Ts,Dl,Ol,Kl,_o,ep,zn,tp,op,np,vo,rp,To,sp,ap,dp,ie,bo,ip,$e,cp,Un,lp,pp,bs,hp,mp,up,mt,gp,ut,fp,gt,yo,_p,wo,vp,En,Tp,bp,ld,Ze,ft,ys,Mo,yp,ws,wp,pd,G,Ro,Mp,Ie,Rp,$n,kp,qp,Ms,Fp,xp,jp,_t,Jp,Rs,Gp,zp,ks,Up,Ep,oe,$p,qs,Zp,Ip,Zn,Cp,Np,Fs,Ap,Wp,In,Xp,Vp,Sp,E,Bp,Cn,Pp,Hp,xs,Lp,Yp,js,Qp,Dp,Js,Op,Kp,Gs,eh,th,Nn,oh,nh,zs,rh,sh,An,ah,dh,Wn,ih,ch,Us,lh,ph,hh,ko,mh,Xn,uh,gh,fh,qo,_h,Fo,vh,Th,bh,ce,xo,yh,Ce,wh,Vn,Mh,Rh,Es,kh,qh,Fh,vt,xh,Tt,jh,bt,jo,Jh,$s,Gh,hd,Ne,yt,Zs,Jo,zh,Is,Uh,md,$,Go,Eh,Ae,$h,Sn,Zh,Ih,Cs,Ch,Nh,Ah,wt,Wh,Ns,Xh,Vh,ne,Sh,As,Bh,Ph,Bn,Hh,Lh,Ws,Yh,Qh,Pn,Dh,Oh,Kh,A,em,Hn,tm,om,Xs,nm,rm,Vs,sm,am,Ss,dm,im,Bs,cm,lm,Ln,pm,hm,Ps,mm,um,Yn,gm,fm,Hs,_m,vm,Tm,zo,bm,Qn,ym,wm,Mm,Uo,Rm,Eo,km,qm,Fm,Ls,xm,jm,le,$o,Jm,We,Gm,Dn,zm,Um,Ys,Em,$m,Zm,Mt,Im,Rt,ud,Xe,kt,Qs,Zo,Cm,Ds,Nm,gd,x,Io,Am,Ve,Wm,On,Xm,Vm,Os,Sm,Bm,Pm,qt,Hm,Ks,Lm,Ym,ea,Qm,Dm,re,Om,ta,Km,eu,Kn,tu,ou,oa,nu,ru,er,su,au,du,W,iu,tr,cu,lu,na,pu,hu,ra,mu,uu,sa,gu,fu,aa,_u,vu,or,Tu,bu,da,yu,wu,nr,Mu,Ru,ia,ku,qu,Fu,Co,xu,rr,ju,Ju,Gu,No,zu,Ao,Uu,Eu,$u,ca,Zu,Iu,pe,Wo,Cu,Se,Nu,sr,Au,Wu,la,Xu,Vu,Su,Ft,Bu,xt,Pu,jt,Xo,Hu,Vo,Lu,ar,Yu,Qu,fd,Be,Jt,pa,So,Du,ha,Ou,_d,j,Bo,Ku,Pe,eg,dr,tg,og,ma,ng,rg,sg,Gt,ag,ua,dg,ig,ga,cg,lg,se,pg,fa,hg,mg,ir,ug,gg,_a,fg,_g,cr,vg,Tg,bg,X,yg,lr,wg,Mg,va,Rg,kg,Ta,qg,Fg,ba,xg,jg,ya,Jg,Gg,pr,zg,Ug,wa,Eg,$g,hr,Zg,Ig,Ma,Cg,Ng,Ag,Po,Wg,mr,Xg,Vg,Sg,Ho,Bg,Lo,Pg,Hg,Lg,Ra,Yg,Qg,he,Yo,Dg,He,Og,ur,Kg,ef,ka,tf,of,nf,zt,rf,Ut,sf,Et,Qo,af,qa,df,vd;return i=new ge({}),Xt=new ge({}),Bt=new ge({}),Pt=new Z({props:{name:"class transformers.RagConfig",anchor:"transformers.RagConfig",parameters:[{name:"vocab_size",val:" = None"},{name:"is_encoder_decoder",val:" = True"},{name:"prefix",val:" = None"},{name:"bos_token_id",val:" = None"},{name:"pad_token_id",val:" = None"},{name:"eos_token_id",val:" = None"},{name:"decoder_start_token_id",val:" = None"},{name:"title_sep",val:" = ' / '"},{name:"doc_sep",val:" = ' // '"},{name:"n_docs",val:" = 5"},{name:"max_combined_length",val:" = 300"},{name:"retrieval_vector_size",val:" = 768"},{name:"retrieval_batch_size",val:" = 8"},{name:"dataset",val:" = 'wiki_dpr'"},{name:"dataset_split",val:" = 'train'"},{name:"index_name",val:" = 'compressed'"},{name:"index_path",val:" = None"},{name:"passages_path",val:" = None"},{name:"use_dummy_dataset",val:" = False"},{name:"reduce_loss",val:" = False"},{name:"label_smoothing",val:" = 0.0"},{name:"do_deduplication",val:" = True"},{name:"exclude_bos_score",val:" = False"},{name:"do_marginalize",val:" = False"},{name:"output_retrieved",val:" = False"},{name:"use_cache",val:" = True"},{name:"forced_eos_token_id",val:" = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.RagConfig.title_sep",description:`<strong>title_sep</strong> (<code>str</code>, <em>optional</em>, defaults to  <code>&quot; / &quot;</code>) &#x2014;
Separator inserted between the title and the text of the retrieved document when calling <a href="/docs/transformers/v4.33.0/en/model_doc/rag#transformers.RagRetriever">RagRetriever</a>.`,name:"title_sep"},{anchor:"transformers.RagConfig.doc_sep",description:`<strong>doc_sep</strong> (<code>str</code>, <em>optional</em>, defaults to  <code>&quot; // &quot;</code>) &#x2014;
Separator inserted between the text of the retrieved document and the original input when calling
<a href="/docs/transformers/v4.33.0/en/model_doc/rag#transformers.RagRetriever">RagRetriever</a>.`,name:"doc_sep"},{anchor:"transformers.RagConfig.n_docs",description:`<strong>n_docs</strong> (<code>int</code>, <em>optional</em>, defaults to 5) &#x2014;
Number of documents to retrieve.`,name:"n_docs"},{anchor:"transformers.RagConfig.max_combined_length",description:`<strong>max_combined_length</strong> (<code>int</code>, <em>optional</em>, defaults to 300) &#x2014;
Max length of contextualized input returned by <code>__call__()</code>.`,name:"max_combined_length"},{anchor:"transformers.RagConfig.retrieval_vector_size",description:`<strong>retrieval_vector_size</strong> (<code>int</code>, <em>optional</em>, defaults to 768) &#x2014;
Dimensionality of the document embeddings indexed by <a href="/docs/transformers/v4.33.0/en/model_doc/rag#transformers.RagRetriever">RagRetriever</a>.`,name:"retrieval_vector_size"},{anchor:"transformers.RagConfig.retrieval_batch_size",description:`<strong>retrieval_batch_size</strong> (<code>int</code>, <em>optional</em>, defaults to 8) &#x2014;
Retrieval batch size, defined as the number of queries issues concurrently to the faiss index encapsulated
<a href="/docs/transformers/v4.33.0/en/model_doc/rag#transformers.RagRetriever">RagRetriever</a>.`,name:"retrieval_batch_size"},{anchor:"transformers.RagConfig.dataset",description:`<strong>dataset</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;wiki_dpr&quot;</code>) &#x2014;
A dataset identifier of the indexed dataset in HuggingFace Datasets (list all available datasets and ids
using <code>datasets.list_datasets()</code>).`,name:"dataset"},{anchor:"transformers.RagConfig.dataset_split",description:`<strong>dataset_split</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;train&quot;</code>) &#x2014;
Which split of the <code>dataset</code> to load.`,name:"dataset_split"},{anchor:"transformers.RagConfig.index_name",description:`<strong>index_name</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;compressed&quot;</code>) &#x2014;
The index name of the index associated with the <code>dataset</code>. One can choose between <code>&quot;legacy&quot;</code>, <code>&quot;exact&quot;</code> and
<code>&quot;compressed&quot;</code>.`,name:"index_name"},{anchor:"transformers.RagConfig.index_path",description:`<strong>index_path</strong> (<code>str</code>, <em>optional</em>) &#x2014;
The path to the serialized faiss index on disk.`,name:"index_path"},{anchor:"transformers.RagConfig.passages_path",description:`<strong>passages_path</strong> (<code>str</code>, <em>optional</em>) &#x2014;
A path to text passages compatible with the faiss index. Required if using
<code>LegacyIndex</code>`,name:"passages_path"},{anchor:"transformers.RagConfig.use_dummy_dataset",description:`<strong>use_dummy_dataset</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to load a &#x201C;dummy&#x201D; variant of the dataset specified by <code>dataset</code>.`,name:"use_dummy_dataset"},{anchor:"transformers.RagConfig.label_smoothing",description:`<strong>label_smoothing</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
Only relevant if <code>return_loss</code> is set to <code>True</code>. Controls the <code>epsilon</code> parameter value for label smoothing
in the loss calculation. If set to 0, no label smoothing is performed.`,name:"label_smoothing"},{anchor:"transformers.RagConfig.do_marginalize",description:`<strong>do_marginalize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
If <code>True</code>, the logits are marginalized over all documents by making use of
<code>torch.nn.functional.log_softmax</code>.`,name:"do_marginalize"},{anchor:"transformers.RagConfig.reduce_loss",description:`<strong>reduce_loss</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to reduce the NLL loss using the <code>torch.Tensor.sum</code> operation.`,name:"reduce_loss"},{anchor:"transformers.RagConfig.do_deduplication",description:`<strong>do_deduplication</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to deduplicate the generations from different context documents for a given input. Has to be
set to <code>False</code> if used while training with distributed backend.`,name:"do_deduplication"},{anchor:"transformers.RagConfig.exclude_bos_score",description:`<strong>exclude_bos_score</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to disregard the BOS token when computing the loss.`,name:"exclude_bos_score"},{anchor:"transformers.RagConfig.output_retrieved(bool,",description:`<strong>output_retrieved(<code>bool</code>,</strong> <em>optional</em>, defaults to <code>False</code>) &#x2014;
If set to <code>True</code>, <code>retrieved_doc_embeds</code>, <code>retrieved_doc_ids</code>, <code>context_input_ids</code> and
<code>context_attention_mask</code> are returned. See returned tensors for more detail.`,name:"output_retrieved(bool,"},{anchor:"transformers.RagConfig.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not the model should return the last key/values attentions (not used by all models).`,name:"use_cache"},{anchor:"transformers.RagConfig.forced_eos_token_id",description:`<strong>forced_eos_token_id</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The id of the token to force as the last generated token when <code>max_length</code> is reached. Usually set to
<code>eos_token_id</code>.`,name:"forced_eos_token_id"}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/models/rag/configuration_rag.py#L81"}}),Ht=new Z({props:{name:"from_question_encoder_generator_configs",anchor:"transformers.RagConfig.from_question_encoder_generator_configs",parameters:[{name:"question_encoder_config",val:": PretrainedConfig"},{name:"generator_config",val:": PretrainedConfig"},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/models/rag/configuration_rag.py#L169",returnDescription:`
<p>An instance of a configuration object</p>
`,returnType:`
<p><a
  href="/docs/transformers/v4.33.0/en/model_doc/encoder-decoder#transformers.EncoderDecoderConfig"
>EncoderDecoderConfig</a></p>
`}}),Yt=new ge({}),Dt=new Z({props:{name:"class transformers.RagTokenizer",anchor:"transformers.RagTokenizer",parameters:[{name:"question_encoder",val:""},{name:"generator",val:""}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/models/rag/tokenization_rag.py#L28"}}),Ot=new ge({}),Kt=new Z({props:{name:"class transformers.models.rag.modeling_rag.RetrievAugLMMarginOutput",anchor:"transformers.models.rag.modeling_rag.RetrievAugLMMarginOutput",parameters:[{name:"loss",val:": typing.Optional[torch.FloatTensor] = None"},{name:"logits",val:": FloatTensor = None"},{name:"doc_scores",val:": FloatTensor = None"},{name:"past_key_values",val:": typing.Optional[typing.List[torch.FloatTensor]] = None"},{name:"retrieved_doc_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"retrieved_doc_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"context_input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"context_attention_mask",val:": typing.Optional[torch.LongTensor] = None"},{name:"question_encoder_last_hidden_state",val:": typing.Optional[torch.FloatTensor] = None"},{name:"question_enc_hidden_states",val:": typing.Optional[typing.Tuple[torch.FloatTensor]] = None"},{name:"question_enc_attentions",val:": typing.Optional[typing.Tuple[torch.FloatTensor]] = None"},{name:"generator_enc_last_hidden_state",val:": typing.Optional[torch.FloatTensor] = None"},{name:"generator_enc_hidden_states",val:": typing.Optional[typing.Tuple[torch.FloatTensor]] = None"},{name:"generator_enc_attentions",val:": typing.Optional[typing.Tuple[torch.FloatTensor]] = None"},{name:"generator_dec_hidden_states",val:": typing.Optional[typing.Tuple[torch.FloatTensor]] = None"},{name:"generator_dec_attentions",val:": typing.Optional[typing.Tuple[torch.FloatTensor]] = None"},{name:"generator_cross_attentions",val:": typing.Optional[typing.Tuple[torch.FloatTensor]] = None"}],parametersDescription:[{anchor:"transformers.models.rag.modeling_rag.RetrievAugLMMarginOutput.loss",description:`<strong>loss</strong> (<code>torch.FloatTensor</code> of shape <code>(1,)</code>, <em>optional</em>, returned when <code>labels</code> is provided) &#x2014;
Language modeling loss.`,name:"loss"},{anchor:"transformers.models.rag.modeling_rag.RetrievAugLMMarginOutput.logits",description:`<strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, config.vocab_size)</code>) &#x2014;
Prediction scores of the language modeling head. The score is possibly marginalized over all documents for
each vocabulary token.`,name:"logits"},{anchor:"transformers.models.rag.modeling_rag.RetrievAugLMMarginOutput.doc_scores",description:`<strong>doc_scores</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, config.n_docs)</code>) &#x2014;
Score between each retrieved document embeddings (see <code>retrieved_doc_embeds</code>) and
<code>question_encoder_last_hidden_state</code>.`,name:"doc_scores"},{anchor:"transformers.models.rag.modeling_rag.RetrievAugLMMarginOutput.past_key_values",description:`<strong>past_key_values</strong> (<code>List[torch.FloatTensor]</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) &#x2014;
List of <code>torch.FloatTensor</code> of length <code>config.n_layers</code>, with each tensor of shape <code>(2, batch_size, num_heads, sequence_length, embed_size_per_head)</code>).</p>
<p>Contains precomputed hidden-states (key and values in the attention blocks) of the decoder that can be used
(see <code>past_key_values</code> input) to speed up sequential decoding.`,name:"past_key_values"},{anchor:"transformers.models.rag.modeling_rag.RetrievAugLMMarginOutput.retrieved_doc_embeds",description:`<strong>retrieved_doc_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, config.n_docs, hidden_size)</code>, <em>optional</em>, returned when <em>output_retrieved=True</em>) &#x2014;
Embedded documents retrieved by the retriever. Is used with <code>question_encoder_last_hidden_state</code> to compute
the <code>doc_scores</code>.`,name:"retrieved_doc_embeds"},{anchor:"transformers.models.rag.modeling_rag.RetrievAugLMMarginOutput.retrieved_doc_ids",description:`<strong>retrieved_doc_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, config.n_docs)</code>, <em>optional</em>, returned when <em>output_retrieved=True</em>) &#x2014;
The indexes of the embedded documents retrieved by the retriever.`,name:"retrieved_doc_ids"},{anchor:"transformers.models.rag.modeling_rag.RetrievAugLMMarginOutput.context_input_ids",description:`<strong>context_input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size * config.n_docs, config.max_combined_length)</code>, <em>optional</em>, returned when <em>output_retrieved=True</em>) &#x2014;
Input ids post-processed from the retrieved documents and the question encoder input_ids by the retriever.`,name:"context_input_ids"},{anchor:"transformers.models.rag.modeling_rag.RetrievAugLMMarginOutput.context_attention_mask",description:`<strong>context_attention_mask</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size * config.n_docs, config.max_combined_length)</code>, <em>optional</em>, returned when <em>output_retrieved=True</em>) &#x2014;
Attention mask post-processed from the retrieved documents and the question encoder <code>input_ids</code> by the
retriever.`,name:"context_attention_mask"},{anchor:"transformers.models.rag.modeling_rag.RetrievAugLMMarginOutput.question_encoder_last_hidden_state",description:`<strong>question_encoder_last_hidden_state</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Sequence of hidden states at the output of the last layer of the question encoder pooled output of the
model.`,name:"question_encoder_last_hidden_state"},{anchor:"transformers.models.rag.modeling_rag.RetrievAugLMMarginOutput.question_enc_hidden_states",description:`<strong>question_enc_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>) &#x2014;
Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings and one for the output of each layer) of
shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden states of the question encoder at the output of each layer plus the initial embedding outputs.`,name:"question_enc_hidden_states"},{anchor:"transformers.models.rag.modeling_rag.RetrievAugLMMarginOutput.question_enc_attentions",description:`<strong>question_enc_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>) &#x2014;
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 of the question encoder, after the attention softmax, used to compute the weighted
average in the self-attention heads.`,name:"question_enc_attentions"},{anchor:"transformers.models.rag.modeling_rag.RetrievAugLMMarginOutput.generator_enc_last_hidden_state",description:`<strong>generator_enc_last_hidden_state</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Sequence of hidden-states at the output of the last layer of the generator encoder of the model.`,name:"generator_enc_last_hidden_state"},{anchor:"transformers.models.rag.modeling_rag.RetrievAugLMMarginOutput.generator_enc_hidden_states",description:`<strong>generator_enc_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>) &#x2014;
Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings and one for the output of each layer) of
shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden states of the generator encoder at the output of each layer plus the initial embedding outputs.`,name:"generator_enc_hidden_states"},{anchor:"transformers.models.rag.modeling_rag.RetrievAugLMMarginOutput.generator_enc_attentions",description:`<strong>generator_enc_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>) &#x2014;
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 of the generator encoder, after the attention softmax, used to compute the weighted
average in the self-attention heads.`,name:"generator_enc_attentions"},{anchor:"transformers.models.rag.modeling_rag.RetrievAugLMMarginOutput.generator_dec_hidden_states",description:`<strong>generator_dec_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>) &#x2014;
Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings and one for the output of each layer) of
shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden states of the generator decoder at the output of each layer plus the initial embedding outputs.`,name:"generator_dec_hidden_states"},{anchor:"transformers.models.rag.modeling_rag.RetrievAugLMMarginOutput.generator_dec_attentions",description:`<strong>generator_dec_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>) &#x2014;
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 of the generator decoder, after the attention softmax, used to compute the weighted
average in the self-attention heads.`,name:"generator_dec_attentions"},{anchor:"transformers.models.rag.modeling_rag.RetrievAugLMMarginOutput.generator_cross_attentions",description:`<strong>generator_cross_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>) &#x2014;
Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Cross-attentions weights of the generator decoder, after the attention softmax, used to compute the
weighted average in the cross-attention heads.`,name:"generator_cross_attentions"}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/models/rag/modeling_rag.py#L39"}}),to=new Z({props:{name:"class transformers.models.rag.modeling_rag.RetrievAugLMOutput",anchor:"transformers.models.rag.modeling_rag.RetrievAugLMOutput",parameters:[{name:"logits",val:": FloatTensor = None"},{name:"doc_scores",val:": FloatTensor = None"},{name:"past_key_values",val:": typing.Optional[typing.List[torch.FloatTensor]] = None"},{name:"retrieved_doc_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"retrieved_doc_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"context_input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"context_attention_mask",val:": typing.Optional[torch.LongTensor] = None"},{name:"question_encoder_last_hidden_state",val:": typing.Optional[torch.FloatTensor] = None"},{name:"question_enc_hidden_states",val:": typing.Optional[typing.Tuple[torch.FloatTensor]] = None"},{name:"question_enc_attentions",val:": typing.Optional[typing.Tuple[torch.FloatTensor]] = None"},{name:"generator_enc_last_hidden_state",val:": typing.Optional[torch.FloatTensor] = None"},{name:"generator_enc_hidden_states",val:": typing.Optional[typing.Tuple[torch.FloatTensor]] = None"},{name:"generator_enc_attentions",val:": typing.Optional[typing.Tuple[torch.FloatTensor]] = None"},{name:"generator_dec_hidden_states",val:": typing.Optional[typing.Tuple[torch.FloatTensor]] = None"},{name:"generator_dec_attentions",val:": typing.Optional[typing.Tuple[torch.FloatTensor]] = None"},{name:"generator_cross_attentions",val:": typing.Optional[typing.Tuple[torch.FloatTensor]] = None"}],parametersDescription:[{anchor:"transformers.models.rag.modeling_rag.RetrievAugLMOutput.logits",description:`<strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, config.vocab_size)</code>) &#x2014;
Prediction scores of the language modeling head. The score is possibly marginalized over all documents for
each vocabulary token.`,name:"logits"},{anchor:"transformers.models.rag.modeling_rag.RetrievAugLMOutput.doc_scores",description:`<strong>doc_scores</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, config.n_docs)</code>) &#x2014;
Score between each retrieved document embeddings (see <code>retrieved_doc_embeds</code>) and
<code>question_encoder_last_hidden_state</code>.`,name:"doc_scores"},{anchor:"transformers.models.rag.modeling_rag.RetrievAugLMOutput.past_key_values",description:`<strong>past_key_values</strong> (<code>List[torch.FloatTensor]</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) &#x2014;
List of <code>torch.FloatTensor</code> of length <code>config.n_layers</code>, with each tensor of shape <code>(2, batch_size, num_heads, sequence_length, embed_size_per_head)</code>).</p>
<p>Contains precomputed hidden-states (key and values in the attention blocks) of the decoder that can be used
(see <code>past_key_values</code> input) to speed up sequential decoding.`,name:"past_key_values"},{anchor:"transformers.models.rag.modeling_rag.RetrievAugLMOutput.retrieved_doc_embeds",description:`<strong>retrieved_doc_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, config.n_docs, hidden_size)</code>, <em>optional</em>, returned when <em>output_retrieved=True</em>) &#x2014;
Embedded documents retrieved by the retriever. Is used with <code>question_encoder_last_hidden_state</code> to compute
the <code>doc_scores</code>.`,name:"retrieved_doc_embeds"},{anchor:"transformers.models.rag.modeling_rag.RetrievAugLMOutput.retrieved_doc_ids",description:`<strong>retrieved_doc_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, config.n_docs)</code>, <em>optional</em>, returned when <em>output_retrieved=True</em>) &#x2014;
The indexes of the embedded documents retrieved by the retriever.`,name:"retrieved_doc_ids"},{anchor:"transformers.models.rag.modeling_rag.RetrievAugLMOutput.context_input_ids",description:`<strong>context_input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size * config.n_docs, config.max_combined_length)</code>, <em>optional</em>, returned when <em>output_retrieved=True</em>) &#x2014;
Input ids post-processed from the retrieved documents and the question encoder input_ids by the retriever.`,name:"context_input_ids"},{anchor:"transformers.models.rag.modeling_rag.RetrievAugLMOutput.context_attention_mask",description:`<strong>context_attention_mask</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size * config.n_docs, config.max_combined_length)</code>, <em>optional</em>, returned when <em>output_retrieved=True</em>) &#x2014;
Attention mask post-processed from the retrieved documents and the question encoder <code>input_ids</code> by the
retriever.`,name:"context_attention_mask"},{anchor:"transformers.models.rag.modeling_rag.RetrievAugLMOutput.question_encoder_last_hidden_state",description:`<strong>question_encoder_last_hidden_state</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Sequence of hidden states at the output of the last layer of the question encoder pooled output of the
model.`,name:"question_encoder_last_hidden_state"},{anchor:"transformers.models.rag.modeling_rag.RetrievAugLMOutput.question_enc_hidden_states",description:`<strong>question_enc_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>) &#x2014;
Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings and one for the output of each layer) of
shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden states of the question encoder at the output of each layer plus the initial embedding outputs.`,name:"question_enc_hidden_states"},{anchor:"transformers.models.rag.modeling_rag.RetrievAugLMOutput.question_enc_attentions",description:`<strong>question_enc_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>) &#x2014;
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 of the question encoder, after the attention softmax, used to compute the weighted
average in the self-attention heads.`,name:"question_enc_attentions"},{anchor:"transformers.models.rag.modeling_rag.RetrievAugLMOutput.generator_enc_last_hidden_state",description:`<strong>generator_enc_last_hidden_state</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Sequence of hidden-states at the output of the last layer of the generator encoder of the model.`,name:"generator_enc_last_hidden_state"},{anchor:"transformers.models.rag.modeling_rag.RetrievAugLMOutput.generator_enc_hidden_states",description:`<strong>generator_enc_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>) &#x2014;
Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings and one for the output of each layer) of
shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden states of the generator encoder at the output of each layer plus the initial embedding outputs.`,name:"generator_enc_hidden_states"},{anchor:"transformers.models.rag.modeling_rag.RetrievAugLMOutput.generator_enc_attentions",description:`<strong>generator_enc_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>) &#x2014;
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 of the generator encoder, after the attention softmax, used to compute the weighted
average in the self-attention heads.`,name:"generator_enc_attentions"},{anchor:"transformers.models.rag.modeling_rag.RetrievAugLMOutput.generator_dec_hidden_states",description:`<strong>generator_dec_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>) &#x2014;
Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings and one for the output of each layer) of
shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden states of the generator decoder at the output of each layer plus the initial embedding outputs.`,name:"generator_dec_hidden_states"},{anchor:"transformers.models.rag.modeling_rag.RetrievAugLMOutput.generator_dec_attentions",description:`<strong>generator_dec_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>) &#x2014;
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 of the generator decoder, after the attention softmax, used to compute the weighted
average in the self-attention heads.`,name:"generator_dec_attentions"},{anchor:"transformers.models.rag.modeling_rag.RetrievAugLMOutput.generator_cross_attentions",description:`<strong>generator_cross_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>) &#x2014;
Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Cross-attentions weights of the generator decoder, after the attention softmax, used to compute the
weighted average in the cross-attention heads.`,name:"generator_cross_attentions"}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/models/rag/modeling_rag.py#L134"}}),oo=new ge({}),no=new Z({props:{name:"class transformers.RagRetriever",anchor:"transformers.RagRetriever",parameters:[{name:"config",val:""},{name:"question_encoder_tokenizer",val:""},{name:"generator_tokenizer",val:""},{name:"index",val:" = None"},{name:"init_retrieval",val:" = True"}],parametersDescription:[{anchor:"transformers.RagRetriever.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.33.0/en/model_doc/rag#transformers.RagConfig">RagConfig</a>) &#x2014;
The configuration of the RAG model this Retriever is used with. Contains parameters indicating which
<code>Index</code> to build. You can load your own custom dataset with <code>config.index_name=&quot;custom&quot;</code> or use a canonical
one (default) from the datasets library with <code>config.index_name=&quot;wiki_dpr&quot;</code> for example.`,name:"config"},{anchor:"transformers.RagRetriever.question_encoder_tokenizer",description:`<strong>question_encoder_tokenizer</strong> (<a href="/docs/transformers/v4.33.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizer">PreTrainedTokenizer</a>) &#x2014;
The tokenizer that was used to tokenize the question. It is used to decode the question and then use the
generator_tokenizer.`,name:"question_encoder_tokenizer"},{anchor:"transformers.RagRetriever.generator_tokenizer",description:`<strong>generator_tokenizer</strong> (<a href="/docs/transformers/v4.33.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizer">PreTrainedTokenizer</a>) &#x2014;
The tokenizer used for the generator part of the RagModel.`,name:"generator_tokenizer"},{anchor:"transformers.RagRetriever.index",description:`<strong>index</strong> (<code>Index</code>, optional, defaults to the one defined by the configuration) &#x2014;
If specified, use this index instead of the one built using the configuration`,name:"index"}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/models/rag/retrieval_rag.py#L323"}}),nt=new tn({props:{anchor:"transformers.RagRetriever.example",$$slots:{default:[UT]},$$scope:{ctx:F}}}),ro=new Z({props:{name:"init_retrieval",anchor:"transformers.RagRetriever.init_retrieval",parameters:[],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/models/rag/retrieval_rag.py#L457"}}),so=new Z({props:{name:"postprocess_docs",anchor:"transformers.RagRetriever.postprocess_docs",parameters:[{name:"docs",val:""},{name:"input_strings",val:""},{name:"prefix",val:""},{name:"n_docs",val:""},{name:"return_tensors",val:" = None"}],parametersDescription:[{anchor:"transformers.RagRetriever.postprocess_docs.docs",description:`<strong>docs</strong>  (<code>dict</code>) &#x2014;
Retrieved documents.`,name:"docs"},{anchor:"transformers.RagRetriever.postprocess_docs.input_strings",description:`<strong>input_strings</strong> (<code>str</code>) &#x2014;
Input strings decoded by <code>preprocess_query</code>.`,name:"input_strings"},{anchor:"transformers.RagRetriever.postprocess_docs.prefix",description:`<strong>prefix</strong> (<code>str</code>) &#x2014;
Prefix added at the beginning of each input, typically used with T5-based models.`,name:"prefix"}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/models/rag/retrieval_rag.py#L465",returnDescription:`
<p>a tuple consisting of two elements: contextualized <code>input_ids</code> and a compatible
<code>attention_mask</code>.</p>
`,returnType:`
<p><code>tuple(tensors)</code></p>
`}}),ao=new Z({props:{name:"retrieve",anchor:"transformers.RagRetriever.retrieve",parameters:[{name:"question_hidden_states",val:": ndarray"},{name:"n_docs",val:": int"}],parametersDescription:[{anchor:"transformers.RagRetriever.retrieve.question_hidden_states",description:`<strong>question_hidden_states</strong> (<code>np.ndarray</code> of shape <code>(batch_size, vector_size)</code>) &#x2014;
A batch of query vectors to retrieve with.`,name:"question_hidden_states"},{anchor:"transformers.RagRetriever.retrieve.n_docs",description:`<strong>n_docs</strong> (<code>int</code>) &#x2014;
The number of docs retrieved per query.`,name:"n_docs"}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/models/rag/retrieval_rag.py#L537",returnDescription:`
<p>A tuple with the following objects:</p>
<ul>
<li><strong>retrieved_doc_embeds</strong> (<code>np.ndarray</code> of shape <code>(batch_size, n_docs, dim)</code>) \u2014 The retrieval embeddings
of the retrieved docs per query.</li>
<li><strong>doc_ids</strong> (<code>np.ndarray</code> of shape <code>(batch_size, n_docs)</code>) \u2014 The ids of the documents in the index</li>
<li><strong>doc_dicts</strong> (<code>List[dict]</code>): The <code>retrieved_doc_embeds</code> examples per query.</li>
</ul>
`,returnType:`
<p><code>Tuple[np.ndarray, np.ndarray, List[dict]]</code></p>
`}}),co=new ge({}),lo=new Z({props:{name:"class transformers.RagModel",anchor:"transformers.RagModel",parameters:[{name:"config",val:": typing.Optional[transformers.configuration_utils.PretrainedConfig] = None"},{name:"question_encoder",val:": typing.Optional[transformers.modeling_utils.PreTrainedModel] = None"},{name:"generator",val:": typing.Optional[transformers.modeling_utils.PreTrainedModel] = None"},{name:"retriever",val:": typing.Optional[transformers.models.rag.retrieval_rag.RagRetriever] = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.RagModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.33.0/en/model_doc/rag#transformers.RagConfig">RagConfig</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.33.0/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"},{anchor:"transformers.RagModel.question_encoder",description:`<strong>question_encoder</strong> (<a href="/docs/transformers/v4.33.0/en/main_classes/model#transformers.PreTrainedModel">PreTrainedModel</a>) &#x2014;
An encoder model compatible with the faiss index encapsulated by the <code>retriever</code>.`,name:"question_encoder"},{anchor:"transformers.RagModel.generator",description:`<strong>generator</strong> (<a href="/docs/transformers/v4.33.0/en/main_classes/model#transformers.PreTrainedModel">PreTrainedModel</a>) &#x2014;
A seq2seq model used as the generator in the RAG architecture.`,name:"generator"},{anchor:"transformers.RagModel.retriever",description:`<strong>retriever</strong> (<a href="/docs/transformers/v4.33.0/en/model_doc/rag#transformers.RagRetriever">RagRetriever</a>) &#x2014;
A retriever class encapsulating a faiss index queried to obtain context documents for current inputs.`,name:"retriever"}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/models/rag/modeling_rag.py#L489"}}),it=new ue({props:{$$slots:{default:[ET]},$$scope:{ctx:F}}}),uo=new Z({props:{name:"forward",anchor:"transformers.RagModel.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"encoder_outputs",val:": typing.Optional[typing.Tuple[typing.Tuple[torch.FloatTensor]]] = None"},{name:"decoder_input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"decoder_attention_mask",val:": typing.Optional[torch.BoolTensor] = None"},{name:"past_key_values",val:": typing.Optional[typing.Tuple[typing.Tuple[torch.FloatTensor]]] = None"},{name:"doc_scores",val:": typing.Optional[torch.FloatTensor] = None"},{name:"context_input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"context_attention_mask",val:": typing.Optional[torch.LongTensor] = None"},{name:"use_cache",val:": typing.Optional[bool] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"output_retrieved",val:": typing.Optional[bool] = None"},{name:"n_docs",val:": typing.Optional[int] = None"}],parametersDescription:[{anchor:"transformers.RagModel.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. <a href="/docs/transformers/v4.33.0/en/model_doc/rag#transformers.RagConfig">RagConfig</a>, used to initialize the model, specifies
which generator to use, it also specifies a compatible generator tokenizer. Use that tokenizer class to
obtain the indices.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.RagModel.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.Tensor</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.RagModel.forward.encoder_outputs",description:`<strong>encoder_outputs</strong> (<code>tuple(tuple(torch.FloatTensor)</code>, <em>optional</em>) &#x2014;
Tuple consists of (<code>generator_enc_last_hidden_state</code>, <em>optional</em>: <code>generator_enc_hidden_states</code>,
<em>optional</em>: <code>generator_enc_attentions</code>). <code>generator_enc_last_hidden_state</code> of shape <code>(batch_size, n_docs * sequence_length, hidden_size)</code> is a sequence of hidden-states at the output of the last layer of the
generator&#x2019;s encoder.</p>
<p>Used by the (<a href="/docs/transformers/v4.33.0/en/model_doc/rag#transformers.RagModel">RagModel</a>) model during decoding.`,name:"encoder_outputs"},{anchor:"transformers.RagModel.forward.decoder_input_ids",description:`<strong>decoder_input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, target_sequence_length)</code>, <em>optional</em>) &#x2014;
Provide for generation tasks. <code>None</code> by default, construct as per instructions for the generator model
you&#x2019;re using with your RAG instance.`,name:"decoder_input_ids"},{anchor:"transformers.RagModel.forward.decoder_attention_mask",description:`<strong>decoder_attention_mask</strong> (<code>torch.BoolTensor</code> of shape <code>(batch_size, target_sequence_length)</code>, <em>optional</em>) &#x2014;
Default behavior: generate a tensor that ignores pad tokens in <code>decoder_input_ids</code>. Causal mask will also
be used by default.`,name:"decoder_attention_mask"},{anchor:"transformers.RagModel.forward.past_key_values",description:`<strong>past_key_values</strong> (<code>tuple(tuple(torch.FloatTensor))</code>) &#x2014;
Tuple consists of two elements: <code>encoder_outputs</code> of the RAG model (see <code>encoder_outputs</code>) and
<code>past_key_values</code> of the underlying generator. Can be used to speed up decoding. <code>past_key_values</code> are used
in the (<a href="/docs/transformers/v4.33.0/en/model_doc/rag#transformers.RagTokenForGeneration">RagTokenForGeneration</a>) model during decoding.`,name:"past_key_values"},{anchor:"transformers.RagModel.forward.doc_scores",description:`<strong>doc_scores</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, config.n_docs)</code>) &#x2014;
Score between each retrieved document embeddings (see <code>retrieved_doc_embeds</code>) and
<code>question_encoder_last_hidden_state</code>. If the model has is not initialized with a <code>retriever</code> <code>doc_scores</code>
has to be provided to the forward pass. <code>doc_scores</code> can be computed via
<code>question_encoder_last_hidden_state</code> and <code>retrieved_doc_embeds</code>, see examples for more information.`,name:"doc_scores"},{anchor:"transformers.RagModel.forward.context_input_ids",description:`<strong>context_input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size * config.n_docs, config.max_combined_length)</code>, <em>optional</em>, returned when <em>output_retrieved=True</em>) &#x2014;
Input IDs post-processed from the retrieved documents and the question encoder <code>input_ids</code> by the
retriever. If the model was not initialized with a <code>retriever</code> \`<code>context_input_ids</code> has to be provided to
the forward pass. <code>context_input_ids</code> are returned by <code>__call__()</code>.`,name:"context_input_ids"},{anchor:"transformers.RagModel.forward.context_attention_mask",description:`<strong>context_attention_mask</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size * config.n_docs, config.max_combined_length)</code>,<em>optional</em>, returned when <em>output_retrieved=True</em>) &#x2014;
Attention mask post-processed from the retrieved documents and the question encoder <code>input_ids</code> by the
retriever. If the model has is not initialized with a <code>retriever</code> <code>context_attention_mask</code> has to be
provided to the forward pass. <code>context_attention_mask</code> are returned by <code>__call__()</code>.`,name:"context_attention_mask"},{anchor:"transformers.RagModel.forward.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
If set to <code>True</code>, <code>past_key_values</code> key value states are returned and can be used to speed up decoding (see
<code>past_key_values</code>).`,name:"use_cache"},{anchor:"transformers.RagModel.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.RagModel.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.RagModel.forward.output_retrieved(bool,",description:`<strong>output_retrieved(<code>bool</code>,</strong> <em>optional</em>) &#x2014;
Whether or not to return the <code>retrieved_doc_embeds</code>, <code>retrieved_doc_ids</code>, <code>context_input_ids</code> and
<code>context_attention_mask</code>. See returned tensors for more detail.`,name:"output_retrieved(bool,"},{anchor:"transformers.RagModel.forward.n_docs",description:"<strong>n_docs</strong> (<code>int</code>, <em>optional</em>, defaults to `config.n_docs&#x201C;) &#x2014;\nNumber of documents to retrieve and/or number of documents for which to generate an answer.",name:"n_docs"}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/models/rag/modeling_rag.py#L532",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.33.0/en/model_doc/rag#transformers.models.rag.modeling_rag.RetrievAugLMOutput"
>transformers.models.rag.modeling_rag.RetrievAugLMOutput</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.33.0/en/model_doc/rag#transformers.RagConfig"
>RagConfig</a>) and inputs.</p>
<ul>
<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. The score is possibly marginalized over all documents for
each vocabulary token.</p>
</li>
<li>
<p><strong>doc_scores</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, config.n_docs)</code>) \u2014 Score between each retrieved document embeddings (see <code>retrieved_doc_embeds</code>) and
<code>question_encoder_last_hidden_state</code>.</p>
</li>
<li>
<p><strong>past_key_values</strong> (<code>List[torch.FloatTensor]</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) \u2014 List of <code>torch.FloatTensor</code> of length <code>config.n_layers</code>, with each tensor of shape <code>(2, batch_size, num_heads, sequence_length, embed_size_per_head)</code>).</p>
<p>Contains precomputed hidden-states (key and values in the attention blocks) of the decoder that can be used
(see <code>past_key_values</code> input) to speed up sequential decoding.</p>
</li>
<li>
<p><strong>retrieved_doc_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, config.n_docs, hidden_size)</code>, <em>optional</em>, returned when <em>output_retrieved=True</em>) \u2014 Embedded documents retrieved by the retriever. Is used with <code>question_encoder_last_hidden_state</code> to compute
the <code>doc_scores</code>.</p>
</li>
<li>
<p><strong>retrieved_doc_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, config.n_docs)</code>, <em>optional</em>, returned when <em>output_retrieved=True</em>) \u2014 The indexes of the embedded documents retrieved by the retriever.</p>
</li>
<li>
<p><strong>context_input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size * config.n_docs, config.max_combined_length)</code>, <em>optional</em>, returned when <em>output_retrieved=True</em>) \u2014 Input ids post-processed from the retrieved documents and the question encoder input_ids by the retriever.</p>
</li>
<li>
<p><strong>context_attention_mask</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size * config.n_docs, config.max_combined_length)</code>, <em>optional</em>, returned when <em>output_retrieved=True</em>) \u2014 Attention mask post-processed from the retrieved documents and the question encoder <code>input_ids</code> by the
retriever.</p>
</li>
<li>
<p><strong>question_encoder_last_hidden_state</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) \u2014 Sequence of hidden states at the output of the last layer of the question encoder pooled output of the
model.</p>
</li>
<li>
<p><strong>question_enc_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 and one for the output of each layer) of
shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden states of the question encoder at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>question_enc_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 of the question encoder, after the attention softmax, used to compute the weighted
average in the self-attention heads.</p>
</li>
<li>
<p><strong>generator_enc_last_hidden_state</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) \u2014 Sequence of hidden-states at the output of the last layer of the generator encoder of the model.</p>
</li>
<li>
<p><strong>generator_enc_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 and one for the output of each layer) of
shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden states of the generator encoder at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>generator_enc_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 of the generator encoder, after the attention softmax, used to compute the weighted
average in the self-attention heads.</p>
</li>
<li>
<p><strong>generator_dec_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 and one for the output of each layer) of
shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden states of the generator decoder at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>generator_dec_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 of the generator decoder, after the attention softmax, used to compute the weighted
average in the self-attention heads.</p>
</li>
<li>
<p><strong>generator_cross_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>Cross-attentions weights of the generator decoder, after the attention softmax, used to compute the
weighted average in the cross-attention heads.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/v4.33.0/en/model_doc/rag#transformers.models.rag.modeling_rag.RetrievAugLMOutput"
>transformers.models.rag.modeling_rag.RetrievAugLMOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),ct=new ue({props:{$$slots:{default:[$T]},$$scope:{ctx:F}}}),lt=new tn({props:{anchor:"transformers.RagModel.forward.example",$$slots:{default:[ZT]},$$scope:{ctx:F}}}),go=new ge({}),fo=new Z({props:{name:"class transformers.RagSequenceForGeneration",anchor:"transformers.RagSequenceForGeneration",parameters:[{name:"config",val:": typing.Optional[transformers.configuration_utils.PretrainedConfig] = None"},{name:"question_encoder",val:": typing.Optional[transformers.modeling_utils.PreTrainedModel] = None"},{name:"generator",val:": typing.Optional[transformers.modeling_utils.PreTrainedModel] = None"},{name:"retriever",val:": typing.Optional[transformers.models.rag.retrieval_rag.RagRetriever] = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.RagSequenceForGeneration.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.33.0/en/model_doc/rag#transformers.RagConfig">RagConfig</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.33.0/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"},{anchor:"transformers.RagSequenceForGeneration.question_encoder",description:`<strong>question_encoder</strong> (<a href="/docs/transformers/v4.33.0/en/main_classes/model#transformers.PreTrainedModel">PreTrainedModel</a>) &#x2014;
An encoder model compatible with the faiss index encapsulated by the <code>retriever</code>.`,name:"question_encoder"},{anchor:"transformers.RagSequenceForGeneration.generator",description:`<strong>generator</strong> (<a href="/docs/transformers/v4.33.0/en/main_classes/model#transformers.PreTrainedModel">PreTrainedModel</a>) &#x2014;
A seq2seq model used as the generator in the RAG architecture.`,name:"generator"},{anchor:"transformers.RagSequenceForGeneration.retriever",description:`<strong>retriever</strong> (<a href="/docs/transformers/v4.33.0/en/model_doc/rag#transformers.RagRetriever">RagRetriever</a>) &#x2014;
A retriever class encapsulating a faiss index queried to obtain context documents for current inputs.`,name:"retriever"}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/models/rag/modeling_rag.py#L735"}}),ht=new ue({props:{$$slots:{default:[IT]},$$scope:{ctx:F}}}),bo=new Z({props:{name:"forward",anchor:"transformers.RagSequenceForGeneration.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"encoder_outputs",val:": typing.Optional[typing.Tuple[typing.Tuple[torch.Tensor]]] = None"},{name:"decoder_input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"decoder_attention_mask",val:": typing.Optional[torch.BoolTensor] = None"},{name:"past_key_values",val:": typing.Optional[typing.Tuple[typing.Tuple[torch.Tensor]]] = None"},{name:"context_input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"context_attention_mask",val:": typing.Optional[torch.LongTensor] = None"},{name:"doc_scores",val:": typing.Optional[torch.FloatTensor] = None"},{name:"use_cache",val:": typing.Optional[bool] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"output_retrieved",val:": typing.Optional[bool] = None"},{name:"exclude_bos_score",val:": typing.Optional[bool] = None"},{name:"reduce_loss",val:": typing.Optional[bool] = None"},{name:"labels",val:": typing.Optional[torch.LongTensor] = None"},{name:"n_docs",val:": typing.Optional[int] = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.RagSequenceForGeneration.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. <a href="/docs/transformers/v4.33.0/en/model_doc/rag#transformers.RagConfig">RagConfig</a>, used to initialize the model, specifies
which generator to use, it also specifies a compatible generator tokenizer. Use that tokenizer class to
obtain the indices.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.RagSequenceForGeneration.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.Tensor</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.RagSequenceForGeneration.forward.encoder_outputs",description:`<strong>encoder_outputs</strong> (<code>tuple(tuple(torch.FloatTensor)</code>, <em>optional</em>) &#x2014;
Tuple consists of (<code>generator_enc_last_hidden_state</code>, <em>optional</em>: <code>generator_enc_hidden_states</code>,
<em>optional</em>: <code>generator_enc_attentions</code>). <code>generator_enc_last_hidden_state</code> of shape <code>(batch_size, n_docs * sequence_length, hidden_size)</code> is a sequence of hidden-states at the output of the last layer of the
generator&#x2019;s encoder.</p>
<p>Used by the (<a href="/docs/transformers/v4.33.0/en/model_doc/rag#transformers.RagModel">RagModel</a>) model during decoding.`,name:"encoder_outputs"},{anchor:"transformers.RagSequenceForGeneration.forward.decoder_input_ids",description:`<strong>decoder_input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, target_sequence_length)</code>, <em>optional</em>) &#x2014;
Provide for generation tasks. <code>None</code> by default, construct as per instructions for the generator model
you&#x2019;re using with your RAG instance.`,name:"decoder_input_ids"},{anchor:"transformers.RagSequenceForGeneration.forward.decoder_attention_mask",description:`<strong>decoder_attention_mask</strong> (<code>torch.BoolTensor</code> of shape <code>(batch_size, target_sequence_length)</code>, <em>optional</em>) &#x2014;
Default behavior: generate a tensor that ignores pad tokens in <code>decoder_input_ids</code>. Causal mask will also
be used by default.`,name:"decoder_attention_mask"},{anchor:"transformers.RagSequenceForGeneration.forward.past_key_values",description:`<strong>past_key_values</strong> (<code>tuple(tuple(torch.FloatTensor))</code>) &#x2014;
Tuple consists of two elements: <code>encoder_outputs</code> of the RAG model (see <code>encoder_outputs</code>) and
<code>past_key_values</code> of the underlying generator. Can be used to speed up decoding. <code>past_key_values</code> are used
in the (<a href="/docs/transformers/v4.33.0/en/model_doc/rag#transformers.RagTokenForGeneration">RagTokenForGeneration</a>) model during decoding.`,name:"past_key_values"},{anchor:"transformers.RagSequenceForGeneration.forward.doc_scores",description:`<strong>doc_scores</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, config.n_docs)</code>) &#x2014;
Score between each retrieved document embeddings (see <code>retrieved_doc_embeds</code>) and
<code>question_encoder_last_hidden_state</code>. If the model has is not initialized with a <code>retriever</code> <code>doc_scores</code>
has to be provided to the forward pass. <code>doc_scores</code> can be computed via
<code>question_encoder_last_hidden_state</code> and <code>retrieved_doc_embeds</code>, see examples for more information.`,name:"doc_scores"},{anchor:"transformers.RagSequenceForGeneration.forward.context_input_ids",description:`<strong>context_input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size * config.n_docs, config.max_combined_length)</code>, <em>optional</em>, returned when <em>output_retrieved=True</em>) &#x2014;
Input IDs post-processed from the retrieved documents and the question encoder <code>input_ids</code> by the
retriever. If the model was not initialized with a <code>retriever</code> \`<code>context_input_ids</code> has to be provided to
the forward pass. <code>context_input_ids</code> are returned by <code>__call__()</code>.`,name:"context_input_ids"},{anchor:"transformers.RagSequenceForGeneration.forward.context_attention_mask",description:`<strong>context_attention_mask</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size * config.n_docs, config.max_combined_length)</code>,<em>optional</em>, returned when <em>output_retrieved=True</em>) &#x2014;
Attention mask post-processed from the retrieved documents and the question encoder <code>input_ids</code> by the
retriever. If the model has is not initialized with a <code>retriever</code> <code>context_attention_mask</code> has to be
provided to the forward pass. <code>context_attention_mask</code> are returned by <code>__call__()</code>.`,name:"context_attention_mask"},{anchor:"transformers.RagSequenceForGeneration.forward.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
If set to <code>True</code>, <code>past_key_values</code> key value states are returned and can be used to speed up decoding (see
<code>past_key_values</code>).`,name:"use_cache"},{anchor:"transformers.RagSequenceForGeneration.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.RagSequenceForGeneration.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.RagSequenceForGeneration.forward.output_retrieved(bool,",description:`<strong>output_retrieved(<code>bool</code>,</strong> <em>optional</em>) &#x2014;
Whether or not to return the <code>retrieved_doc_embeds</code>, <code>retrieved_doc_ids</code>, <code>context_input_ids</code> and
<code>context_attention_mask</code>. See returned tensors for more detail.`,name:"output_retrieved(bool,"},{anchor:"transformers.RagSequenceForGeneration.forward.n_docs",description:"<strong>n_docs</strong> (<code>int</code>, <em>optional</em>, defaults to `config.n_docs&#x201C;) &#x2014;\nNumber of documents to retrieve and/or number of documents for which to generate an answer.",name:"n_docs"},{anchor:"transformers.RagSequenceForGeneration.forward.exclude_bos_score",description:`<strong>exclude_bos_score</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Only relevant if <code>labels</code> is passed. If <code>True</code>, the score of the BOS token is disregarded when computing
the loss.`,name:"exclude_bos_score"},{anchor:"transformers.RagSequenceForGeneration.forward.reduce_loss",description:`<strong>reduce_loss</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Only relevant if <code>labels</code> is passed. If <code>True</code>, the NLL loss is reduced using the <code>torch.Tensor.sum</code>
operation.`,name:"reduce_loss"},{anchor:"transformers.RagSequenceForGeneration.forward.kwargs",description:`<strong>kwargs</strong> (<code>Dict[str, any]</code>, optional, defaults to <em>{}</em>) &#x2014;
Legacy dictionary, which is required so that model can use <em>generate()</em> function.`,name:"kwargs"}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/models/rag/modeling_rag.py#L764",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.33.0/en/model_doc/rag#transformers.models.rag.modeling_rag.RetrievAugLMMarginOutput"
>transformers.models.rag.modeling_rag.RetrievAugLMMarginOutput</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.33.0/en/model_doc/rag#transformers.RagConfig"
>RagConfig</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 Language modeling 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. The score is possibly marginalized over all documents for
each vocabulary token.</p>
</li>
<li>
<p><strong>doc_scores</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, config.n_docs)</code>) \u2014 Score between each retrieved document embeddings (see <code>retrieved_doc_embeds</code>) and
<code>question_encoder_last_hidden_state</code>.</p>
</li>
<li>
<p><strong>past_key_values</strong> (<code>List[torch.FloatTensor]</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) \u2014 List of <code>torch.FloatTensor</code> of length <code>config.n_layers</code>, with each tensor of shape <code>(2, batch_size, num_heads, sequence_length, embed_size_per_head)</code>).</p>
<p>Contains precomputed hidden-states (key and values in the attention blocks) of the decoder that can be used
(see <code>past_key_values</code> input) to speed up sequential decoding.</p>
</li>
<li>
<p><strong>retrieved_doc_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, config.n_docs, hidden_size)</code>, <em>optional</em>, returned when <em>output_retrieved=True</em>) \u2014 Embedded documents retrieved by the retriever. Is used with <code>question_encoder_last_hidden_state</code> to compute
the <code>doc_scores</code>.</p>
</li>
<li>
<p><strong>retrieved_doc_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, config.n_docs)</code>, <em>optional</em>, returned when <em>output_retrieved=True</em>) \u2014 The indexes of the embedded documents retrieved by the retriever.</p>
</li>
<li>
<p><strong>context_input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size * config.n_docs, config.max_combined_length)</code>, <em>optional</em>, returned when <em>output_retrieved=True</em>) \u2014 Input ids post-processed from the retrieved documents and the question encoder input_ids by the retriever.</p>
</li>
<li>
<p><strong>context_attention_mask</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size * config.n_docs, config.max_combined_length)</code>, <em>optional</em>, returned when <em>output_retrieved=True</em>) \u2014 Attention mask post-processed from the retrieved documents and the question encoder <code>input_ids</code> by the
retriever.</p>
</li>
<li>
<p><strong>question_encoder_last_hidden_state</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) \u2014 Sequence of hidden states at the output of the last layer of the question encoder pooled output of the
model.</p>
</li>
<li>
<p><strong>question_enc_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 and one for the output of each layer) of
shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden states of the question encoder at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>question_enc_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 of the question encoder, after the attention softmax, used to compute the weighted
average in the self-attention heads.</p>
</li>
<li>
<p><strong>generator_enc_last_hidden_state</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) \u2014 Sequence of hidden-states at the output of the last layer of the generator encoder of the model.</p>
</li>
<li>
<p><strong>generator_enc_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 and one for the output of each layer) of
shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden states of the generator encoder at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>generator_enc_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 of the generator encoder, after the attention softmax, used to compute the weighted
average in the self-attention heads.</p>
</li>
<li>
<p><strong>generator_dec_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 and one for the output of each layer) of
shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden states of the generator decoder at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>generator_dec_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 of the generator decoder, after the attention softmax, used to compute the weighted
average in the self-attention heads.</p>
</li>
<li>
<p><strong>generator_cross_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>Cross-attentions weights of the generator decoder, after the attention softmax, used to compute the
weighted average in the cross-attention heads.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/v4.33.0/en/model_doc/rag#transformers.models.rag.modeling_rag.RetrievAugLMMarginOutput"
>transformers.models.rag.modeling_rag.RetrievAugLMMarginOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),mt=new ue({props:{$$slots:{default:[CT]},$$scope:{ctx:F}}}),ut=new tn({props:{anchor:"transformers.RagSequenceForGeneration.forward.example",$$slots:{default:[NT]},$$scope:{ctx:F}}}),yo=new Z({props:{name:"generate",anchor:"transformers.RagSequenceForGeneration.generate",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.LongTensor] = None"},{name:"context_input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"context_attention_mask",val:": typing.Optional[torch.LongTensor] = None"},{name:"doc_scores",val:": typing.Optional[torch.FloatTensor] = None"},{name:"do_deduplication",val:": typing.Optional[bool] = None"},{name:"num_return_sequences",val:": typing.Optional[int] = None"},{name:"num_beams",val:": typing.Optional[int] = None"},{name:"n_docs",val:": typing.Optional[int] = None"},{name:"**model_kwargs",val:""}],parametersDescription:[{anchor:"transformers.RagSequenceForGeneration.generate.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
The sequence used as a prompt for the generation. If <code>input_ids</code> is not passed, then
<code>context_input_ids</code> has to be provided.`,name:"input_ids"},{anchor:"transformers.RagSequenceForGeneration.generate.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.Tensor</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.RagSequenceForGeneration.generate.context_input_ids",description:`<strong>context_input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size * config.n_docs, config.max_combined_length)</code>, <em>optional</em>, returned when <em>output_retrieved=True</em>) &#x2014;
Input IDs post-processed from the retrieved documents and the question encoder input_ids by the
retriever.`,name:"context_input_ids"},{anchor:"transformers.RagSequenceForGeneration.generate.context_attention_mask",description:`<strong>context_attention_mask</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size * config.n_docs, config.max_combined_length)</code>, <em>optional</em>, returned when <em>output_retrieved=True</em>) &#x2014;
Attention mask post-processed from the retrieved documents and the question encoder <code>input_ids</code> by the
retriever.</p>
<p>If the model is not initialized with a <code>retriever</code> or <code>input_ids</code> is not given, <code>context_input_ids</code> and
<code>context_attention_mask</code> have to be provided to the forward pass. They are returned by
<code>__call__()</code>.`,name:"context_attention_mask"},{anchor:"transformers.RagSequenceForGeneration.generate.doc_scores",description:`<strong>doc_scores</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, config.n_docs)</code>) &#x2014;
Score between each retrieved document embeddings (see <code>retrieved_doc_embeds</code>) and
<code>question_encoder_last_hidden_state</code>.</p>
<p>If the model is not initialized with a <code>retriever</code> or <code>input_ids</code> is not given, <code>doc_scores</code> has to be
provided to the forward pass. <code>doc_scores</code> are returned by <code>__call__()</code>.`,name:"doc_scores"},{anchor:"transformers.RagSequenceForGeneration.generate.do_deduplication",description:`<strong>do_deduplication</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to deduplicate the generations from different context documents for a given input. Has
to be set to <code>False</code> if used while training with distributed backend.`,name:"do_deduplication"},{anchor:"transformers.RagSequenceForGeneration.generate.num_return_sequences(int,",description:`<strong>num_return_sequences(<code>int</code>,</strong> <em>optional</em>, defaults to 1) &#x2014;
The number of independently computed returned sequences for each element in the batch. Note that this
is not the value we pass to the <code>generator</code>&#x2019;s <code>[generate()](/docs/transformers/v4.33.0/en/main_classes/text_generation#transformers.GenerationMixin.generate)</code> function,
where we set <code>num_return_sequences</code> to <code>num_beams</code>.`,name:"num_return_sequences(int,"},{anchor:"transformers.RagSequenceForGeneration.generate.num_beams",description:`<strong>num_beams</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
Number of beams for beam search. 1 means no beam search.`,name:"num_beams"},{anchor:"transformers.RagSequenceForGeneration.generate.n_docs",description:`<strong>n_docs</strong> (<code>int</code>, <em>optional</em>, defaults to <code>config.n_docs</code>) &#x2014;
Number of documents to retrieve and/or number of documents for which to generate an answer.`,name:"n_docs"},{anchor:"transformers.RagSequenceForGeneration.generate.kwargs",description:`<strong>kwargs</strong> (<code>Dict[str, Any]</code>, <em>optional</em>) &#x2014;
Additional kwargs will be passed to <a href="/docs/transformers/v4.33.0/en/main_classes/text_generation#transformers.GenerationMixin.generate">generate()</a>.`,name:"kwargs"}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/models/rag/modeling_rag.py#L905",returnDescription:`
<p>The generated
sequences. The second dimension (sequence length) is either equal to <code>max_length</code> or shorter if all batches
finished early due to the <code>eos_token_id</code>.</p>
`,returnType:`
<p><code>torch.LongTensor</code> of shape <code>(batch_size * num_return_sequences, sequence_length)</code></p>
`}}),Mo=new ge({}),Ro=new Z({props:{name:"class transformers.RagTokenForGeneration",anchor:"transformers.RagTokenForGeneration",parameters:[{name:"config",val:": typing.Optional[transformers.configuration_utils.PretrainedConfig] = None"},{name:"question_encoder",val:": typing.Optional[transformers.modeling_utils.PreTrainedModel] = None"},{name:"generator",val:": typing.Optional[transformers.modeling_utils.PreTrainedModel] = None"},{name:"retriever",val:": typing.Optional[transformers.models.rag.retrieval_rag.RagRetriever] = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.RagTokenForGeneration.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.33.0/en/model_doc/rag#transformers.RagConfig">RagConfig</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.33.0/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"},{anchor:"transformers.RagTokenForGeneration.question_encoder",description:`<strong>question_encoder</strong> (<a href="/docs/transformers/v4.33.0/en/main_classes/model#transformers.PreTrainedModel">PreTrainedModel</a>) &#x2014;
An encoder model compatible with the faiss index encapsulated by the <code>retriever</code>.`,name:"question_encoder"},{anchor:"transformers.RagTokenForGeneration.generator",description:`<strong>generator</strong> (<a href="/docs/transformers/v4.33.0/en/main_classes/model#transformers.PreTrainedModel">PreTrainedModel</a>) &#x2014;
A seq2seq model used as the generator in the RAG architecture.`,name:"generator"},{anchor:"transformers.RagTokenForGeneration.retriever",description:`<strong>retriever</strong> (<a href="/docs/transformers/v4.33.0/en/model_doc/rag#transformers.RagRetriever">RagRetriever</a>) &#x2014;
A retriever class encapsulating a faiss index queried to obtain context documents for current inputs.`,name:"retriever"}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/models/rag/modeling_rag.py#L1133"}}),_t=new ue({props:{$$slots:{default:[AT]},$$scope:{ctx:F}}}),xo=new Z({props:{name:"forward",anchor:"transformers.RagTokenForGeneration.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"encoder_outputs",val:": typing.Optional[typing.Tuple[typing.Tuple[torch.Tensor]]] = None"},{name:"decoder_input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"decoder_attention_mask",val:": typing.Optional[torch.BoolTensor] = None"},{name:"past_key_values",val:": typing.Optional[typing.Tuple[typing.Tuple[torch.Tensor]]] = None"},{name:"context_input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"context_attention_mask",val:": typing.Optional[torch.LongTensor] = None"},{name:"doc_scores",val:": typing.Optional[torch.FloatTensor] = None"},{name:"use_cache",val:": typing.Optional[bool] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"output_retrieved",val:": typing.Optional[bool] = None"},{name:"do_marginalize",val:": typing.Optional[bool] = None"},{name:"reduce_loss",val:": typing.Optional[bool] = None"},{name:"labels",val:": typing.Optional[torch.LongTensor] = None"},{name:"n_docs",val:": typing.Optional[int] = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.RagTokenForGeneration.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. <a href="/docs/transformers/v4.33.0/en/model_doc/rag#transformers.RagConfig">RagConfig</a>, used to initialize the model, specifies
which generator to use, it also specifies a compatible generator tokenizer. Use that tokenizer class to
obtain the indices.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.RagTokenForGeneration.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.Tensor</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.RagTokenForGeneration.forward.encoder_outputs",description:`<strong>encoder_outputs</strong> (<code>tuple(tuple(torch.FloatTensor)</code>, <em>optional</em>) &#x2014;
Tuple consists of (<code>generator_enc_last_hidden_state</code>, <em>optional</em>: <code>generator_enc_hidden_states</code>,
<em>optional</em>: <code>generator_enc_attentions</code>). <code>generator_enc_last_hidden_state</code> of shape <code>(batch_size, n_docs * sequence_length, hidden_size)</code> is a sequence of hidden-states at the output of the last layer of the
generator&#x2019;s encoder.</p>
<p>Used by the (<a href="/docs/transformers/v4.33.0/en/model_doc/rag#transformers.RagModel">RagModel</a>) model during decoding.`,name:"encoder_outputs"},{anchor:"transformers.RagTokenForGeneration.forward.decoder_input_ids",description:`<strong>decoder_input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, target_sequence_length)</code>, <em>optional</em>) &#x2014;
Provide for generation tasks. <code>None</code> by default, construct as per instructions for the generator model
you&#x2019;re using with your RAG instance.`,name:"decoder_input_ids"},{anchor:"transformers.RagTokenForGeneration.forward.decoder_attention_mask",description:`<strong>decoder_attention_mask</strong> (<code>torch.BoolTensor</code> of shape <code>(batch_size, target_sequence_length)</code>, <em>optional</em>) &#x2014;
Default behavior: generate a tensor that ignores pad tokens in <code>decoder_input_ids</code>. Causal mask will also
be used by default.`,name:"decoder_attention_mask"},{anchor:"transformers.RagTokenForGeneration.forward.past_key_values",description:`<strong>past_key_values</strong> (<code>tuple(tuple(torch.FloatTensor))</code>) &#x2014;
Tuple consists of two elements: <code>encoder_outputs</code> of the RAG model (see <code>encoder_outputs</code>) and
<code>past_key_values</code> of the underlying generator. Can be used to speed up decoding. <code>past_key_values</code> are used
in the (<a href="/docs/transformers/v4.33.0/en/model_doc/rag#transformers.RagTokenForGeneration">RagTokenForGeneration</a>) model during decoding.`,name:"past_key_values"},{anchor:"transformers.RagTokenForGeneration.forward.doc_scores",description:`<strong>doc_scores</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, config.n_docs)</code>) &#x2014;
Score between each retrieved document embeddings (see <code>retrieved_doc_embeds</code>) and
<code>question_encoder_last_hidden_state</code>. If the model has is not initialized with a <code>retriever</code> <code>doc_scores</code>
has to be provided to the forward pass. <code>doc_scores</code> can be computed via
<code>question_encoder_last_hidden_state</code> and <code>retrieved_doc_embeds</code>, see examples for more information.`,name:"doc_scores"},{anchor:"transformers.RagTokenForGeneration.forward.context_input_ids",description:`<strong>context_input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size * config.n_docs, config.max_combined_length)</code>, <em>optional</em>, returned when <em>output_retrieved=True</em>) &#x2014;
Input IDs post-processed from the retrieved documents and the question encoder <code>input_ids</code> by the
retriever. If the model was not initialized with a <code>retriever</code> \`<code>context_input_ids</code> has to be provided to
the forward pass. <code>context_input_ids</code> are returned by <code>__call__()</code>.`,name:"context_input_ids"},{anchor:"transformers.RagTokenForGeneration.forward.context_attention_mask",description:`<strong>context_attention_mask</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size * config.n_docs, config.max_combined_length)</code>,<em>optional</em>, returned when <em>output_retrieved=True</em>) &#x2014;
Attention mask post-processed from the retrieved documents and the question encoder <code>input_ids</code> by the
retriever. If the model has is not initialized with a <code>retriever</code> <code>context_attention_mask</code> has to be
provided to the forward pass. <code>context_attention_mask</code> are returned by <code>__call__()</code>.`,name:"context_attention_mask"},{anchor:"transformers.RagTokenForGeneration.forward.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
If set to <code>True</code>, <code>past_key_values</code> key value states are returned and can be used to speed up decoding (see
<code>past_key_values</code>).`,name:"use_cache"},{anchor:"transformers.RagTokenForGeneration.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.RagTokenForGeneration.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.RagTokenForGeneration.forward.output_retrieved(bool,",description:`<strong>output_retrieved(<code>bool</code>,</strong> <em>optional</em>) &#x2014;
Whether or not to return the <code>retrieved_doc_embeds</code>, <code>retrieved_doc_ids</code>, <code>context_input_ids</code> and
<code>context_attention_mask</code>. See returned tensors for more detail.`,name:"output_retrieved(bool,"},{anchor:"transformers.RagTokenForGeneration.forward.n_docs",description:"<strong>n_docs</strong> (<code>int</code>, <em>optional</em>, defaults to `config.n_docs&#x201C;) &#x2014;\nNumber of documents to retrieve and/or number of documents for which to generate an answer.",name:"n_docs"},{anchor:"transformers.RagTokenForGeneration.forward.do_marginalize",description:`<strong>do_marginalize</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
If <code>True</code>, the logits are marginalized over all documents by making use of
<code>torch.nn.functional.log_softmax</code>.`,name:"do_marginalize"},{anchor:"transformers.RagTokenForGeneration.forward.reduce_loss",description:`<strong>reduce_loss</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Only relevant if <code>labels</code> is passed. If <code>True</code>, the NLL loss is reduced using the <code>torch.Tensor.sum</code>
operation.`,name:"reduce_loss"},{anchor:"transformers.RagTokenForGeneration.forward.kwargs",description:`<strong>kwargs</strong> (<code>Dict[str, any]</code>, optional, defaults to <em>{}</em>) &#x2014;
Legacy dictionary, which is required so that model can use <em>generate()</em> function.`,name:"kwargs"}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/models/rag/modeling_rag.py#L1231",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.33.0/en/model_doc/rag#transformers.models.rag.modeling_rag.RetrievAugLMMarginOutput"
>transformers.models.rag.modeling_rag.RetrievAugLMMarginOutput</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.33.0/en/model_doc/rag#transformers.RagConfig"
>RagConfig</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 Language modeling 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. The score is possibly marginalized over all documents for
each vocabulary token.</p>
</li>
<li>
<p><strong>doc_scores</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, config.n_docs)</code>) \u2014 Score between each retrieved document embeddings (see <code>retrieved_doc_embeds</code>) and
<code>question_encoder_last_hidden_state</code>.</p>
</li>
<li>
<p><strong>past_key_values</strong> (<code>List[torch.FloatTensor]</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) \u2014 List of <code>torch.FloatTensor</code> of length <code>config.n_layers</code>, with each tensor of shape <code>(2, batch_size, num_heads, sequence_length, embed_size_per_head)</code>).</p>
<p>Contains precomputed hidden-states (key and values in the attention blocks) of the decoder that can be used
(see <code>past_key_values</code> input) to speed up sequential decoding.</p>
</li>
<li>
<p><strong>retrieved_doc_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, config.n_docs, hidden_size)</code>, <em>optional</em>, returned when <em>output_retrieved=True</em>) \u2014 Embedded documents retrieved by the retriever. Is used with <code>question_encoder_last_hidden_state</code> to compute
the <code>doc_scores</code>.</p>
</li>
<li>
<p><strong>retrieved_doc_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, config.n_docs)</code>, <em>optional</em>, returned when <em>output_retrieved=True</em>) \u2014 The indexes of the embedded documents retrieved by the retriever.</p>
</li>
<li>
<p><strong>context_input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size * config.n_docs, config.max_combined_length)</code>, <em>optional</em>, returned when <em>output_retrieved=True</em>) \u2014 Input ids post-processed from the retrieved documents and the question encoder input_ids by the retriever.</p>
</li>
<li>
<p><strong>context_attention_mask</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size * config.n_docs, config.max_combined_length)</code>, <em>optional</em>, returned when <em>output_retrieved=True</em>) \u2014 Attention mask post-processed from the retrieved documents and the question encoder <code>input_ids</code> by the
retriever.</p>
</li>
<li>
<p><strong>question_encoder_last_hidden_state</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) \u2014 Sequence of hidden states at the output of the last layer of the question encoder pooled output of the
model.</p>
</li>
<li>
<p><strong>question_enc_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 and one for the output of each layer) of
shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden states of the question encoder at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>question_enc_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 of the question encoder, after the attention softmax, used to compute the weighted
average in the self-attention heads.</p>
</li>
<li>
<p><strong>generator_enc_last_hidden_state</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) \u2014 Sequence of hidden-states at the output of the last layer of the generator encoder of the model.</p>
</li>
<li>
<p><strong>generator_enc_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 and one for the output of each layer) of
shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden states of the generator encoder at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>generator_enc_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 of the generator encoder, after the attention softmax, used to compute the weighted
average in the self-attention heads.</p>
</li>
<li>
<p><strong>generator_dec_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 and one for the output of each layer) of
shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden states of the generator decoder at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>generator_dec_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 of the generator decoder, after the attention softmax, used to compute the weighted
average in the self-attention heads.</p>
</li>
<li>
<p><strong>generator_cross_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>Cross-attentions weights of the generator decoder, after the attention softmax, used to compute the
weighted average in the cross-attention heads.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/v4.33.0/en/model_doc/rag#transformers.models.rag.modeling_rag.RetrievAugLMMarginOutput"
>transformers.models.rag.modeling_rag.RetrievAugLMMarginOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),vt=new ue({props:{$$slots:{default:[WT]},$$scope:{ctx:F}}}),Tt=new tn({props:{anchor:"transformers.RagTokenForGeneration.forward.example",$$slots:{default:[XT]},$$scope:{ctx:F}}}),jo=new Z({props:{name:"generate",anchor:"transformers.RagTokenForGeneration.generate",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.LongTensor] = None"},{name:"context_input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"context_attention_mask",val:": typing.Optional[torch.LongTensor] = None"},{name:"doc_scores",val:": typing.Optional[torch.FloatTensor] = None"},{name:"n_docs",val:": typing.Optional[int] = None"},{name:"generation_config",val:": typing.Optional[transformers.generation.configuration_utils.GenerationConfig] = None"},{name:"prefix_allowed_tokens_fn",val:": typing.Callable[[int, torch.Tensor], typing.List[int]] = None"},{name:"logits_processor",val:": typing.Optional[transformers.generation.logits_process.LogitsProcessorList] = []"},{name:"stopping_criteria",val:": typing.Optional[transformers.generation.stopping_criteria.StoppingCriteriaList] = []"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.RagTokenForGeneration.generate.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
The sequence used as a prompt for the generation. If <code>input_ids</code> is not passed, then
<code>context_input_ids</code> has to be provided.`,name:"input_ids"},{anchor:"transformers.RagTokenForGeneration.generate.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.Tensor</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.RagTokenForGeneration.generate.context_input_ids",description:`<strong>context_input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size * config.n_docs, config.max_combined_length)</code>, <em>optional</em>, returned when <em>output_retrieved=True</em>) &#x2014;
Input IDs post-processed from the retrieved documents and the question encoder <code>input_ids</code> by the
retriever.</p>
<p>If the model has is not initialized with a <code>retriever</code>, <code>context_input_ids</code> has to be provided to the
forward pass. <code>context_input_ids</code> are returned by <code>__call__()</code>.`,name:"context_input_ids"},{anchor:"transformers.RagTokenForGeneration.generate.context_attention_mask",description:`<strong>context_attention_mask</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size * config.n_docs, config.max_combined_length)</code>, <em>optional</em>, returned when <em>output_retrieved=True</em>) &#x2014;
Attention mask post-processed from the retrieved documents and the question encoder <code>input_ids</code> by the
retriever.</p>
<p>If the model has is not initialized with a <code>retriever</code>, <code>context_input_ids</code> has to be provided to the
forward pass. <code>context_input_ids</code> are returned by <code>__call__()</code>.`,name:"context_attention_mask"},{anchor:"transformers.RagTokenForGeneration.generate.doc_scores",description:`<strong>doc_scores</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, config.n_docs)</code>) &#x2014;
Score between each retrieved document embeddings (see <code>retrieved_doc_embeds</code>) and
<code>question_encoder_last_hidden_state</code>.</p>
<p>If the model has is not initialized with a <code>retriever</code>, <code>context_input_ids</code> has to be provided to the
forward pass. <code>context_input_ids</code> are returned by <code>__call__()</code>.`,name:"doc_scores"},{anchor:"transformers.RagTokenForGeneration.generate.n_docs",description:`<strong>n_docs</strong> (<code>int</code>, <em>optional</em>, defaults to <code>config.n_docs</code>) &#x2014;
Number of documents to retrieve and/or number of documents for which to generate an answer.`,name:"n_docs"},{anchor:"transformers.RagTokenForGeneration.generate.generation_config",description:`<strong>generation_config</strong> (<code>~generation.GenerationConfig</code>, <em>optional</em>) &#x2014;
The generation configuration to be used as base parametrization for the generation call. <code>**kwargs</code>
passed to generate matching the attributes of <code>generation_config</code> will override them. If
<code>generation_config</code> is not provided, the default will be used, which has the following loading
priority: 1) from the <code>generation_config.json</code> model file, if it exists; 2) from the model
configuration. Please note that unspecified parameters will inherit <a href="/docs/transformers/v4.33.0/en/main_classes/text_generation#transformers.GenerationConfig">GenerationConfig</a>&#x2019;s
default values, whose documentation should be checked to parameterize generation.`,name:"generation_config"},{anchor:"transformers.RagTokenForGeneration.generate.prefix_allowed_tokens_fn",description:`<strong>prefix_allowed_tokens_fn</strong> (<code>Callable[[int, torch.Tensor], List[int]]</code>, <em>optional</em>) &#x2014;
If provided, this function constraints the beam search to allowed tokens only at each step. If not
provided no constraint is applied. This function takes 2 arguments <code>inputs_ids</code> and the batch ID
<code>batch_id</code>. It has to return a list with the allowed tokens for the next generation step conditioned on
the previously generated tokens <code>inputs_ids</code> and the batch ID <code>batch_id</code>. This argument is useful for
constrained generation conditioned on the prefix, as described in <a href="https://arxiv.org/abs/2010.00904" rel="nofollow">Autoregressive Entity
Retrieval</a>.`,name:"prefix_allowed_tokens_fn"},{anchor:"transformers.RagTokenForGeneration.generate.logits_processor",description:`<strong>logits_processor</strong> (<code>LogitsProcessorList</code>, <em>optional</em>) &#x2014;
Custom logits processors that complement the default logits processors built from arguments and a
model&#x2019;s config. If a logit processor is passed that is already created with the arguments or a model&#x2019;s
config an error is thrown.`,name:"logits_processor"},{anchor:"transformers.RagTokenForGeneration.generate.stopping_criteria",description:`<strong>stopping_criteria</strong> (<code>StoppingCriteriaList</code>, <em>optional</em>) &#x2014;
Custom stopping criteria that complement the default stopping criteria built from arguments and a
model&#x2019;s config. If a stopping criteria is passed that is already created with the arguments or a
model&#x2019;s config an error is thrown.`,name:"stopping_criteria"},{anchor:"transformers.RagTokenForGeneration.generate.kwargs",description:`<strong>kwargs</strong> (<code>Dict[str, Any]</code>, <em>optional</em>) &#x2014;
Ad hoc parametrization of <code>generate_config</code> and/or additional model-specific kwargs that will be
forwarded to the <code>forward</code> function of the model.`,name:"kwargs"}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/models/rag/modeling_rag.py#L1372",returnDescription:`
<p>The generated
sequences. The second dimension (sequence_length) is either equal to <code>max_length</code> or shorter if all batches
finished early due to the <code>eos_token_id</code>.</p>
`,returnType:`
<p><code>torch.LongTensor</code> of shape <code>(batch_size * num_return_sequences, sequence_length)</code></p>
`}}),Jo=new ge({}),Go=new Z({props:{name:"class transformers.TFRagModel",anchor:"transformers.TFRagModel",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.TFRagModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.33.0/en/model_doc/rag#transformers.RagConfig">RagConfig</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.33.0/en/main_classes/model#transformers.TFPreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"},{anchor:"transformers.TFRagModel.question_encoder",description:`<strong>question_encoder</strong> (<a href="/docs/transformers/v4.33.0/en/main_classes/model#transformers.TFPreTrainedModel">TFPreTrainedModel</a>) &#x2014;
An encoder model compatible with the faiss index encapsulated by the <code>retriever</code>.`,name:"question_encoder"},{anchor:"transformers.TFRagModel.generator",description:`<strong>generator</strong> (<a href="/docs/transformers/v4.33.0/en/main_classes/model#transformers.TFPreTrainedModel">TFPreTrainedModel</a>) &#x2014;
A seq2seq model used as the generator in the RAG architecture.`,name:"generator"},{anchor:"transformers.TFRagModel.retriever",description:`<strong>retriever</strong> (<a href="/docs/transformers/v4.33.0/en/model_doc/rag#transformers.RagRetriever">RagRetriever</a>) &#x2014;
A retriever class encapsulating a faiss index queried to obtain context documents for current inputs.`,name:"retriever"}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/models/rag/modeling_tf_rag.py#L496"}}),wt=new ue({props:{$$slots:{default:[VT]},$$scope:{ctx:F}}}),$o=new Z({props:{name:"call",anchor:"transformers.TFRagModel.call",parameters:[{name:"input_ids",val:": TFModelInputType | None = None"},{name:"attention_mask",val:": np.ndarray | tf.Tensor | None = None"},{name:"encoder_outputs",val:": np.ndarray | tf.Tensor | None = None"},{name:"decoder_input_ids",val:": np.ndarray | tf.Tensor | None = None"},{name:"decoder_attention_mask",val:": np.ndarray | tf.Tensor | None = None"},{name:"past_key_values",val:": Tuple[Tuple[Union[np.ndarray, tf.Tensor]]] | None = None"},{name:"doc_scores",val:": np.ndarray | tf.Tensor | None = None"},{name:"context_input_ids",val:": np.ndarray | tf.Tensor | None = None"},{name:"context_attention_mask",val:": np.ndarray | tf.Tensor | None = None"},{name:"use_cache",val:": bool | None = None"},{name:"output_attentions",val:": bool | None = None"},{name:"output_hidden_states",val:": bool | None = None"},{name:"output_retrieved",val:": bool | None = None"},{name:"n_docs",val:": int | None = None"},{name:"return_dict",val:": bool | None = None"},{name:"training",val:": bool = False"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.TFRagModel.call.input_ids",description:`<strong>input_ids</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, sequence_length)</code>) &#x2014;
Indices of input sequence tokens in the vocabulary. <a href="/docs/transformers/v4.33.0/en/model_doc/rag#transformers.RagConfig">RagConfig</a>, used to initialize the model, specifies
which generator to use, it also specifies a compatible generator tokenizer. Use that tokenizer class to
obtain the indices.`,name:"input_ids"},{anchor:"transformers.TFRagModel.call.attention_mask",description:`<strong>attention_mask</strong> (<code>tf.Tensor</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.TFRagModel.call.encoder_outputs",description:`<strong>encoder_outputs</strong> (<code>tuple(tuple(tf.Tensor)</code>, <em>optional</em>) &#x2014;
Tuple consists of (<code>generator_enc_last_hidden_state</code>, <em>optional</em>: <code>generator_enc_hidden_states</code>,
<em>optional</em>: <code>generator_enc_attentions</code>). <code>generator_enc_last_hidden_state</code> of shape <code>(batch_size, n_docs * sequence_length, hidden_size)</code> is a sequence of hidden-states at the output of the last layer of the
generator&#x2019;s encoder.</p>
<p>Used by the (<a href="/docs/transformers/v4.33.0/en/model_doc/rag#transformers.TFRagModel">TFRagModel</a>) model during decoding.`,name:"encoder_outputs"},{anchor:"transformers.TFRagModel.call.decoder_input_ids",description:`<strong>decoder_input_ids</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, target_sequence_length)</code>, <em>optional</em>) &#x2014;
Provide for generation tasks. <code>None</code> by default, construct as per instructions for the generator model
you&#x2019;re using with your RAG instance.`,name:"decoder_input_ids"},{anchor:"transformers.TFRagModel.call.decoder_attention_mask",description:`<strong>decoder_attention_mask</strong> (<code>torch.BoolTensor</code> of shape <code>(batch_size, target_sequence_length)</code>, <em>optional</em>) &#x2014;
Default behavior: generate a tensor that ignores pad tokens in <code>decoder_input_ids</code>. Causal mask will also
be used by default.`,name:"decoder_attention_mask"},{anchor:"transformers.TFRagModel.call.past_key_values",description:`<strong>past_key_values</strong> (<code>tuple(tuple(tf.Tensor))</code>) &#x2014;
Tuple consists of two elements: <code>encoder_outputs</code> of the RAG model (see <code>encoder_outputs</code>) and
<code>past_key_values</code> of the underlying generator. Can be used to speed up decoding. <code>past_key_values</code> are used
in the (<a href="/docs/transformers/v4.33.0/en/model_doc/rag#transformers.RagTokenForGeneration">RagTokenForGeneration</a>) model during decoding.`,name:"past_key_values"},{anchor:"transformers.TFRagModel.call.doc_scores",description:`<strong>doc_scores</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, config.n_docs)</code>) &#x2014;
Score between each retrieved document embeddings (see <code>retrieved_doc_embeds</code>) and
<code>question_encoder_last_hidden_state</code>. If the model has is not initialized with a <code>retriever</code> <code>doc_scores</code>
has to be provided to the forward pass. <code>doc_scores</code> can be computed via
<code>question_encoder_last_hidden_state</code> and <code>retrieved_doc_embeds</code>, see examples for more information.`,name:"doc_scores"},{anchor:"transformers.TFRagModel.call.context_input_ids",description:`<strong>context_input_ids</strong> (<code>tf.Tensor</code> of shape <code>(batch_size * config.n_docs, config.max_combined_length)</code>, <em>optional</em>, returned when <em>output_retrieved=True</em>) &#x2014;
Input IDs post-processed from the retrieved documents and the question encoder <code>input_ids</code> by the
retriever.</p>
<p>If the model has is not initialized with a <code>retriever</code> \`<code>context_input_ids</code> has to be provided to the
forward pass. <code>context_input_ids</code> are returned by <code>__call__()</code>. context_attention_mask
(<code>tf.Tensor</code> of shape <code>(batch_size * config.n_docs, config.max_combined_length)</code>, <em>optional</em>, returned when
<em>output_retrieved=True</em>): Attention mask post-processed from the retrieved documents and the question
encoder <code>input_ids</code> by the retriever.</p>
<p>If the model has is not initialized with a <code>retriever</code> <code>context_attention_mask</code> has to be provided to the
forward pass. <code>context_attention_mask</code> are returned by <code>__call__()</code>.`,name:"context_input_ids"},{anchor:"transformers.TFRagModel.call.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
If set to <code>True</code>, <code>past_key_values</code> key value states are returned and can be used to speed up decoding (see
<code>past_key_values</code>).`,name:"use_cache"},{anchor:"transformers.TFRagModel.call.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.TFRagModel.call.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.TFRagModel.call.output_retrieved(bool,",description:`<strong>output_retrieved(<code>bool</code>,</strong> <em>optional</em>) &#x2014;
Whether or not to return the <code>retrieved_doc_embeds</code>, <code>retrieved_doc_ids</code>, <code>context_input_ids</code> and
<code>context_attention_mask</code>. See returned tensors for more detail.`,name:"output_retrieved(bool,"},{anchor:"transformers.TFRagModel.call.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <code>TFRetrievAugLMOutput</code> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.TFRagModel.call.n_docs",description:"<strong>n_docs</strong> (<code>int</code>, <em>optional</em>, defaults to `config.n_docs&#x201C;) &#x2014;\nNumber of documents to retrieve and/or number of documents for which to generate an answer.",name:"n_docs"}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/models/rag/modeling_tf_rag.py#L546",returnDescription:`
<p>A <code>transformers.models.rag.modeling_tf_rag.TFRetrievAugLMOutput</code> or a tuple of <code>tf.Tensor</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.33.0/en/model_doc/rag#transformers.RagConfig"
>RagConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>logits</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, sequence_length, config.vocab_size)</code>) \u2014 Prediction scores of the language modeling head. The score is possibly marginalized over all documents for
each vocabulary token.</p>
</li>
<li>
<p><strong>past_key_values</strong> (<code>List[tf.Tensor]</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) \u2014 List of <code>tf.Tensor</code> of length <code>config.n_layers</code>, with each tensor of shape <code>(2, batch_size, num_heads, sequence_length, embed_size_per_head)</code>).</p>
<p>Contains precomputed hidden-states (key and values in the attention blocks) of the decoder that can be used
(see <code>past_key_values</code> input) to speed up sequential decoding.</p>
</li>
<li>
<p><strong>doc_scores</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, config.n_docs)</code>) \u2014 Score between each retrieved document embeddings (see <code>retrieved_doc_embeds</code>) and
<code>question_encoder_last_hidden_state</code>.</p>
</li>
<li>
<p><strong>retrieved_doc_embeds</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, config.n_docs, hidden_size)</code>, <em>optional</em>, returned when <em>output_retrieved=True</em>) \u2014 Embedded documents retrieved by the retriever. Is used with <code>question_encoder_last_hidden_state</code> to compute
the <code>doc_scores</code>.</p>
</li>
<li>
<p><strong>retrieved_doc_ids</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, config.n_docs)</code>, <em>optional</em>, returned when <em>output_retrieved=True</em>) \u2014 The indexes of the embedded documents retrieved by the retriever.</p>
</li>
<li>
<p><strong>context_input_ids</strong> (<code>tf.Tensor</code> of shape <code>(batch_size * config.n_docs, config.max_combined_length)</code>, <em>optional</em>, returned when <em>output_retrieved=True</em>) \u2014 Input ids post-processed from the retrieved documents and the question encoder input_ids by the retriever.</p>
</li>
<li>
<p><strong>context_attention_mask</strong> (<code>tf.Tensor</code> of shape <code>(batch_size * config.n_docs, config.max_combined_length)</code>, <em>optional</em>, returned when <em>output_retrieved=True</em>) \u2014 Attention mask post-processed from the retrieved documents and the question encoder <code>input_ids</code> by the
retriever.</p>
</li>
<li>
<p><strong>question_encoder_last_hidden_state</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) \u2014 Sequence of hidden states at the output of the last layer of the question encoder pooled output of the
model.</p>
</li>
<li>
<p><strong>question_enc_hidden_states</strong> (<code>tuple(tf.Tensor)</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>tf.Tensor</code> (one for the output of the embeddings and one for the output of each layer) of shape
<code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden states of the question encoder at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>question_enc_attentions</strong> (<code>tuple(tf.Tensor)</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>tf.Tensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights of the question encoder, after the attention softmax, used to compute the weighted
average in the self-attention heads.</p>
</li>
<li>
<p><strong>generator_enc_last_hidden_state</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) \u2014 Sequence of hidden-states at the output of the last layer of the generator encoder of the model.</p>
</li>
<li>
<p><strong>generator_enc_hidden_states</strong> (<code>tuple(tf.Tensor)</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>tf.Tensor</code> (one for the output of the embeddings and one for the output of each layer) of shape
<code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden states of the generator encoder at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>generator_enc_attentions</strong> (<code>tuple(tf.Tensor)</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>tf.Tensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights of the generator encoder, after the attention softmax, used to compute the weighted
average in the self-attention heads.</p>
</li>
<li>
<p><strong>generator_dec_hidden_states</strong> (<code>tuple(tf.Tensor)</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>tf.Tensor</code> (one for the output of the embeddings and one for the output of each layer) of shape
<code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden states of the generator decoder at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>generator_dec_attentions</strong> (<code>tuple(tf.Tensor)</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>tf.Tensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights of the generator decoder, after the attention softmax, used to compute the weighted
average in the self-attention heads.</p>
</li>
</ul>
`,returnType:`
<p><code>transformers.models.rag.modeling_tf_rag.TFRetrievAugLMOutput</code> or <code>tuple(tf.Tensor)</code></p>
`}}),Mt=new ue({props:{$$slots:{default:[ST]},$$scope:{ctx:F}}}),Rt=new tn({props:{anchor:"transformers.TFRagModel.call.example",$$slots:{default:[BT]},$$scope:{ctx:F}}}),Zo=new ge({}),Io=new Z({props:{name:"class transformers.TFRagSequenceForGeneration",anchor:"transformers.TFRagSequenceForGeneration",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.TFRagSequenceForGeneration.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.33.0/en/model_doc/rag#transformers.RagConfig">RagConfig</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.33.0/en/main_classes/model#transformers.TFPreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"},{anchor:"transformers.TFRagSequenceForGeneration.question_encoder",description:`<strong>question_encoder</strong> (<a href="/docs/transformers/v4.33.0/en/main_classes/model#transformers.TFPreTrainedModel">TFPreTrainedModel</a>) &#x2014;
An encoder model compatible with the faiss index encapsulated by the <code>retriever</code>.`,name:"question_encoder"},{anchor:"transformers.TFRagSequenceForGeneration.generator",description:`<strong>generator</strong> (<a href="/docs/transformers/v4.33.0/en/main_classes/model#transformers.TFPreTrainedModel">TFPreTrainedModel</a>) &#x2014;
A seq2seq model used as the generator in the RAG architecture.`,name:"generator"},{anchor:"transformers.TFRagSequenceForGeneration.retriever",description:`<strong>retriever</strong> (<a href="/docs/transformers/v4.33.0/en/model_doc/rag#transformers.RagRetriever">RagRetriever</a>) &#x2014;
A retriever class encapsulating a faiss index queried to obtain context documents for current inputs.`,name:"retriever"}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/models/rag/modeling_tf_rag.py#L1301"}}),qt=new ue({props:{$$slots:{default:[PT]},$$scope:{ctx:F}}}),Wo=new Z({props:{name:"call",anchor:"transformers.TFRagSequenceForGeneration.call",parameters:[{name:"input_ids",val:": TFModelInputType | None = None"},{name:"attention_mask",val:": np.ndarray | tf.Tensor | None = None"},{name:"decoder_input_ids",val:": np.ndarray | tf.Tensor | None = None"},{name:"decoder_attention_mask",val:": np.ndarray | tf.Tensor | None = None"},{name:"encoder_outputs",val:": np.ndarray | tf.Tensor | None = None"},{name:"past_key_values",val:": Optional[Tuple[Tuple[Union[np.ndarray, tf.Tensor]]]] = None"},{name:"doc_scores",val:": np.ndarray | tf.Tensor | None = None"},{name:"context_input_ids",val:": np.ndarray | tf.Tensor | None = None"},{name:"context_attention_mask",val:": np.ndarray | tf.Tensor | None = None"},{name:"use_cache",val:": Optional[bool] = None"},{name:"output_attentions",val:": Optional[bool] = None"},{name:"output_hidden_states",val:": Optional[bool] = None"},{name:"output_retrieved",val:": Optional[bool] = None"},{name:"n_docs",val:": Optional[int] = None"},{name:"exclude_bos_score",val:": Optional[bool] = None"},{name:"labels",val:": np.ndarray | tf.Tensor | None = None"},{name:"reduce_loss",val:": Optional[bool] = None"},{name:"return_dict",val:": Optional[bool] = None"},{name:"training",val:": bool = False"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.TFRagSequenceForGeneration.call.input_ids",description:`<strong>input_ids</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, sequence_length)</code>) &#x2014;
Indices of input sequence tokens in the vocabulary. <a href="/docs/transformers/v4.33.0/en/model_doc/rag#transformers.RagConfig">RagConfig</a>, used to initialize the model, specifies
which generator to use, it also specifies a compatible generator tokenizer. Use that tokenizer class to
obtain the indices.`,name:"input_ids"},{anchor:"transformers.TFRagSequenceForGeneration.call.attention_mask",description:`<strong>attention_mask</strong> (<code>tf.Tensor</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.TFRagSequenceForGeneration.call.encoder_outputs",description:`<strong>encoder_outputs</strong> (<code>tuple(tuple(tf.Tensor)</code>, <em>optional</em>) &#x2014;
Tuple consists of (<code>generator_enc_last_hidden_state</code>, <em>optional</em>: <code>generator_enc_hidden_states</code>,
<em>optional</em>: <code>generator_enc_attentions</code>). <code>generator_enc_last_hidden_state</code> of shape <code>(batch_size, n_docs * sequence_length, hidden_size)</code> is a sequence of hidden-states at the output of the last layer of the
generator&#x2019;s encoder.</p>
<p>Used by the (<a href="/docs/transformers/v4.33.0/en/model_doc/rag#transformers.TFRagModel">TFRagModel</a>) model during decoding.`,name:"encoder_outputs"},{anchor:"transformers.TFRagSequenceForGeneration.call.decoder_input_ids",description:`<strong>decoder_input_ids</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, target_sequence_length)</code>, <em>optional</em>) &#x2014;
Provide for generation tasks. <code>None</code> by default, construct as per instructions for the generator model
you&#x2019;re using with your RAG instance.`,name:"decoder_input_ids"},{anchor:"transformers.TFRagSequenceForGeneration.call.decoder_attention_mask",description:`<strong>decoder_attention_mask</strong> (<code>torch.BoolTensor</code> of shape <code>(batch_size, target_sequence_length)</code>, <em>optional</em>) &#x2014;
Default behavior: generate a tensor that ignores pad tokens in <code>decoder_input_ids</code>. Causal mask will also
be used by default.`,name:"decoder_attention_mask"},{anchor:"transformers.TFRagSequenceForGeneration.call.past_key_values",description:`<strong>past_key_values</strong> (<code>tuple(tuple(tf.Tensor))</code>) &#x2014;
Tuple consists of two elements: <code>encoder_outputs</code> of the RAG model (see <code>encoder_outputs</code>) and
<code>past_key_values</code> of the underlying generator. Can be used to speed up decoding. <code>past_key_values</code> are used
in the (<a href="/docs/transformers/v4.33.0/en/model_doc/rag#transformers.RagTokenForGeneration">RagTokenForGeneration</a>) model during decoding.`,name:"past_key_values"},{anchor:"transformers.TFRagSequenceForGeneration.call.doc_scores",description:`<strong>doc_scores</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, config.n_docs)</code>) &#x2014;
Score between each retrieved document embeddings (see <code>retrieved_doc_embeds</code>) and
<code>question_encoder_last_hidden_state</code>. If the model has is not initialized with a <code>retriever</code> <code>doc_scores</code>
has to be provided to the forward pass. <code>doc_scores</code> can be computed via
<code>question_encoder_last_hidden_state</code> and <code>retrieved_doc_embeds</code>, see examples for more information.`,name:"doc_scores"},{anchor:"transformers.TFRagSequenceForGeneration.call.context_input_ids",description:`<strong>context_input_ids</strong> (<code>tf.Tensor</code> of shape <code>(batch_size * config.n_docs, config.max_combined_length)</code>, <em>optional</em>, returned when <em>output_retrieved=True</em>) &#x2014;
Input IDs post-processed from the retrieved documents and the question encoder <code>input_ids</code> by the
retriever.</p>
<p>If the model has is not initialized with a <code>retriever</code> \`<code>context_input_ids</code> has to be provided to the
forward pass. <code>context_input_ids</code> are returned by <code>__call__()</code>. context_attention_mask
(<code>tf.Tensor</code> of shape <code>(batch_size * config.n_docs, config.max_combined_length)</code>, <em>optional</em>, returned when
<em>output_retrieved=True</em>): Attention mask post-processed from the retrieved documents and the question
encoder <code>input_ids</code> by the retriever.</p>
<p>If the model has is not initialized with a <code>retriever</code> <code>context_attention_mask</code> has to be provided to the
forward pass. <code>context_attention_mask</code> are returned by <code>__call__()</code>.`,name:"context_input_ids"},{anchor:"transformers.TFRagSequenceForGeneration.call.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
If set to <code>True</code>, <code>past_key_values</code> key value states are returned and can be used to speed up decoding (see
<code>past_key_values</code>).`,name:"use_cache"},{anchor:"transformers.TFRagSequenceForGeneration.call.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.TFRagSequenceForGeneration.call.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.TFRagSequenceForGeneration.call.output_retrieved(bool,",description:`<strong>output_retrieved(<code>bool</code>,</strong> <em>optional</em>) &#x2014;
Whether or not to return the <code>retrieved_doc_embeds</code>, <code>retrieved_doc_ids</code>, <code>context_input_ids</code> and
<code>context_attention_mask</code>. See returned tensors for more detail.`,name:"output_retrieved(bool,"},{anchor:"transformers.TFRagSequenceForGeneration.call.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <code>TFRetrievAugLMOutput</code> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.TFRagSequenceForGeneration.call.n_docs",description:"<strong>n_docs</strong> (<code>int</code>, <em>optional</em>, defaults to `config.n_docs&#x201C;) &#x2014;\nNumber of documents to retrieve and/or number of documents for which to generate an answer.",name:"n_docs"},{anchor:"transformers.TFRagSequenceForGeneration.call.exclude_bos_score",description:`<strong>exclude_bos_score</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Only relevant if <code>labels</code> is passed. If <code>True</code>, the score of the BOS token is disregarded when computing
the loss.`,name:"exclude_bos_score"},{anchor:"transformers.TFRagSequenceForGeneration.call.labels",description:`<strong>labels</strong> (<code>tf.Tensor</code> or <code>np.ndarray</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Labels for computing the cross entropy classification loss according to Rag-Sequence model formulation See
<a href="https://arxiv.org/pdf/2005.11401.pdf" rel="nofollow">https://arxiv.org/pdf/2005.11401.pdf</a> Section 2.1 for details about Rag-Sequence formulation. Indices should
be in <code>[0, ..., config.vocab_size - 1]</code>.`,name:"labels"},{anchor:"transformers.TFRagSequenceForGeneration.call.reduce_loss",description:`<strong>reduce_loss</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Only relevant if <code>labels</code> is passed. If <code>True</code>, the NLL loss is reduced using the <code>tf.Tensor.sum</code>
operation.`,name:"reduce_loss"},{anchor:"transformers.TFRagSequenceForGeneration.call.kwargs",description:`<strong>kwargs</strong> (<code>Dict[str, any]</code>, optional, defaults to <em>{}</em>) &#x2014;
Legacy dictionary, which is required so that model can use <em>generate()</em> function.`,name:"kwargs"}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/models/rag/modeling_tf_rag.py#L1348",returnDescription:`
<p>A <code>transformers.models.rag.modeling_tf_rag.TFRetrievAugLMMarginOutput</code> or a tuple of <code>tf.Tensor</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.33.0/en/model_doc/rag#transformers.RagConfig"
>RagConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>loss</strong> (<code>tf.Tensor</code> of shape <code>(1,)</code>, <em>optional</em>, returned when <code>labels</code> is provided) \u2014 Language modeling loss.</p>
</li>
<li>
<p><strong>logits</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, sequence_length, config.vocab_size)</code>) \u2014 Prediction scores of the language modeling head. The score is possibly marginalized over all documents for
each vocabulary token.</p>
</li>
<li>
<p><strong>past_key_values</strong> (<code>List[tf.Tensor]</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) \u2014 List of <code>tf.Tensor</code> of length <code>config.n_layers</code>, with each tensor of shape <code>(2, batch_size, num_heads, sequence_length, embed_size_per_head)</code>).</p>
<p>Contains precomputed hidden-states (key and values in the attention blocks) of the decoder that can be used
(see <code>past_key_values</code> input) to speed up sequential decoding.</p>
</li>
<li>
<p><strong>doc_scores</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, config.n_docs)</code>) \u2014 Score between each retrieved document embeddings (see <code>retrieved_doc_embeds</code>) and
<code>question_encoder_last_hidden_state</code>.</p>
</li>
<li>
<p><strong>retrieved_doc_embeds</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, config.n_docs, hidden_size)</code>, <em>optional</em>, returned when <em>output_retrieved=True</em>) \u2014 Embedded documents retrieved by the retriever. Is used with <code>question_encoder_last_hidden_state</code> to compute
the <code>doc_scores</code>.</p>
</li>
<li>
<p><strong>retrieved_doc_ids</strong> (<code>tf.Tensor</code> (int32) of shape <code>(batch_size, config.n_docs)</code>, <em>optional</em>, returned when <em>output_retrieved=True</em>) \u2014 The indexes of the embedded documents retrieved by the retriever.</p>
</li>
<li>
<p><strong>context_input_ids</strong> (<code>tf.Tensor</code>(int32) of shape <code>(batch_size * config.n_docs, config.max_combined_length)</code>, <em>optional</em>, returned when <em>output_retrieved=True</em>) \u2014 Input ids post-processed from the retrieved documents and the question encoder input_ids by the retriever.</p>
</li>
<li>
<p><strong>context_attention_mask</strong> (<code>tf.Tensor</code> (int32) of shape <code>(batch_size * config.n_docs, config.max_combined_length)</code>, <em>optional</em>, returned when <em>output_retrieved=True</em>) \u2014 Attention mask post-processed from the retrieved documents and the question encoder <code>input_ids</code> by the
retriever.</p>
</li>
<li>
<p><strong>question_encoder_last_hidden_state</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) \u2014 Sequence of hidden states at the output of the last layer of the question encoder pooled output of the
model.</p>
</li>
<li>
<p><strong>question_enc_hidden_states</strong> (<code>tuple(tf.Tensor)</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>tf.Tensor</code> (one for the output of the embeddings and one for the output of each layer) of shape
<code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden states of the question encoder at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>question_enc_attentions</strong> (<code>tuple(tf.Tensor)</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>tf.Tensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights of the question encoder, after the attention softmax, used to compute the weighted
average in the self-attention heads.</p>
</li>
<li>
<p><strong>generator_enc_last_hidden_state</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) \u2014 Sequence of hidden-states at the output of the last layer of the generator encoder of the model.</p>
</li>
<li>
<p><strong>generator_enc_hidden_states</strong> (<code>tuple(tf.Tensor)</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>tf.Tensor</code> (one for the output of the embeddings and one for the output of each layer) of shape
<code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden states of the generator encoder at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>generator_enc_attentions</strong> (<code>tuple(tf.Tensor)</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>tf.Tensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights of the generator encoder, after the attention softmax, used to compute the weighted
average in the self-attention heads.</p>
</li>
<li>
<p><strong>generator_dec_hidden_states</strong> (<code>tuple(tf.Tensor)</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>tf.Tensor</code> (one for the output of the embeddings and one for the output of each layer) of shape
<code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden states of the generator decoder at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>generator_dec_attentions</strong> (<code>tuple(tf.Tensor)</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>tf.Tensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights of the generator decoder, after the attention softmax, used to compute the weighted
average in the self-attention heads.</p>
</li>
</ul>
`,returnType:`
<p><code>transformers.models.rag.modeling_tf_rag.TFRetrievAugLMMarginOutput</code> or <code>tuple(tf.Tensor)</code></p>
`}}),Ft=new ue({props:{$$slots:{default:[HT]},$$scope:{ctx:F}}}),xt=new tn({props:{anchor:"transformers.TFRagSequenceForGeneration.call.example",$$slots:{default:[LT]},$$scope:{ctx:F}}}),Xo=new Z({props:{name:"generate",anchor:"transformers.TFRagSequenceForGeneration.generate",parameters:[{name:"input_ids",val:": TFModelInputType | None = None"},{name:"attention_mask",val:": tf.Tensor | None = None"},{name:"context_input_ids",val:" = None"},{name:"context_attention_mask",val:" = None"},{name:"doc_scores",val:" = None"},{name:"do_deduplication",val:" = None"},{name:"num_return_sequences",val:" = None"},{name:"num_beams",val:" = None"},{name:"n_docs",val:" = None"},{name:"**model_kwargs",val:""}],parametersDescription:[{anchor:"transformers.TFRagSequenceForGeneration.generate.input_ids",description:`<strong>input_ids</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
The sequence used as a prompt for the generation. If <code>input_ids</code> is not passed, then
<code>context_input_ids</code> has to be provided.`,name:"input_ids"},{anchor:"transformers.TFRagSequenceForGeneration.generate.attention_mask",description:`<strong>attention_mask</strong> (<code>tf.Tensor</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>: - 1 for
tokens that are <strong>not masked</strong>, - 0 for tokens that are <strong>masked</strong>. <a href="../glossary#attention-mask">What are attention
masks?</a>`,name:"attention_mask"},{anchor:"transformers.TFRagSequenceForGeneration.generate.context_input_ids",description:`<strong>context_input_ids</strong> (<code>tf.Tensor</code> of shape <code>(batch_size * config.n_docs, config.max_combined_length)</code>, <em>optional</em>, returned when <em>output_retrieved=True</em>) &#x2014;
Input IDs post-processed from the retrieved documents and the question encoder input_ids by the
retriever.`,name:"context_input_ids"},{anchor:"transformers.TFRagSequenceForGeneration.generate.context_attention_mask",description:`<strong>context_attention_mask</strong> (<code>tf.Tensor</code> of shape <code>(batch_size * config.n_docs, config.max_combined_length)</code>, <em>optional</em>, returned when <em>output_retrieved=True</em>) &#x2014;
Attention mask post-processed from the retrieved documents and the question encoder <code>input_ids</code> by the
retriever. If the model has is not initialized with a <code>retriever</code> or <code>input_ids</code> is not given,
<code>context_input_ids</code> and <code>context_attention_mask</code> have to be provided to the forward pass. They are
returned by <code>__call__()</code>.`,name:"context_attention_mask"},{anchor:"transformers.TFRagSequenceForGeneration.generate.doc_scores",description:`<strong>doc_scores</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, config.n_docs)</code>) &#x2014;
Score between each retrieved document embeddings (see <code>retrieved_doc_embeds</code>) and
<code>question_encoder_last_hidden_state</code>. If the model has is not initialized with a <code>retriever</code> or
<code>input_ids</code> is not given, <code>doc_scores</code> has to be provided to the forward pass. <code>doc_scores</code> are
returned by <code>__call__()</code>.`,name:"doc_scores"},{anchor:"transformers.TFRagSequenceForGeneration.generate.do_deduplication",description:`<strong>do_deduplication</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to deduplicate the generations from different context documents for a given input. Has
to be set to <code>False</code> if used while training with distributed backend.`,name:"do_deduplication"},{anchor:"transformers.TFRagSequenceForGeneration.generate.num_return_sequences(int,",description:`<strong>num_return_sequences(<code>int</code>,</strong> <em>optional</em>, defaults to 1) &#x2014;
The number of independently computed returned sequences for each element in the batch. Note that this
is not the value we pass to the <code>generator</code>&#x2019;s <code>[generate()](/docs/transformers/v4.33.0/en/main_classes/text_generation#transformers.GenerationMixin.generate)</code> function,
where we set <code>num_return_sequences</code> to <code>num_beams</code>.`,name:"num_return_sequences(int,"},{anchor:"transformers.TFRagSequenceForGeneration.generate.num_beams",description:`<strong>num_beams</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
Number of beams for beam search. 1 means no beam search.`,name:"num_beams"},{anchor:"transformers.TFRagSequenceForGeneration.generate.n_docs",description:`<strong>n_docs</strong> (<code>int</code>, <em>optional</em>, defaults to <code>config.n_docs</code>) &#x2014;
Number of documents to retrieve and/or number of documents for which to generate an answer.`,name:"n_docs"},{anchor:"transformers.TFRagSequenceForGeneration.generate.kwargs",description:`<strong>kwargs</strong> (<code>Dict[str, Any]</code>, <em>optional</em>) &#x2014;
Additional kwargs will be passed to <a href="/docs/transformers/v4.33.0/en/main_classes/text_generation#transformers.GenerationMixin.generate">generate()</a>`,name:"kwargs"}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/models/rag/modeling_tf_rag.py#L1583",returnDescription:`
<p>The generated sequences. The
second dimension (sequence length) is either equal to <code>max_length</code> or shorter if all batches finished early
due to the <code>eos_token_id</code>.</p>
`,returnType:`
<p><code>tf.Tensor</code> of shape <code>(batch_size * num_return_sequences, sequence_length)</code></p>
`}}),So=new ge({}),Bo=new Z({props:{name:"class transformers.TFRagTokenForGeneration",anchor:"transformers.TFRagTokenForGeneration",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.TFRagTokenForGeneration.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.33.0/en/model_doc/rag#transformers.RagConfig">RagConfig</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.33.0/en/main_classes/model#transformers.TFPreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"},{anchor:"transformers.TFRagTokenForGeneration.question_encoder",description:`<strong>question_encoder</strong> (<a href="/docs/transformers/v4.33.0/en/main_classes/model#transformers.TFPreTrainedModel">TFPreTrainedModel</a>) &#x2014;
An encoder model compatible with the faiss index encapsulated by the <code>retriever</code>.`,name:"question_encoder"},{anchor:"transformers.TFRagTokenForGeneration.generator",description:`<strong>generator</strong> (<a href="/docs/transformers/v4.33.0/en/main_classes/model#transformers.TFPreTrainedModel">TFPreTrainedModel</a>) &#x2014;
A seq2seq model used as the generator in the RAG architecture.`,name:"generator"},{anchor:"transformers.TFRagTokenForGeneration.retriever",description:`<strong>retriever</strong> (<a href="/docs/transformers/v4.33.0/en/model_doc/rag#transformers.RagRetriever">RagRetriever</a>) &#x2014;
A retriever class encapsulating a faiss index queried to obtain context documents for current inputs.`,name:"retriever"}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/models/rag/modeling_tf_rag.py#L729"}}),Gt=new ue({props:{$$slots:{default:[YT]},$$scope:{ctx:F}}}),Yo=new Z({props:{name:"call",anchor:"transformers.TFRagTokenForGeneration.call",parameters:[{name:"input_ids",val:": TFModelInputType | None = None"},{name:"attention_mask",val:": np.ndarray | tf.Tensor | None = None"},{name:"decoder_input_ids",val:": np.ndarray | tf.Tensor | None = None"},{name:"decoder_attention_mask",val:": np.ndarray | tf.Tensor | None = None"},{name:"encoder_outputs",val:": np.ndarray | tf.Tensor | None = None"},{name:"past_key_values",val:": Tuple[Tuple[Union[np.ndarray, tf.Tensor]]] | None = None"},{name:"doc_scores",val:": np.ndarray | tf.Tensor | None = None"},{name:"context_input_ids",val:": np.ndarray | tf.Tensor | None = None"},{name:"context_attention_mask",val:": np.ndarray | tf.Tensor | None = None"},{name:"use_cache",val:": bool | None = None"},{name:"output_attentions",val:": bool | None = None"},{name:"output_hidden_states",val:": bool | None = None"},{name:"output_retrieved",val:": bool | None = None"},{name:"n_docs",val:": int | None = None"},{name:"do_marginalize",val:": bool | None = None"},{name:"labels",val:": np.ndarray | tf.Tensor | None = None"},{name:"reduce_loss",val:": bool | None = None"},{name:"return_dict",val:": bool | None = None"},{name:"training",val:": bool = False"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.TFRagTokenForGeneration.call.input_ids",description:`<strong>input_ids</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, sequence_length)</code>) &#x2014;
Indices of input sequence tokens in the vocabulary. <a href="/docs/transformers/v4.33.0/en/model_doc/rag#transformers.RagConfig">RagConfig</a>, used to initialize the model, specifies
which generator to use, it also specifies a compatible generator tokenizer. Use that tokenizer class to
obtain the indices.`,name:"input_ids"},{anchor:"transformers.TFRagTokenForGeneration.call.attention_mask",description:`<strong>attention_mask</strong> (<code>tf.Tensor</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.TFRagTokenForGeneration.call.encoder_outputs",description:`<strong>encoder_outputs</strong> (<code>tuple(tuple(tf.Tensor)</code>, <em>optional</em>) &#x2014;
Tuple consists of (<code>generator_enc_last_hidden_state</code>, <em>optional</em>: <code>generator_enc_hidden_states</code>,
<em>optional</em>: <code>generator_enc_attentions</code>). <code>generator_enc_last_hidden_state</code> of shape <code>(batch_size, n_docs * sequence_length, hidden_size)</code> is a sequence of hidden-states at the output of the last layer of the
generator&#x2019;s encoder.</p>
<p>Used by the (<a href="/docs/transformers/v4.33.0/en/model_doc/rag#transformers.TFRagModel">TFRagModel</a>) model during decoding.`,name:"encoder_outputs"},{anchor:"transformers.TFRagTokenForGeneration.call.decoder_input_ids",description:`<strong>decoder_input_ids</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, target_sequence_length)</code>, <em>optional</em>) &#x2014;
Provide for generation tasks. <code>None</code> by default, construct as per instructions for the generator model
you&#x2019;re using with your RAG instance.`,name:"decoder_input_ids"},{anchor:"transformers.TFRagTokenForGeneration.call.decoder_attention_mask",description:`<strong>decoder_attention_mask</strong> (<code>torch.BoolTensor</code> of shape <code>(batch_size, target_sequence_length)</code>, <em>optional</em>) &#x2014;
Default behavior: generate a tensor that ignores pad tokens in <code>decoder_input_ids</code>. Causal mask will also
be used by default.`,name:"decoder_attention_mask"},{anchor:"transformers.TFRagTokenForGeneration.call.past_key_values",description:`<strong>past_key_values</strong> (<code>tuple(tuple(tf.Tensor))</code>) &#x2014;
Tuple consists of two elements: <code>encoder_outputs</code> of the RAG model (see <code>encoder_outputs</code>) and
<code>past_key_values</code> of the underlying generator. Can be used to speed up decoding. <code>past_key_values</code> are used
in the (<a href="/docs/transformers/v4.33.0/en/model_doc/rag#transformers.RagTokenForGeneration">RagTokenForGeneration</a>) model during decoding.`,name:"past_key_values"},{anchor:"transformers.TFRagTokenForGeneration.call.doc_scores",description:`<strong>doc_scores</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, config.n_docs)</code>) &#x2014;
Score between each retrieved document embeddings (see <code>retrieved_doc_embeds</code>) and
<code>question_encoder_last_hidden_state</code>. If the model has is not initialized with a <code>retriever</code> <code>doc_scores</code>
has to be provided to the forward pass. <code>doc_scores</code> can be computed via
<code>question_encoder_last_hidden_state</code> and <code>retrieved_doc_embeds</code>, see examples for more information.`,name:"doc_scores"},{anchor:"transformers.TFRagTokenForGeneration.call.context_input_ids",description:`<strong>context_input_ids</strong> (<code>tf.Tensor</code> of shape <code>(batch_size * config.n_docs, config.max_combined_length)</code>, <em>optional</em>, returned when <em>output_retrieved=True</em>) &#x2014;
Input IDs post-processed from the retrieved documents and the question encoder <code>input_ids</code> by the
retriever.</p>
<p>If the model has is not initialized with a <code>retriever</code> \`<code>context_input_ids</code> has to be provided to the
forward pass. <code>context_input_ids</code> are returned by <code>__call__()</code>. context_attention_mask
(<code>tf.Tensor</code> of shape <code>(batch_size * config.n_docs, config.max_combined_length)</code>, <em>optional</em>, returned when
<em>output_retrieved=True</em>): Attention mask post-processed from the retrieved documents and the question
encoder <code>input_ids</code> by the retriever.</p>
<p>If the model has is not initialized with a <code>retriever</code> <code>context_attention_mask</code> has to be provided to the
forward pass. <code>context_attention_mask</code> are returned by <code>__call__()</code>.`,name:"context_input_ids"},{anchor:"transformers.TFRagTokenForGeneration.call.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
If set to <code>True</code>, <code>past_key_values</code> key value states are returned and can be used to speed up decoding (see
<code>past_key_values</code>).`,name:"use_cache"},{anchor:"transformers.TFRagTokenForGeneration.call.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.TFRagTokenForGeneration.call.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.TFRagTokenForGeneration.call.output_retrieved(bool,",description:`<strong>output_retrieved(<code>bool</code>,</strong> <em>optional</em>) &#x2014;
Whether or not to return the <code>retrieved_doc_embeds</code>, <code>retrieved_doc_ids</code>, <code>context_input_ids</code> and
<code>context_attention_mask</code>. See returned tensors for more detail.`,name:"output_retrieved(bool,"},{anchor:"transformers.TFRagTokenForGeneration.call.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <code>TFRetrievAugLMOutput</code> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.TFRagTokenForGeneration.call.n_docs",description:"<strong>n_docs</strong> (<code>int</code>, <em>optional</em>, defaults to `config.n_docs&#x201C;) &#x2014;\nNumber of documents to retrieve and/or number of documents for which to generate an answer.",name:"n_docs"},{anchor:"transformers.TFRagTokenForGeneration.call.do_marginalize",description:`<strong>do_marginalize</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
If <code>True</code>, the logits are marginalized over all documents by making use of
<code>torch.nn.functional.log_softmax</code>.`,name:"do_marginalize"},{anchor:"transformers.TFRagTokenForGeneration.call.labels",description:`<strong>labels</strong> (<code>tf.Tensor</code> or <code>np.ndarray</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Labels for computing the cross entropy classification loss according to Rag-Token model formulation See
<a href="https://arxiv.org/pdf/2005.11401.pdf" rel="nofollow">https://arxiv.org/pdf/2005.11401.pdf</a> Section 2.1 for details about Rag-Token formulation. Indices should be
in <code>[0, ..., config.vocab_size - 1]</code>.`,name:"labels"},{anchor:"transformers.TFRagTokenForGeneration.call.reduce_loss",description:`<strong>reduce_loss</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Only relevant if <code>labels</code> is passed. If <code>True</code>, the NLL loss is reduced using the <code>tf.Tensor.sum</code>
operation.`,name:"reduce_loss"},{anchor:"transformers.TFRagTokenForGeneration.call.kwargs",description:`<strong>kwargs</strong> (<code>Dict[str, any]</code>, optional, defaults to <em>{}</em>) &#x2014;
Legacy dictionary, which is required so that model can use <em>generate()</em> function.`,name:"kwargs"}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/models/rag/modeling_tf_rag.py#L842",returnDescription:`
<p>A <code>transformers.models.rag.modeling_tf_rag.TFRetrievAugLMMarginOutput</code> or a tuple of <code>tf.Tensor</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.33.0/en/model_doc/rag#transformers.RagConfig"
>RagConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>loss</strong> (<code>tf.Tensor</code> of shape <code>(1,)</code>, <em>optional</em>, returned when <code>labels</code> is provided) \u2014 Language modeling loss.</p>
</li>
<li>
<p><strong>logits</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, sequence_length, config.vocab_size)</code>) \u2014 Prediction scores of the language modeling head. The score is possibly marginalized over all documents for
each vocabulary token.</p>
</li>
<li>
<p><strong>past_key_values</strong> (<code>List[tf.Tensor]</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) \u2014 List of <code>tf.Tensor</code> of length <code>config.n_layers</code>, with each tensor of shape <code>(2, batch_size, num_heads, sequence_length, embed_size_per_head)</code>).</p>
<p>Contains precomputed hidden-states (key and values in the attention blocks) of the decoder that can be used
(see <code>past_key_values</code> input) to speed up sequential decoding.</p>
</li>
<li>
<p><strong>doc_scores</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, config.n_docs)</code>) \u2014 Score between each retrieved document embeddings (see <code>retrieved_doc_embeds</code>) and
<code>question_encoder_last_hidden_state</code>.</p>
</li>
<li>
<p><strong>retrieved_doc_embeds</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, config.n_docs, hidden_size)</code>, <em>optional</em>, returned when <em>output_retrieved=True</em>) \u2014 Embedded documents retrieved by the retriever. Is used with <code>question_encoder_last_hidden_state</code> to compute
the <code>doc_scores</code>.</p>
</li>
<li>
<p><strong>retrieved_doc_ids</strong> (<code>tf.Tensor</code> (int32) of shape <code>(batch_size, config.n_docs)</code>, <em>optional</em>, returned when <em>output_retrieved=True</em>) \u2014 The indexes of the embedded documents retrieved by the retriever.</p>
</li>
<li>
<p><strong>context_input_ids</strong> (<code>tf.Tensor</code>(int32) of shape <code>(batch_size * config.n_docs, config.max_combined_length)</code>, <em>optional</em>, returned when <em>output_retrieved=True</em>) \u2014 Input ids post-processed from the retrieved documents and the question encoder input_ids by the retriever.</p>
</li>
<li>
<p><strong>context_attention_mask</strong> (<code>tf.Tensor</code> (int32) of shape <code>(batch_size * config.n_docs, config.max_combined_length)</code>, <em>optional</em>, returned when <em>output_retrieved=True</em>) \u2014 Attention mask post-processed from the retrieved documents and the question encoder <code>input_ids</code> by the
retriever.</p>
</li>
<li>
<p><strong>question_encoder_last_hidden_state</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) \u2014 Sequence of hidden states at the output of the last layer of the question encoder pooled output of the
model.</p>
</li>
<li>
<p><strong>question_enc_hidden_states</strong> (<code>tuple(tf.Tensor)</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>tf.Tensor</code> (one for the output of the embeddings and one for the output of each layer) of shape
<code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden states of the question encoder at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>question_enc_attentions</strong> (<code>tuple(tf.Tensor)</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>tf.Tensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights of the question encoder, after the attention softmax, used to compute the weighted
average in the self-attention heads.</p>
</li>
<li>
<p><strong>generator_enc_last_hidden_state</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) \u2014 Sequence of hidden-states at the output of the last layer of the generator encoder of the model.</p>
</li>
<li>
<p><strong>generator_enc_hidden_states</strong> (<code>tuple(tf.Tensor)</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>tf.Tensor</code> (one for the output of the embeddings and one for the output of each layer) of shape
<code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden states of the generator encoder at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>generator_enc_attentions</strong> (<code>tuple(tf.Tensor)</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>tf.Tensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights of the generator encoder, after the attention softmax, used to compute the weighted
average in the self-attention heads.</p>
</li>
<li>
<p><strong>generator_dec_hidden_states</strong> (<code>tuple(tf.Tensor)</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>tf.Tensor</code> (one for the output of the embeddings and one for the output of each layer) of shape
<code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden states of the generator decoder at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>generator_dec_attentions</strong> (<code>tuple(tf.Tensor)</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>tf.Tensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights of the generator decoder, after the attention softmax, used to compute the weighted
average in the self-attention heads.</p>
</li>
</ul>
`,returnType:`
<p><code>transformers.models.rag.modeling_tf_rag.TFRetrievAugLMMarginOutput</code> or <code>tuple(tf.Tensor)</code></p>
`}}),zt=new ue({props:{$$slots:{default:[QT]},$$scope:{ctx:F}}}),Ut=new tn({props:{anchor:"transformers.TFRagTokenForGeneration.call.example",$$slots:{default:[DT]},$$scope:{ctx:F}}}),Qo=new Z({props:{name:"generate",anchor:"transformers.TFRagTokenForGeneration.generate",parameters:[{name:"input_ids",val:": TFModelInputType | None = None"},{name:"attention_mask",val:": tf.Tensor | None = None"},{name:"context_input_ids",val:" = None"},{name:"context_attention_mask",val:" = None"},{name:"doc_scores",val:" = None"},{name:"n_docs",val:" = None"},{name:"generation_config",val:" = None"},{name:"logits_processor",val:" = []"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.TFRagTokenForGeneration.generate.input_ids",description:`<strong>input_ids</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
The sequence used as a prompt for the generation. If <code>input_ids</code> is not passed, then
<code>context_input_ids</code> has to be provided.`,name:"input_ids"},{anchor:"transformers.TFRagTokenForGeneration.generate.attention_mask",description:`<strong>attention_mask</strong> (<code>tf.Tensor</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.TFRagTokenForGeneration.generate.context_input_ids",description:`<strong>context_input_ids</strong> (<code>tf.Tensor</code> of shape <code>(batch_size * config.n_docs, config.max_combined_length)</code>, <em>optional</em>, returned when <em>output_retrieved=True</em>) &#x2014;
Input IDs post-processed from the retrieved documents and the question encoder <code>input_ids</code> by the
retriever.</p>
<p>If the model has is not initialized with a <code>retriever</code>, <code>context_input_ids</code> has to be provided to the
forward pass. <code>context_input_ids</code> are returned by <code>__call__()</code>.`,name:"context_input_ids"},{anchor:"transformers.TFRagTokenForGeneration.generate.context_attention_mask",description:`<strong>context_attention_mask</strong> (<code>tf.Tensor</code> of shape <code>(batch_size * config.n_docs, config.max_combined_length)</code>, <em>optional</em>, returned when <em>output_retrieved=True</em>) &#x2014;
Attention mask post-processed from the retrieved documents and the question encoder <code>input_ids</code> by the
retriever.</p>
<p>If the model has is not initialized with a <code>retriever</code>, <code>context_input_ids</code> has to be provided to the
forward pass. <code>context_input_ids</code> are returned by <code>__call__()</code>.`,name:"context_attention_mask"},{anchor:"transformers.TFRagTokenForGeneration.generate.doc_scores",description:`<strong>doc_scores</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, config.n_docs)</code>) &#x2014;
Score between each retrieved document embeddings (see <code>retrieved_doc_embeds</code>) and
<code>question_encoder_last_hidden_state</code>.</p>
<p>If the model has is not initialized with a <code>retriever</code>, <code>context_input_ids</code> has to be provided to the
forward pass. <code>context_input_ids</code> are returned by <code>__call__()</code>.`,name:"doc_scores"},{anchor:"transformers.TFRagTokenForGeneration.generate.n_docs",description:`<strong>n_docs</strong> (<code>int</code>, <em>optional</em>, defaults to <code>config.n_docs</code>) &#x2014;
Number of documents to retrieve and/or number of documents for which to generate an answer.`,name:"n_docs"},{anchor:"transformers.TFRagTokenForGeneration.generate.generation_config",description:`<strong>generation_config</strong> (<code>~generation.GenerationConfig</code>, <em>optional</em>) &#x2014;
The generation configuration to be used as base parametrization for the generation call. <code>**kwargs</code>
passed to generate matching the attributes of <code>generation_config</code> will override them. If
<code>generation_config</code> is not provided, the default will be used, which had the following loading
priority: 1) from the <code>generation_config.json</code> model file, if it exists; 2) from the model
configuration. Please note that unspecified parameters will inherit <a href="/docs/transformers/v4.33.0/en/main_classes/text_generation#transformers.GenerationConfig">GenerationConfig</a>&#x2019;s
default values, whose documentation should be checked to parameterize generation.`,name:"generation_config"},{anchor:"transformers.TFRagTokenForGeneration.generate.logits_processor",description:`<strong>logits_processor</strong> (<code>TFLogitsProcessorList</code>, <em>optional</em>) &#x2014;
Custom logits processors that complement the default logits processors built from arguments and a
model&#x2019;s config. If a logit processor is passed that is already created with the arguments or a model&#x2019;s
config an error is thrown.`,name:"logits_processor"},{anchor:"transformers.TFRagTokenForGeneration.generate.kwargs",description:`<strong>kwargs</strong> (<code>Dict[str, Any]</code>, <em>optional</em>) &#x2014;
Ad hoc parametrization of <code>generate_config</code> and/or additional model-specific kwargs that will be
forwarded to the <code>forward</code> function of the model.`,name:"kwargs"}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/models/rag/modeling_tf_rag.py#L997",returnDescription:`
<p>The generated sequences. The
second dimension (sequence_length) is either equal to <code>max_length</code> or shorter if all batches finished early
due to the <code>eos_token_id</code>.</p>
`,returnType:`
<p><code>tf.Tensor</code> of shape <code>(batch_size * num_return_sequences, sequence_length)</code></p>
`}}),{c(){c=s("meta"),T=p(),u=s("h1"),g=s("a"),_=s("span"),b(i.$$.fragment),m=p(),q=s("span"),ei=o("RAG"),Xa=p(),Wt=s("div"),rn=s("a"),sn=s("img"),Va=p(),Me=s("h2"),Ye=s("a"),jr=s("span"),b(Xt.$$.fragment),ti=p(),Jr=s("span"),oi=o("Overview"),Sa=p(),an=s("p"),ni=o(`Retrieval-augmented generation (\u201CRAG\u201D) models combine the powers of pretrained dense retrieval (DPR) and
sequence-to-sequence models. RAG models retrieve documents, pass them to a seq2seq model, then marginalize to generate
outputs. The retriever and seq2seq modules are initialized from pretrained models, and fine-tuned jointly, allowing
both retrieval and generation to adapt to downstream tasks.`),Ba=p(),Qe=s("p"),ri=o("It is based on the paper "),Vt=s("a"),si=o("Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks"),ai=o(` by Patrick Lewis, Ethan Perez, Aleksandara Piktus, Fabio Petroni, Vladimir
Karpukhin, Naman Goyal, Heinrich K\xFCttler, Mike Lewis, Wen-tau Yih, Tim Rockt\xE4schel, Sebastian Riedel, Douwe Kiela.`),Pa=p(),dn=s("p"),di=o("The abstract from the paper is the following:"),Ha=p(),cn=s("p"),Gr=s("em"),ii=o(`Large pre-trained language models have been shown to store factual knowledge in their parameters, and achieve
state-of-the-art results when fine-tuned on downstream NLP tasks. However, their ability to access and precisely
manipulate knowledge is still limited, and hence on knowledge-intensive tasks, their performance lags behind
task-specific architectures. Additionally, providing provenance for their decisions and updating their world knowledge
remain open research problems. Pre-trained models with a differentiable access mechanism to explicit nonparametric
memory can overcome this issue, but have so far been only investigated for extractive downstream tasks. We explore a
general-purpose fine-tuning recipe for retrieval-augmented generation (RAG) \u2014 models which combine pre-trained
parametric and non-parametric memory for language generation. We introduce RAG models where the parametric memory is a
pre-trained seq2seq model and the non-parametric memory is a dense vector index of Wikipedia, accessed with a
pre-trained neural retriever. We compare two RAG formulations, one which conditions on the same retrieved passages
across the whole generated sequence, the other can use different passages per token. We fine-tune and evaluate our
models on a wide range of knowledge-intensive NLP tasks and set the state-of-the-art on three open domain QA tasks,
outperforming parametric seq2seq models and task-specific retrieve-and-extract architectures. For language generation
tasks, we find that RAG models generate more specific, diverse and factual language than a state-of-the-art
parametric-only seq2seq baseline.`),La=p(),De=s("p"),ci=o("This model was contributed by "),St=s("a"),li=o("ola13"),pi=o("."),Ya=p(),ln=s("p"),hi=o("Tips:"),Qa=p(),pn=s("ul"),zr=s("li"),mi=o("Retrieval-augmented generation (\u201CRAG\u201D) models combine the powers of pretrained dense retrieval (DPR) and Seq2Seq models. RAG models retrieve docs, pass them to a seq2seq model, then marginalize to generate outputs. The retriever and seq2seq modules are initialized from pretrained models, and fine-tuned jointly, allowing both retrieval and generation to adapt to downstream tasks."),Da=p(),Re=s("h2"),Oe=s("a"),Ur=s("span"),b(Bt.$$.fragment),ui=p(),Er=s("span"),gi=o("RagConfig"),Oa=p(),fe=s("div"),b(Pt.$$.fragment),fi=p(),ae=s("p"),hn=s("a"),_i=o("RagConfig"),vi=o(" stores the configuration of a "),$r=s("em"),Ti=o("RagModel"),bi=o(". Configuration objects inherit from "),mn=s("a"),yi=o("PretrainedConfig"),wi=o(` and
can be used to control the model outputs. Read the documentation from `),un=s("a"),Mi=o("PretrainedConfig"),Ri=o(" for more information."),ki=p(),Ke=s("div"),b(Ht.$$.fragment),qi=p(),Lt=s("p"),Fi=o("Instantiate a "),gn=s("a"),xi=o("EncoderDecoderConfig"),ji=o(` (or a derived class) from a pre-trained encoder model configuration and
decoder model configuration.`),Ka=p(),ke=s("h2"),et=s("a"),Zr=s("span"),b(Yt.$$.fragment),Ji=p(),Ir=s("span"),Gi=o("RagTokenizer"),ed=p(),Qt=s("div"),b(Dt.$$.fragment),td=p(),qe=s("h2"),tt=s("a"),Cr=s("span"),b(Ot.$$.fragment),zi=p(),Nr=s("span"),Ui=o("Rag specific outputs"),od=p(),Fe=s("div"),b(Kt.$$.fragment),Ei=p(),Ar=s("p"),$i=o("Base class for retriever augmented marginalized models outputs."),nd=p(),eo=s("div"),b(to.$$.fragment),rd=p(),xe=s("h2"),ot=s("a"),Wr=s("span"),b(oo.$$.fragment),Zi=p(),Xr=s("span"),Ii=o("RagRetriever"),sd=p(),K=s("div"),b(no.$$.fragment),Ci=p(),Vr=s("p"),Ni=o(`Retriever used to get documents from vector queries. It retrieves the documents embeddings as well as the documents
contents, and it formats them to be used with a RagModel.`),Ai=p(),b(nt.$$.fragment),Wi=p(),rt=s("div"),b(ro.$$.fragment),Xi=p(),Sr=s("p"),Vi=o("Retriever initialization function. It loads the index into memory."),Si=p(),st=s("div"),b(so.$$.fragment),Bi=p(),je=s("p"),Pi=o("Postprocessing retrieved "),Br=s("code"),Hi=o("docs"),Li=o(" and combining them with "),Pr=s("code"),Yi=o("input_strings"),Qi=o("."),Di=p(),at=s("div"),b(ao.$$.fragment),Oi=p(),io=s("p"),Ki=o("Retrieves documents for specified "),Hr=s("code"),ec=o("question_hidden_states"),tc=o("."),ad=p(),Je=s("h2"),dt=s("a"),Lr=s("span"),b(co.$$.fragment),oc=p(),Yr=s("span"),nc=o("RagModel"),dd=p(),N=s("div"),b(lo.$$.fragment),rc=p(),Ge=s("p"),sc=o("The "),fn=s("a"),ac=o("RagModel"),dc=o(" forward method, overrides the "),Qr=s("code"),ic=o("__call__"),cc=o(" special method."),lc=p(),b(it.$$.fragment),pc=p(),Dr=s("p"),hc=o(`RAG is a seq2seq model which encapsulates two core components: a question encoder and a generator. During a forward
pass, we encode the input with the question encoder and pass it to the retriever to extract relevant context
documents. The documents are then prepended to the input. Such contextualized inputs is passed to the generator.`),mc=p(),ee=s("p"),uc=o("The question encoder can be any "),Or=s("em"),gc=o("autoencoding"),fc=o(" model, preferably "),_n=s("a"),_c=o("DPRQuestionEncoder"),vc=o(`, and the generator can be
any `),Kr=s("em"),Tc=o("seq2seq"),bc=o(" model, preferably "),vn=s("a"),yc=o("BartForConditionalGeneration"),wc=o("."),Mc=p(),z=s("p"),Rc=o("The model can be initialized with a "),Tn=s("a"),kc=o("RagRetriever"),qc=o(` for end-to-end generation or used in combination with the
outputs of a retriever in multiple steps---see examples for more details. The model is compatible any
`),es=s("em"),Fc=o("autoencoding"),xc=o(" model as the "),ts=s("code"),jc=o("question_encoder"),Jc=o(" and any "),os=s("em"),Gc=o("seq2seq"),zc=o(" model with language model head as the "),ns=s("code"),Uc=o("generator"),Ec=o(`.
It has been tested with `),bn=s("a"),$c=o("DPRQuestionEncoder"),Zc=o(" as the "),rs=s("code"),Ic=o("question_encoder"),Cc=o(" and "),yn=s("a"),Nc=o("BartForConditionalGeneration"),Ac=o(` or
`),wn=s("a"),Wc=o("T5ForConditionalGeneration"),Xc=o(" as the "),ss=s("code"),Vc=o("generator"),Sc=o("."),Bc=p(),po=s("p"),Pc=o("This model inherits from "),Mn=s("a"),Hc=o("PreTrainedModel"),Lc=o(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),Yc=p(),ho=s("p"),Qc=o("This model is also a PyTorch "),mo=s("a"),Dc=o("torch.nn.Module"),Oc=o(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Kc=p(),de=s("div"),b(uo.$$.fragment),el=p(),ze=s("p"),tl=o("The "),Rn=s("a"),ol=o("RagModel"),nl=o(" forward method, overrides the "),as=s("code"),rl=o("__call__"),sl=o(" special method."),al=p(),b(ct.$$.fragment),dl=p(),b(lt.$$.fragment),id=p(),Ue=s("h2"),pt=s("a"),ds=s("span"),b(go.$$.fragment),il=p(),is=s("span"),cl=o("RagSequenceForGeneration"),cd=p(),J=s("div"),b(fo.$$.fragment),ll=p(),Ee=s("p"),pl=o("The "),kn=s("a"),hl=o("RagSequenceForGeneration"),ml=o(" forward method, overrides the "),cs=s("code"),ul=o("__call__"),gl=o(" special method."),fl=p(),b(ht.$$.fragment),_l=p(),ls=s("p"),vl=o("A RAG-sequence model implementation. It performs RAG-sequence specific marginalization in the forward pass."),Tl=p(),ps=s("p"),bl=o(`RAG is a seq2seq model which encapsulates two core components: a question encoder and a generator. During a forward
pass, we encode the input with the question encoder and pass it to the retriever to extract relevant context
documents. The documents are then prepended to the input. Such contextualized inputs is passed to the generator.`),yl=p(),te=s("p"),wl=o("The question encoder can be any "),hs=s("em"),Ml=o("autoencoding"),Rl=o(" model, preferably "),qn=s("a"),kl=o("DPRQuestionEncoder"),ql=o(`, and the generator can be
any `),ms=s("em"),Fl=o("seq2seq"),xl=o(" model, preferably "),Fn=s("a"),jl=o("BartForConditionalGeneration"),Jl=o("."),Gl=p(),U=s("p"),zl=o("The model can be initialized with a "),xn=s("a"),Ul=o("RagRetriever"),El=o(` for end-to-end generation or used in combination with the
outputs of a retriever in multiple steps---see examples for more details. The model is compatible any
`),us=s("em"),$l=o("autoencoding"),Zl=o(" model as the "),gs=s("code"),Il=o("question_encoder"),Cl=o(" and any "),fs=s("em"),Nl=o("seq2seq"),Al=o(" model with language model head as the "),_s=s("code"),Wl=o("generator"),Xl=o(`.
It has been tested with `),jn=s("a"),Vl=o("DPRQuestionEncoder"),Sl=o(" as the "),vs=s("code"),Bl=o("question_encoder"),Pl=o(" and "),Jn=s("a"),Hl=o("BartForConditionalGeneration"),Ll=o(` or
`),Gn=s("a"),Yl=o("T5ForConditionalGeneration"),Ql=o(" as the "),Ts=s("code"),Dl=o("generator"),Ol=o("."),Kl=p(),_o=s("p"),ep=o("This model inherits from "),zn=s("a"),tp=o("PreTrainedModel"),op=o(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),np=p(),vo=s("p"),rp=o("This model is also a PyTorch "),To=s("a"),sp=o("torch.nn.Module"),ap=o(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),dp=p(),ie=s("div"),b(bo.$$.fragment),ip=p(),$e=s("p"),cp=o("The "),Un=s("a"),lp=o("RagSequenceForGeneration"),pp=o(" forward method, overrides the "),bs=s("code"),hp=o("__call__"),mp=o(" special method."),up=p(),b(mt.$$.fragment),gp=p(),b(ut.$$.fragment),fp=p(),gt=s("div"),b(yo.$$.fragment),_p=p(),wo=s("p"),vp=o("Implements RAG sequence \u201Cthorough\u201D decoding. Read the "),En=s("a"),Tp=o("generate()"),bp=o("` documentation\nfor more information on how to set other generate input parameters."),ld=p(),Ze=s("h2"),ft=s("a"),ys=s("span"),b(Mo.$$.fragment),yp=p(),ws=s("span"),wp=o("RagTokenForGeneration"),pd=p(),G=s("div"),b(Ro.$$.fragment),Mp=p(),Ie=s("p"),Rp=o("The "),$n=s("a"),kp=o("RagTokenForGeneration"),qp=o(" forward method, overrides the "),Ms=s("code"),Fp=o("__call__"),xp=o(" special method."),jp=p(),b(_t.$$.fragment),Jp=p(),Rs=s("p"),Gp=o("A RAG-token model implementation. It performs RAG-token specific marginalization in the forward pass."),zp=p(),ks=s("p"),Up=o(`RAG is a seq2seq model which encapsulates two core components: a question encoder and a generator. During a forward
pass, we encode the input with the question encoder and pass it to the retriever to extract relevant context
documents. The documents are then prepended to the input. Such contextualized inputs is passed to the generator.`),Ep=p(),oe=s("p"),$p=o("The question encoder can be any "),qs=s("em"),Zp=o("autoencoding"),Ip=o(" model, preferably "),Zn=s("a"),Cp=o("DPRQuestionEncoder"),Np=o(`, and the generator can be
any `),Fs=s("em"),Ap=o("seq2seq"),Wp=o(" model, preferably "),In=s("a"),Xp=o("BartForConditionalGeneration"),Vp=o("."),Sp=p(),E=s("p"),Bp=o("The model can be initialized with a "),Cn=s("a"),Pp=o("RagRetriever"),Hp=o(` for end-to-end generation or used in combination with the
outputs of a retriever in multiple steps---see examples for more details. The model is compatible any
`),xs=s("em"),Lp=o("autoencoding"),Yp=o(" model as the "),js=s("code"),Qp=o("question_encoder"),Dp=o(" and any "),Js=s("em"),Op=o("seq2seq"),Kp=o(" model with language model head as the "),Gs=s("code"),eh=o("generator"),th=o(`.
It has been tested with `),Nn=s("a"),oh=o("DPRQuestionEncoder"),nh=o(" as the "),zs=s("code"),rh=o("question_encoder"),sh=o(" and "),An=s("a"),ah=o("BartForConditionalGeneration"),dh=o(` or
`),Wn=s("a"),ih=o("T5ForConditionalGeneration"),ch=o(" as the "),Us=s("code"),lh=o("generator"),ph=o("."),hh=p(),ko=s("p"),mh=o("This model inherits from "),Xn=s("a"),uh=o("PreTrainedModel"),gh=o(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),fh=p(),qo=s("p"),_h=o("This model is also a PyTorch "),Fo=s("a"),vh=o("torch.nn.Module"),Th=o(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),bh=p(),ce=s("div"),b(xo.$$.fragment),yh=p(),Ce=s("p"),wh=o("The "),Vn=s("a"),Mh=o("RagTokenForGeneration"),Rh=o(" forward method, overrides the "),Es=s("code"),kh=o("__call__"),qh=o(" special method."),Fh=p(),b(vt.$$.fragment),xh=p(),b(Tt.$$.fragment),jh=p(),bt=s("div"),b(jo.$$.fragment),Jh=p(),$s=s("p"),Gh=o("Implements RAG token decoding."),hd=p(),Ne=s("h2"),yt=s("a"),Zs=s("span"),b(Jo.$$.fragment),zh=p(),Is=s("span"),Uh=o("TFRagModel"),md=p(),$=s("div"),b(Go.$$.fragment),Eh=p(),Ae=s("p"),$h=o("The "),Sn=s("a"),Zh=o("TFRagModel"),Ih=o(" forward method, overrides the "),Cs=s("code"),Ch=o("__call__"),Nh=o(" special method."),Ah=p(),b(wt.$$.fragment),Wh=p(),Ns=s("p"),Xh=o(`RAG is a sequence-to-sequence model which encapsulates two core components: a question encoder and a generator.
During a forward pass, we encode the input with the question encoder and pass it to the retriever to extract
relevant context documents. The documents are then prepended to the input. Such contextualized inputs is passed to
the generator.`),Vh=p(),ne=s("p"),Sh=o("The question encoder can be any "),As=s("em"),Bh=o("autoencoding"),Ph=o(" model, preferably "),Bn=s("a"),Hh=o("TFDPRQuestionEncoder"),Lh=o(`, and the generator can be
any `),Ws=s("em"),Yh=o("seq2seq"),Qh=o(" model, preferably "),Pn=s("a"),Dh=o("TFBartForConditionalGeneration"),Oh=o("."),Kh=p(),A=s("p"),em=o("The model can be initialized with a "),Hn=s("a"),tm=o("RagRetriever"),om=o(` for end-to-end generation or used in combination with the
outputs of a retriever in multiple steps---see examples for more details. The model is compatible any
`),Xs=s("em"),nm=o("autoencoding"),rm=o(" model as the "),Vs=s("code"),sm=o("question_encoder"),am=o(" and any "),Ss=s("em"),dm=o("seq2seq"),im=o(" model with language model head as the "),Bs=s("code"),cm=o("generator"),lm=o(`.
It has been tested with `),Ln=s("a"),pm=o("TFDPRQuestionEncoder"),hm=o(" as the "),Ps=s("code"),mm=o("question_encoder"),um=o(" and "),Yn=s("a"),gm=o("TFBartForConditionalGeneration"),fm=o(`
as the `),Hs=s("code"),_m=o("generator"),vm=o("."),Tm=p(),zo=s("p"),bm=o("This model inherits from "),Qn=s("a"),ym=o("TFPreTrainedModel"),wm=o(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),Mm=p(),Uo=s("p"),Rm=o("This model is also a Tensorflow "),Eo=s("a"),km=o("tf.keras.Model"),qm=o(`
subclass. Use it as a regular TF 2.0 Keras Model and refer to the TF 2.0 documentation for all matter related to
general usage and behavior.`),Fm=p(),Ls=s("p"),xm=o(`The model is in a developing state as it is now fully supports in eager-mode only, and may not be exported in
SavedModel format.`),jm=p(),le=s("div"),b($o.$$.fragment),Jm=p(),We=s("p"),Gm=o("The "),Dn=s("a"),zm=o("TFRagModel"),Um=o(" forward method, overrides the "),Ys=s("code"),Em=o("__call__"),$m=o(" special method."),Zm=p(),b(Mt.$$.fragment),Im=p(),b(Rt.$$.fragment),ud=p(),Xe=s("h2"),kt=s("a"),Qs=s("span"),b(Zo.$$.fragment),Cm=p(),Ds=s("span"),Nm=o("TFRagSequenceForGeneration"),gd=p(),x=s("div"),b(Io.$$.fragment),Am=p(),Ve=s("p"),Wm=o("The "),On=s("a"),Xm=o("TFRagSequenceForGeneration"),Vm=o(" forward method, overrides the "),Os=s("code"),Sm=o("__call__"),Bm=o(" special method."),Pm=p(),b(qt.$$.fragment),Hm=p(),Ks=s("p"),Lm=o("A TF RAG-sequence model implementation. It performs RAG-sequence specific marginalization in the forward pass."),Ym=p(),ea=s("p"),Qm=o(`RAG is a sequence-to-sequence model which encapsulates two core components: a question encoder and a generator.
During a forward pass, we encode the input with the question encoder and pass it to the retriever to extract
relevant context documents. The documents are then prepended to the input. Such contextualized inputs is passed to
the generator.`),Dm=p(),re=s("p"),Om=o("The question encoder can be any "),ta=s("em"),Km=o("autoencoding"),eu=o(" model, preferably "),Kn=s("a"),tu=o("TFDPRQuestionEncoder"),ou=o(`, and the generator can be
any `),oa=s("em"),nu=o("seq2seq"),ru=o(" model, preferably "),er=s("a"),su=o("TFBartForConditionalGeneration"),au=o("."),du=p(),W=s("p"),iu=o("The model can be initialized with a "),tr=s("a"),cu=o("RagRetriever"),lu=o(` for end-to-end generation or used in combination with the
outputs of a retriever in multiple steps---see examples for more details. The model is compatible any
`),na=s("em"),pu=o("autoencoding"),hu=o(" model as the "),ra=s("code"),mu=o("question_encoder"),uu=o(" and any "),sa=s("em"),gu=o("seq2seq"),fu=o(" model with language model head as the "),aa=s("code"),_u=o("generator"),vu=o(`.
It has been tested with `),or=s("a"),Tu=o("TFDPRQuestionEncoder"),bu=o(" as the "),da=s("code"),yu=o("question_encoder"),wu=o(" and "),nr=s("a"),Mu=o("TFBartForConditionalGeneration"),Ru=o(`
as the `),ia=s("code"),ku=o("generator"),qu=o("."),Fu=p(),Co=s("p"),xu=o("This model inherits from "),rr=s("a"),ju=o("TFPreTrainedModel"),Ju=o(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),Gu=p(),No=s("p"),zu=o("This model is also a Tensorflow "),Ao=s("a"),Uu=o("tf.keras.Model"),Eu=o(`
subclass. Use it as a regular TF 2.0 Keras Model and refer to the TF 2.0 documentation for all matter related to
general usage and behavior.`),$u=p(),ca=s("p"),Zu=o(`The model is in a developing state as it is now fully supports in eager-mode only, and may not be exported in
SavedModel format.`),Iu=p(),pe=s("div"),b(Wo.$$.fragment),Cu=p(),Se=s("p"),Nu=o("The "),sr=s("a"),Au=o("TFRagSequenceForGeneration"),Wu=o(" forward method, overrides the "),la=s("code"),Xu=o("__call__"),Vu=o(" special method."),Su=p(),b(Ft.$$.fragment),Bu=p(),b(xt.$$.fragment),Pu=p(),jt=s("div"),b(Xo.$$.fragment),Hu=p(),Vo=s("p"),Lu=o("Implements RAG sequence \u201Cthorough\u201D decoding. Read the "),ar=s("a"),Yu=o("generate()"),Qu=o("` documentation\nfor more information on how to set other generate input parameters"),fd=p(),Be=s("h2"),Jt=s("a"),pa=s("span"),b(So.$$.fragment),Du=p(),ha=s("span"),Ou=o("TFRagTokenForGeneration"),_d=p(),j=s("div"),b(Bo.$$.fragment),Ku=p(),Pe=s("p"),eg=o("The "),dr=s("a"),tg=o("TFRagTokenForGeneration"),og=o(" forward method, overrides the "),ma=s("code"),ng=o("__call__"),rg=o(" special method."),sg=p(),b(Gt.$$.fragment),ag=p(),ua=s("p"),dg=o("A TF RAG-token model implementation. It performs RAG-token specific marginalization in the forward pass."),ig=p(),ga=s("p"),cg=o(`RAG is a sequence-to-sequence model which encapsulates two core components: a question encoder and a generator.
During a forward pass, we encode the input with the question encoder and pass it to the retriever to extract
relevant context documents. The documents are then prepended to the input. Such contextualized inputs is passed to
the generator.`),lg=p(),se=s("p"),pg=o("The question encoder can be any "),fa=s("em"),hg=o("autoencoding"),mg=o(" model, preferably "),ir=s("a"),ug=o("TFDPRQuestionEncoder"),gg=o(`, and the generator can be
any `),_a=s("em"),fg=o("seq2seq"),_g=o(" model, preferably "),cr=s("a"),vg=o("TFBartForConditionalGeneration"),Tg=o("."),bg=p(),X=s("p"),yg=o("The model can be initialized with a "),lr=s("a"),wg=o("RagRetriever"),Mg=o(` for end-to-end generation or used in combination with the
outputs of a retriever in multiple steps---see examples for more details. The model is compatible any
`),va=s("em"),Rg=o("autoencoding"),kg=o(" model as the "),Ta=s("code"),qg=o("question_encoder"),Fg=o(" and any "),ba=s("em"),xg=o("seq2seq"),jg=o(" model with language model head as the "),ya=s("code"),Jg=o("generator"),Gg=o(`.
It has been tested with `),pr=s("a"),zg=o("TFDPRQuestionEncoder"),Ug=o(" as the "),wa=s("code"),Eg=o("question_encoder"),$g=o(" and "),hr=s("a"),Zg=o("TFBartForConditionalGeneration"),Ig=o(`
as the `),Ma=s("code"),Cg=o("generator"),Ng=o("."),Ag=p(),Po=s("p"),Wg=o("This model inherits from "),mr=s("a"),Xg=o("TFPreTrainedModel"),Vg=o(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),Sg=p(),Ho=s("p"),Bg=o("This model is also a Tensorflow "),Lo=s("a"),Pg=o("tf.keras.Model"),Hg=o(`
subclass. Use it as a regular TF 2.0 Keras Model and refer to the TF 2.0 documentation for all matter related to
general usage and behavior.`),Lg=p(),Ra=s("p"),Yg=o(`The model is in a developing state as it is now fully supports in eager-mode only, and may not be exported in
SavedModel format.`),Qg=p(),he=s("div"),b(Yo.$$.fragment),Dg=p(),He=s("p"),Og=o("The "),ur=s("a"),Kg=o("TFRagTokenForGeneration"),ef=o(" forward method, overrides the "),ka=s("code"),tf=o("__call__"),of=o(" special method."),nf=p(),b(zt.$$.fragment),rf=p(),b(Ut.$$.fragment),sf=p(),Et=s("div"),b(Qo.$$.fragment),af=p(),qa=s("p"),df=o("Implements TFRAG token decoding."),this.h()},l(r){const f=JT('[data-svelte="svelte-1phssyn"]',document.head);c=a(f,"META",{name:!0,content:!0}),f.forEach(t),T=h(r),u=a(r,"H1",{class:!0});var Do=d(u);g=a(Do,"A",{id:!0,class:!0,href:!0});var Fa=d(g);_=a(Fa,"SPAN",{});var xa=d(_);y(i.$$.fragment,xa),xa.forEach(t),Fa.forEach(t),m=h(Do),q=a(Do,"SPAN",{});var ja=d(q);ei=n(ja,"RAG"),ja.forEach(t),Do.forEach(t),Xa=h(r),Wt=a(r,"DIV",{class:!0});var Ja=d(Wt);rn=a(Ja,"A",{href:!0});var Ga=d(rn);sn=a(Ga,"IMG",{alt:!0,src:!0}),Ga.forEach(t),Ja.forEach(t),Va=h(r),Me=a(r,"H2",{class:!0});var Oo=d(Me);Ye=a(Oo,"A",{id:!0,class:!0,href:!0});var za=d(Ye);jr=a(za,"SPAN",{});var Ua=d(jr);y(Xt.$$.fragment,Ua),Ua.forEach(t),za.forEach(t),ti=h(Oo),Jr=a(Oo,"SPAN",{});var Ea=d(Jr);oi=n(Ea,"Overview"),Ea.forEach(t),Oo.forEach(t),Sa=h(r),an=a(r,"P",{});var $a=d(an);ni=n($a,`Retrieval-augmented generation (\u201CRAG\u201D) models combine the powers of pretrained dense retrieval (DPR) and
sequence-to-sequence models. RAG models retrieve documents, pass them to a seq2seq model, then marginalize to generate
outputs. The retriever and seq2seq modules are initialized from pretrained models, and fine-tuned jointly, allowing
both retrieval and generation to adapt to downstream tasks.`),$a.forEach(t),Ba=h(r),Qe=a(r,"P",{});var Ko=d(Qe);ri=n(Ko,"It is based on the paper "),Vt=a(Ko,"A",{href:!0,rel:!0});var Za=d(Vt);si=n(Za,"Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks"),Za.forEach(t),ai=n(Ko,` by Patrick Lewis, Ethan Perez, Aleksandara Piktus, Fabio Petroni, Vladimir
Karpukhin, Naman Goyal, Heinrich K\xFCttler, Mike Lewis, Wen-tau Yih, Tim Rockt\xE4schel, Sebastian Riedel, Douwe Kiela.`),Ko.forEach(t),Pa=h(r),dn=a(r,"P",{});var Ia=d(dn);di=n(Ia,"The abstract from the paper is the following:"),Ia.forEach(t),Ha=h(r),cn=a(r,"P",{});var Ca=d(cn);Gr=a(Ca,"EM",{});var Na=d(Gr);ii=n(Na,`Large pre-trained language models have been shown to store factual knowledge in their parameters, and achieve
state-of-the-art results when fine-tuned on downstream NLP tasks. However, their ability to access and precisely
manipulate knowledge is still limited, and hence on knowledge-intensive tasks, their performance lags behind
task-specific architectures. Additionally, providing provenance for their decisions and updating their world knowledge
remain open research problems. Pre-trained models with a differentiable access mechanism to explicit nonparametric
memory can overcome this issue, but have so far been only investigated for extractive downstream tasks. We explore a
general-purpose fine-tuning recipe for retrieval-augmented generation (RAG) \u2014 models which combine pre-trained
parametric and non-parametric memory for language generation. We introduce RAG models where the parametric memory is a
pre-trained seq2seq model and the non-parametric memory is a dense vector index of Wikipedia, accessed with a
pre-trained neural retriever. We compare two RAG formulations, one which conditions on the same retrieved passages
across the whole generated sequence, the other can use different passages per token. We fine-tune and evaluate our
models on a wide range of knowledge-intensive NLP tasks and set the state-of-the-art on three open domain QA tasks,
outperforming parametric seq2seq models and task-specific retrieve-and-extract architectures. For language generation
tasks, we find that RAG models generate more specific, diverse and factual language than a state-of-the-art
parametric-only seq2seq baseline.`),Na.forEach(t),Ca.forEach(t),La=h(r),De=a(r,"P",{});var en=d(De);ci=n(en,"This model was contributed by "),St=a(en,"A",{href:!0,rel:!0});var Aa=d(St);li=n(Aa,"ola13"),Aa.forEach(t),pi=n(en,"."),en.forEach(t),Ya=h(r),ln=a(r,"P",{});var Wa=d(ln);hi=n(Wa,"Tips:"),Wa.forEach(t),Qa=h(r),pn=a(r,"UL",{});var lf=d(pn);zr=a(lf,"LI",{});var pf=d(zr);mi=n(pf,"Retrieval-augmented generation (\u201CRAG\u201D) models combine the powers of pretrained dense retrieval (DPR) and Seq2Seq models. RAG models retrieve docs, pass them to a seq2seq model, then marginalize to generate outputs. The retriever and seq2seq modules are initialized from pretrained models, and fine-tuned jointly, allowing both retrieval and generation to adapt to downstream tasks."),pf.forEach(t),lf.forEach(t),Da=h(r),Re=a(r,"H2",{class:!0});var Td=d(Re);Oe=a(Td,"A",{id:!0,class:!0,href:!0});var hf=d(Oe);Ur=a(hf,"SPAN",{});var mf=d(Ur);y(Bt.$$.fragment,mf),mf.forEach(t),hf.forEach(t),ui=h(Td),Er=a(Td,"SPAN",{});var uf=d(Er);gi=n(uf,"RagConfig"),uf.forEach(t),Td.forEach(t),Oa=h(r),fe=a(r,"DIV",{class:!0});var gr=d(fe);y(Pt.$$.fragment,gr),fi=h(gr),ae=a(gr,"P",{});var Le=d(ae);hn=a(Le,"A",{href:!0});var gf=d(hn);_i=n(gf,"RagConfig"),gf.forEach(t),vi=n(Le," stores the configuration of a "),$r=a(Le,"EM",{});var ff=d($r);Ti=n(ff,"RagModel"),ff.forEach(t),bi=n(Le,". Configuration objects inherit from "),mn=a(Le,"A",{href:!0});var _f=d(mn);yi=n(_f,"PretrainedConfig"),_f.forEach(t),wi=n(Le,` and
can be used to control the model outputs. Read the documentation from `),un=a(Le,"A",{href:!0});var vf=d(un);Mi=n(vf,"PretrainedConfig"),vf.forEach(t),Ri=n(Le," for more information."),Le.forEach(t),ki=h(gr),Ke=a(gr,"DIV",{class:!0});var bd=d(Ke);y(Ht.$$.fragment,bd),qi=h(bd),Lt=a(bd,"P",{});var yd=d(Lt);Fi=n(yd,"Instantiate a "),gn=a(yd,"A",{href:!0});var Tf=d(gn);xi=n(Tf,"EncoderDecoderConfig"),Tf.forEach(t),ji=n(yd,` (or a derived class) from a pre-trained encoder model configuration and
decoder model configuration.`),yd.forEach(t),bd.forEach(t),gr.forEach(t),Ka=h(r),ke=a(r,"H2",{class:!0});var wd=d(ke);et=a(wd,"A",{id:!0,class:!0,href:!0});var bf=d(et);Zr=a(bf,"SPAN",{});var yf=d(Zr);y(Yt.$$.fragment,yf),yf.forEach(t),bf.forEach(t),Ji=h(wd),Ir=a(wd,"SPAN",{});var wf=d(Ir);Gi=n(wf,"RagTokenizer"),wf.forEach(t),wd.forEach(t),ed=h(r),Qt=a(r,"DIV",{class:!0});var Mf=d(Qt);y(Dt.$$.fragment,Mf),Mf.forEach(t),td=h(r),qe=a(r,"H2",{class:!0});var Md=d(qe);tt=a(Md,"A",{id:!0,class:!0,href:!0});var Rf=d(tt);Cr=a(Rf,"SPAN",{});var kf=d(Cr);y(Ot.$$.fragment,kf),kf.forEach(t),Rf.forEach(t),zi=h(Md),Nr=a(Md,"SPAN",{});var qf=d(Nr);Ui=n(qf,"Rag specific outputs"),qf.forEach(t),Md.forEach(t),od=h(r),Fe=a(r,"DIV",{class:!0});var Rd=d(Fe);y(Kt.$$.fragment,Rd),Ei=h(Rd),Ar=a(Rd,"P",{});var Ff=d(Ar);$i=n(Ff,"Base class for retriever augmented marginalized models outputs."),Ff.forEach(t),Rd.forEach(t),nd=h(r),eo=a(r,"DIV",{class:!0});var xf=d(eo);y(to.$$.fragment,xf),xf.forEach(t),rd=h(r),xe=a(r,"H2",{class:!0});var kd=d(xe);ot=a(kd,"A",{id:!0,class:!0,href:!0});var jf=d(ot);Wr=a(jf,"SPAN",{});var Jf=d(Wr);y(oo.$$.fragment,Jf),Jf.forEach(t),jf.forEach(t),Zi=h(kd),Xr=a(kd,"SPAN",{});var Gf=d(Xr);Ii=n(Gf,"RagRetriever"),Gf.forEach(t),kd.forEach(t),sd=h(r),K=a(r,"DIV",{class:!0});var me=d(K);y(no.$$.fragment,me),Ci=h(me),Vr=a(me,"P",{});var zf=d(Vr);Ni=n(zf,`Retriever used to get documents from vector queries. It retrieves the documents embeddings as well as the documents
contents, and it formats them to be used with a RagModel.`),zf.forEach(t),Ai=h(me),y(nt.$$.fragment,me),Wi=h(me),rt=a(me,"DIV",{class:!0});var qd=d(rt);y(ro.$$.fragment,qd),Xi=h(qd),Sr=a(qd,"P",{});var Uf=d(Sr);Vi=n(Uf,"Retriever initialization function. It loads the index into memory."),Uf.forEach(t),qd.forEach(t),Si=h(me),st=a(me,"DIV",{class:!0});var Fd=d(st);y(so.$$.fragment,Fd),Bi=h(Fd),je=a(Fd,"P",{});var fr=d(je);Pi=n(fr,"Postprocessing retrieved "),Br=a(fr,"CODE",{});var Ef=d(Br);Hi=n(Ef,"docs"),Ef.forEach(t),Li=n(fr," and combining them with "),Pr=a(fr,"CODE",{});var $f=d(Pr);Yi=n($f,"input_strings"),$f.forEach(t),Qi=n(fr,"."),fr.forEach(t),Fd.forEach(t),Di=h(me),at=a(me,"DIV",{class:!0});var xd=d(at);y(ao.$$.fragment,xd),Oi=h(xd),io=a(xd,"P",{});var jd=d(io);Ki=n(jd,"Retrieves documents for specified "),Hr=a(jd,"CODE",{});var Zf=d(Hr);ec=n(Zf,"question_hidden_states"),Zf.forEach(t),tc=n(jd,"."),jd.forEach(t),xd.forEach(t),me.forEach(t),ad=h(r),Je=a(r,"H2",{class:!0});var Jd=d(Je);dt=a(Jd,"A",{id:!0,class:!0,href:!0});var If=d(dt);Lr=a(If,"SPAN",{});var Cf=d(Lr);y(co.$$.fragment,Cf),Cf.forEach(t),If.forEach(t),oc=h(Jd),Yr=a(Jd,"SPAN",{});var Nf=d(Yr);nc=n(Nf,"RagModel"),Nf.forEach(t),Jd.forEach(t),dd=h(r),N=a(r,"DIV",{class:!0});var O=d(N);y(lo.$$.fragment,O),rc=h(O),Ge=a(O,"P",{});var _r=d(Ge);sc=n(_r,"The "),fn=a(_r,"A",{href:!0});var Af=d(fn);ac=n(Af,"RagModel"),Af.forEach(t),dc=n(_r," forward method, overrides the "),Qr=a(_r,"CODE",{});var Wf=d(Qr);ic=n(Wf,"__call__"),Wf.forEach(t),cc=n(_r," special method."),_r.forEach(t),lc=h(O),y(it.$$.fragment,O),pc=h(O),Dr=a(O,"P",{});var Xf=d(Dr);hc=n(Xf,`RAG is a seq2seq model which encapsulates two core components: a question encoder and a generator. During a forward
pass, we encode the input with the question encoder and pass it to the retriever to extract relevant context
documents. The documents are then prepended to the input. Such contextualized inputs is passed to the generator.`),Xf.forEach(t),mc=h(O),ee=a(O,"P",{});var _e=d(ee);uc=n(_e,"The question encoder can be any "),Or=a(_e,"EM",{});var Vf=d(Or);gc=n(Vf,"autoencoding"),Vf.forEach(t),fc=n(_e," model, preferably "),_n=a(_e,"A",{href:!0});var Sf=d(_n);_c=n(Sf,"DPRQuestionEncoder"),Sf.forEach(t),vc=n(_e,`, and the generator can be
any `),Kr=a(_e,"EM",{});var Bf=d(Kr);Tc=n(Bf,"seq2seq"),Bf.forEach(t),bc=n(_e," model, preferably "),vn=a(_e,"A",{href:!0});var Pf=d(vn);yc=n(Pf,"BartForConditionalGeneration"),Pf.forEach(t),wc=n(_e,"."),_e.forEach(t),Mc=h(O),z=a(O,"P",{});var V=d(z);Rc=n(V,"The model can be initialized with a "),Tn=a(V,"A",{href:!0});var Hf=d(Tn);kc=n(Hf,"RagRetriever"),Hf.forEach(t),qc=n(V,` for end-to-end generation or used in combination with the
outputs of a retriever in multiple steps---see examples for more details. The model is compatible any
`),es=a(V,"EM",{});var Lf=d(es);Fc=n(Lf,"autoencoding"),Lf.forEach(t),xc=n(V," model as the "),ts=a(V,"CODE",{});var Yf=d(ts);jc=n(Yf,"question_encoder"),Yf.forEach(t),Jc=n(V," and any "),os=a(V,"EM",{});var Qf=d(os);Gc=n(Qf,"seq2seq"),Qf.forEach(t),zc=n(V," model with language model head as the "),ns=a(V,"CODE",{});var Df=d(ns);Uc=n(Df,"generator"),Df.forEach(t),Ec=n(V,`.
It has been tested with `),bn=a(V,"A",{href:!0});var Of=d(bn);$c=n(Of,"DPRQuestionEncoder"),Of.forEach(t),Zc=n(V," as the "),rs=a(V,"CODE",{});var Kf=d(rs);Ic=n(Kf,"question_encoder"),Kf.forEach(t),Cc=n(V," and "),yn=a(V,"A",{href:!0});var e_=d(yn);Nc=n(e_,"BartForConditionalGeneration"),e_.forEach(t),Ac=n(V,` or
`),wn=a(V,"A",{href:!0});var t_=d(wn);Wc=n(t_,"T5ForConditionalGeneration"),t_.forEach(t),Xc=n(V," as the "),ss=a(V,"CODE",{});var o_=d(ss);Vc=n(o_,"generator"),o_.forEach(t),Sc=n(V,"."),V.forEach(t),Bc=h(O),po=a(O,"P",{});var Gd=d(po);Pc=n(Gd,"This model inherits from "),Mn=a(Gd,"A",{href:!0});var n_=d(Mn);Hc=n(n_,"PreTrainedModel"),n_.forEach(t),Lc=n(Gd,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),Gd.forEach(t),Yc=h(O),ho=a(O,"P",{});var zd=d(ho);Qc=n(zd,"This model is also a PyTorch "),mo=a(zd,"A",{href:!0,rel:!0});var r_=d(mo);Dc=n(r_,"torch.nn.Module"),r_.forEach(t),Oc=n(zd,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),zd.forEach(t),Kc=h(O),de=a(O,"DIV",{class:!0});var $t=d(de);y(uo.$$.fragment,$t),el=h($t),ze=a($t,"P",{});var vr=d(ze);tl=n(vr,"The "),Rn=a(vr,"A",{href:!0});var s_=d(Rn);ol=n(s_,"RagModel"),s_.forEach(t),nl=n(vr," forward method, overrides the "),as=a(vr,"CODE",{});var a_=d(as);rl=n(a_,"__call__"),a_.forEach(t),sl=n(vr," special method."),vr.forEach(t),al=h($t),y(ct.$$.fragment,$t),dl=h($t),y(lt.$$.fragment,$t),$t.forEach(t),O.forEach(t),id=h(r),Ue=a(r,"H2",{class:!0});var Ud=d(Ue);pt=a(Ud,"A",{id:!0,class:!0,href:!0});var d_=d(pt);ds=a(d_,"SPAN",{});var i_=d(ds);y(go.$$.fragment,i_),i_.forEach(t),d_.forEach(t),il=h(Ud),is=a(Ud,"SPAN",{});var c_=d(is);cl=n(c_,"RagSequenceForGeneration"),c_.forEach(t),Ud.forEach(t),cd=h(r),J=a(r,"DIV",{class:!0});var S=d(J);y(fo.$$.fragment,S),ll=h(S),Ee=a(S,"P",{});var Tr=d(Ee);pl=n(Tr,"The "),kn=a(Tr,"A",{href:!0});var l_=d(kn);hl=n(l_,"RagSequenceForGeneration"),l_.forEach(t),ml=n(Tr," forward method, overrides the "),cs=a(Tr,"CODE",{});var p_=d(cs);ul=n(p_,"__call__"),p_.forEach(t),gl=n(Tr," special method."),Tr.forEach(t),fl=h(S),y(ht.$$.fragment,S),_l=h(S),ls=a(S,"P",{});var h_=d(ls);vl=n(h_,"A RAG-sequence model implementation. It performs RAG-sequence specific marginalization in the forward pass."),h_.forEach(t),Tl=h(S),ps=a(S,"P",{});var m_=d(ps);bl=n(m_,`RAG is a seq2seq model which encapsulates two core components: a question encoder and a generator. During a forward
pass, we encode the input with the question encoder and pass it to the retriever to extract relevant context
documents. The documents are then prepended to the input. Such contextualized inputs is passed to the generator.`),m_.forEach(t),yl=h(S),te=a(S,"P",{});var ve=d(te);wl=n(ve,"The question encoder can be any "),hs=a(ve,"EM",{});var u_=d(hs);Ml=n(u_,"autoencoding"),u_.forEach(t),Rl=n(ve," model, preferably "),qn=a(ve,"A",{href:!0});var g_=d(qn);kl=n(g_,"DPRQuestionEncoder"),g_.forEach(t),ql=n(ve,`, and the generator can be
any `),ms=a(ve,"EM",{});var f_=d(ms);Fl=n(f_,"seq2seq"),f_.forEach(t),xl=n(ve," model, preferably "),Fn=a(ve,"A",{href:!0});var __=d(Fn);jl=n(__,"BartForConditionalGeneration"),__.forEach(t),Jl=n(ve,"."),ve.forEach(t),Gl=h(S),U=a(S,"P",{});var B=d(U);zl=n(B,"The model can be initialized with a "),xn=a(B,"A",{href:!0});var v_=d(xn);Ul=n(v_,"RagRetriever"),v_.forEach(t),El=n(B,` for end-to-end generation or used in combination with the
outputs of a retriever in multiple steps---see examples for more details. The model is compatible any
`),us=a(B,"EM",{});var T_=d(us);$l=n(T_,"autoencoding"),T_.forEach(t),Zl=n(B," model as the "),gs=a(B,"CODE",{});var b_=d(gs);Il=n(b_,"question_encoder"),b_.forEach(t),Cl=n(B," and any "),fs=a(B,"EM",{});var y_=d(fs);Nl=n(y_,"seq2seq"),y_.forEach(t),Al=n(B," model with language model head as the "),_s=a(B,"CODE",{});var w_=d(_s);Wl=n(w_,"generator"),w_.forEach(t),Xl=n(B,`.
It has been tested with `),jn=a(B,"A",{href:!0});var M_=d(jn);Vl=n(M_,"DPRQuestionEncoder"),M_.forEach(t),Sl=n(B," as the "),vs=a(B,"CODE",{});var R_=d(vs);Bl=n(R_,"question_encoder"),R_.forEach(t),Pl=n(B," and "),Jn=a(B,"A",{href:!0});var k_=d(Jn);Hl=n(k_,"BartForConditionalGeneration"),k_.forEach(t),Ll=n(B,` or
`),Gn=a(B,"A",{href:!0});var q_=d(Gn);Yl=n(q_,"T5ForConditionalGeneration"),q_.forEach(t),Ql=n(B," as the "),Ts=a(B,"CODE",{});var F_=d(Ts);Dl=n(F_,"generator"),F_.forEach(t),Ol=n(B,"."),B.forEach(t),Kl=h(S),_o=a(S,"P",{});var Ed=d(_o);ep=n(Ed,"This model inherits from "),zn=a(Ed,"A",{href:!0});var x_=d(zn);tp=n(x_,"PreTrainedModel"),x_.forEach(t),op=n(Ed,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),Ed.forEach(t),np=h(S),vo=a(S,"P",{});var $d=d(vo);rp=n($d,"This model is also a PyTorch "),To=a($d,"A",{href:!0,rel:!0});var j_=d(To);sp=n(j_,"torch.nn.Module"),j_.forEach(t),ap=n($d,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),$d.forEach(t),dp=h(S),ie=a(S,"DIV",{class:!0});var Zt=d(ie);y(bo.$$.fragment,Zt),ip=h(Zt),$e=a(Zt,"P",{});var br=d($e);cp=n(br,"The "),Un=a(br,"A",{href:!0});var J_=d(Un);lp=n(J_,"RagSequenceForGeneration"),J_.forEach(t),pp=n(br," forward method, overrides the "),bs=a(br,"CODE",{});var G_=d(bs);hp=n(G_,"__call__"),G_.forEach(t),mp=n(br," special method."),br.forEach(t),up=h(Zt),y(mt.$$.fragment,Zt),gp=h(Zt),y(ut.$$.fragment,Zt),Zt.forEach(t),fp=h(S),gt=a(S,"DIV",{class:!0});var Zd=d(gt);y(yo.$$.fragment,Zd),_p=h(Zd),wo=a(Zd,"P",{});var Id=d(wo);vp=n(Id,"Implements RAG sequence \u201Cthorough\u201D decoding. Read the "),En=a(Id,"A",{href:!0});var z_=d(En);Tp=n(z_,"generate()"),z_.forEach(t),bp=n(Id,"` documentation\nfor more information on how to set other generate input parameters."),Id.forEach(t),Zd.forEach(t),S.forEach(t),ld=h(r),Ze=a(r,"H2",{class:!0});var Cd=d(Ze);ft=a(Cd,"A",{id:!0,class:!0,href:!0});var U_=d(ft);ys=a(U_,"SPAN",{});var E_=d(ys);y(Mo.$$.fragment,E_),E_.forEach(t),U_.forEach(t),yp=h(Cd),ws=a(Cd,"SPAN",{});var $_=d(ws);wp=n($_,"RagTokenForGeneration"),$_.forEach(t),Cd.forEach(t),pd=h(r),G=a(r,"DIV",{class:!0});var P=d(G);y(Ro.$$.fragment,P),Mp=h(P),Ie=a(P,"P",{});var yr=d(Ie);Rp=n(yr,"The "),$n=a(yr,"A",{href:!0});var Z_=d($n);kp=n(Z_,"RagTokenForGeneration"),Z_.forEach(t),qp=n(yr," forward method, overrides the "),Ms=a(yr,"CODE",{});var I_=d(Ms);Fp=n(I_,"__call__"),I_.forEach(t),xp=n(yr," special method."),yr.forEach(t),jp=h(P),y(_t.$$.fragment,P),Jp=h(P),Rs=a(P,"P",{});var C_=d(Rs);Gp=n(C_,"A RAG-token model implementation. It performs RAG-token specific marginalization in the forward pass."),C_.forEach(t),zp=h(P),ks=a(P,"P",{});var N_=d(ks);Up=n(N_,`RAG is a seq2seq model which encapsulates two core components: a question encoder and a generator. During a forward
pass, we encode the input with the question encoder and pass it to the retriever to extract relevant context
documents. The documents are then prepended to the input. Such contextualized inputs is passed to the generator.`),N_.forEach(t),Ep=h(P),oe=a(P,"P",{});var Te=d(oe);$p=n(Te,"The question encoder can be any "),qs=a(Te,"EM",{});var A_=d(qs);Zp=n(A_,"autoencoding"),A_.forEach(t),Ip=n(Te," model, preferably "),Zn=a(Te,"A",{href:!0});var W_=d(Zn);Cp=n(W_,"DPRQuestionEncoder"),W_.forEach(t),Np=n(Te,`, and the generator can be
any `),Fs=a(Te,"EM",{});var X_=d(Fs);Ap=n(X_,"seq2seq"),X_.forEach(t),Wp=n(Te," model, preferably "),In=a(Te,"A",{href:!0});var V_=d(In);Xp=n(V_,"BartForConditionalGeneration"),V_.forEach(t),Vp=n(Te,"."),Te.forEach(t),Sp=h(P),E=a(P,"P",{});var H=d(E);Bp=n(H,"The model can be initialized with a "),Cn=a(H,"A",{href:!0});var S_=d(Cn);Pp=n(S_,"RagRetriever"),S_.forEach(t),Hp=n(H,` for end-to-end generation or used in combination with the
outputs of a retriever in multiple steps---see examples for more details. The model is compatible any
`),xs=a(H,"EM",{});var B_=d(xs);Lp=n(B_,"autoencoding"),B_.forEach(t),Yp=n(H," model as the "),js=a(H,"CODE",{});var P_=d(js);Qp=n(P_,"question_encoder"),P_.forEach(t),Dp=n(H," and any "),Js=a(H,"EM",{});var H_=d(Js);Op=n(H_,"seq2seq"),H_.forEach(t),Kp=n(H," model with language model head as the "),Gs=a(H,"CODE",{});var L_=d(Gs);eh=n(L_,"generator"),L_.forEach(t),th=n(H,`.
It has been tested with `),Nn=a(H,"A",{href:!0});var Y_=d(Nn);oh=n(Y_,"DPRQuestionEncoder"),Y_.forEach(t),nh=n(H," as the "),zs=a(H,"CODE",{});var Q_=d(zs);rh=n(Q_,"question_encoder"),Q_.forEach(t),sh=n(H," and "),An=a(H,"A",{href:!0});var D_=d(An);ah=n(D_,"BartForConditionalGeneration"),D_.forEach(t),dh=n(H,` or
`),Wn=a(H,"A",{href:!0});var O_=d(Wn);ih=n(O_,"T5ForConditionalGeneration"),O_.forEach(t),ch=n(H," as the "),Us=a(H,"CODE",{});var K_=d(Us);lh=n(K_,"generator"),K_.forEach(t),ph=n(H,"."),H.forEach(t),hh=h(P),ko=a(P,"P",{});var Nd=d(ko);mh=n(Nd,"This model inherits from "),Xn=a(Nd,"A",{href:!0});var ev=d(Xn);uh=n(ev,"PreTrainedModel"),ev.forEach(t),gh=n(Nd,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),Nd.forEach(t),fh=h(P),qo=a(P,"P",{});var Ad=d(qo);_h=n(Ad,"This model is also a PyTorch "),Fo=a(Ad,"A",{href:!0,rel:!0});var tv=d(Fo);vh=n(tv,"torch.nn.Module"),tv.forEach(t),Th=n(Ad,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Ad.forEach(t),bh=h(P),ce=a(P,"DIV",{class:!0});var It=d(ce);y(xo.$$.fragment,It),yh=h(It),Ce=a(It,"P",{});var wr=d(Ce);wh=n(wr,"The "),Vn=a(wr,"A",{href:!0});var ov=d(Vn);Mh=n(ov,"RagTokenForGeneration"),ov.forEach(t),Rh=n(wr," forward method, overrides the "),Es=a(wr,"CODE",{});var nv=d(Es);kh=n(nv,"__call__"),nv.forEach(t),qh=n(wr," special method."),wr.forEach(t),Fh=h(It),y(vt.$$.fragment,It),xh=h(It),y(Tt.$$.fragment,It),It.forEach(t),jh=h(P),bt=a(P,"DIV",{class:!0});var Wd=d(bt);y(jo.$$.fragment,Wd),Jh=h(Wd),$s=a(Wd,"P",{});var rv=d($s);Gh=n(rv,"Implements RAG token decoding."),rv.forEach(t),Wd.forEach(t),P.forEach(t),hd=h(r),Ne=a(r,"H2",{class:!0});var Xd=d(Ne);yt=a(Xd,"A",{id:!0,class:!0,href:!0});var sv=d(yt);Zs=a(sv,"SPAN",{});var av=d(Zs);y(Jo.$$.fragment,av),av.forEach(t),sv.forEach(t),zh=h(Xd),Is=a(Xd,"SPAN",{});var dv=d(Is);Uh=n(dv,"TFRagModel"),dv.forEach(t),Xd.forEach(t),md=h(r),$=a(r,"DIV",{class:!0});var L=d($);y(Go.$$.fragment,L),Eh=h(L),Ae=a(L,"P",{});var Mr=d(Ae);$h=n(Mr,"The "),Sn=a(Mr,"A",{href:!0});var iv=d(Sn);Zh=n(iv,"TFRagModel"),iv.forEach(t),Ih=n(Mr," forward method, overrides the "),Cs=a(Mr,"CODE",{});var cv=d(Cs);Ch=n(cv,"__call__"),cv.forEach(t),Nh=n(Mr," special method."),Mr.forEach(t),Ah=h(L),y(wt.$$.fragment,L),Wh=h(L),Ns=a(L,"P",{});var lv=d(Ns);Xh=n(lv,`RAG is a sequence-to-sequence model which encapsulates two core components: a question encoder and a generator.
During a forward pass, we encode the input with the question encoder and pass it to the retriever to extract
relevant context documents. The documents are then prepended to the input. Such contextualized inputs is passed to
the generator.`),lv.forEach(t),Vh=h(L),ne=a(L,"P",{});var be=d(ne);Sh=n(be,"The question encoder can be any "),As=a(be,"EM",{});var pv=d(As);Bh=n(pv,"autoencoding"),pv.forEach(t),Ph=n(be," model, preferably "),Bn=a(be,"A",{href:!0});var hv=d(Bn);Hh=n(hv,"TFDPRQuestionEncoder"),hv.forEach(t),Lh=n(be,`, and the generator can be
any `),Ws=a(be,"EM",{});var mv=d(Ws);Yh=n(mv,"seq2seq"),mv.forEach(t),Qh=n(be," model, preferably "),Pn=a(be,"A",{href:!0});var uv=d(Pn);Dh=n(uv,"TFBartForConditionalGeneration"),uv.forEach(t),Oh=n(be,"."),be.forEach(t),Kh=h(L),A=a(L,"P",{});var Y=d(A);em=n(Y,"The model can be initialized with a "),Hn=a(Y,"A",{href:!0});var gv=d(Hn);tm=n(gv,"RagRetriever"),gv.forEach(t),om=n(Y,` for end-to-end generation or used in combination with the
outputs of a retriever in multiple steps---see examples for more details. The model is compatible any
`),Xs=a(Y,"EM",{});var fv=d(Xs);nm=n(fv,"autoencoding"),fv.forEach(t),rm=n(Y," model as the "),Vs=a(Y,"CODE",{});var _v=d(Vs);sm=n(_v,"question_encoder"),_v.forEach(t),am=n(Y," and any "),Ss=a(Y,"EM",{});var vv=d(Ss);dm=n(vv,"seq2seq"),vv.forEach(t),im=n(Y," model with language model head as the "),Bs=a(Y,"CODE",{});var Tv=d(Bs);cm=n(Tv,"generator"),Tv.forEach(t),lm=n(Y,`.
It has been tested with `),Ln=a(Y,"A",{href:!0});var bv=d(Ln);pm=n(bv,"TFDPRQuestionEncoder"),bv.forEach(t),hm=n(Y," as the "),Ps=a(Y,"CODE",{});var yv=d(Ps);mm=n(yv,"question_encoder"),yv.forEach(t),um=n(Y," and "),Yn=a(Y,"A",{href:!0});var wv=d(Yn);gm=n(wv,"TFBartForConditionalGeneration"),wv.forEach(t),fm=n(Y,`
as the `),Hs=a(Y,"CODE",{});var Mv=d(Hs);_m=n(Mv,"generator"),Mv.forEach(t),vm=n(Y,"."),Y.forEach(t),Tm=h(L),zo=a(L,"P",{});var Vd=d(zo);bm=n(Vd,"This model inherits from "),Qn=a(Vd,"A",{href:!0});var Rv=d(Qn);ym=n(Rv,"TFPreTrainedModel"),Rv.forEach(t),wm=n(Vd,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),Vd.forEach(t),Mm=h(L),Uo=a(L,"P",{});var Sd=d(Uo);Rm=n(Sd,"This model is also a Tensorflow "),Eo=a(Sd,"A",{href:!0,rel:!0});var kv=d(Eo);km=n(kv,"tf.keras.Model"),kv.forEach(t),qm=n(Sd,`
subclass. Use it as a regular TF 2.0 Keras Model and refer to the TF 2.0 documentation for all matter related to
general usage and behavior.`),Sd.forEach(t),Fm=h(L),Ls=a(L,"P",{});var qv=d(Ls);xm=n(qv,`The model is in a developing state as it is now fully supports in eager-mode only, and may not be exported in
SavedModel format.`),qv.forEach(t),jm=h(L),le=a(L,"DIV",{class:!0});var Ct=d(le);y($o.$$.fragment,Ct),Jm=h(Ct),We=a(Ct,"P",{});var Rr=d(We);Gm=n(Rr,"The "),Dn=a(Rr,"A",{href:!0});var Fv=d(Dn);zm=n(Fv,"TFRagModel"),Fv.forEach(t),Um=n(Rr," forward method, overrides the "),Ys=a(Rr,"CODE",{});var xv=d(Ys);Em=n(xv,"__call__"),xv.forEach(t),$m=n(Rr," special method."),Rr.forEach(t),Zm=h(Ct),y(Mt.$$.fragment,Ct),Im=h(Ct),y(Rt.$$.fragment,Ct),Ct.forEach(t),L.forEach(t),ud=h(r),Xe=a(r,"H2",{class:!0});var Bd=d(Xe);kt=a(Bd,"A",{id:!0,class:!0,href:!0});var jv=d(kt);Qs=a(jv,"SPAN",{});var Jv=d(Qs);y(Zo.$$.fragment,Jv),Jv.forEach(t),jv.forEach(t),Cm=h(Bd),Ds=a(Bd,"SPAN",{});var Gv=d(Ds);Nm=n(Gv,"TFRagSequenceForGeneration"),Gv.forEach(t),Bd.forEach(t),gd=h(r),x=a(r,"DIV",{class:!0});var I=d(x);y(Io.$$.fragment,I),Am=h(I),Ve=a(I,"P",{});var kr=d(Ve);Wm=n(kr,"The "),On=a(kr,"A",{href:!0});var zv=d(On);Xm=n(zv,"TFRagSequenceForGeneration"),zv.forEach(t),Vm=n(kr," forward method, overrides the "),Os=a(kr,"CODE",{});var Uv=d(Os);Sm=n(Uv,"__call__"),Uv.forEach(t),Bm=n(kr," special method."),kr.forEach(t),Pm=h(I),y(qt.$$.fragment,I),Hm=h(I),Ks=a(I,"P",{});var Ev=d(Ks);Lm=n(Ev,"A TF RAG-sequence model implementation. It performs RAG-sequence specific marginalization in the forward pass."),Ev.forEach(t),Ym=h(I),ea=a(I,"P",{});var $v=d(ea);Qm=n($v,`RAG is a sequence-to-sequence model which encapsulates two core components: a question encoder and a generator.
During a forward pass, we encode the input with the question encoder and pass it to the retriever to extract
relevant context documents. The documents are then prepended to the input. Such contextualized inputs is passed to
the generator.`),$v.forEach(t),Dm=h(I),re=a(I,"P",{});var ye=d(re);Om=n(ye,"The question encoder can be any "),ta=a(ye,"EM",{});var Zv=d(ta);Km=n(Zv,"autoencoding"),Zv.forEach(t),eu=n(ye," model, preferably "),Kn=a(ye,"A",{href:!0});var Iv=d(Kn);tu=n(Iv,"TFDPRQuestionEncoder"),Iv.forEach(t),ou=n(ye,`, and the generator can be
any `),oa=a(ye,"EM",{});var Cv=d(oa);nu=n(Cv,"seq2seq"),Cv.forEach(t),ru=n(ye," model, preferably "),er=a(ye,"A",{href:!0});var Nv=d(er);su=n(Nv,"TFBartForConditionalGeneration"),Nv.forEach(t),au=n(ye,"."),ye.forEach(t),du=h(I),W=a(I,"P",{});var Q=d(W);iu=n(Q,"The model can be initialized with a "),tr=a(Q,"A",{href:!0});var Av=d(tr);cu=n(Av,"RagRetriever"),Av.forEach(t),lu=n(Q,` for end-to-end generation or used in combination with the
outputs of a retriever in multiple steps---see examples for more details. The model is compatible any
`),na=a(Q,"EM",{});var Wv=d(na);pu=n(Wv,"autoencoding"),Wv.forEach(t),hu=n(Q," model as the "),ra=a(Q,"CODE",{});var Xv=d(ra);mu=n(Xv,"question_encoder"),Xv.forEach(t),uu=n(Q," and any "),sa=a(Q,"EM",{});var Vv=d(sa);gu=n(Vv,"seq2seq"),Vv.forEach(t),fu=n(Q," model with language model head as the "),aa=a(Q,"CODE",{});var Sv=d(aa);_u=n(Sv,"generator"),Sv.forEach(t),vu=n(Q,`.
It has been tested with `),or=a(Q,"A",{href:!0});var Bv=d(or);Tu=n(Bv,"TFDPRQuestionEncoder"),Bv.forEach(t),bu=n(Q," as the "),da=a(Q,"CODE",{});var Pv=d(da);yu=n(Pv,"question_encoder"),Pv.forEach(t),wu=n(Q," and "),nr=a(Q,"A",{href:!0});var Hv=d(nr);Mu=n(Hv,"TFBartForConditionalGeneration"),Hv.forEach(t),Ru=n(Q,`
as the `),ia=a(Q,"CODE",{});var Lv=d(ia);ku=n(Lv,"generator"),Lv.forEach(t),qu=n(Q,"."),Q.forEach(t),Fu=h(I),Co=a(I,"P",{});var Pd=d(Co);xu=n(Pd,"This model inherits from "),rr=a(Pd,"A",{href:!0});var Yv=d(rr);ju=n(Yv,"TFPreTrainedModel"),Yv.forEach(t),Ju=n(Pd,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),Pd.forEach(t),Gu=h(I),No=a(I,"P",{});var Hd=d(No);zu=n(Hd,"This model is also a Tensorflow "),Ao=a(Hd,"A",{href:!0,rel:!0});var Qv=d(Ao);Uu=n(Qv,"tf.keras.Model"),Qv.forEach(t),Eu=n(Hd,`
subclass. Use it as a regular TF 2.0 Keras Model and refer to the TF 2.0 documentation for all matter related to
general usage and behavior.`),Hd.forEach(t),$u=h(I),ca=a(I,"P",{});var Dv=d(ca);Zu=n(Dv,`The model is in a developing state as it is now fully supports in eager-mode only, and may not be exported in
SavedModel format.`),Dv.forEach(t),Iu=h(I),pe=a(I,"DIV",{class:!0});var Nt=d(pe);y(Wo.$$.fragment,Nt),Cu=h(Nt),Se=a(Nt,"P",{});var qr=d(Se);Nu=n(qr,"The "),sr=a(qr,"A",{href:!0});var Ov=d(sr);Au=n(Ov,"TFRagSequenceForGeneration"),Ov.forEach(t),Wu=n(qr," forward method, overrides the "),la=a(qr,"CODE",{});var Kv=d(la);Xu=n(Kv,"__call__"),Kv.forEach(t),Vu=n(qr," special method."),qr.forEach(t),Su=h(Nt),y(Ft.$$.fragment,Nt),Bu=h(Nt),y(xt.$$.fragment,Nt),Nt.forEach(t),Pu=h(I),jt=a(I,"DIV",{class:!0});var Ld=d(jt);y(Xo.$$.fragment,Ld),Hu=h(Ld),Vo=a(Ld,"P",{});var Yd=d(Vo);Lu=n(Yd,"Implements RAG sequence \u201Cthorough\u201D decoding. Read the "),ar=a(Yd,"A",{href:!0});var eT=d(ar);Yu=n(eT,"generate()"),eT.forEach(t),Qu=n(Yd,"` documentation\nfor more information on how to set other generate input parameters"),Yd.forEach(t),Ld.forEach(t),I.forEach(t),fd=h(r),Be=a(r,"H2",{class:!0});var Qd=d(Be);Jt=a(Qd,"A",{id:!0,class:!0,href:!0});var tT=d(Jt);pa=a(tT,"SPAN",{});var oT=d(pa);y(So.$$.fragment,oT),oT.forEach(t),tT.forEach(t),Du=h(Qd),ha=a(Qd,"SPAN",{});var nT=d(ha);Ou=n(nT,"TFRagTokenForGeneration"),nT.forEach(t),Qd.forEach(t),_d=h(r),j=a(r,"DIV",{class:!0});var C=d(j);y(Bo.$$.fragment,C),Ku=h(C),Pe=a(C,"P",{});var Fr=d(Pe);eg=n(Fr,"The "),dr=a(Fr,"A",{href:!0});var rT=d(dr);tg=n(rT,"TFRagTokenForGeneration"),rT.forEach(t),og=n(Fr," forward method, overrides the "),ma=a(Fr,"CODE",{});var sT=d(ma);ng=n(sT,"__call__"),sT.forEach(t),rg=n(Fr," special method."),Fr.forEach(t),sg=h(C),y(Gt.$$.fragment,C),ag=h(C),ua=a(C,"P",{});var aT=d(ua);dg=n(aT,"A TF RAG-token model implementation. It performs RAG-token specific marginalization in the forward pass."),aT.forEach(t),ig=h(C),ga=a(C,"P",{});var dT=d(ga);cg=n(dT,`RAG is a sequence-to-sequence model which encapsulates two core components: a question encoder and a generator.
During a forward pass, we encode the input with the question encoder and pass it to the retriever to extract
relevant context documents. The documents are then prepended to the input. Such contextualized inputs is passed to
the generator.`),dT.forEach(t),lg=h(C),se=a(C,"P",{});var we=d(se);pg=n(we,"The question encoder can be any "),fa=a(we,"EM",{});var iT=d(fa);hg=n(iT,"autoencoding"),iT.forEach(t),mg=n(we," model, preferably "),ir=a(we,"A",{href:!0});var cT=d(ir);ug=n(cT,"TFDPRQuestionEncoder"),cT.forEach(t),gg=n(we,`, and the generator can be
any `),_a=a(we,"EM",{});var lT=d(_a);fg=n(lT,"seq2seq"),lT.forEach(t),_g=n(we," model, preferably "),cr=a(we,"A",{href:!0});var pT=d(cr);vg=n(pT,"TFBartForConditionalGeneration"),pT.forEach(t),Tg=n(we,"."),we.forEach(t),bg=h(C),X=a(C,"P",{});var D=d(X);yg=n(D,"The model can be initialized with a "),lr=a(D,"A",{href:!0});var hT=d(lr);wg=n(hT,"RagRetriever"),hT.forEach(t),Mg=n(D,` for end-to-end generation or used in combination with the
outputs of a retriever in multiple steps---see examples for more details. The model is compatible any
`),va=a(D,"EM",{});var mT=d(va);Rg=n(mT,"autoencoding"),mT.forEach(t),kg=n(D," model as the "),Ta=a(D,"CODE",{});var uT=d(Ta);qg=n(uT,"question_encoder"),uT.forEach(t),Fg=n(D," and any "),ba=a(D,"EM",{});var gT=d(ba);xg=n(gT,"seq2seq"),gT.forEach(t),jg=n(D," model with language model head as the "),ya=a(D,"CODE",{});var fT=d(ya);Jg=n(fT,"generator"),fT.forEach(t),Gg=n(D,`.
It has been tested with `),pr=a(D,"A",{href:!0});var _T=d(pr);zg=n(_T,"TFDPRQuestionEncoder"),_T.forEach(t),Ug=n(D," as the "),wa=a(D,"CODE",{});var vT=d(wa);Eg=n(vT,"question_encoder"),vT.forEach(t),$g=n(D," and "),hr=a(D,"A",{href:!0});var TT=d(hr);Zg=n(TT,"TFBartForConditionalGeneration"),TT.forEach(t),Ig=n(D,`
as the `),Ma=a(D,"CODE",{});var bT=d(Ma);Cg=n(bT,"generator"),bT.forEach(t),Ng=n(D,"."),D.forEach(t),Ag=h(C),Po=a(C,"P",{});var Dd=d(Po);Wg=n(Dd,"This model inherits from "),mr=a(Dd,"A",{href:!0});var yT=d(mr);Xg=n(yT,"TFPreTrainedModel"),yT.forEach(t),Vg=n(Dd,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),Dd.forEach(t),Sg=h(C),Ho=a(C,"P",{});var Od=d(Ho);Bg=n(Od,"This model is also a Tensorflow "),Lo=a(Od,"A",{href:!0,rel:!0});var wT=d(Lo);Pg=n(wT,"tf.keras.Model"),wT.forEach(t),Hg=n(Od,`
subclass. Use it as a regular TF 2.0 Keras Model and refer to the TF 2.0 documentation for all matter related to
general usage and behavior.`),Od.forEach(t),Lg=h(C),Ra=a(C,"P",{});var MT=d(Ra);Yg=n(MT,`The model is in a developing state as it is now fully supports in eager-mode only, and may not be exported in
SavedModel format.`),MT.forEach(t),Qg=h(C),he=a(C,"DIV",{class:!0});var At=d(he);y(Yo.$$.fragment,At),Dg=h(At),He=a(At,"P",{});var xr=d(He);Og=n(xr,"The "),ur=a(xr,"A",{href:!0});var RT=d(ur);Kg=n(RT,"TFRagTokenForGeneration"),RT.forEach(t),ef=n(xr," forward method, overrides the "),ka=a(xr,"CODE",{});var kT=d(ka);tf=n(kT,"__call__"),kT.forEach(t),of=n(xr," special method."),xr.forEach(t),nf=h(At),y(zt.$$.fragment,At),rf=h(At),y(Ut.$$.fragment,At),At.forEach(t),sf=h(C),Et=a(C,"DIV",{class:!0});var Kd=d(Et);y(Qo.$$.fragment,Kd),af=h(Kd),qa=a(Kd,"P",{});var qT=d(qa);df=n(qT,"Implements TFRAG token decoding."),qT.forEach(t),Kd.forEach(t),C.forEach(t),this.h()},h(){l(c,"name","hf:doc:metadata"),l(c,"content",JSON.stringify(KT)),l(g,"id","rag"),l(g,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(g,"href","#rag"),l(u,"class","relative group"),l(sn,"alt","Models"),GT(sn.src,cf="https://img.shields.io/badge/All_model_pages-rag-blueviolet")||l(sn,"src",cf),l(rn,"href","https://huggingface.co/models?filter=rag"),l(Wt,"class","flex flex-wrap space-x-1"),l(Ye,"id","overview"),l(Ye,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(Ye,"href","#overview"),l(Me,"class","relative group"),l(Vt,"href","https://arxiv.org/abs/2005.11401"),l(Vt,"rel","nofollow"),l(St,"href","https://huggingface.co/ola13"),l(St,"rel","nofollow"),l(Oe,"id","transformers.RagConfig"),l(Oe,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(Oe,"href","#transformers.RagConfig"),l(Re,"class","relative group"),l(hn,"href","/docs/transformers/v4.33.0/en/model_doc/rag#transformers.RagConfig"),l(mn,"href","/docs/transformers/v4.33.0/en/main_classes/configuration#transformers.PretrainedConfig"),l(un,"href","/docs/transformers/v4.33.0/en/main_classes/configuration#transformers.PretrainedConfig"),l(gn,"href","/docs/transformers/v4.33.0/en/model_doc/encoder-decoder#transformers.EncoderDecoderConfig"),l(Ke,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(fe,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(et,"id","transformers.RagTokenizer"),l(et,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(et,"href","#transformers.RagTokenizer"),l(ke,"class","relative group"),l(Qt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(tt,"id","transformers.models.rag.modeling_rag.RetrievAugLMMarginOutput"),l(tt,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(tt,"href","#transformers.models.rag.modeling_rag.RetrievAugLMMarginOutput"),l(qe,"class","relative group"),l(Fe,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(eo,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(ot,"id","transformers.RagRetriever"),l(ot,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(ot,"href","#transformers.RagRetriever"),l(xe,"class","relative group"),l(rt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(st,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(at,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(K,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(dt,"id","transformers.RagModel"),l(dt,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(dt,"href","#transformers.RagModel"),l(Je,"class","relative group"),l(fn,"href","/docs/transformers/v4.33.0/en/model_doc/rag#transformers.RagModel"),l(_n,"href","/docs/transformers/v4.33.0/en/model_doc/dpr#transformers.DPRQuestionEncoder"),l(vn,"href","/docs/transformers/v4.33.0/en/model_doc/bart#transformers.BartForConditionalGeneration"),l(Tn,"href","/docs/transformers/v4.33.0/en/model_doc/rag#transformers.RagRetriever"),l(bn,"href","/docs/transformers/v4.33.0/en/model_doc/dpr#transformers.DPRQuestionEncoder"),l(yn,"href","/docs/transformers/v4.33.0/en/model_doc/bart#transformers.BartForConditionalGeneration"),l(wn,"href","/docs/transformers/v4.33.0/en/model_doc/t5#transformers.T5ForConditionalGeneration"),l(Mn,"href","/docs/transformers/v4.33.0/en/main_classes/model#transformers.PreTrainedModel"),l(mo,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),l(mo,"rel","nofollow"),l(Rn,"href","/docs/transformers/v4.33.0/en/model_doc/rag#transformers.RagModel"),l(de,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(N,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(pt,"id","transformers.RagSequenceForGeneration"),l(pt,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(pt,"href","#transformers.RagSequenceForGeneration"),l(Ue,"class","relative group"),l(kn,"href","/docs/transformers/v4.33.0/en/model_doc/rag#transformers.RagSequenceForGeneration"),l(qn,"href","/docs/transformers/v4.33.0/en/model_doc/dpr#transformers.DPRQuestionEncoder"),l(Fn,"href","/docs/transformers/v4.33.0/en/model_doc/bart#transformers.BartForConditionalGeneration"),l(xn,"href","/docs/transformers/v4.33.0/en/model_doc/rag#transformers.RagRetriever"),l(jn,"href","/docs/transformers/v4.33.0/en/model_doc/dpr#transformers.DPRQuestionEncoder"),l(Jn,"href","/docs/transformers/v4.33.0/en/model_doc/bart#transformers.BartForConditionalGeneration"),l(Gn,"href","/docs/transformers/v4.33.0/en/model_doc/t5#transformers.T5ForConditionalGeneration"),l(zn,"href","/docs/transformers/v4.33.0/en/main_classes/model#transformers.PreTrainedModel"),l(To,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),l(To,"rel","nofollow"),l(Un,"href","/docs/transformers/v4.33.0/en/model_doc/rag#transformers.RagSequenceForGeneration"),l(ie,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(En,"href","/docs/transformers/v4.33.0/en/main_classes/text_generation#transformers.GenerationMixin.generate"),l(gt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(J,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(ft,"id","transformers.RagTokenForGeneration"),l(ft,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(ft,"href","#transformers.RagTokenForGeneration"),l(Ze,"class","relative group"),l($n,"href","/docs/transformers/v4.33.0/en/model_doc/rag#transformers.RagTokenForGeneration"),l(Zn,"href","/docs/transformers/v4.33.0/en/model_doc/dpr#transformers.DPRQuestionEncoder"),l(In,"href","/docs/transformers/v4.33.0/en/model_doc/bart#transformers.BartForConditionalGeneration"),l(Cn,"href","/docs/transformers/v4.33.0/en/model_doc/rag#transformers.RagRetriever"),l(Nn,"href","/docs/transformers/v4.33.0/en/model_doc/dpr#transformers.DPRQuestionEncoder"),l(An,"href","/docs/transformers/v4.33.0/en/model_doc/bart#transformers.BartForConditionalGeneration"),l(Wn,"href","/docs/transformers/v4.33.0/en/model_doc/t5#transformers.T5ForConditionalGeneration"),l(Xn,"href","/docs/transformers/v4.33.0/en/main_classes/model#transformers.PreTrainedModel"),l(Fo,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),l(Fo,"rel","nofollow"),l(Vn,"href","/docs/transformers/v4.33.0/en/model_doc/rag#transformers.RagTokenForGeneration"),l(ce,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(bt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(G,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(yt,"id","transformers.TFRagModel"),l(yt,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(yt,"href","#transformers.TFRagModel"),l(Ne,"class","relative group"),l(Sn,"href","/docs/transformers/v4.33.0/en/model_doc/rag#transformers.TFRagModel"),l(Bn,"href","/docs/transformers/v4.33.0/en/model_doc/dpr#transformers.TFDPRQuestionEncoder"),l(Pn,"href","/docs/transformers/v4.33.0/en/model_doc/bart#transformers.TFBartForConditionalGeneration"),l(Hn,"href","/docs/transformers/v4.33.0/en/model_doc/rag#transformers.RagRetriever"),l(Ln,"href","/docs/transformers/v4.33.0/en/model_doc/dpr#transformers.TFDPRQuestionEncoder"),l(Yn,"href","/docs/transformers/v4.33.0/en/model_doc/bart#transformers.TFBartForConditionalGeneration"),l(Qn,"href","/docs/transformers/v4.33.0/en/main_classes/model#transformers.TFPreTrainedModel"),l(Eo,"href","https://www.tensorflow.org/api_docs/python/tf/keras/Model"),l(Eo,"rel","nofollow"),l(Dn,"href","/docs/transformers/v4.33.0/en/model_doc/rag#transformers.TFRagModel"),l(le,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l($,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(kt,"id","transformers.TFRagSequenceForGeneration"),l(kt,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(kt,"href","#transformers.TFRagSequenceForGeneration"),l(Xe,"class","relative group"),l(On,"href","/docs/transformers/v4.33.0/en/model_doc/rag#transformers.TFRagSequenceForGeneration"),l(Kn,"href","/docs/transformers/v4.33.0/en/model_doc/dpr#transformers.TFDPRQuestionEncoder"),l(er,"href","/docs/transformers/v4.33.0/en/model_doc/bart#transformers.TFBartForConditionalGeneration"),l(tr,"href","/docs/transformers/v4.33.0/en/model_doc/rag#transformers.RagRetriever"),l(or,"href","/docs/transformers/v4.33.0/en/model_doc/dpr#transformers.TFDPRQuestionEncoder"),l(nr,"href","/docs/transformers/v4.33.0/en/model_doc/bart#transformers.TFBartForConditionalGeneration"),l(rr,"href","/docs/transformers/v4.33.0/en/main_classes/model#transformers.TFPreTrainedModel"),l(Ao,"href","https://www.tensorflow.org/api_docs/python/tf/keras/Model"),l(Ao,"rel","nofollow"),l(sr,"href","/docs/transformers/v4.33.0/en/model_doc/rag#transformers.TFRagSequenceForGeneration"),l(pe,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(ar,"href","/docs/transformers/v4.33.0/en/main_classes/text_generation#transformers.GenerationMixin.generate"),l(jt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(x,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(Jt,"id","transformers.TFRagTokenForGeneration"),l(Jt,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(Jt,"href","#transformers.TFRagTokenForGeneration"),l(Be,"class","relative group"),l(dr,"href","/docs/transformers/v4.33.0/en/model_doc/rag#transformers.TFRagTokenForGeneration"),l(ir,"href","/docs/transformers/v4.33.0/en/model_doc/dpr#transformers.TFDPRQuestionEncoder"),l(cr,"href","/docs/transformers/v4.33.0/en/model_doc/bart#transformers.TFBartForConditionalGeneration"),l(lr,"href","/docs/transformers/v4.33.0/en/model_doc/rag#transformers.RagRetriever"),l(pr,"href","/docs/transformers/v4.33.0/en/model_doc/dpr#transformers.TFDPRQuestionEncoder"),l(hr,"href","/docs/transformers/v4.33.0/en/model_doc/bart#transformers.TFBartForConditionalGeneration"),l(mr,"href","/docs/transformers/v4.33.0/en/main_classes/model#transformers.TFPreTrainedModel"),l(Lo,"href","https://www.tensorflow.org/api_docs/python/tf/keras/Model"),l(Lo,"rel","nofollow"),l(ur,"href","/docs/transformers/v4.33.0/en/model_doc/rag#transformers.TFRagTokenForGeneration"),l(he,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(Et,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(j,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(r,f){e(document.head,c),v(r,T,f),v(r,u,f),e(u,g),e(g,_),w(i,_,null),e(u,m),e(u,q),e(q,ei),v(r,Xa,f),v(r,Wt,f),e(Wt,rn),e(rn,sn),v(r,Va,f),v(r,Me,f),e(Me,Ye),e(Ye,jr),w(Xt,jr,null),e(Me,ti),e(Me,Jr),e(Jr,oi),v(r,Sa,f),v(r,an,f),e(an,ni),v(r,Ba,f),v(r,Qe,f),e(Qe,ri),e(Qe,Vt),e(Vt,si),e(Qe,ai),v(r,Pa,f),v(r,dn,f),e(dn,di),v(r,Ha,f),v(r,cn,f),e(cn,Gr),e(Gr,ii),v(r,La,f),v(r,De,f),e(De,ci),e(De,St),e(St,li),e(De,pi),v(r,Ya,f),v(r,ln,f),e(ln,hi),v(r,Qa,f),v(r,pn,f),e(pn,zr),e(zr,mi),v(r,Da,f),v(r,Re,f),e(Re,Oe),e(Oe,Ur),w(Bt,Ur,null),e(Re,ui),e(Re,Er),e(Er,gi),v(r,Oa,f),v(r,fe,f),w(Pt,fe,null),e(fe,fi),e(fe,ae),e(ae,hn),e(hn,_i),e(ae,vi),e(ae,$r),e($r,Ti),e(ae,bi),e(ae,mn),e(mn,yi),e(ae,wi),e(ae,un),e(un,Mi),e(ae,Ri),e(fe,ki),e(fe,Ke),w(Ht,Ke,null),e(Ke,qi),e(Ke,Lt),e(Lt,Fi),e(Lt,gn),e(gn,xi),e(Lt,ji),v(r,Ka,f),v(r,ke,f),e(ke,et),e(et,Zr),w(Yt,Zr,null),e(ke,Ji),e(ke,Ir),e(Ir,Gi),v(r,ed,f),v(r,Qt,f),w(Dt,Qt,null),v(r,td,f),v(r,qe,f),e(qe,tt),e(tt,Cr),w(Ot,Cr,null),e(qe,zi),e(qe,Nr),e(Nr,Ui),v(r,od,f),v(r,Fe,f),w(Kt,Fe,null),e(Fe,Ei),e(Fe,Ar),e(Ar,$i),v(r,nd,f),v(r,eo,f),w(to,eo,null),v(r,rd,f),v(r,xe,f),e(xe,ot),e(ot,Wr),w(oo,Wr,null),e(xe,Zi),e(xe,Xr),e(Xr,Ii),v(r,sd,f),v(r,K,f),w(no,K,null),e(K,Ci),e(K,Vr),e(Vr,Ni),e(K,Ai),w(nt,K,null),e(K,Wi),e(K,rt),w(ro,rt,null),e(rt,Xi),e(rt,Sr),e(Sr,Vi),e(K,Si),e(K,st),w(so,st,null),e(st,Bi),e(st,je),e(je,Pi),e(je,Br),e(Br,Hi),e(je,Li),e(je,Pr),e(Pr,Yi),e(je,Qi),e(K,Di),e(K,at),w(ao,at,null),e(at,Oi),e(at,io),e(io,Ki),e(io,Hr),e(Hr,ec),e(io,tc),v(r,ad,f),v(r,Je,f),e(Je,dt),e(dt,Lr),w(co,Lr,null),e(Je,oc),e(Je,Yr),e(Yr,nc),v(r,dd,f),v(r,N,f),w(lo,N,null),e(N,rc),e(N,Ge),e(Ge,sc),e(Ge,fn),e(fn,ac),e(Ge,dc),e(Ge,Qr),e(Qr,ic),e(Ge,cc),e(N,lc),w(it,N,null),e(N,pc),e(N,Dr),e(Dr,hc),e(N,mc),e(N,ee),e(ee,uc),e(ee,Or),e(Or,gc),e(ee,fc),e(ee,_n),e(_n,_c),e(ee,vc),e(ee,Kr),e(Kr,Tc),e(ee,bc),e(ee,vn),e(vn,yc),e(ee,wc),e(N,Mc),e(N,z),e(z,Rc),e(z,Tn),e(Tn,kc),e(z,qc),e(z,es),e(es,Fc),e(z,xc),e(z,ts),e(ts,jc),e(z,Jc),e(z,os),e(os,Gc),e(z,zc),e(z,ns),e(ns,Uc),e(z,Ec),e(z,bn),e(bn,$c),e(z,Zc),e(z,rs),e(rs,Ic),e(z,Cc),e(z,yn),e(yn,Nc),e(z,Ac),e(z,wn),e(wn,Wc),e(z,Xc),e(z,ss),e(ss,Vc),e(z,Sc),e(N,Bc),e(N,po),e(po,Pc),e(po,Mn),e(Mn,Hc),e(po,Lc),e(N,Yc),e(N,ho),e(ho,Qc),e(ho,mo),e(mo,Dc),e(ho,Oc),e(N,Kc),e(N,de),w(uo,de,null),e(de,el),e(de,ze),e(ze,tl),e(ze,Rn),e(Rn,ol),e(ze,nl),e(ze,as),e(as,rl),e(ze,sl),e(de,al),w(ct,de,null),e(de,dl),w(lt,de,null),v(r,id,f),v(r,Ue,f),e(Ue,pt),e(pt,ds),w(go,ds,null),e(Ue,il),e(Ue,is),e(is,cl),v(r,cd,f),v(r,J,f),w(fo,J,null),e(J,ll),e(J,Ee),e(Ee,pl),e(Ee,kn),e(kn,hl),e(Ee,ml),e(Ee,cs),e(cs,ul),e(Ee,gl),e(J,fl),w(ht,J,null),e(J,_l),e(J,ls),e(ls,vl),e(J,Tl),e(J,ps),e(ps,bl),e(J,yl),e(J,te),e(te,wl),e(te,hs),e(hs,Ml),e(te,Rl),e(te,qn),e(qn,kl),e(te,ql),e(te,ms),e(ms,Fl),e(te,xl),e(te,Fn),e(Fn,jl),e(te,Jl),e(J,Gl),e(J,U),e(U,zl),e(U,xn),e(xn,Ul),e(U,El),e(U,us),e(us,$l),e(U,Zl),e(U,gs),e(gs,Il),e(U,Cl),e(U,fs),e(fs,Nl),e(U,Al),e(U,_s),e(_s,Wl),e(U,Xl),e(U,jn),e(jn,Vl),e(U,Sl),e(U,vs),e(vs,Bl),e(U,Pl),e(U,Jn),e(Jn,Hl),e(U,Ll),e(U,Gn),e(Gn,Yl),e(U,Ql),e(U,Ts),e(Ts,Dl),e(U,Ol),e(J,Kl),e(J,_o),e(_o,ep),e(_o,zn),e(zn,tp),e(_o,op),e(J,np),e(J,vo),e(vo,rp),e(vo,To),e(To,sp),e(vo,ap),e(J,dp),e(J,ie),w(bo,ie,null),e(ie,ip),e(ie,$e),e($e,cp),e($e,Un),e(Un,lp),e($e,pp),e($e,bs),e(bs,hp),e($e,mp),e(ie,up),w(mt,ie,null),e(ie,gp),w(ut,ie,null),e(J,fp),e(J,gt),w(yo,gt,null),e(gt,_p),e(gt,wo),e(wo,vp),e(wo,En),e(En,Tp),e(wo,bp),v(r,ld,f),v(r,Ze,f),e(Ze,ft),e(ft,ys),w(Mo,ys,null),e(Ze,yp),e(Ze,ws),e(ws,wp),v(r,pd,f),v(r,G,f),w(Ro,G,null),e(G,Mp),e(G,Ie),e(Ie,Rp),e(Ie,$n),e($n,kp),e(Ie,qp),e(Ie,Ms),e(Ms,Fp),e(Ie,xp),e(G,jp),w(_t,G,null),e(G,Jp),e(G,Rs),e(Rs,Gp),e(G,zp),e(G,ks),e(ks,Up),e(G,Ep),e(G,oe),e(oe,$p),e(oe,qs),e(qs,Zp),e(oe,Ip),e(oe,Zn),e(Zn,Cp),e(oe,Np),e(oe,Fs),e(Fs,Ap),e(oe,Wp),e(oe,In),e(In,Xp),e(oe,Vp),e(G,Sp),e(G,E),e(E,Bp),e(E,Cn),e(Cn,Pp),e(E,Hp),e(E,xs),e(xs,Lp),e(E,Yp),e(E,js),e(js,Qp),e(E,Dp),e(E,Js),e(Js,Op),e(E,Kp),e(E,Gs),e(Gs,eh),e(E,th),e(E,Nn),e(Nn,oh),e(E,nh),e(E,zs),e(zs,rh),e(E,sh),e(E,An),e(An,ah),e(E,dh),e(E,Wn),e(Wn,ih),e(E,ch),e(E,Us),e(Us,lh),e(E,ph),e(G,hh),e(G,ko),e(ko,mh),e(ko,Xn),e(Xn,uh),e(ko,gh),e(G,fh),e(G,qo),e(qo,_h),e(qo,Fo),e(Fo,vh),e(qo,Th),e(G,bh),e(G,ce),w(xo,ce,null),e(ce,yh),e(ce,Ce),e(Ce,wh),e(Ce,Vn),e(Vn,Mh),e(Ce,Rh),e(Ce,Es),e(Es,kh),e(Ce,qh),e(ce,Fh),w(vt,ce,null),e(ce,xh),w(Tt,ce,null),e(G,jh),e(G,bt),w(jo,bt,null),e(bt,Jh),e(bt,$s),e($s,Gh),v(r,hd,f),v(r,Ne,f),e(Ne,yt),e(yt,Zs),w(Jo,Zs,null),e(Ne,zh),e(Ne,Is),e(Is,Uh),v(r,md,f),v(r,$,f),w(Go,$,null),e($,Eh),e($,Ae),e(Ae,$h),e(Ae,Sn),e(Sn,Zh),e(Ae,Ih),e(Ae,Cs),e(Cs,Ch),e(Ae,Nh),e($,Ah),w(wt,$,null),e($,Wh),e($,Ns),e(Ns,Xh),e($,Vh),e($,ne),e(ne,Sh),e(ne,As),e(As,Bh),e(ne,Ph),e(ne,Bn),e(Bn,Hh),e(ne,Lh),e(ne,Ws),e(Ws,Yh),e(ne,Qh),e(ne,Pn),e(Pn,Dh),e(ne,Oh),e($,Kh),e($,A),e(A,em),e(A,Hn),e(Hn,tm),e(A,om),e(A,Xs),e(Xs,nm),e(A,rm),e(A,Vs),e(Vs,sm),e(A,am),e(A,Ss),e(Ss,dm),e(A,im),e(A,Bs),e(Bs,cm),e(A,lm),e(A,Ln),e(Ln,pm),e(A,hm),e(A,Ps),e(Ps,mm),e(A,um),e(A,Yn),e(Yn,gm),e(A,fm),e(A,Hs),e(Hs,_m),e(A,vm),e($,Tm),e($,zo),e(zo,bm),e(zo,Qn),e(Qn,ym),e(zo,wm),e($,Mm),e($,Uo),e(Uo,Rm),e(Uo,Eo),e(Eo,km),e(Uo,qm),e($,Fm),e($,Ls),e(Ls,xm),e($,jm),e($,le),w($o,le,null),e(le,Jm),e(le,We),e(We,Gm),e(We,Dn),e(Dn,zm),e(We,Um),e(We,Ys),e(Ys,Em),e(We,$m),e(le,Zm),w(Mt,le,null),e(le,Im),w(Rt,le,null),v(r,ud,f),v(r,Xe,f),e(Xe,kt),e(kt,Qs),w(Zo,Qs,null),e(Xe,Cm),e(Xe,Ds),e(Ds,Nm),v(r,gd,f),v(r,x,f),w(Io,x,null),e(x,Am),e(x,Ve),e(Ve,Wm),e(Ve,On),e(On,Xm),e(Ve,Vm),e(Ve,Os),e(Os,Sm),e(Ve,Bm),e(x,Pm),w(qt,x,null),e(x,Hm),e(x,Ks),e(Ks,Lm),e(x,Ym),e(x,ea),e(ea,Qm),e(x,Dm),e(x,re),e(re,Om),e(re,ta),e(ta,Km),e(re,eu),e(re,Kn),e(Kn,tu),e(re,ou),e(re,oa),e(oa,nu),e(re,ru),e(re,er),e(er,su),e(re,au),e(x,du),e(x,W),e(W,iu),e(W,tr),e(tr,cu),e(W,lu),e(W,na),e(na,pu),e(W,hu),e(W,ra),e(ra,mu),e(W,uu),e(W,sa),e(sa,gu),e(W,fu),e(W,aa),e(aa,_u),e(W,vu),e(W,or),e(or,Tu),e(W,bu),e(W,da),e(da,yu),e(W,wu),e(W,nr),e(nr,Mu),e(W,Ru),e(W,ia),e(ia,ku),e(W,qu),e(x,Fu),e(x,Co),e(Co,xu),e(Co,rr),e(rr,ju),e(Co,Ju),e(x,Gu),e(x,No),e(No,zu),e(No,Ao),e(Ao,Uu),e(No,Eu),e(x,$u),e(x,ca),e(ca,Zu),e(x,Iu),e(x,pe),w(Wo,pe,null),e(pe,Cu),e(pe,Se),e(Se,Nu),e(Se,sr),e(sr,Au),e(Se,Wu),e(Se,la),e(la,Xu),e(Se,Vu),e(pe,Su),w(Ft,pe,null),e(pe,Bu),w(xt,pe,null),e(x,Pu),e(x,jt),w(Xo,jt,null),e(jt,Hu),e(jt,Vo),e(Vo,Lu),e(Vo,ar),e(ar,Yu),e(Vo,Qu),v(r,fd,f),v(r,Be,f),e(Be,Jt),e(Jt,pa),w(So,pa,null),e(Be,Du),e(Be,ha),e(ha,Ou),v(r,_d,f),v(r,j,f),w(Bo,j,null),e(j,Ku),e(j,Pe),e(Pe,eg),e(Pe,dr),e(dr,tg),e(Pe,og),e(Pe,ma),e(ma,ng),e(Pe,rg),e(j,sg),w(Gt,j,null),e(j,ag),e(j,ua),e(ua,dg),e(j,ig),e(j,ga),e(ga,cg),e(j,lg),e(j,se),e(se,pg),e(se,fa),e(fa,hg),e(se,mg),e(se,ir),e(ir,ug),e(se,gg),e(se,_a),e(_a,fg),e(se,_g),e(se,cr),e(cr,vg),e(se,Tg),e(j,bg),e(j,X),e(X,yg),e(X,lr),e(lr,wg),e(X,Mg),e(X,va),e(va,Rg),e(X,kg),e(X,Ta),e(Ta,qg),e(X,Fg),e(X,ba),e(ba,xg),e(X,jg),e(X,ya),e(ya,Jg),e(X,Gg),e(X,pr),e(pr,zg),e(X,Ug),e(X,wa),e(wa,Eg),e(X,$g),e(X,hr),e(hr,Zg),e(X,Ig),e(X,Ma),e(Ma,Cg),e(X,Ng),e(j,Ag),e(j,Po),e(Po,Wg),e(Po,mr),e(mr,Xg),e(Po,Vg),e(j,Sg),e(j,Ho),e(Ho,Bg),e(Ho,Lo),e(Lo,Pg),e(Ho,Hg),e(j,Lg),e(j,Ra),e(Ra,Yg),e(j,Qg),e(j,he),w(Yo,he,null),e(he,Dg),e(he,He),e(He,Og),e(He,ur),e(ur,Kg),e(He,ef),e(He,ka),e(ka,tf),e(He,of),e(he,nf),w(zt,he,null),e(he,rf),w(Ut,he,null),e(j,sf),e(j,Et),w(Qo,Et,null),e(Et,af),e(Et,qa),e(qa,df),vd=!0},p(r,[f]){const Do={};f&2&&(Do.$$scope={dirty:f,ctx:r}),nt.$set(Do);const Fa={};f&2&&(Fa.$$scope={dirty:f,ctx:r}),it.$set(Fa);const xa={};f&2&&(xa.$$scope={dirty:f,ctx:r}),ct.$set(xa);const ja={};f&2&&(ja.$$scope={dirty:f,ctx:r}),lt.$set(ja);const Ja={};f&2&&(Ja.$$scope={dirty:f,ctx:r}),ht.$set(Ja);const Ga={};f&2&&(Ga.$$scope={dirty:f,ctx:r}),mt.$set(Ga);const Oo={};f&2&&(Oo.$$scope={dirty:f,ctx:r}),ut.$set(Oo);const za={};f&2&&(za.$$scope={dirty:f,ctx:r}),_t.$set(za);const Ua={};f&2&&(Ua.$$scope={dirty:f,ctx:r}),vt.$set(Ua);const Ea={};f&2&&(Ea.$$scope={dirty:f,ctx:r}),Tt.$set(Ea);const $a={};f&2&&($a.$$scope={dirty:f,ctx:r}),wt.$set($a);const Ko={};f&2&&(Ko.$$scope={dirty:f,ctx:r}),Mt.$set(Ko);const Za={};f&2&&(Za.$$scope={dirty:f,ctx:r}),Rt.$set(Za);const Ia={};f&2&&(Ia.$$scope={dirty:f,ctx:r}),qt.$set(Ia);const Ca={};f&2&&(Ca.$$scope={dirty:f,ctx:r}),Ft.$set(Ca);const Na={};f&2&&(Na.$$scope={dirty:f,ctx:r}),xt.$set(Na);const en={};f&2&&(en.$$scope={dirty:f,ctx:r}),Gt.$set(en);const Aa={};f&2&&(Aa.$$scope={dirty:f,ctx:r}),zt.$set(Aa);const Wa={};f&2&&(Wa.$$scope={dirty:f,ctx:r}),Ut.$set(Wa)},i(r){vd||(M(i.$$.fragment,r),M(Xt.$$.fragment,r),M(Bt.$$.fragment,r),M(Pt.$$.fragment,r),M(Ht.$$.fragment,r),M(Yt.$$.fragment,r),M(Dt.$$.fragment,r),M(Ot.$$.fragment,r),M(Kt.$$.fragment,r),M(to.$$.fragment,r),M(oo.$$.fragment,r),M(no.$$.fragment,r),M(nt.$$.fragment,r),M(ro.$$.fragment,r),M(so.$$.fragment,r),M(ao.$$.fragment,r),M(co.$$.fragment,r),M(lo.$$.fragment,r),M(it.$$.fragment,r),M(uo.$$.fragment,r),M(ct.$$.fragment,r),M(lt.$$.fragment,r),M(go.$$.fragment,r),M(fo.$$.fragment,r),M(ht.$$.fragment,r),M(bo.$$.fragment,r),M(mt.$$.fragment,r),M(ut.$$.fragment,r),M(yo.$$.fragment,r),M(Mo.$$.fragment,r),M(Ro.$$.fragment,r),M(_t.$$.fragment,r),M(xo.$$.fragment,r),M(vt.$$.fragment,r),M(Tt.$$.fragment,r),M(jo.$$.fragment,r),M(Jo.$$.fragment,r),M(Go.$$.fragment,r),M(wt.$$.fragment,r),M($o.$$.fragment,r),M(Mt.$$.fragment,r),M(Rt.$$.fragment,r),M(Zo.$$.fragment,r),M(Io.$$.fragment,r),M(qt.$$.fragment,r),M(Wo.$$.fragment,r),M(Ft.$$.fragment,r),M(xt.$$.fragment,r),M(Xo.$$.fragment,r),M(So.$$.fragment,r),M(Bo.$$.fragment,r),M(Gt.$$.fragment,r),M(Yo.$$.fragment,r),M(zt.$$.fragment,r),M(Ut.$$.fragment,r),M(Qo.$$.fragment,r),vd=!0)},o(r){R(i.$$.fragment,r),R(Xt.$$.fragment,r),R(Bt.$$.fragment,r),R(Pt.$$.fragment,r),R(Ht.$$.fragment,r),R(Yt.$$.fragment,r),R(Dt.$$.fragment,r),R(Ot.$$.fragment,r),R(Kt.$$.fragment,r),R(to.$$.fragment,r),R(oo.$$.fragment,r),R(no.$$.fragment,r),R(nt.$$.fragment,r),R(ro.$$.fragment,r),R(so.$$.fragment,r),R(ao.$$.fragment,r),R(co.$$.fragment,r),R(lo.$$.fragment,r),R(it.$$.fragment,r),R(uo.$$.fragment,r),R(ct.$$.fragment,r),R(lt.$$.fragment,r),R(go.$$.fragment,r),R(fo.$$.fragment,r),R(ht.$$.fragment,r),R(bo.$$.fragment,r),R(mt.$$.fragment,r),R(ut.$$.fragment,r),R(yo.$$.fragment,r),R(Mo.$$.fragment,r),R(Ro.$$.fragment,r),R(_t.$$.fragment,r),R(xo.$$.fragment,r),R(vt.$$.fragment,r),R(Tt.$$.fragment,r),R(jo.$$.fragment,r),R(Jo.$$.fragment,r),R(Go.$$.fragment,r),R(wt.$$.fragment,r),R($o.$$.fragment,r),R(Mt.$$.fragment,r),R(Rt.$$.fragment,r),R(Zo.$$.fragment,r),R(Io.$$.fragment,r),R(qt.$$.fragment,r),R(Wo.$$.fragment,r),R(Ft.$$.fragment,r),R(xt.$$.fragment,r),R(Xo.$$.fragment,r),R(So.$$.fragment,r),R(Bo.$$.fragment,r),R(Gt.$$.fragment,r),R(Yo.$$.fragment,r),R(zt.$$.fragment,r),R(Ut.$$.fragment,r),R(Qo.$$.fragment,r),vd=!1},d(r){t(c),r&&t(T),r&&t(u),k(i),r&&t(Xa),r&&t(Wt),r&&t(Va),r&&t(Me),k(Xt),r&&t(Sa),r&&t(an),r&&t(Ba),r&&t(Qe),r&&t(Pa),r&&t(dn),r&&t(Ha),r&&t(cn),r&&t(La),r&&t(De),r&&t(Ya),r&&t(ln),r&&t(Qa),r&&t(pn),r&&t(Da),r&&t(Re),k(Bt),r&&t(Oa),r&&t(fe),k(Pt),k(Ht),r&&t(Ka),r&&t(ke),k(Yt),r&&t(ed),r&&t(Qt),k(Dt),r&&t(td),r&&t(qe),k(Ot),r&&t(od),r&&t(Fe),k(Kt),r&&t(nd),r&&t(eo),k(to),r&&t(rd),r&&t(xe),k(oo),r&&t(sd),r&&t(K),k(no),k(nt),k(ro),k(so),k(ao),r&&t(ad),r&&t(Je),k(co),r&&t(dd),r&&t(N),k(lo),k(it),k(uo),k(ct),k(lt),r&&t(id),r&&t(Ue),k(go),r&&t(cd),r&&t(J),k(fo),k(ht),k(bo),k(mt),k(ut),k(yo),r&&t(ld),r&&t(Ze),k(Mo),r&&t(pd),r&&t(G),k(Ro),k(_t),k(xo),k(vt),k(Tt),k(jo),r&&t(hd),r&&t(Ne),k(Jo),r&&t(md),r&&t($),k(Go),k(wt),k($o),k(Mt),k(Rt),r&&t(ud),r&&t(Xe),k(Zo),r&&t(gd),r&&t(x),k(Io),k(qt),k(Wo),k(Ft),k(xt),k(Xo),r&&t(fd),r&&t(Be),k(So),r&&t(_d),r&&t(j),k(Bo),k(Gt),k(Yo),k(zt),k(Ut),k(Qo)}}}const KT={local:"rag",sections:[{local:"overview",title:"Overview"},{local:"transformers.RagConfig",title:"RagConfig"},{local:"transformers.RagTokenizer",title:"RagTokenizer"},{local:"transformers.models.rag.modeling_rag.RetrievAugLMMarginOutput",title:"Rag specific outputs"},{local:"transformers.RagRetriever",title:"RagRetriever"},{local:"transformers.RagModel",title:"RagModel"},{local:"transformers.RagSequenceForGeneration",title:"RagSequenceForGeneration"},{local:"transformers.RagTokenForGeneration",title:"RagTokenForGeneration"},{local:"transformers.TFRagModel",title:"TFRagModel"},{local:"transformers.TFRagSequenceForGeneration",title:"TFRagSequenceForGeneration"},{local:"transformers.TFRagTokenForGeneration",title:"TFRagTokenForGeneration"}],title:"RAG"};function eb(F){return zT(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class db extends FT{constructor(c){super();xT(this,c,eb,OT,jT,{})}}export{db as default,KT as metadata};
