import{S as Nb,i as Ab,s as Wb,e as s,k as p,w as T,t as o,M as Xb,c as a,d as t,m as h,a as d,x as y,h as n,b as l,N as Vb,G as e,g as v,y as w,q as M,o as R,B as k,v as Bb,L as an}from"../../chunks/vendor-hf-doc-builder.js";import{T as ge}from"../../chunks/Tip-hf-doc-builder.js";import{D as z}from"../../chunks/Docstring-hf-doc-builder.js";import{C as dn}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as fe}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as sn}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";function Sb(F){let c,b,m,g,_;return g=new dn({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"),b=o("Examples:"),m=p(),T(g.$$.fragment)},l(i){c=a(i,"P",{});var u=d(c);b=n(u,"Examples:"),u.forEach(t),m=h(i),y(g.$$.fragment,i)},m(i,u){v(i,c,u),e(c,b),v(i,m,u),w(g,i,u),_=!0},p:an,i(i){_||(M(g.$$.fragment,i),_=!0)},o(i){R(g.$$.fragment,i),_=!1},d(i){i&&t(c),i&&t(m),k(g,i)}}}function Pb(F){let c,b,m,g,_;return{c(){c=s("p"),b=o("Although the recipe for forward pass needs to be defined within this function, one should call the "),m=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 u=d(c);b=n(u,"Although the recipe for forward pass needs to be defined within this function, one should call the "),m=a(u,"CODE",{});var q=d(m);g=n(q,"Module"),q.forEach(t),_=n(u,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),u.forEach(t)},m(i,u){v(i,c,u),e(c,b),e(c,m),e(m,g),e(c,_)},d(i){i&&t(c)}}}function Hb(F){let c,b,m,g,_;return{c(){c=s("p"),b=o("Although the recipe for forward pass needs to be defined within this function, one should call the "),m=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 u=d(c);b=n(u,"Although the recipe for forward pass needs to be defined within this function, one should call the "),m=a(u,"CODE",{});var q=d(m);g=n(q,"Module"),q.forEach(t),_=n(u,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),u.forEach(t)},m(i,u){v(i,c,u),e(c,b),e(c,m),e(m,g),e(c,_)},d(i){i&&t(c)}}}function Lb(F){let c,b,m,g,_;return g=new dn({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"),b=o("Example:"),m=p(),T(g.$$.fragment)},l(i){c=a(i,"P",{});var u=d(c);b=n(u,"Example:"),u.forEach(t),m=h(i),y(g.$$.fragment,i)},m(i,u){v(i,c,u),e(c,b),v(i,m,u),w(g,i,u),_=!0},p:an,i(i){_||(M(g.$$.fragment,i),_=!0)},o(i){R(g.$$.fragment,i),_=!1},d(i){i&&t(c),i&&t(m),k(g,i)}}}function Ob(F){let c,b,m,g,_;return{c(){c=s("p"),b=o("Although the recipe for forward pass needs to be defined within this function, one should call the "),m=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 u=d(c);b=n(u,"Although the recipe for forward pass needs to be defined within this function, one should call the "),m=a(u,"CODE",{});var q=d(m);g=n(q,"Module"),q.forEach(t),_=n(u,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),u.forEach(t)},m(i,u){v(i,c,u),e(c,b),e(c,m),e(m,g),e(c,_)},d(i){i&&t(c)}}}function Yb(F){let c,b,m,g,_;return{c(){c=s("p"),b=o("Although the recipe for forward pass needs to be defined within this function, one should call the "),m=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 u=d(c);b=n(u,"Although the recipe for forward pass needs to be defined within this function, one should call the "),m=a(u,"CODE",{});var q=d(m);g=n(q,"Module"),q.forEach(t),_=n(u,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),u.forEach(t)},m(i,u){v(i,c,u),e(c,b),e(c,m),e(m,g),e(c,_)},d(i){i&&t(c)}}}function Qb(F){let c,b,m,g,_;return g=new dn({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"),b=o("Example:"),m=p(),T(g.$$.fragment)},l(i){c=a(i,"P",{});var u=d(c);b=n(u,"Example:"),u.forEach(t),m=h(i),y(g.$$.fragment,i)},m(i,u){v(i,c,u),e(c,b),v(i,m,u),w(g,i,u),_=!0},p:an,i(i){_||(M(g.$$.fragment,i),_=!0)},o(i){R(g.$$.fragment,i),_=!1},d(i){i&&t(c),i&&t(m),k(g,i)}}}function Db(F){let c,b,m,g,_;return{c(){c=s("p"),b=o("Although the recipe for forward pass needs to be defined within this function, one should call the "),m=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 u=d(c);b=n(u,"Although the recipe for forward pass needs to be defined within this function, one should call the "),m=a(u,"CODE",{});var q=d(m);g=n(q,"Module"),q.forEach(t),_=n(u,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),u.forEach(t)},m(i,u){v(i,c,u),e(c,b),e(c,m),e(m,g),e(c,_)},d(i){i&&t(c)}}}function Kb(F){let c,b,m,g,_;return{c(){c=s("p"),b=o("Although the recipe for forward pass needs to be defined within this function, one should call the "),m=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 u=d(c);b=n(u,"Although the recipe for forward pass needs to be defined within this function, one should call the "),m=a(u,"CODE",{});var q=d(m);g=n(q,"Module"),q.forEach(t),_=n(u,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),u.forEach(t)},m(i,u){v(i,c,u),e(c,b),e(c,m),e(m,g),e(c,_)},d(i){i&&t(c)}}}function eT(F){let c,b,m,g,_;return g=new dn({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"),b=o("Example:"),m=p(),T(g.$$.fragment)},l(i){c=a(i,"P",{});var u=d(c);b=n(u,"Example:"),u.forEach(t),m=h(i),y(g.$$.fragment,i)},m(i,u){v(i,c,u),e(c,b),v(i,m,u),w(g,i,u),_=!0},p:an,i(i){_||(M(g.$$.fragment,i),_=!0)},o(i){R(g.$$.fragment,i),_=!1},d(i){i&&t(c),i&&t(m),k(g,i)}}}function tT(F){let c,b,m,g,_;return{c(){c=s("p"),b=o("Although the recipe for forward pass needs to be defined within this function, one should call the "),m=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 u=d(c);b=n(u,"Although the recipe for forward pass needs to be defined within this function, one should call the "),m=a(u,"CODE",{});var q=d(m);g=n(q,"Module"),q.forEach(t),_=n(u,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),u.forEach(t)},m(i,u){v(i,c,u),e(c,b),e(c,m),e(m,g),e(c,_)},d(i){i&&t(c)}}}function oT(F){let c,b,m,g,_;return{c(){c=s("p"),b=o("Although the recipe for forward pass needs to be defined within this function, one should call the "),m=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 u=d(c);b=n(u,"Although the recipe for forward pass needs to be defined within this function, one should call the "),m=a(u,"CODE",{});var q=d(m);g=n(q,"Module"),q.forEach(t),_=n(u,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),u.forEach(t)},m(i,u){v(i,c,u),e(c,b),e(c,m),e(m,g),e(c,_)},d(i){i&&t(c)}}}function nT(F){let c,b,m,g,_;return g=new dn({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"),b=o("Example:"),m=p(),T(g.$$.fragment)},l(i){c=a(i,"P",{});var u=d(c);b=n(u,"Example:"),u.forEach(t),m=h(i),y(g.$$.fragment,i)},m(i,u){v(i,c,u),e(c,b),v(i,m,u),w(g,i,u),_=!0},p:an,i(i){_||(M(g.$$.fragment,i),_=!0)},o(i){R(g.$$.fragment,i),_=!1},d(i){i&&t(c),i&&t(m),k(g,i)}}}function rT(F){let c,b,m,g,_;return{c(){c=s("p"),b=o("Although the recipe for forward pass needs to be defined within this function, one should call the "),m=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 u=d(c);b=n(u,"Although the recipe for forward pass needs to be defined within this function, one should call the "),m=a(u,"CODE",{});var q=d(m);g=n(q,"Module"),q.forEach(t),_=n(u,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),u.forEach(t)},m(i,u){v(i,c,u),e(c,b),e(c,m),e(m,g),e(c,_)},d(i){i&&t(c)}}}function sT(F){let c,b,m,g,_;return{c(){c=s("p"),b=o("Although the recipe for forward pass needs to be defined within this function, one should call the "),m=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 u=d(c);b=n(u,"Although the recipe for forward pass needs to be defined within this function, one should call the "),m=a(u,"CODE",{});var q=d(m);g=n(q,"Module"),q.forEach(t),_=n(u,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),u.forEach(t)},m(i,u){v(i,c,u),e(c,b),e(c,m),e(m,g),e(c,_)},d(i){i&&t(c)}}}function aT(F){let c,b,m,g,_;return g=new dn({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"),b=o("Example:"),m=p(),T(g.$$.fragment)},l(i){c=a(i,"P",{});var u=d(c);b=n(u,"Example:"),u.forEach(t),m=h(i),y(g.$$.fragment,i)},m(i,u){v(i,c,u),e(c,b),v(i,m,u),w(g,i,u),_=!0},p:an,i(i){_||(M(g.$$.fragment,i),_=!0)},o(i){R(g.$$.fragment,i),_=!1},d(i){i&&t(c),i&&t(m),k(g,i)}}}function dT(F){let c,b,m,g,_;return{c(){c=s("p"),b=o("Although the recipe for forward pass needs to be defined within this function, one should call the "),m=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 u=d(c);b=n(u,"Although the recipe for forward pass needs to be defined within this function, one should call the "),m=a(u,"CODE",{});var q=d(m);g=n(q,"Module"),q.forEach(t),_=n(u,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),u.forEach(t)},m(i,u){v(i,c,u),e(c,b),e(c,m),e(m,g),e(c,_)},d(i){i&&t(c)}}}function iT(F){let c,b,m,g,_;return{c(){c=s("p"),b=o("Although the recipe for forward pass needs to be defined within this function, one should call the "),m=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 u=d(c);b=n(u,"Although the recipe for forward pass needs to be defined within this function, one should call the "),m=a(u,"CODE",{});var q=d(m);g=n(q,"Module"),q.forEach(t),_=n(u,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),u.forEach(t)},m(i,u){v(i,c,u),e(c,b),e(c,m),e(m,g),e(c,_)},d(i){i&&t(c)}}}function cT(F){let c,b,m,g,_;return g=new dn({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"),b=o("Example:"),m=p(),T(g.$$.fragment)},l(i){c=a(i,"P",{});var u=d(c);b=n(u,"Example:"),u.forEach(t),m=h(i),y(g.$$.fragment,i)},m(i,u){v(i,c,u),e(c,b),v(i,m,u),w(g,i,u),_=!0},p:an,i(i){_||(M(g.$$.fragment,i),_=!0)},o(i){R(g.$$.fragment,i),_=!1},d(i){i&&t(c),i&&t(m),k(g,i)}}}function lT(F){let c,b,m,g,_,i,u,q,ai,Pa,Vt,cn,ln,Tf,Ha,Me,Oe,Ur,Bt,di,Er,ii,La,pn,ci,Oa,Ye,li,St,pi,hi,Ya,hn,ui,Qa,un,$r,mi,Da,Qe,gi,Pt,fi,_i,Ka,mn,vi,ed,gn,Zr,bi,td,Re,De,Ir,Ht,Ti,Cr,yi,od,ee,Lt,wi,de,fn,Mi,Ri,Nr,ki,qi,_n,Fi,xi,vn,ji,Ji,Gi,Ke,Ot,zi,Yt,Ui,bn,Ei,$i,Zi,et,Qt,Ii,Dt,Ci,Tn,Ni,Ai,nd,ke,tt,Ar,Kt,Wi,Wr,Xi,rd,eo,to,sd,qe,ot,Xr,oo,Vi,Vr,Bi,ad,Fe,no,Si,Br,Pi,dd,ro,so,id,xe,nt,Sr,ao,Hi,Pr,Li,cd,K,io,Oi,Hr,Yi,Qi,rt,Di,st,co,Ki,Lr,ec,tc,at,lo,oc,je,nc,Or,rc,sc,Yr,ac,dc,ic,dt,po,cc,ho,lc,Qr,pc,hc,ld,Je,it,Dr,uo,uc,Kr,mc,pd,N,mo,gc,Ge,fc,yn,_c,vc,es,bc,Tc,yc,ct,wc,ts,Mc,Rc,te,kc,os,qc,Fc,wn,xc,jc,ns,Jc,Gc,Mn,zc,Uc,Ec,U,$c,Rn,Zc,Ic,rs,Cc,Nc,ss,Ac,Wc,as,Xc,Vc,ds,Bc,Sc,kn,Pc,Hc,is,Lc,Oc,qn,Yc,Qc,Fn,Dc,Kc,cs,el,tl,ol,go,nl,xn,rl,sl,al,fo,dl,_o,il,cl,ll,ie,vo,pl,ze,hl,jn,ul,ml,ls,gl,fl,_l,lt,vl,pt,hd,Ue,ht,ps,bo,bl,hs,Tl,ud,J,To,yl,Ee,wl,Jn,Ml,Rl,us,kl,ql,Fl,ut,xl,ms,jl,Jl,gs,Gl,zl,oe,Ul,fs,El,$l,Gn,Zl,Il,_s,Cl,Nl,zn,Al,Wl,Xl,E,Vl,Un,Bl,Sl,vs,Pl,Hl,bs,Ll,Ol,Ts,Yl,Ql,ys,Dl,Kl,En,ep,tp,ws,op,np,$n,rp,sp,Zn,ap,dp,Ms,ip,cp,lp,yo,pp,In,hp,up,mp,wo,gp,Mo,fp,_p,vp,ce,Ro,bp,$e,Tp,Cn,yp,wp,Rs,Mp,Rp,kp,mt,qp,gt,Fp,ft,ko,xp,qo,jp,Nn,Jp,Gp,md,Ze,_t,ks,Fo,zp,qs,Up,gd,G,xo,Ep,Ie,$p,An,Zp,Ip,Fs,Cp,Np,Ap,vt,Wp,xs,Xp,Vp,js,Bp,Sp,ne,Pp,Js,Hp,Lp,Wn,Op,Yp,Gs,Qp,Dp,Xn,Kp,eh,th,$,oh,Vn,nh,rh,zs,sh,ah,Us,dh,ih,Es,ch,lh,$s,ph,hh,Bn,uh,mh,Zs,gh,fh,Sn,_h,vh,Pn,bh,Th,Is,yh,wh,Mh,jo,Rh,Hn,kh,qh,Fh,Jo,xh,Go,jh,Jh,Gh,le,zo,zh,Ce,Uh,Ln,Eh,$h,Cs,Zh,Ih,Ch,bt,Nh,Tt,Ah,yt,Uo,Wh,Ns,Xh,fd,Ne,wt,As,Eo,Vh,Ws,Bh,_d,Z,$o,Sh,Ae,Ph,On,Hh,Lh,Xs,Oh,Yh,Qh,Mt,Dh,Vs,Kh,eu,re,tu,Bs,ou,nu,Yn,ru,su,Ss,au,du,Qn,iu,cu,lu,A,pu,Dn,hu,uu,Ps,mu,gu,Hs,fu,_u,Ls,vu,bu,Os,Tu,yu,Kn,wu,Mu,Ys,Ru,ku,er,qu,Fu,Qs,xu,ju,Ju,Zo,Gu,tr,zu,Uu,Eu,Io,$u,Co,Zu,Iu,Cu,Ds,Nu,Au,pe,No,Wu,We,Xu,or,Vu,Bu,Ks,Su,Pu,Hu,Rt,Lu,kt,vd,Xe,qt,ea,Ao,Ou,ta,Yu,bd,x,Wo,Qu,Ve,Du,nr,Ku,em,oa,tm,om,nm,Ft,rm,na,sm,am,ra,dm,im,se,cm,sa,lm,pm,rr,hm,um,aa,mm,gm,sr,fm,_m,vm,W,bm,ar,Tm,ym,da,wm,Mm,ia,Rm,km,ca,qm,Fm,la,xm,jm,dr,Jm,Gm,pa,zm,Um,ir,Em,$m,ha,Zm,Im,Cm,Xo,Nm,cr,Am,Wm,Xm,Vo,Vm,Bo,Bm,Sm,Pm,ua,Hm,Lm,he,So,Om,Be,Ym,lr,Qm,Dm,ma,Km,eg,tg,xt,og,jt,ng,Jt,Po,rg,Ho,sg,pr,ag,dg,Td,Se,Gt,ga,Lo,ig,fa,cg,yd,j,Oo,lg,Pe,pg,hr,hg,ug,_a,mg,gg,fg,zt,_g,va,vg,bg,ba,Tg,yg,ae,wg,Ta,Mg,Rg,ur,kg,qg,ya,Fg,xg,mr,jg,Jg,Gg,X,zg,gr,Ug,Eg,wa,$g,Zg,Ma,Ig,Cg,Ra,Ng,Ag,ka,Wg,Xg,fr,Vg,Bg,qa,Sg,Pg,_r,Hg,Lg,Fa,Og,Yg,Qg,Yo,Dg,vr,Kg,ef,tf,Qo,of,Do,nf,rf,sf,xa,af,df,ue,Ko,cf,He,lf,br,pf,hf,ja,uf,mf,gf,Ut,ff,Et,_f,$t,en,vf,Ja,bf,wd;return i=new fe({}),Bt=new fe({}),Ht=new fe({}),Lt=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.30.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.30.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.30.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.30.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.30.0/src/transformers/models/rag/configuration_rag.py#L82"}}),Ot=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.30.0/src/transformers/models/rag/configuration_rag.py#L170",returnDescription:`
<p>An instance of a configuration object</p>
`,returnType:`
<p><a
  href="/docs/transformers/v4.30.0/en/model_doc/encoder-decoder#transformers.EncoderDecoderConfig"
>EncoderDecoderConfig</a></p>
`}}),Qt=new z({props:{name:"to_dict",anchor:"transformers.RagConfig.to_dict",parameters:[],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/rag/configuration_rag.py#L183",returnDescription:`
<p>Dictionary of all the attributes that make up this configuration instance,</p>
`,returnType:`
<p><code>Dict[str, any]</code></p>
`}}),Kt=new fe({}),to=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.30.0/src/transformers/models/rag/tokenization_rag.py#L28"}}),oo=new fe({}),no=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.30.0/src/transformers/models/rag/modeling_rag.py#L39"}}),so=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.30.0/src/transformers/models/rag/modeling_rag.py#L134"}}),ao=new fe({}),io=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.30.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.30.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.30.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.30.0/src/transformers/models/rag/retrieval_rag.py#L323"}}),rt=new sn({props:{anchor:"transformers.RagRetriever.example",$$slots:{default:[Sb]},$$scope:{ctx:F}}}),co=new z({props:{name:"init_retrieval",anchor:"transformers.RagRetriever.init_retrieval",parameters:[],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/rag/retrieval_rag.py#L457"}}),lo=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.30.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>
`}}),po=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.30.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>
`}}),uo=new fe({}),mo=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.30.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.30.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.30.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.30.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.30.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.30.0/src/transformers/models/rag/modeling_rag.py#L494"}}),ct=new ge({props:{$$slots:{default:[Pb]},$$scope:{ctx:F}}}),vo=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:" = 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.30.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.30.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.30.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.</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>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>): 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.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.30.0/src/transformers/models/rag/modeling_rag.py#L537",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.30.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.30.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.30.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>
`}}),lt=new ge({props:{$$slots:{default:[Hb]},$$scope:{ctx:F}}}),pt=new sn({props:{anchor:"transformers.RagModel.forward.example",$$slots:{default:[Lb]},$$scope:{ctx:F}}}),bo=new fe({}),To=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.30.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.30.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.30.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.30.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.30.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.30.0/src/transformers/models/rag/modeling_rag.py#L740"}}),ut=new ge({props:{$$slots:{default:[Ob]},$$scope:{ctx:F}}}),Ro=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.30.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.30.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.30.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.</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>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>): 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.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.30.0/src/transformers/models/rag/modeling_rag.py#L769",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.30.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.30.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.30.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 ge({props:{$$slots:{default:[Yb]},$$scope:{ctx:F}}}),gt=new sn({props:{anchor:"transformers.RagSequenceForGeneration.forward.example",$$slots:{default:[Qb]},$$scope:{ctx:F}}}),ko=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.30.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.
kwargs &#x2014;
Additional kwargs will be passed to <a href="/docs/transformers/v4.30.0/en/main_classes/text_generation#transformers.GenerationMixin.generate">generate()</a>.`,name:"n_docs"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/rag/modeling_rag.py#L910",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>
`}}),Fo=new fe({}),xo=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.30.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.30.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.30.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.30.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.30.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.30.0/src/transformers/models/rag/modeling_rag.py#L1138"}}),vt=new ge({props:{$$slots:{default:[Db]},$$scope:{ctx:F}}}),zo=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.30.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.30.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.30.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.</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>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>): 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.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.30.0/src/transformers/models/rag/modeling_rag.py#L1236",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.30.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.30.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.30.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>
`}}),bt=new ge({props:{$$slots:{default:[Kb]},$$scope:{ctx:F}}}),Tt=new sn({props:{anchor:"transformers.RagTokenForGeneration.forward.example",$$slots:{default:[eT]},$$scope:{ctx:F}}}),Uo=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.30.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.
kwargs &#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:"stopping_criteria"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/rag/modeling_rag.py#L1377",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>
`}}),Eo=new fe({}),$o=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.30.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.30.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.30.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.30.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.30.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.30.0/src/transformers/models/rag/modeling_tf_rag.py#L496"}}),Mt=new ge({props:{$$slots:{default:[tT]},$$scope:{ctx:F}}}),No=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:": 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:"return_dict",val:": Optional[bool] = 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.30.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.30.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.30.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.30.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.30.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>
`}}),Rt=new ge({props:{$$slots:{default:[oT]},$$scope:{ctx:F}}}),kt=new sn({props:{anchor:"transformers.TFRagModel.call.example",$$slots:{default:[nT]},$$scope:{ctx:F}}}),Ao=new fe({}),Wo=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.30.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.30.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.30.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.30.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.30.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.30.0/src/transformers/models/rag/modeling_tf_rag.py#L1301"}}),Ft=new ge({props:{$$slots:{default:[rT]},$$scope:{ctx:F}}}),So=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.30.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.30.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.30.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.30.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.30.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>
`}}),xt=new ge({props:{$$slots:{default:[sT]},$$scope:{ctx:F}}}),jt=new sn({props:{anchor:"transformers.TFRagSequenceForGeneration.call.example",$$slots:{default:[aT]},$$scope:{ctx:F}}}),Po=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.30.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.
kwargs &#x2014;
Additional kwargs will be passed to <a href="/docs/transformers/v4.30.0/en/main_classes/text_generation#transformers.GenerationMixin.generate">generate()</a>`,name:"n_docs"}],source:"https://github.com/huggingface/transformers/blob/v4.30.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>
`}}),Lo=new fe({}),Oo=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.30.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.30.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.30.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.30.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.30.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.30.0/src/transformers/models/rag/modeling_tf_rag.py#L729"}}),zt=new ge({props:{$$slots:{default:[dT]},$$scope:{ctx:F}}}),Ko=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:": 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:"do_marginalize",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.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.30.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.30.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.30.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.30.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.30.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>
`}}),Ut=new ge({props:{$$slots:{default:[iT]},$$scope:{ctx:F}}}),Et=new sn({props:{anchor:"transformers.TFRagTokenForGeneration.call.example",$$slots:{default:[cT]},$$scope:{ctx:F}}}),en=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.30.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.
kwargs &#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:"logits_processor"}],source:"https://github.com/huggingface/transformers/blob/v4.30.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"),b=p(),m=s("h1"),g=s("a"),_=s("span"),T(i.$$.fragment),u=p(),q=s("span"),ai=o("RAG"),Pa=p(),Vt=s("div"),cn=s("a"),ln=s("img"),Ha=p(),Me=s("h2"),Oe=s("a"),Ur=s("span"),T(Bt.$$.fragment),di=p(),Er=s("span"),ii=o("Overview"),La=p(),pn=s("p"),ci=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.`),Oa=p(),Ye=s("p"),li=o("It is based on the paper "),St=s("a"),pi=o("Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks"),hi=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.`),Ya=p(),hn=s("p"),ui=o("The abstract from the paper is the following:"),Qa=p(),un=s("p"),$r=s("em"),mi=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.`),Da=p(),Qe=s("p"),gi=o("This model was contributed by "),Pt=s("a"),fi=o("ola13"),_i=o("."),Ka=p(),mn=s("p"),vi=o("Tips:"),ed=p(),gn=s("ul"),Zr=s("li"),bi=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."),td=p(),Re=s("h2"),De=s("a"),Ir=s("span"),T(Ht.$$.fragment),Ti=p(),Cr=s("span"),yi=o("RagConfig"),od=p(),ee=s("div"),T(Lt.$$.fragment),wi=p(),de=s("p"),fn=s("a"),Mi=o("RagConfig"),Ri=o(" stores the configuration of a "),Nr=s("em"),ki=o("RagModel"),qi=o(". Configuration objects inherit from "),_n=s("a"),Fi=o("PretrainedConfig"),xi=o(` and
can be used to control the model outputs. Read the documentation from `),vn=s("a"),ji=o("PretrainedConfig"),Ji=o(" for more information."),Gi=p(),Ke=s("div"),T(Ot.$$.fragment),zi=p(),Yt=s("p"),Ui=o("Instantiate a "),bn=s("a"),Ei=o("EncoderDecoderConfig"),$i=o(` (or a derived class) from a pre-trained encoder model configuration and
decoder model configuration.`),Zi=p(),et=s("div"),T(Qt.$$.fragment),Ii=p(),Dt=s("p"),Ci=o("Serializes this instance to a Python dictionary. Override the default "),Tn=s("a"),Ni=o("to_dict()"),Ai=o("."),nd=p(),ke=s("h2"),tt=s("a"),Ar=s("span"),T(Kt.$$.fragment),Wi=p(),Wr=s("span"),Xi=o("RagTokenizer"),rd=p(),eo=s("div"),T(to.$$.fragment),sd=p(),qe=s("h2"),ot=s("a"),Xr=s("span"),T(oo.$$.fragment),Vi=p(),Vr=s("span"),Bi=o("Rag specific outputs"),ad=p(),Fe=s("div"),T(no.$$.fragment),Si=p(),Br=s("p"),Pi=o("Base class for retriever augmented marginalized models outputs."),dd=p(),ro=s("div"),T(so.$$.fragment),id=p(),xe=s("h2"),nt=s("a"),Sr=s("span"),T(ao.$$.fragment),Hi=p(),Pr=s("span"),Li=o("RagRetriever"),cd=p(),K=s("div"),T(io.$$.fragment),Oi=p(),Hr=s("p"),Yi=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.`),Qi=p(),T(rt.$$.fragment),Di=p(),st=s("div"),T(co.$$.fragment),Ki=p(),Lr=s("p"),ec=o("Retriever initialization function. It loads the index into memory."),tc=p(),at=s("div"),T(lo.$$.fragment),oc=p(),je=s("p"),nc=o("Postprocessing retrieved "),Or=s("code"),rc=o("docs"),sc=o(" and combining them with "),Yr=s("code"),ac=o("input_strings"),dc=o("."),ic=p(),dt=s("div"),T(po.$$.fragment),cc=p(),ho=s("p"),lc=o("Retrieves documents for specified "),Qr=s("code"),pc=o("question_hidden_states"),hc=o("."),ld=p(),Je=s("h2"),it=s("a"),Dr=s("span"),T(uo.$$.fragment),uc=p(),Kr=s("span"),mc=o("RagModel"),pd=p(),N=s("div"),T(mo.$$.fragment),gc=p(),Ge=s("p"),fc=o("The "),yn=s("a"),_c=o("RagModel"),vc=o(" forward method, overrides the "),es=s("code"),bc=o("__call__"),Tc=o(" special method."),yc=p(),T(ct.$$.fragment),wc=p(),ts=s("p"),Mc=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.`),Rc=p(),te=s("p"),kc=o("The question encoder can be any "),os=s("em"),qc=o("autoencoding"),Fc=o(" model, preferably "),wn=s("a"),xc=o("DPRQuestionEncoder"),jc=o(`, and the generator can be
any `),ns=s("em"),Jc=o("seq2seq"),Gc=o(" model, preferably "),Mn=s("a"),zc=o("BartForConditionalGeneration"),Uc=o("."),Ec=p(),U=s("p"),$c=o("The model can be initialized with a "),Rn=s("a"),Zc=o("RagRetriever"),Ic=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
`),rs=s("em"),Cc=o("autoencoding"),Nc=o(" model as the "),ss=s("code"),Ac=o("question_encoder"),Wc=o(" and any "),as=s("em"),Xc=o("seq2seq"),Vc=o(" model with language model head as the "),ds=s("code"),Bc=o("generator"),Sc=o(`.
It has been tested with `),kn=s("a"),Pc=o("DPRQuestionEncoder"),Hc=o(" as the "),is=s("code"),Lc=o("question_encoder"),Oc=o(" and "),qn=s("a"),Yc=o("BartForConditionalGeneration"),Qc=o(` or
`),Fn=s("a"),Dc=o("T5ForConditionalGeneration"),Kc=o(" as the "),cs=s("code"),el=o("generator"),tl=o("."),ol=p(),go=s("p"),nl=o("This model inherits from "),xn=s("a"),rl=o("PreTrainedModel"),sl=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.)`),al=p(),fo=s("p"),dl=o("This model is also a PyTorch "),_o=s("a"),il=o("torch.nn.Module"),cl=o(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),ll=p(),ie=s("div"),T(vo.$$.fragment),pl=p(),ze=s("p"),hl=o("The "),jn=s("a"),ul=o("RagModel"),ml=o(" forward method, overrides the "),ls=s("code"),gl=o("__call__"),fl=o(" special method."),_l=p(),T(lt.$$.fragment),vl=p(),T(pt.$$.fragment),hd=p(),Ue=s("h2"),ht=s("a"),ps=s("span"),T(bo.$$.fragment),bl=p(),hs=s("span"),Tl=o("RagSequenceForGeneration"),ud=p(),J=s("div"),T(To.$$.fragment),yl=p(),Ee=s("p"),wl=o("The "),Jn=s("a"),Ml=o("RagSequenceForGeneration"),Rl=o(" forward method, overrides the "),us=s("code"),kl=o("__call__"),ql=o(" special method."),Fl=p(),T(ut.$$.fragment),xl=p(),ms=s("p"),jl=o("A RAG-sequence model implementation. It performs RAG-sequence specific marginalization in the forward pass."),Jl=p(),gs=s("p"),Gl=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.`),zl=p(),oe=s("p"),Ul=o("The question encoder can be any "),fs=s("em"),El=o("autoencoding"),$l=o(" model, preferably "),Gn=s("a"),Zl=o("DPRQuestionEncoder"),Il=o(`, and the generator can be
any `),_s=s("em"),Cl=o("seq2seq"),Nl=o(" model, preferably "),zn=s("a"),Al=o("BartForConditionalGeneration"),Wl=o("."),Xl=p(),E=s("p"),Vl=o("The model can be initialized with a "),Un=s("a"),Bl=o("RagRetriever"),Sl=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
`),vs=s("em"),Pl=o("autoencoding"),Hl=o(" model as the "),bs=s("code"),Ll=o("question_encoder"),Ol=o(" and any "),Ts=s("em"),Yl=o("seq2seq"),Ql=o(" model with language model head as the "),ys=s("code"),Dl=o("generator"),Kl=o(`.
It has been tested with `),En=s("a"),ep=o("DPRQuestionEncoder"),tp=o(" as the "),ws=s("code"),op=o("question_encoder"),np=o(" and "),$n=s("a"),rp=o("BartForConditionalGeneration"),sp=o(` or
`),Zn=s("a"),ap=o("T5ForConditionalGeneration"),dp=o(" as the "),Ms=s("code"),ip=o("generator"),cp=o("."),lp=p(),yo=s("p"),pp=o("This model inherits from "),In=s("a"),hp=o("PreTrainedModel"),up=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.)`),mp=p(),wo=s("p"),gp=o("This model is also a PyTorch "),Mo=s("a"),fp=o("torch.nn.Module"),_p=o(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),vp=p(),ce=s("div"),T(Ro.$$.fragment),bp=p(),$e=s("p"),Tp=o("The "),Cn=s("a"),yp=o("RagSequenceForGeneration"),wp=o(" forward method, overrides the "),Rs=s("code"),Mp=o("__call__"),Rp=o(" special method."),kp=p(),T(mt.$$.fragment),qp=p(),T(gt.$$.fragment),Fp=p(),ft=s("div"),T(ko.$$.fragment),xp=p(),qo=s("p"),jp=o("Implements RAG sequence \u201Cthorough\u201D decoding. Read the "),Nn=s("a"),Jp=o("generate()"),Gp=o("` documentation\nfor more information on how to set other generate input parameters."),md=p(),Ze=s("h2"),_t=s("a"),ks=s("span"),T(Fo.$$.fragment),zp=p(),qs=s("span"),Up=o("RagTokenForGeneration"),gd=p(),G=s("div"),T(xo.$$.fragment),Ep=p(),Ie=s("p"),$p=o("The "),An=s("a"),Zp=o("RagTokenForGeneration"),Ip=o(" forward method, overrides the "),Fs=s("code"),Cp=o("__call__"),Np=o(" special method."),Ap=p(),T(vt.$$.fragment),Wp=p(),xs=s("p"),Xp=o("A RAG-token model implementation. It performs RAG-token specific marginalization in the forward pass."),Vp=p(),js=s("p"),Bp=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.`),Sp=p(),ne=s("p"),Pp=o("The question encoder can be any "),Js=s("em"),Hp=o("autoencoding"),Lp=o(" model, preferably "),Wn=s("a"),Op=o("DPRQuestionEncoder"),Yp=o(`, and the generator can be
any `),Gs=s("em"),Qp=o("seq2seq"),Dp=o(" model, preferably "),Xn=s("a"),Kp=o("BartForConditionalGeneration"),eh=o("."),th=p(),$=s("p"),oh=o("The model can be initialized with a "),Vn=s("a"),nh=o("RagRetriever"),rh=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
`),zs=s("em"),sh=o("autoencoding"),ah=o(" model as the "),Us=s("code"),dh=o("question_encoder"),ih=o(" and any "),Es=s("em"),ch=o("seq2seq"),lh=o(" model with language model head as the "),$s=s("code"),ph=o("generator"),hh=o(`.
It has been tested with `),Bn=s("a"),uh=o("DPRQuestionEncoder"),mh=o(" as the "),Zs=s("code"),gh=o("question_encoder"),fh=o(" and "),Sn=s("a"),_h=o("BartForConditionalGeneration"),vh=o(` or
`),Pn=s("a"),bh=o("T5ForConditionalGeneration"),Th=o(" as the "),Is=s("code"),yh=o("generator"),wh=o("."),Mh=p(),jo=s("p"),Rh=o("This model inherits from "),Hn=s("a"),kh=o("PreTrainedModel"),qh=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(),Jo=s("p"),xh=o("This model is also a PyTorch "),Go=s("a"),jh=o("torch.nn.Module"),Jh=o(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Gh=p(),le=s("div"),T(zo.$$.fragment),zh=p(),Ce=s("p"),Uh=o("The "),Ln=s("a"),Eh=o("RagTokenForGeneration"),$h=o(" forward method, overrides the "),Cs=s("code"),Zh=o("__call__"),Ih=o(" special method."),Ch=p(),T(bt.$$.fragment),Nh=p(),T(Tt.$$.fragment),Ah=p(),yt=s("div"),T(Uo.$$.fragment),Wh=p(),Ns=s("p"),Xh=o("Implements RAG token decoding."),fd=p(),Ne=s("h2"),wt=s("a"),As=s("span"),T(Eo.$$.fragment),Vh=p(),Ws=s("span"),Bh=o("TFRagModel"),_d=p(),Z=s("div"),T($o.$$.fragment),Sh=p(),Ae=s("p"),Ph=o("The "),On=s("a"),Hh=o("TFRagModel"),Lh=o(" forward method, overrides the "),Xs=s("code"),Oh=o("__call__"),Yh=o(" special method."),Qh=p(),T(Mt.$$.fragment),Dh=p(),Vs=s("p"),Kh=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.`),eu=p(),re=s("p"),tu=o("The question encoder can be any "),Bs=s("em"),ou=o("autoencoding"),nu=o(" model, preferably "),Yn=s("a"),ru=o("TFDPRQuestionEncoder"),su=o(`, and the generator can be
any `),Ss=s("em"),au=o("seq2seq"),du=o(" model, preferably "),Qn=s("a"),iu=o("TFBartForConditionalGeneration"),cu=o("."),lu=p(),A=s("p"),pu=o("The model can be initialized with a "),Dn=s("a"),hu=o("RagRetriever"),uu=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
`),Ps=s("em"),mu=o("autoencoding"),gu=o(" model as the "),Hs=s("code"),fu=o("question_encoder"),_u=o(" and any "),Ls=s("em"),vu=o("seq2seq"),bu=o(" model with language model head as the "),Os=s("code"),Tu=o("generator"),yu=o(`.
It has been tested with `),Kn=s("a"),wu=o("TFDPRQuestionEncoder"),Mu=o(" as the "),Ys=s("code"),Ru=o("question_encoder"),ku=o(" and "),er=s("a"),qu=o("TFBartForConditionalGeneration"),Fu=o(`
as the `),Qs=s("code"),xu=o("generator"),ju=o("."),Ju=p(),Zo=s("p"),Gu=o("This model inherits from "),tr=s("a"),zu=o("TFPreTrainedModel"),Uu=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.)`),Eu=p(),Io=s("p"),$u=o("This model is also a Tensorflow "),Co=s("a"),Zu=o("tf.keras.Model"),Iu=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.`),Cu=p(),Ds=s("p"),Nu=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.`),Au=p(),pe=s("div"),T(No.$$.fragment),Wu=p(),We=s("p"),Xu=o("The "),or=s("a"),Vu=o("TFRagModel"),Bu=o(" forward method, overrides the "),Ks=s("code"),Su=o("__call__"),Pu=o(" special method."),Hu=p(),T(Rt.$$.fragment),Lu=p(),T(kt.$$.fragment),vd=p(),Xe=s("h2"),qt=s("a"),ea=s("span"),T(Ao.$$.fragment),Ou=p(),ta=s("span"),Yu=o("TFRagSequenceForGeneration"),bd=p(),x=s("div"),T(Wo.$$.fragment),Qu=p(),Ve=s("p"),Du=o("The "),nr=s("a"),Ku=o("TFRagSequenceForGeneration"),em=o(" forward method, overrides the "),oa=s("code"),tm=o("__call__"),om=o(" special method."),nm=p(),T(Ft.$$.fragment),rm=p(),na=s("p"),sm=o("A TF RAG-sequence model implementation. It performs RAG-sequence specific marginalization in the forward pass."),am=p(),ra=s("p"),dm=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.`),im=p(),se=s("p"),cm=o("The question encoder can be any "),sa=s("em"),lm=o("autoencoding"),pm=o(" model, preferably "),rr=s("a"),hm=o("TFDPRQuestionEncoder"),um=o(`, and the generator can be
any `),aa=s("em"),mm=o("seq2seq"),gm=o(" model, preferably "),sr=s("a"),fm=o("TFBartForConditionalGeneration"),_m=o("."),vm=p(),W=s("p"),bm=o("The model can be initialized with a "),ar=s("a"),Tm=o("RagRetriever"),ym=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
`),da=s("em"),wm=o("autoencoding"),Mm=o(" model as the "),ia=s("code"),Rm=o("question_encoder"),km=o(" and any "),ca=s("em"),qm=o("seq2seq"),Fm=o(" model with language model head as the "),la=s("code"),xm=o("generator"),jm=o(`.
It has been tested with `),dr=s("a"),Jm=o("TFDPRQuestionEncoder"),Gm=o(" as the "),pa=s("code"),zm=o("question_encoder"),Um=o(" and "),ir=s("a"),Em=o("TFBartForConditionalGeneration"),$m=o(`
as the `),ha=s("code"),Zm=o("generator"),Im=o("."),Cm=p(),Xo=s("p"),Nm=o("This model inherits from "),cr=s("a"),Am=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.)`),Xm=p(),Vo=s("p"),Vm=o("This model is also a Tensorflow "),Bo=s("a"),Bm=o("tf.keras.Model"),Sm=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.`),Pm=p(),ua=s("p"),Hm=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.`),Lm=p(),he=s("div"),T(So.$$.fragment),Om=p(),Be=s("p"),Ym=o("The "),lr=s("a"),Qm=o("TFRagSequenceForGeneration"),Dm=o(" forward method, overrides the "),ma=s("code"),Km=o("__call__"),eg=o(" special method."),tg=p(),T(xt.$$.fragment),og=p(),T(jt.$$.fragment),ng=p(),Jt=s("div"),T(Po.$$.fragment),rg=p(),Ho=s("p"),sg=o("Implements RAG sequence \u201Cthorough\u201D decoding. Read the "),pr=s("a"),ag=o("generate()"),dg=o("` documentation\nfor more information on how to set other generate input parameters"),Td=p(),Se=s("h2"),Gt=s("a"),ga=s("span"),T(Lo.$$.fragment),ig=p(),fa=s("span"),cg=o("TFRagTokenForGeneration"),yd=p(),j=s("div"),T(Oo.$$.fragment),lg=p(),Pe=s("p"),pg=o("The "),hr=s("a"),hg=o("TFRagTokenForGeneration"),ug=o(" forward method, overrides the "),_a=s("code"),mg=o("__call__"),gg=o(" special method."),fg=p(),T(zt.$$.fragment),_g=p(),va=s("p"),vg=o("A TF RAG-token model implementation. It performs RAG-token specific marginalization in the forward pass."),bg=p(),ba=s("p"),Tg=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.`),yg=p(),ae=s("p"),wg=o("The question encoder can be any "),Ta=s("em"),Mg=o("autoencoding"),Rg=o(" model, preferably "),ur=s("a"),kg=o("TFDPRQuestionEncoder"),qg=o(`, and the generator can be
any `),ya=s("em"),Fg=o("seq2seq"),xg=o(" model, preferably "),mr=s("a"),jg=o("TFBartForConditionalGeneration"),Jg=o("."),Gg=p(),X=s("p"),zg=o("The model can be initialized with a "),gr=s("a"),Ug=o("RagRetriever"),Eg=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
`),wa=s("em"),$g=o("autoencoding"),Zg=o(" model as the "),Ma=s("code"),Ig=o("question_encoder"),Cg=o(" and any "),Ra=s("em"),Ng=o("seq2seq"),Ag=o(" model with language model head as the "),ka=s("code"),Wg=o("generator"),Xg=o(`.
It has been tested with `),fr=s("a"),Vg=o("TFDPRQuestionEncoder"),Bg=o(" as the "),qa=s("code"),Sg=o("question_encoder"),Pg=o(" and "),_r=s("a"),Hg=o("TFBartForConditionalGeneration"),Lg=o(`
as the `),Fa=s("code"),Og=o("generator"),Yg=o("."),Qg=p(),Yo=s("p"),Dg=o("This model inherits from "),vr=s("a"),Kg=o("TFPreTrainedModel"),ef=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.)`),tf=p(),Qo=s("p"),of=o("This model is also a Tensorflow "),Do=s("a"),nf=o("tf.keras.Model"),rf=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.`),sf=p(),xa=s("p"),af=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.`),df=p(),ue=s("div"),T(Ko.$$.fragment),cf=p(),He=s("p"),lf=o("The "),br=s("a"),pf=o("TFRagTokenForGeneration"),hf=o(" forward method, overrides the "),ja=s("code"),uf=o("__call__"),mf=o(" special method."),gf=p(),T(Ut.$$.fragment),ff=p(),T(Et.$$.fragment),_f=p(),$t=s("div"),T(en.$$.fragment),vf=p(),Ja=s("p"),bf=o("Implements TFRAG token decoding."),this.h()},l(r){const f=Xb('[data-svelte="svelte-1phssyn"]',document.head);c=a(f,"META",{name:!0,content:!0}),f.forEach(t),b=h(r),m=a(r,"H1",{class:!0});var tn=d(m);g=a(tn,"A",{id:!0,class:!0,href:!0});var Ga=d(g);_=a(Ga,"SPAN",{});var za=d(_);y(i.$$.fragment,za),za.forEach(t),Ga.forEach(t),u=h(tn),q=a(tn,"SPAN",{});var Ua=d(q);ai=n(Ua,"RAG"),Ua.forEach(t),tn.forEach(t),Pa=h(r),Vt=a(r,"DIV",{class:!0});var Ea=d(Vt);cn=a(Ea,"A",{href:!0});var $a=d(cn);ln=a($a,"IMG",{alt:!0,src:!0}),$a.forEach(t),Ea.forEach(t),Ha=h(r),Me=a(r,"H2",{class:!0});var on=d(Me);Oe=a(on,"A",{id:!0,class:!0,href:!0});var Za=d(Oe);Ur=a(Za,"SPAN",{});var Ia=d(Ur);y(Bt.$$.fragment,Ia),Ia.forEach(t),Za.forEach(t),di=h(on),Er=a(on,"SPAN",{});var Ca=d(Er);ii=n(Ca,"Overview"),Ca.forEach(t),on.forEach(t),La=h(r),pn=a(r,"P",{});var Na=d(pn);ci=n(Na,`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.`),Na.forEach(t),Oa=h(r),Ye=a(r,"P",{});var nn=d(Ye);li=n(nn,"It is based on the paper "),St=a(nn,"A",{href:!0,rel:!0});var Aa=d(St);pi=n(Aa,"Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks"),Aa.forEach(t),hi=n(nn,` 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.`),nn.forEach(t),Ya=h(r),hn=a(r,"P",{});var Wa=d(hn);ui=n(Wa,"The abstract from the paper is the following:"),Wa.forEach(t),Qa=h(r),un=a(r,"P",{});var Xa=d(un);$r=a(Xa,"EM",{});var Va=d($r);mi=n(Va,`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.`),Va.forEach(t),Xa.forEach(t),Da=h(r),Qe=a(r,"P",{});var rn=d(Qe);gi=n(rn,"This model was contributed by "),Pt=a(rn,"A",{href:!0,rel:!0});var Ba=d(Pt);fi=n(Ba,"ola13"),Ba.forEach(t),_i=n(rn,"."),rn.forEach(t),Ka=h(r),mn=a(r,"P",{});var Sa=d(mn);vi=n(Sa,"Tips:"),Sa.forEach(t),ed=h(r),gn=a(r,"UL",{});var yf=d(gn);Zr=a(yf,"LI",{});var wf=d(Zr);bi=n(wf,"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."),wf.forEach(t),yf.forEach(t),td=h(r),Re=a(r,"H2",{class:!0});var Md=d(Re);De=a(Md,"A",{id:!0,class:!0,href:!0});var Mf=d(De);Ir=a(Mf,"SPAN",{});var Rf=d(Ir);y(Ht.$$.fragment,Rf),Rf.forEach(t),Mf.forEach(t),Ti=h(Md),Cr=a(Md,"SPAN",{});var kf=d(Cr);yi=n(kf,"RagConfig"),kf.forEach(t),Md.forEach(t),od=h(r),ee=a(r,"DIV",{class:!0});var Zt=d(ee);y(Lt.$$.fragment,Zt),wi=h(Zt),de=a(Zt,"P",{});var Le=d(de);fn=a(Le,"A",{href:!0});var qf=d(fn);Mi=n(qf,"RagConfig"),qf.forEach(t),Ri=n(Le," stores the configuration of a "),Nr=a(Le,"EM",{});var Ff=d(Nr);ki=n(Ff,"RagModel"),Ff.forEach(t),qi=n(Le,". Configuration objects inherit from "),_n=a(Le,"A",{href:!0});var xf=d(_n);Fi=n(xf,"PretrainedConfig"),xf.forEach(t),xi=n(Le,` and
can be used to control the model outputs. Read the documentation from `),vn=a(Le,"A",{href:!0});var jf=d(vn);ji=n(jf,"PretrainedConfig"),jf.forEach(t),Ji=n(Le," for more information."),Le.forEach(t),Gi=h(Zt),Ke=a(Zt,"DIV",{class:!0});var Rd=d(Ke);y(Ot.$$.fragment,Rd),zi=h(Rd),Yt=a(Rd,"P",{});var kd=d(Yt);Ui=n(kd,"Instantiate a "),bn=a(kd,"A",{href:!0});var Jf=d(bn);Ei=n(Jf,"EncoderDecoderConfig"),Jf.forEach(t),$i=n(kd,` (or a derived class) from a pre-trained encoder model configuration and
decoder model configuration.`),kd.forEach(t),Rd.forEach(t),Zi=h(Zt),et=a(Zt,"DIV",{class:!0});var qd=d(et);y(Qt.$$.fragment,qd),Ii=h(qd),Dt=a(qd,"P",{});var Fd=d(Dt);Ci=n(Fd,"Serializes this instance to a Python dictionary. Override the default "),Tn=a(Fd,"A",{href:!0});var Gf=d(Tn);Ni=n(Gf,"to_dict()"),Gf.forEach(t),Ai=n(Fd,"."),Fd.forEach(t),qd.forEach(t),Zt.forEach(t),nd=h(r),ke=a(r,"H2",{class:!0});var xd=d(ke);tt=a(xd,"A",{id:!0,class:!0,href:!0});var zf=d(tt);Ar=a(zf,"SPAN",{});var Uf=d(Ar);y(Kt.$$.fragment,Uf),Uf.forEach(t),zf.forEach(t),Wi=h(xd),Wr=a(xd,"SPAN",{});var Ef=d(Wr);Xi=n(Ef,"RagTokenizer"),Ef.forEach(t),xd.forEach(t),rd=h(r),eo=a(r,"DIV",{class:!0});var $f=d(eo);y(to.$$.fragment,$f),$f.forEach(t),sd=h(r),qe=a(r,"H2",{class:!0});var jd=d(qe);ot=a(jd,"A",{id:!0,class:!0,href:!0});var Zf=d(ot);Xr=a(Zf,"SPAN",{});var If=d(Xr);y(oo.$$.fragment,If),If.forEach(t),Zf.forEach(t),Vi=h(jd),Vr=a(jd,"SPAN",{});var Cf=d(Vr);Bi=n(Cf,"Rag specific outputs"),Cf.forEach(t),jd.forEach(t),ad=h(r),Fe=a(r,"DIV",{class:!0});var Jd=d(Fe);y(no.$$.fragment,Jd),Si=h(Jd),Br=a(Jd,"P",{});var Nf=d(Br);Pi=n(Nf,"Base class for retriever augmented marginalized models outputs."),Nf.forEach(t),Jd.forEach(t),dd=h(r),ro=a(r,"DIV",{class:!0});var Af=d(ro);y(so.$$.fragment,Af),Af.forEach(t),id=h(r),xe=a(r,"H2",{class:!0});var Gd=d(xe);nt=a(Gd,"A",{id:!0,class:!0,href:!0});var Wf=d(nt);Sr=a(Wf,"SPAN",{});var Xf=d(Sr);y(ao.$$.fragment,Xf),Xf.forEach(t),Wf.forEach(t),Hi=h(Gd),Pr=a(Gd,"SPAN",{});var Vf=d(Pr);Li=n(Vf,"RagRetriever"),Vf.forEach(t),Gd.forEach(t),cd=h(r),K=a(r,"DIV",{class:!0});var me=d(K);y(io.$$.fragment,me),Oi=h(me),Hr=a(me,"P",{});var Bf=d(Hr);Yi=n(Bf,`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.`),Bf.forEach(t),Qi=h(me),y(rt.$$.fragment,me),Di=h(me),st=a(me,"DIV",{class:!0});var zd=d(st);y(co.$$.fragment,zd),Ki=h(zd),Lr=a(zd,"P",{});var Sf=d(Lr);ec=n(Sf,"Retriever initialization function. It loads the index into memory."),Sf.forEach(t),zd.forEach(t),tc=h(me),at=a(me,"DIV",{class:!0});var Ud=d(at);y(lo.$$.fragment,Ud),oc=h(Ud),je=a(Ud,"P",{});var Tr=d(je);nc=n(Tr,"Postprocessing retrieved "),Or=a(Tr,"CODE",{});var Pf=d(Or);rc=n(Pf,"docs"),Pf.forEach(t),sc=n(Tr," and combining them with "),Yr=a(Tr,"CODE",{});var Hf=d(Yr);ac=n(Hf,"input_strings"),Hf.forEach(t),dc=n(Tr,"."),Tr.forEach(t),Ud.forEach(t),ic=h(me),dt=a(me,"DIV",{class:!0});var Ed=d(dt);y(po.$$.fragment,Ed),cc=h(Ed),ho=a(Ed,"P",{});var $d=d(ho);lc=n($d,"Retrieves documents for specified "),Qr=a($d,"CODE",{});var Lf=d(Qr);pc=n(Lf,"question_hidden_states"),Lf.forEach(t),hc=n($d,"."),$d.forEach(t),Ed.forEach(t),me.forEach(t),ld=h(r),Je=a(r,"H2",{class:!0});var Zd=d(Je);it=a(Zd,"A",{id:!0,class:!0,href:!0});var Of=d(it);Dr=a(Of,"SPAN",{});var Yf=d(Dr);y(uo.$$.fragment,Yf),Yf.forEach(t),Of.forEach(t),uc=h(Zd),Kr=a(Zd,"SPAN",{});var Qf=d(Kr);mc=n(Qf,"RagModel"),Qf.forEach(t),Zd.forEach(t),pd=h(r),N=a(r,"DIV",{class:!0});var D=d(N);y(mo.$$.fragment,D),gc=h(D),Ge=a(D,"P",{});var yr=d(Ge);fc=n(yr,"The "),yn=a(yr,"A",{href:!0});var Df=d(yn);_c=n(Df,"RagModel"),Df.forEach(t),vc=n(yr," forward method, overrides the "),es=a(yr,"CODE",{});var Kf=d(es);bc=n(Kf,"__call__"),Kf.forEach(t),Tc=n(yr," special method."),yr.forEach(t),yc=h(D),y(ct.$$.fragment,D),wc=h(D),ts=a(D,"P",{});var e_=d(ts);Mc=n(e_,`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.`),e_.forEach(t),Rc=h(D),te=a(D,"P",{});var _e=d(te);kc=n(_e,"The question encoder can be any "),os=a(_e,"EM",{});var t_=d(os);qc=n(t_,"autoencoding"),t_.forEach(t),Fc=n(_e," model, preferably "),wn=a(_e,"A",{href:!0});var o_=d(wn);xc=n(o_,"DPRQuestionEncoder"),o_.forEach(t),jc=n(_e,`, and the generator can be
any `),ns=a(_e,"EM",{});var n_=d(ns);Jc=n(n_,"seq2seq"),n_.forEach(t),Gc=n(_e," model, preferably "),Mn=a(_e,"A",{href:!0});var r_=d(Mn);zc=n(r_,"BartForConditionalGeneration"),r_.forEach(t),Uc=n(_e,"."),_e.forEach(t),Ec=h(D),U=a(D,"P",{});var V=d(U);$c=n(V,"The model can be initialized with a "),Rn=a(V,"A",{href:!0});var s_=d(Rn);Zc=n(s_,"RagRetriever"),s_.forEach(t),Ic=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
`),rs=a(V,"EM",{});var a_=d(rs);Cc=n(a_,"autoencoding"),a_.forEach(t),Nc=n(V," model as the "),ss=a(V,"CODE",{});var d_=d(ss);Ac=n(d_,"question_encoder"),d_.forEach(t),Wc=n(V," and any "),as=a(V,"EM",{});var i_=d(as);Xc=n(i_,"seq2seq"),i_.forEach(t),Vc=n(V," model with language model head as the "),ds=a(V,"CODE",{});var c_=d(ds);Bc=n(c_,"generator"),c_.forEach(t),Sc=n(V,`.
It has been tested with `),kn=a(V,"A",{href:!0});var l_=d(kn);Pc=n(l_,"DPRQuestionEncoder"),l_.forEach(t),Hc=n(V," as the "),is=a(V,"CODE",{});var p_=d(is);Lc=n(p_,"question_encoder"),p_.forEach(t),Oc=n(V," and "),qn=a(V,"A",{href:!0});var h_=d(qn);Yc=n(h_,"BartForConditionalGeneration"),h_.forEach(t),Qc=n(V,` or
`),Fn=a(V,"A",{href:!0});var u_=d(Fn);Dc=n(u_,"T5ForConditionalGeneration"),u_.forEach(t),Kc=n(V," as the "),cs=a(V,"CODE",{});var m_=d(cs);el=n(m_,"generator"),m_.forEach(t),tl=n(V,"."),V.forEach(t),ol=h(D),go=a(D,"P",{});var Id=d(go);nl=n(Id,"This model inherits from "),xn=a(Id,"A",{href:!0});var g_=d(xn);rl=n(g_,"PreTrainedModel"),g_.forEach(t),sl=n(Id,`. 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.)`),Id.forEach(t),al=h(D),fo=a(D,"P",{});var Cd=d(fo);dl=n(Cd,"This model is also a PyTorch "),_o=a(Cd,"A",{href:!0,rel:!0});var f_=d(_o);il=n(f_,"torch.nn.Module"),f_.forEach(t),cl=n(Cd,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Cd.forEach(t),ll=h(D),ie=a(D,"DIV",{class:!0});var It=d(ie);y(vo.$$.fragment,It),pl=h(It),ze=a(It,"P",{});var wr=d(ze);hl=n(wr,"The "),jn=a(wr,"A",{href:!0});var __=d(jn);ul=n(__,"RagModel"),__.forEach(t),ml=n(wr," forward method, overrides the "),ls=a(wr,"CODE",{});var v_=d(ls);gl=n(v_,"__call__"),v_.forEach(t),fl=n(wr," special method."),wr.forEach(t),_l=h(It),y(lt.$$.fragment,It),vl=h(It),y(pt.$$.fragment,It),It.forEach(t),D.forEach(t),hd=h(r),Ue=a(r,"H2",{class:!0});var Nd=d(Ue);ht=a(Nd,"A",{id:!0,class:!0,href:!0});var b_=d(ht);ps=a(b_,"SPAN",{});var T_=d(ps);y(bo.$$.fragment,T_),T_.forEach(t),b_.forEach(t),bl=h(Nd),hs=a(Nd,"SPAN",{});var y_=d(hs);Tl=n(y_,"RagSequenceForGeneration"),y_.forEach(t),Nd.forEach(t),ud=h(r),J=a(r,"DIV",{class:!0});var B=d(J);y(To.$$.fragment,B),yl=h(B),Ee=a(B,"P",{});var Mr=d(Ee);wl=n(Mr,"The "),Jn=a(Mr,"A",{href:!0});var w_=d(Jn);Ml=n(w_,"RagSequenceForGeneration"),w_.forEach(t),Rl=n(Mr," forward method, overrides the "),us=a(Mr,"CODE",{});var M_=d(us);kl=n(M_,"__call__"),M_.forEach(t),ql=n(Mr," special method."),Mr.forEach(t),Fl=h(B),y(ut.$$.fragment,B),xl=h(B),ms=a(B,"P",{});var R_=d(ms);jl=n(R_,"A RAG-sequence model implementation. It performs RAG-sequence specific marginalization in the forward pass."),R_.forEach(t),Jl=h(B),gs=a(B,"P",{});var k_=d(gs);Gl=n(k_,`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.`),k_.forEach(t),zl=h(B),oe=a(B,"P",{});var ve=d(oe);Ul=n(ve,"The question encoder can be any "),fs=a(ve,"EM",{});var q_=d(fs);El=n(q_,"autoencoding"),q_.forEach(t),$l=n(ve," model, preferably "),Gn=a(ve,"A",{href:!0});var F_=d(Gn);Zl=n(F_,"DPRQuestionEncoder"),F_.forEach(t),Il=n(ve,`, and the generator can be
any `),_s=a(ve,"EM",{});var x_=d(_s);Cl=n(x_,"seq2seq"),x_.forEach(t),Nl=n(ve," model, preferably "),zn=a(ve,"A",{href:!0});var j_=d(zn);Al=n(j_,"BartForConditionalGeneration"),j_.forEach(t),Wl=n(ve,"."),ve.forEach(t),Xl=h(B),E=a(B,"P",{});var S=d(E);Vl=n(S,"The model can be initialized with a "),Un=a(S,"A",{href:!0});var J_=d(Un);Bl=n(J_,"RagRetriever"),J_.forEach(t),Sl=n(S,` 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
`),vs=a(S,"EM",{});var G_=d(vs);Pl=n(G_,"autoencoding"),G_.forEach(t),Hl=n(S," model as the "),bs=a(S,"CODE",{});var z_=d(bs);Ll=n(z_,"question_encoder"),z_.forEach(t),Ol=n(S," and any "),Ts=a(S,"EM",{});var U_=d(Ts);Yl=n(U_,"seq2seq"),U_.forEach(t),Ql=n(S," model with language model head as the "),ys=a(S,"CODE",{});var E_=d(ys);Dl=n(E_,"generator"),E_.forEach(t),Kl=n(S,`.
It has been tested with `),En=a(S,"A",{href:!0});var $_=d(En);ep=n($_,"DPRQuestionEncoder"),$_.forEach(t),tp=n(S," as the "),ws=a(S,"CODE",{});var Z_=d(ws);op=n(Z_,"question_encoder"),Z_.forEach(t),np=n(S," and "),$n=a(S,"A",{href:!0});var I_=d($n);rp=n(I_,"BartForConditionalGeneration"),I_.forEach(t),sp=n(S,` or
`),Zn=a(S,"A",{href:!0});var C_=d(Zn);ap=n(C_,"T5ForConditionalGeneration"),C_.forEach(t),dp=n(S," as the "),Ms=a(S,"CODE",{});var N_=d(Ms);ip=n(N_,"generator"),N_.forEach(t),cp=n(S,"."),S.forEach(t),lp=h(B),yo=a(B,"P",{});var Ad=d(yo);pp=n(Ad,"This model inherits from "),In=a(Ad,"A",{href:!0});var A_=d(In);hp=n(A_,"PreTrainedModel"),A_.forEach(t),up=n(Ad,`. 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.)`),Ad.forEach(t),mp=h(B),wo=a(B,"P",{});var Wd=d(wo);gp=n(Wd,"This model is also a PyTorch "),Mo=a(Wd,"A",{href:!0,rel:!0});var W_=d(Mo);fp=n(W_,"torch.nn.Module"),W_.forEach(t),_p=n(Wd,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Wd.forEach(t),vp=h(B),ce=a(B,"DIV",{class:!0});var Ct=d(ce);y(Ro.$$.fragment,Ct),bp=h(Ct),$e=a(Ct,"P",{});var Rr=d($e);Tp=n(Rr,"The "),Cn=a(Rr,"A",{href:!0});var X_=d(Cn);yp=n(X_,"RagSequenceForGeneration"),X_.forEach(t),wp=n(Rr," forward method, overrides the "),Rs=a(Rr,"CODE",{});var V_=d(Rs);Mp=n(V_,"__call__"),V_.forEach(t),Rp=n(Rr," special method."),Rr.forEach(t),kp=h(Ct),y(mt.$$.fragment,Ct),qp=h(Ct),y(gt.$$.fragment,Ct),Ct.forEach(t),Fp=h(B),ft=a(B,"DIV",{class:!0});var Xd=d(ft);y(ko.$$.fragment,Xd),xp=h(Xd),qo=a(Xd,"P",{});var Vd=d(qo);jp=n(Vd,"Implements RAG sequence \u201Cthorough\u201D decoding. Read the "),Nn=a(Vd,"A",{href:!0});var B_=d(Nn);Jp=n(B_,"generate()"),B_.forEach(t),Gp=n(Vd,"` documentation\nfor more information on how to set other generate input parameters."),Vd.forEach(t),Xd.forEach(t),B.forEach(t),md=h(r),Ze=a(r,"H2",{class:!0});var Bd=d(Ze);_t=a(Bd,"A",{id:!0,class:!0,href:!0});var S_=d(_t);ks=a(S_,"SPAN",{});var P_=d(ks);y(Fo.$$.fragment,P_),P_.forEach(t),S_.forEach(t),zp=h(Bd),qs=a(Bd,"SPAN",{});var H_=d(qs);Up=n(H_,"RagTokenForGeneration"),H_.forEach(t),Bd.forEach(t),gd=h(r),G=a(r,"DIV",{class:!0});var P=d(G);y(xo.$$.fragment,P),Ep=h(P),Ie=a(P,"P",{});var kr=d(Ie);$p=n(kr,"The "),An=a(kr,"A",{href:!0});var L_=d(An);Zp=n(L_,"RagTokenForGeneration"),L_.forEach(t),Ip=n(kr," forward method, overrides the "),Fs=a(kr,"CODE",{});var O_=d(Fs);Cp=n(O_,"__call__"),O_.forEach(t),Np=n(kr," special method."),kr.forEach(t),Ap=h(P),y(vt.$$.fragment,P),Wp=h(P),xs=a(P,"P",{});var Y_=d(xs);Xp=n(Y_,"A RAG-token model implementation. It performs RAG-token specific marginalization in the forward pass."),Y_.forEach(t),Vp=h(P),js=a(P,"P",{});var Q_=d(js);Bp=n(Q_,`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.`),Q_.forEach(t),Sp=h(P),ne=a(P,"P",{});var be=d(ne);Pp=n(be,"The question encoder can be any "),Js=a(be,"EM",{});var D_=d(Js);Hp=n(D_,"autoencoding"),D_.forEach(t),Lp=n(be," model, preferably "),Wn=a(be,"A",{href:!0});var K_=d(Wn);Op=n(K_,"DPRQuestionEncoder"),K_.forEach(t),Yp=n(be,`, and the generator can be
any `),Gs=a(be,"EM",{});var ev=d(Gs);Qp=n(ev,"seq2seq"),ev.forEach(t),Dp=n(be," model, preferably "),Xn=a(be,"A",{href:!0});var tv=d(Xn);Kp=n(tv,"BartForConditionalGeneration"),tv.forEach(t),eh=n(be,"."),be.forEach(t),th=h(P),$=a(P,"P",{});var H=d($);oh=n(H,"The model can be initialized with a "),Vn=a(H,"A",{href:!0});var ov=d(Vn);nh=n(ov,"RagRetriever"),ov.forEach(t),rh=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
`),zs=a(H,"EM",{});var nv=d(zs);sh=n(nv,"autoencoding"),nv.forEach(t),ah=n(H," model as the "),Us=a(H,"CODE",{});var rv=d(Us);dh=n(rv,"question_encoder"),rv.forEach(t),ih=n(H," and any "),Es=a(H,"EM",{});var sv=d(Es);ch=n(sv,"seq2seq"),sv.forEach(t),lh=n(H," model with language model head as the "),$s=a(H,"CODE",{});var av=d($s);ph=n(av,"generator"),av.forEach(t),hh=n(H,`.
It has been tested with `),Bn=a(H,"A",{href:!0});var dv=d(Bn);uh=n(dv,"DPRQuestionEncoder"),dv.forEach(t),mh=n(H," as the "),Zs=a(H,"CODE",{});var iv=d(Zs);gh=n(iv,"question_encoder"),iv.forEach(t),fh=n(H," and "),Sn=a(H,"A",{href:!0});var cv=d(Sn);_h=n(cv,"BartForConditionalGeneration"),cv.forEach(t),vh=n(H,` or
`),Pn=a(H,"A",{href:!0});var lv=d(Pn);bh=n(lv,"T5ForConditionalGeneration"),lv.forEach(t),Th=n(H," as the "),Is=a(H,"CODE",{});var pv=d(Is);yh=n(pv,"generator"),pv.forEach(t),wh=n(H,"."),H.forEach(t),Mh=h(P),jo=a(P,"P",{});var Sd=d(jo);Rh=n(Sd,"This model inherits from "),Hn=a(Sd,"A",{href:!0});var hv=d(Hn);kh=n(hv,"PreTrainedModel"),hv.forEach(t),qh=n(Sd,`. 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.)`),Sd.forEach(t),Fh=h(P),Jo=a(P,"P",{});var Pd=d(Jo);xh=n(Pd,"This model is also a PyTorch "),Go=a(Pd,"A",{href:!0,rel:!0});var uv=d(Go);jh=n(uv,"torch.nn.Module"),uv.forEach(t),Jh=n(Pd,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Pd.forEach(t),Gh=h(P),le=a(P,"DIV",{class:!0});var Nt=d(le);y(zo.$$.fragment,Nt),zh=h(Nt),Ce=a(Nt,"P",{});var qr=d(Ce);Uh=n(qr,"The "),Ln=a(qr,"A",{href:!0});var mv=d(Ln);Eh=n(mv,"RagTokenForGeneration"),mv.forEach(t),$h=n(qr," forward method, overrides the "),Cs=a(qr,"CODE",{});var gv=d(Cs);Zh=n(gv,"__call__"),gv.forEach(t),Ih=n(qr," special method."),qr.forEach(t),Ch=h(Nt),y(bt.$$.fragment,Nt),Nh=h(Nt),y(Tt.$$.fragment,Nt),Nt.forEach(t),Ah=h(P),yt=a(P,"DIV",{class:!0});var Hd=d(yt);y(Uo.$$.fragment,Hd),Wh=h(Hd),Ns=a(Hd,"P",{});var fv=d(Ns);Xh=n(fv,"Implements RAG token decoding."),fv.forEach(t),Hd.forEach(t),P.forEach(t),fd=h(r),Ne=a(r,"H2",{class:!0});var Ld=d(Ne);wt=a(Ld,"A",{id:!0,class:!0,href:!0});var _v=d(wt);As=a(_v,"SPAN",{});var vv=d(As);y(Eo.$$.fragment,vv),vv.forEach(t),_v.forEach(t),Vh=h(Ld),Ws=a(Ld,"SPAN",{});var bv=d(Ws);Bh=n(bv,"TFRagModel"),bv.forEach(t),Ld.forEach(t),_d=h(r),Z=a(r,"DIV",{class:!0});var L=d(Z);y($o.$$.fragment,L),Sh=h(L),Ae=a(L,"P",{});var Fr=d(Ae);Ph=n(Fr,"The "),On=a(Fr,"A",{href:!0});var Tv=d(On);Hh=n(Tv,"TFRagModel"),Tv.forEach(t),Lh=n(Fr," forward method, overrides the "),Xs=a(Fr,"CODE",{});var yv=d(Xs);Oh=n(yv,"__call__"),yv.forEach(t),Yh=n(Fr," special method."),Fr.forEach(t),Qh=h(L),y(Mt.$$.fragment,L),Dh=h(L),Vs=a(L,"P",{});var wv=d(Vs);Kh=n(wv,`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.`),wv.forEach(t),eu=h(L),re=a(L,"P",{});var Te=d(re);tu=n(Te,"The question encoder can be any "),Bs=a(Te,"EM",{});var Mv=d(Bs);ou=n(Mv,"autoencoding"),Mv.forEach(t),nu=n(Te," model, preferably "),Yn=a(Te,"A",{href:!0});var Rv=d(Yn);ru=n(Rv,"TFDPRQuestionEncoder"),Rv.forEach(t),su=n(Te,`, and the generator can be
any `),Ss=a(Te,"EM",{});var kv=d(Ss);au=n(kv,"seq2seq"),kv.forEach(t),du=n(Te," model, preferably "),Qn=a(Te,"A",{href:!0});var qv=d(Qn);iu=n(qv,"TFBartForConditionalGeneration"),qv.forEach(t),cu=n(Te,"."),Te.forEach(t),lu=h(L),A=a(L,"P",{});var O=d(A);pu=n(O,"The model can be initialized with a "),Dn=a(O,"A",{href:!0});var Fv=d(Dn);hu=n(Fv,"RagRetriever"),Fv.forEach(t),uu=n(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
`),Ps=a(O,"EM",{});var xv=d(Ps);mu=n(xv,"autoencoding"),xv.forEach(t),gu=n(O," model as the "),Hs=a(O,"CODE",{});var jv=d(Hs);fu=n(jv,"question_encoder"),jv.forEach(t),_u=n(O," and any "),Ls=a(O,"EM",{});var Jv=d(Ls);vu=n(Jv,"seq2seq"),Jv.forEach(t),bu=n(O," model with language model head as the "),Os=a(O,"CODE",{});var Gv=d(Os);Tu=n(Gv,"generator"),Gv.forEach(t),yu=n(O,`.
It has been tested with `),Kn=a(O,"A",{href:!0});var zv=d(Kn);wu=n(zv,"TFDPRQuestionEncoder"),zv.forEach(t),Mu=n(O," as the "),Ys=a(O,"CODE",{});var Uv=d(Ys);Ru=n(Uv,"question_encoder"),Uv.forEach(t),ku=n(O," and "),er=a(O,"A",{href:!0});var Ev=d(er);qu=n(Ev,"TFBartForConditionalGeneration"),Ev.forEach(t),Fu=n(O,`
as the `),Qs=a(O,"CODE",{});var $v=d(Qs);xu=n($v,"generator"),$v.forEach(t),ju=n(O,"."),O.forEach(t),Ju=h(L),Zo=a(L,"P",{});var Od=d(Zo);Gu=n(Od,"This model inherits from "),tr=a(Od,"A",{href:!0});var Zv=d(tr);zu=n(Zv,"TFPreTrainedModel"),Zv.forEach(t),Uu=n(Od,`. 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.)`),Od.forEach(t),Eu=h(L),Io=a(L,"P",{});var Yd=d(Io);$u=n(Yd,"This model is also a Tensorflow "),Co=a(Yd,"A",{href:!0,rel:!0});var Iv=d(Co);Zu=n(Iv,"tf.keras.Model"),Iv.forEach(t),Iu=n(Yd,`
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.`),Yd.forEach(t),Cu=h(L),Ds=a(L,"P",{});var Cv=d(Ds);Nu=n(Cv,`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.`),Cv.forEach(t),Au=h(L),pe=a(L,"DIV",{class:!0});var At=d(pe);y(No.$$.fragment,At),Wu=h(At),We=a(At,"P",{});var xr=d(We);Xu=n(xr,"The "),or=a(xr,"A",{href:!0});var Nv=d(or);Vu=n(Nv,"TFRagModel"),Nv.forEach(t),Bu=n(xr," forward method, overrides the "),Ks=a(xr,"CODE",{});var Av=d(Ks);Su=n(Av,"__call__"),Av.forEach(t),Pu=n(xr," special method."),xr.forEach(t),Hu=h(At),y(Rt.$$.fragment,At),Lu=h(At),y(kt.$$.fragment,At),At.forEach(t),L.forEach(t),vd=h(r),Xe=a(r,"H2",{class:!0});var Qd=d(Xe);qt=a(Qd,"A",{id:!0,class:!0,href:!0});var Wv=d(qt);ea=a(Wv,"SPAN",{});var Xv=d(ea);y(Ao.$$.fragment,Xv),Xv.forEach(t),Wv.forEach(t),Ou=h(Qd),ta=a(Qd,"SPAN",{});var Vv=d(ta);Yu=n(Vv,"TFRagSequenceForGeneration"),Vv.forEach(t),Qd.forEach(t),bd=h(r),x=a(r,"DIV",{class:!0});var I=d(x);y(Wo.$$.fragment,I),Qu=h(I),Ve=a(I,"P",{});var jr=d(Ve);Du=n(jr,"The "),nr=a(jr,"A",{href:!0});var Bv=d(nr);Ku=n(Bv,"TFRagSequenceForGeneration"),Bv.forEach(t),em=n(jr," forward method, overrides the "),oa=a(jr,"CODE",{});var Sv=d(oa);tm=n(Sv,"__call__"),Sv.forEach(t),om=n(jr," special method."),jr.forEach(t),nm=h(I),y(Ft.$$.fragment,I),rm=h(I),na=a(I,"P",{});var Pv=d(na);sm=n(Pv,"A TF RAG-sequence model implementation. It performs RAG-sequence specific marginalization in the forward pass."),Pv.forEach(t),am=h(I),ra=a(I,"P",{});var Hv=d(ra);dm=n(Hv,`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.`),Hv.forEach(t),im=h(I),se=a(I,"P",{});var ye=d(se);cm=n(ye,"The question encoder can be any "),sa=a(ye,"EM",{});var Lv=d(sa);lm=n(Lv,"autoencoding"),Lv.forEach(t),pm=n(ye," model, preferably "),rr=a(ye,"A",{href:!0});var Ov=d(rr);hm=n(Ov,"TFDPRQuestionEncoder"),Ov.forEach(t),um=n(ye,`, and the generator can be
any `),aa=a(ye,"EM",{});var Yv=d(aa);mm=n(Yv,"seq2seq"),Yv.forEach(t),gm=n(ye," model, preferably "),sr=a(ye,"A",{href:!0});var Qv=d(sr);fm=n(Qv,"TFBartForConditionalGeneration"),Qv.forEach(t),_m=n(ye,"."),ye.forEach(t),vm=h(I),W=a(I,"P",{});var Y=d(W);bm=n(Y,"The model can be initialized with a "),ar=a(Y,"A",{href:!0});var Dv=d(ar);Tm=n(Dv,"RagRetriever"),Dv.forEach(t),ym=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
`),da=a(Y,"EM",{});var Kv=d(da);wm=n(Kv,"autoencoding"),Kv.forEach(t),Mm=n(Y," model as the "),ia=a(Y,"CODE",{});var eb=d(ia);Rm=n(eb,"question_encoder"),eb.forEach(t),km=n(Y," and any "),ca=a(Y,"EM",{});var tb=d(ca);qm=n(tb,"seq2seq"),tb.forEach(t),Fm=n(Y," model with language model head as the "),la=a(Y,"CODE",{});var ob=d(la);xm=n(ob,"generator"),ob.forEach(t),jm=n(Y,`.
It has been tested with `),dr=a(Y,"A",{href:!0});var nb=d(dr);Jm=n(nb,"TFDPRQuestionEncoder"),nb.forEach(t),Gm=n(Y," as the "),pa=a(Y,"CODE",{});var rb=d(pa);zm=n(rb,"question_encoder"),rb.forEach(t),Um=n(Y," and "),ir=a(Y,"A",{href:!0});var sb=d(ir);Em=n(sb,"TFBartForConditionalGeneration"),sb.forEach(t),$m=n(Y,`
as the `),ha=a(Y,"CODE",{});var ab=d(ha);Zm=n(ab,"generator"),ab.forEach(t),Im=n(Y,"."),Y.forEach(t),Cm=h(I),Xo=a(I,"P",{});var Dd=d(Xo);Nm=n(Dd,"This model inherits from "),cr=a(Dd,"A",{href:!0});var db=d(cr);Am=n(db,"TFPreTrainedModel"),db.forEach(t),Wm=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),Xm=h(I),Vo=a(I,"P",{});var Kd=d(Vo);Vm=n(Kd,"This model is also a Tensorflow "),Bo=a(Kd,"A",{href:!0,rel:!0});var ib=d(Bo);Bm=n(ib,"tf.keras.Model"),ib.forEach(t),Sm=n(Kd,`
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.`),Kd.forEach(t),Pm=h(I),ua=a(I,"P",{});var cb=d(ua);Hm=n(cb,`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.`),cb.forEach(t),Lm=h(I),he=a(I,"DIV",{class:!0});var Wt=d(he);y(So.$$.fragment,Wt),Om=h(Wt),Be=a(Wt,"P",{});var Jr=d(Be);Ym=n(Jr,"The "),lr=a(Jr,"A",{href:!0});var lb=d(lr);Qm=n(lb,"TFRagSequenceForGeneration"),lb.forEach(t),Dm=n(Jr," forward method, overrides the "),ma=a(Jr,"CODE",{});var pb=d(ma);Km=n(pb,"__call__"),pb.forEach(t),eg=n(Jr," special method."),Jr.forEach(t),tg=h(Wt),y(xt.$$.fragment,Wt),og=h(Wt),y(jt.$$.fragment,Wt),Wt.forEach(t),ng=h(I),Jt=a(I,"DIV",{class:!0});var ei=d(Jt);y(Po.$$.fragment,ei),rg=h(ei),Ho=a(ei,"P",{});var ti=d(Ho);sg=n(ti,"Implements RAG sequence \u201Cthorough\u201D decoding. Read the "),pr=a(ti,"A",{href:!0});var hb=d(pr);ag=n(hb,"generate()"),hb.forEach(t),dg=n(ti,"` documentation\nfor more information on how to set other generate input parameters"),ti.forEach(t),ei.forEach(t),I.forEach(t),Td=h(r),Se=a(r,"H2",{class:!0});var oi=d(Se);Gt=a(oi,"A",{id:!0,class:!0,href:!0});var ub=d(Gt);ga=a(ub,"SPAN",{});var mb=d(ga);y(Lo.$$.fragment,mb),mb.forEach(t),ub.forEach(t),ig=h(oi),fa=a(oi,"SPAN",{});var gb=d(fa);cg=n(gb,"TFRagTokenForGeneration"),gb.forEach(t),oi.forEach(t),yd=h(r),j=a(r,"DIV",{class:!0});var C=d(j);y(Oo.$$.fragment,C),lg=h(C),Pe=a(C,"P",{});var Gr=d(Pe);pg=n(Gr,"The "),hr=a(Gr,"A",{href:!0});var fb=d(hr);hg=n(fb,"TFRagTokenForGeneration"),fb.forEach(t),ug=n(Gr," forward method, overrides the "),_a=a(Gr,"CODE",{});var _b=d(_a);mg=n(_b,"__call__"),_b.forEach(t),gg=n(Gr," special method."),Gr.forEach(t),fg=h(C),y(zt.$$.fragment,C),_g=h(C),va=a(C,"P",{});var vb=d(va);vg=n(vb,"A TF RAG-token model implementation. It performs RAG-token specific marginalization in the forward pass."),vb.forEach(t),bg=h(C),ba=a(C,"P",{});var bb=d(ba);Tg=n(bb,`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.`),bb.forEach(t),yg=h(C),ae=a(C,"P",{});var we=d(ae);wg=n(we,"The question encoder can be any "),Ta=a(we,"EM",{});var Tb=d(Ta);Mg=n(Tb,"autoencoding"),Tb.forEach(t),Rg=n(we," model, preferably "),ur=a(we,"A",{href:!0});var yb=d(ur);kg=n(yb,"TFDPRQuestionEncoder"),yb.forEach(t),qg=n(we,`, and the generator can be
any `),ya=a(we,"EM",{});var wb=d(ya);Fg=n(wb,"seq2seq"),wb.forEach(t),xg=n(we," model, preferably "),mr=a(we,"A",{href:!0});var Mb=d(mr);jg=n(Mb,"TFBartForConditionalGeneration"),Mb.forEach(t),Jg=n(we,"."),we.forEach(t),Gg=h(C),X=a(C,"P",{});var Q=d(X);zg=n(Q,"The model can be initialized with a "),gr=a(Q,"A",{href:!0});var Rb=d(gr);Ug=n(Rb,"RagRetriever"),Rb.forEach(t),Eg=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
`),wa=a(Q,"EM",{});var kb=d(wa);$g=n(kb,"autoencoding"),kb.forEach(t),Zg=n(Q," model as the "),Ma=a(Q,"CODE",{});var qb=d(Ma);Ig=n(qb,"question_encoder"),qb.forEach(t),Cg=n(Q," and any "),Ra=a(Q,"EM",{});var Fb=d(Ra);Ng=n(Fb,"seq2seq"),Fb.forEach(t),Ag=n(Q," model with language model head as the "),ka=a(Q,"CODE",{});var xb=d(ka);Wg=n(xb,"generator"),xb.forEach(t),Xg=n(Q,`.
It has been tested with `),fr=a(Q,"A",{href:!0});var jb=d(fr);Vg=n(jb,"TFDPRQuestionEncoder"),jb.forEach(t),Bg=n(Q," as the "),qa=a(Q,"CODE",{});var Jb=d(qa);Sg=n(Jb,"question_encoder"),Jb.forEach(t),Pg=n(Q," and "),_r=a(Q,"A",{href:!0});var Gb=d(_r);Hg=n(Gb,"TFBartForConditionalGeneration"),Gb.forEach(t),Lg=n(Q,`
as the `),Fa=a(Q,"CODE",{});var zb=d(Fa);Og=n(zb,"generator"),zb.forEach(t),Yg=n(Q,"."),Q.forEach(t),Qg=h(C),Yo=a(C,"P",{});var ni=d(Yo);Dg=n(ni,"This model inherits from "),vr=a(ni,"A",{href:!0});var Ub=d(vr);Kg=n(Ub,"TFPreTrainedModel"),Ub.forEach(t),ef=n(ni,`. 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.)`),ni.forEach(t),tf=h(C),Qo=a(C,"P",{});var ri=d(Qo);of=n(ri,"This model is also a Tensorflow "),Do=a(ri,"A",{href:!0,rel:!0});var Eb=d(Do);nf=n(Eb,"tf.keras.Model"),Eb.forEach(t),rf=n(ri,`
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.`),ri.forEach(t),sf=h(C),xa=a(C,"P",{});var $b=d(xa);af=n($b,`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.`),$b.forEach(t),df=h(C),ue=a(C,"DIV",{class:!0});var Xt=d(ue);y(Ko.$$.fragment,Xt),cf=h(Xt),He=a(Xt,"P",{});var zr=d(He);lf=n(zr,"The "),br=a(zr,"A",{href:!0});var Zb=d(br);pf=n(Zb,"TFRagTokenForGeneration"),Zb.forEach(t),hf=n(zr," forward method, overrides the "),ja=a(zr,"CODE",{});var Ib=d(ja);uf=n(Ib,"__call__"),Ib.forEach(t),mf=n(zr," special method."),zr.forEach(t),gf=h(Xt),y(Ut.$$.fragment,Xt),ff=h(Xt),y(Et.$$.fragment,Xt),Xt.forEach(t),_f=h(C),$t=a(C,"DIV",{class:!0});var si=d($t);y(en.$$.fragment,si),vf=h(si),Ja=a(si,"P",{});var Cb=d(Ja);bf=n(Cb,"Implements TFRAG token decoding."),Cb.forEach(t),si.forEach(t),C.forEach(t),this.h()},h(){l(c,"name","hf:doc:metadata"),l(c,"content",JSON.stringify(pT)),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(m,"class","relative group"),l(ln,"alt","Models"),Vb(ln.src,Tf="https://img.shields.io/badge/All_model_pages-rag-blueviolet")||l(ln,"src",Tf),l(cn,"href","https://huggingface.co/models?filter=rag"),l(Vt,"class","flex flex-wrap space-x-1"),l(Oe,"id","overview"),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","#overview"),l(Me,"class","relative group"),l(St,"href","https://arxiv.org/abs/2005.11401"),l(St,"rel","nofollow"),l(Pt,"href","https://huggingface.co/ola13"),l(Pt,"rel","nofollow"),l(De,"id","transformers.RagConfig"),l(De,"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(De,"href","#transformers.RagConfig"),l(Re,"class","relative group"),l(fn,"href","/docs/transformers/v4.30.0/en/model_doc/rag#transformers.RagConfig"),l(_n,"href","/docs/transformers/v4.30.0/en/main_classes/configuration#transformers.PretrainedConfig"),l(vn,"href","/docs/transformers/v4.30.0/en/main_classes/configuration#transformers.PretrainedConfig"),l(bn,"href","/docs/transformers/v4.30.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(Tn,"href","/docs/transformers/v4.30.0/en/main_classes/configuration#transformers.PretrainedConfig.to_dict"),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(ee,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(tt,"id","transformers.RagTokenizer"),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.RagTokenizer"),l(ke,"class","relative group"),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.models.rag.modeling_rag.RetrievAugLMMarginOutput"),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.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(ro,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(nt,"id","transformers.RagRetriever"),l(nt,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(nt,"href","#transformers.RagRetriever"),l(xe,"class","relative group"),l(st,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(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(dt,"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(it,"id","transformers.RagModel"),l(it,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(it,"href","#transformers.RagModel"),l(Je,"class","relative group"),l(yn,"href","/docs/transformers/v4.30.0/en/model_doc/rag#transformers.RagModel"),l(wn,"href","/docs/transformers/v4.30.0/en/model_doc/dpr#transformers.DPRQuestionEncoder"),l(Mn,"href","/docs/transformers/v4.30.0/en/model_doc/bart#transformers.BartForConditionalGeneration"),l(Rn,"href","/docs/transformers/v4.30.0/en/model_doc/rag#transformers.RagRetriever"),l(kn,"href","/docs/transformers/v4.30.0/en/model_doc/dpr#transformers.DPRQuestionEncoder"),l(qn,"href","/docs/transformers/v4.30.0/en/model_doc/bart#transformers.BartForConditionalGeneration"),l(Fn,"href","/docs/transformers/v4.30.0/en/model_doc/t5#transformers.T5ForConditionalGeneration"),l(xn,"href","/docs/transformers/v4.30.0/en/main_classes/model#transformers.PreTrainedModel"),l(_o,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),l(_o,"rel","nofollow"),l(jn,"href","/docs/transformers/v4.30.0/en/model_doc/rag#transformers.RagModel"),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(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(ht,"id","transformers.RagSequenceForGeneration"),l(ht,"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(ht,"href","#transformers.RagSequenceForGeneration"),l(Ue,"class","relative group"),l(Jn,"href","/docs/transformers/v4.30.0/en/model_doc/rag#transformers.RagSequenceForGeneration"),l(Gn,"href","/docs/transformers/v4.30.0/en/model_doc/dpr#transformers.DPRQuestionEncoder"),l(zn,"href","/docs/transformers/v4.30.0/en/model_doc/bart#transformers.BartForConditionalGeneration"),l(Un,"href","/docs/transformers/v4.30.0/en/model_doc/rag#transformers.RagRetriever"),l(En,"href","/docs/transformers/v4.30.0/en/model_doc/dpr#transformers.DPRQuestionEncoder"),l($n,"href","/docs/transformers/v4.30.0/en/model_doc/bart#transformers.BartForConditionalGeneration"),l(Zn,"href","/docs/transformers/v4.30.0/en/model_doc/t5#transformers.T5ForConditionalGeneration"),l(In,"href","/docs/transformers/v4.30.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(Cn,"href","/docs/transformers/v4.30.0/en/model_doc/rag#transformers.RagSequenceForGeneration"),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(Nn,"href","/docs/transformers/v4.30.0/en/main_classes/text_generation#transformers.GenerationMixin.generate"),l(ft,"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(_t,"id","transformers.RagTokenForGeneration"),l(_t,"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(_t,"href","#transformers.RagTokenForGeneration"),l(Ze,"class","relative group"),l(An,"href","/docs/transformers/v4.30.0/en/model_doc/rag#transformers.RagTokenForGeneration"),l(Wn,"href","/docs/transformers/v4.30.0/en/model_doc/dpr#transformers.DPRQuestionEncoder"),l(Xn,"href","/docs/transformers/v4.30.0/en/model_doc/bart#transformers.BartForConditionalGeneration"),l(Vn,"href","/docs/transformers/v4.30.0/en/model_doc/rag#transformers.RagRetriever"),l(Bn,"href","/docs/transformers/v4.30.0/en/model_doc/dpr#transformers.DPRQuestionEncoder"),l(Sn,"href","/docs/transformers/v4.30.0/en/model_doc/bart#transformers.BartForConditionalGeneration"),l(Pn,"href","/docs/transformers/v4.30.0/en/model_doc/t5#transformers.T5ForConditionalGeneration"),l(Hn,"href","/docs/transformers/v4.30.0/en/main_classes/model#transformers.PreTrainedModel"),l(Go,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),l(Go,"rel","nofollow"),l(Ln,"href","/docs/transformers/v4.30.0/en/model_doc/rag#transformers.RagTokenForGeneration"),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(yt,"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(wt,"id","transformers.TFRagModel"),l(wt,"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(wt,"href","#transformers.TFRagModel"),l(Ne,"class","relative group"),l(On,"href","/docs/transformers/v4.30.0/en/model_doc/rag#transformers.TFRagModel"),l(Yn,"href","/docs/transformers/v4.30.0/en/model_doc/dpr#transformers.TFDPRQuestionEncoder"),l(Qn,"href","/docs/transformers/v4.30.0/en/model_doc/bart#transformers.TFBartForConditionalGeneration"),l(Dn,"href","/docs/transformers/v4.30.0/en/model_doc/rag#transformers.RagRetriever"),l(Kn,"href","/docs/transformers/v4.30.0/en/model_doc/dpr#transformers.TFDPRQuestionEncoder"),l(er,"href","/docs/transformers/v4.30.0/en/model_doc/bart#transformers.TFBartForConditionalGeneration"),l(tr,"href","/docs/transformers/v4.30.0/en/main_classes/model#transformers.TFPreTrainedModel"),l(Co,"href","https://www.tensorflow.org/api_docs/python/tf/keras/Model"),l(Co,"rel","nofollow"),l(or,"href","/docs/transformers/v4.30.0/en/model_doc/rag#transformers.TFRagModel"),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(Z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(qt,"id","transformers.TFRagSequenceForGeneration"),l(qt,"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(qt,"href","#transformers.TFRagSequenceForGeneration"),l(Xe,"class","relative group"),l(nr,"href","/docs/transformers/v4.30.0/en/model_doc/rag#transformers.TFRagSequenceForGeneration"),l(rr,"href","/docs/transformers/v4.30.0/en/model_doc/dpr#transformers.TFDPRQuestionEncoder"),l(sr,"href","/docs/transformers/v4.30.0/en/model_doc/bart#transformers.TFBartForConditionalGeneration"),l(ar,"href","/docs/transformers/v4.30.0/en/model_doc/rag#transformers.RagRetriever"),l(dr,"href","/docs/transformers/v4.30.0/en/model_doc/dpr#transformers.TFDPRQuestionEncoder"),l(ir,"href","/docs/transformers/v4.30.0/en/model_doc/bart#transformers.TFBartForConditionalGeneration"),l(cr,"href","/docs/transformers/v4.30.0/en/main_classes/model#transformers.TFPreTrainedModel"),l(Bo,"href","https://www.tensorflow.org/api_docs/python/tf/keras/Model"),l(Bo,"rel","nofollow"),l(lr,"href","/docs/transformers/v4.30.0/en/model_doc/rag#transformers.TFRagSequenceForGeneration"),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(pr,"href","/docs/transformers/v4.30.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(Gt,"id","transformers.TFRagTokenForGeneration"),l(Gt,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(Gt,"href","#transformers.TFRagTokenForGeneration"),l(Se,"class","relative group"),l(hr,"href","/docs/transformers/v4.30.0/en/model_doc/rag#transformers.TFRagTokenForGeneration"),l(ur,"href","/docs/transformers/v4.30.0/en/model_doc/dpr#transformers.TFDPRQuestionEncoder"),l(mr,"href","/docs/transformers/v4.30.0/en/model_doc/bart#transformers.TFBartForConditionalGeneration"),l(gr,"href","/docs/transformers/v4.30.0/en/model_doc/rag#transformers.RagRetriever"),l(fr,"href","/docs/transformers/v4.30.0/en/model_doc/dpr#transformers.TFDPRQuestionEncoder"),l(_r,"href","/docs/transformers/v4.30.0/en/model_doc/bart#transformers.TFBartForConditionalGeneration"),l(vr,"href","/docs/transformers/v4.30.0/en/main_classes/model#transformers.TFPreTrainedModel"),l(Do,"href","https://www.tensorflow.org/api_docs/python/tf/keras/Model"),l(Do,"rel","nofollow"),l(br,"href","/docs/transformers/v4.30.0/en/model_doc/rag#transformers.TFRagTokenForGeneration"),l(ue,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l($t,"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,b,f),v(r,m,f),e(m,g),e(g,_),w(i,_,null),e(m,u),e(m,q),e(q,ai),v(r,Pa,f),v(r,Vt,f),e(Vt,cn),e(cn,ln),v(r,Ha,f),v(r,Me,f),e(Me,Oe),e(Oe,Ur),w(Bt,Ur,null),e(Me,di),e(Me,Er),e(Er,ii),v(r,La,f),v(r,pn,f),e(pn,ci),v(r,Oa,f),v(r,Ye,f),e(Ye,li),e(Ye,St),e(St,pi),e(Ye,hi),v(r,Ya,f),v(r,hn,f),e(hn,ui),v(r,Qa,f),v(r,un,f),e(un,$r),e($r,mi),v(r,Da,f),v(r,Qe,f),e(Qe,gi),e(Qe,Pt),e(Pt,fi),e(Qe,_i),v(r,Ka,f),v(r,mn,f),e(mn,vi),v(r,ed,f),v(r,gn,f),e(gn,Zr),e(Zr,bi),v(r,td,f),v(r,Re,f),e(Re,De),e(De,Ir),w(Ht,Ir,null),e(Re,Ti),e(Re,Cr),e(Cr,yi),v(r,od,f),v(r,ee,f),w(Lt,ee,null),e(ee,wi),e(ee,de),e(de,fn),e(fn,Mi),e(de,Ri),e(de,Nr),e(Nr,ki),e(de,qi),e(de,_n),e(_n,Fi),e(de,xi),e(de,vn),e(vn,ji),e(de,Ji),e(ee,Gi),e(ee,Ke),w(Ot,Ke,null),e(Ke,zi),e(Ke,Yt),e(Yt,Ui),e(Yt,bn),e(bn,Ei),e(Yt,$i),e(ee,Zi),e(ee,et),w(Qt,et,null),e(et,Ii),e(et,Dt),e(Dt,Ci),e(Dt,Tn),e(Tn,Ni),e(Dt,Ai),v(r,nd,f),v(r,ke,f),e(ke,tt),e(tt,Ar),w(Kt,Ar,null),e(ke,Wi),e(ke,Wr),e(Wr,Xi),v(r,rd,f),v(r,eo,f),w(to,eo,null),v(r,sd,f),v(r,qe,f),e(qe,ot),e(ot,Xr),w(oo,Xr,null),e(qe,Vi),e(qe,Vr),e(Vr,Bi),v(r,ad,f),v(r,Fe,f),w(no,Fe,null),e(Fe,Si),e(Fe,Br),e(Br,Pi),v(r,dd,f),v(r,ro,f),w(so,ro,null),v(r,id,f),v(r,xe,f),e(xe,nt),e(nt,Sr),w(ao,Sr,null),e(xe,Hi),e(xe,Pr),e(Pr,Li),v(r,cd,f),v(r,K,f),w(io,K,null),e(K,Oi),e(K,Hr),e(Hr,Yi),e(K,Qi),w(rt,K,null),e(K,Di),e(K,st),w(co,st,null),e(st,Ki),e(st,Lr),e(Lr,ec),e(K,tc),e(K,at),w(lo,at,null),e(at,oc),e(at,je),e(je,nc),e(je,Or),e(Or,rc),e(je,sc),e(je,Yr),e(Yr,ac),e(je,dc),e(K,ic),e(K,dt),w(po,dt,null),e(dt,cc),e(dt,ho),e(ho,lc),e(ho,Qr),e(Qr,pc),e(ho,hc),v(r,ld,f),v(r,Je,f),e(Je,it),e(it,Dr),w(uo,Dr,null),e(Je,uc),e(Je,Kr),e(Kr,mc),v(r,pd,f),v(r,N,f),w(mo,N,null),e(N,gc),e(N,Ge),e(Ge,fc),e(Ge,yn),e(yn,_c),e(Ge,vc),e(Ge,es),e(es,bc),e(Ge,Tc),e(N,yc),w(ct,N,null),e(N,wc),e(N,ts),e(ts,Mc),e(N,Rc),e(N,te),e(te,kc),e(te,os),e(os,qc),e(te,Fc),e(te,wn),e(wn,xc),e(te,jc),e(te,ns),e(ns,Jc),e(te,Gc),e(te,Mn),e(Mn,zc),e(te,Uc),e(N,Ec),e(N,U),e(U,$c),e(U,Rn),e(Rn,Zc),e(U,Ic),e(U,rs),e(rs,Cc),e(U,Nc),e(U,ss),e(ss,Ac),e(U,Wc),e(U,as),e(as,Xc),e(U,Vc),e(U,ds),e(ds,Bc),e(U,Sc),e(U,kn),e(kn,Pc),e(U,Hc),e(U,is),e(is,Lc),e(U,Oc),e(U,qn),e(qn,Yc),e(U,Qc),e(U,Fn),e(Fn,Dc),e(U,Kc),e(U,cs),e(cs,el),e(U,tl),e(N,ol),e(N,go),e(go,nl),e(go,xn),e(xn,rl),e(go,sl),e(N,al),e(N,fo),e(fo,dl),e(fo,_o),e(_o,il),e(fo,cl),e(N,ll),e(N,ie),w(vo,ie,null),e(ie,pl),e(ie,ze),e(ze,hl),e(ze,jn),e(jn,ul),e(ze,ml),e(ze,ls),e(ls,gl),e(ze,fl),e(ie,_l),w(lt,ie,null),e(ie,vl),w(pt,ie,null),v(r,hd,f),v(r,Ue,f),e(Ue,ht),e(ht,ps),w(bo,ps,null),e(Ue,bl),e(Ue,hs),e(hs,Tl),v(r,ud,f),v(r,J,f),w(To,J,null),e(J,yl),e(J,Ee),e(Ee,wl),e(Ee,Jn),e(Jn,Ml),e(Ee,Rl),e(Ee,us),e(us,kl),e(Ee,ql),e(J,Fl),w(ut,J,null),e(J,xl),e(J,ms),e(ms,jl),e(J,Jl),e(J,gs),e(gs,Gl),e(J,zl),e(J,oe),e(oe,Ul),e(oe,fs),e(fs,El),e(oe,$l),e(oe,Gn),e(Gn,Zl),e(oe,Il),e(oe,_s),e(_s,Cl),e(oe,Nl),e(oe,zn),e(zn,Al),e(oe,Wl),e(J,Xl),e(J,E),e(E,Vl),e(E,Un),e(Un,Bl),e(E,Sl),e(E,vs),e(vs,Pl),e(E,Hl),e(E,bs),e(bs,Ll),e(E,Ol),e(E,Ts),e(Ts,Yl),e(E,Ql),e(E,ys),e(ys,Dl),e(E,Kl),e(E,En),e(En,ep),e(E,tp),e(E,ws),e(ws,op),e(E,np),e(E,$n),e($n,rp),e(E,sp),e(E,Zn),e(Zn,ap),e(E,dp),e(E,Ms),e(Ms,ip),e(E,cp),e(J,lp),e(J,yo),e(yo,pp),e(yo,In),e(In,hp),e(yo,up),e(J,mp),e(J,wo),e(wo,gp),e(wo,Mo),e(Mo,fp),e(wo,_p),e(J,vp),e(J,ce),w(Ro,ce,null),e(ce,bp),e(ce,$e),e($e,Tp),e($e,Cn),e(Cn,yp),e($e,wp),e($e,Rs),e(Rs,Mp),e($e,Rp),e(ce,kp),w(mt,ce,null),e(ce,qp),w(gt,ce,null),e(J,Fp),e(J,ft),w(ko,ft,null),e(ft,xp),e(ft,qo),e(qo,jp),e(qo,Nn),e(Nn,Jp),e(qo,Gp),v(r,md,f),v(r,Ze,f),e(Ze,_t),e(_t,ks),w(Fo,ks,null),e(Ze,zp),e(Ze,qs),e(qs,Up),v(r,gd,f),v(r,G,f),w(xo,G,null),e(G,Ep),e(G,Ie),e(Ie,$p),e(Ie,An),e(An,Zp),e(Ie,Ip),e(Ie,Fs),e(Fs,Cp),e(Ie,Np),e(G,Ap),w(vt,G,null),e(G,Wp),e(G,xs),e(xs,Xp),e(G,Vp),e(G,js),e(js,Bp),e(G,Sp),e(G,ne),e(ne,Pp),e(ne,Js),e(Js,Hp),e(ne,Lp),e(ne,Wn),e(Wn,Op),e(ne,Yp),e(ne,Gs),e(Gs,Qp),e(ne,Dp),e(ne,Xn),e(Xn,Kp),e(ne,eh),e(G,th),e(G,$),e($,oh),e($,Vn),e(Vn,nh),e($,rh),e($,zs),e(zs,sh),e($,ah),e($,Us),e(Us,dh),e($,ih),e($,Es),e(Es,ch),e($,lh),e($,$s),e($s,ph),e($,hh),e($,Bn),e(Bn,uh),e($,mh),e($,Zs),e(Zs,gh),e($,fh),e($,Sn),e(Sn,_h),e($,vh),e($,Pn),e(Pn,bh),e($,Th),e($,Is),e(Is,yh),e($,wh),e(G,Mh),e(G,jo),e(jo,Rh),e(jo,Hn),e(Hn,kh),e(jo,qh),e(G,Fh),e(G,Jo),e(Jo,xh),e(Jo,Go),e(Go,jh),e(Jo,Jh),e(G,Gh),e(G,le),w(zo,le,null),e(le,zh),e(le,Ce),e(Ce,Uh),e(Ce,Ln),e(Ln,Eh),e(Ce,$h),e(Ce,Cs),e(Cs,Zh),e(Ce,Ih),e(le,Ch),w(bt,le,null),e(le,Nh),w(Tt,le,null),e(G,Ah),e(G,yt),w(Uo,yt,null),e(yt,Wh),e(yt,Ns),e(Ns,Xh),v(r,fd,f),v(r,Ne,f),e(Ne,wt),e(wt,As),w(Eo,As,null),e(Ne,Vh),e(Ne,Ws),e(Ws,Bh),v(r,_d,f),v(r,Z,f),w($o,Z,null),e(Z,Sh),e(Z,Ae),e(Ae,Ph),e(Ae,On),e(On,Hh),e(Ae,Lh),e(Ae,Xs),e(Xs,Oh),e(Ae,Yh),e(Z,Qh),w(Mt,Z,null),e(Z,Dh),e(Z,Vs),e(Vs,Kh),e(Z,eu),e(Z,re),e(re,tu),e(re,Bs),e(Bs,ou),e(re,nu),e(re,Yn),e(Yn,ru),e(re,su),e(re,Ss),e(Ss,au),e(re,du),e(re,Qn),e(Qn,iu),e(re,cu),e(Z,lu),e(Z,A),e(A,pu),e(A,Dn),e(Dn,hu),e(A,uu),e(A,Ps),e(Ps,mu),e(A,gu),e(A,Hs),e(Hs,fu),e(A,_u),e(A,Ls),e(Ls,vu),e(A,bu),e(A,Os),e(Os,Tu),e(A,yu),e(A,Kn),e(Kn,wu),e(A,Mu),e(A,Ys),e(Ys,Ru),e(A,ku),e(A,er),e(er,qu),e(A,Fu),e(A,Qs),e(Qs,xu),e(A,ju),e(Z,Ju),e(Z,Zo),e(Zo,Gu),e(Zo,tr),e(tr,zu),e(Zo,Uu),e(Z,Eu),e(Z,Io),e(Io,$u),e(Io,Co),e(Co,Zu),e(Io,Iu),e(Z,Cu),e(Z,Ds),e(Ds,Nu),e(Z,Au),e(Z,pe),w(No,pe,null),e(pe,Wu),e(pe,We),e(We,Xu),e(We,or),e(or,Vu),e(We,Bu),e(We,Ks),e(Ks,Su),e(We,Pu),e(pe,Hu),w(Rt,pe,null),e(pe,Lu),w(kt,pe,null),v(r,vd,f),v(r,Xe,f),e(Xe,qt),e(qt,ea),w(Ao,ea,null),e(Xe,Ou),e(Xe,ta),e(ta,Yu),v(r,bd,f),v(r,x,f),w(Wo,x,null),e(x,Qu),e(x,Ve),e(Ve,Du),e(Ve,nr),e(nr,Ku),e(Ve,em),e(Ve,oa),e(oa,tm),e(Ve,om),e(x,nm),w(Ft,x,null),e(x,rm),e(x,na),e(na,sm),e(x,am),e(x,ra),e(ra,dm),e(x,im),e(x,se),e(se,cm),e(se,sa),e(sa,lm),e(se,pm),e(se,rr),e(rr,hm),e(se,um),e(se,aa),e(aa,mm),e(se,gm),e(se,sr),e(sr,fm),e(se,_m),e(x,vm),e(x,W),e(W,bm),e(W,ar),e(ar,Tm),e(W,ym),e(W,da),e(da,wm),e(W,Mm),e(W,ia),e(ia,Rm),e(W,km),e(W,ca),e(ca,qm),e(W,Fm),e(W,la),e(la,xm),e(W,jm),e(W,dr),e(dr,Jm),e(W,Gm),e(W,pa),e(pa,zm),e(W,Um),e(W,ir),e(ir,Em),e(W,$m),e(W,ha),e(ha,Zm),e(W,Im),e(x,Cm),e(x,Xo),e(Xo,Nm),e(Xo,cr),e(cr,Am),e(Xo,Wm),e(x,Xm),e(x,Vo),e(Vo,Vm),e(Vo,Bo),e(Bo,Bm),e(Vo,Sm),e(x,Pm),e(x,ua),e(ua,Hm),e(x,Lm),e(x,he),w(So,he,null),e(he,Om),e(he,Be),e(Be,Ym),e(Be,lr),e(lr,Qm),e(Be,Dm),e(Be,ma),e(ma,Km),e(Be,eg),e(he,tg),w(xt,he,null),e(he,og),w(jt,he,null),e(x,ng),e(x,Jt),w(Po,Jt,null),e(Jt,rg),e(Jt,Ho),e(Ho,sg),e(Ho,pr),e(pr,ag),e(Ho,dg),v(r,Td,f),v(r,Se,f),e(Se,Gt),e(Gt,ga),w(Lo,ga,null),e(Se,ig),e(Se,fa),e(fa,cg),v(r,yd,f),v(r,j,f),w(Oo,j,null),e(j,lg),e(j,Pe),e(Pe,pg),e(Pe,hr),e(hr,hg),e(Pe,ug),e(Pe,_a),e(_a,mg),e(Pe,gg),e(j,fg),w(zt,j,null),e(j,_g),e(j,va),e(va,vg),e(j,bg),e(j,ba),e(ba,Tg),e(j,yg),e(j,ae),e(ae,wg),e(ae,Ta),e(Ta,Mg),e(ae,Rg),e(ae,ur),e(ur,kg),e(ae,qg),e(ae,ya),e(ya,Fg),e(ae,xg),e(ae,mr),e(mr,jg),e(ae,Jg),e(j,Gg),e(j,X),e(X,zg),e(X,gr),e(gr,Ug),e(X,Eg),e(X,wa),e(wa,$g),e(X,Zg),e(X,Ma),e(Ma,Ig),e(X,Cg),e(X,Ra),e(Ra,Ng),e(X,Ag),e(X,ka),e(ka,Wg),e(X,Xg),e(X,fr),e(fr,Vg),e(X,Bg),e(X,qa),e(qa,Sg),e(X,Pg),e(X,_r),e(_r,Hg),e(X,Lg),e(X,Fa),e(Fa,Og),e(X,Yg),e(j,Qg),e(j,Yo),e(Yo,Dg),e(Yo,vr),e(vr,Kg),e(Yo,ef),e(j,tf),e(j,Qo),e(Qo,of),e(Qo,Do),e(Do,nf),e(Qo,rf),e(j,sf),e(j,xa),e(xa,af),e(j,df),e(j,ue),w(Ko,ue,null),e(ue,cf),e(ue,He),e(He,lf),e(He,br),e(br,pf),e(He,hf),e(He,ja),e(ja,uf),e(He,mf),e(ue,gf),w(Ut,ue,null),e(ue,ff),w(Et,ue,null),e(j,_f),e(j,$t),w(en,$t,null),e($t,vf),e($t,Ja),e(Ja,bf),wd=!0},p(r,[f]){const tn={};f&2&&(tn.$$scope={dirty:f,ctx:r}),rt.$set(tn);const Ga={};f&2&&(Ga.$$scope={dirty:f,ctx:r}),ct.$set(Ga);const za={};f&2&&(za.$$scope={dirty:f,ctx:r}),lt.$set(za);const Ua={};f&2&&(Ua.$$scope={dirty:f,ctx:r}),pt.$set(Ua);const Ea={};f&2&&(Ea.$$scope={dirty:f,ctx:r}),ut.$set(Ea);const $a={};f&2&&($a.$$scope={dirty:f,ctx:r}),mt.$set($a);const on={};f&2&&(on.$$scope={dirty:f,ctx:r}),gt.$set(on);const Za={};f&2&&(Za.$$scope={dirty:f,ctx:r}),vt.$set(Za);const Ia={};f&2&&(Ia.$$scope={dirty:f,ctx:r}),bt.$set(Ia);const Ca={};f&2&&(Ca.$$scope={dirty:f,ctx:r}),Tt.$set(Ca);const Na={};f&2&&(Na.$$scope={dirty:f,ctx:r}),Mt.$set(Na);const nn={};f&2&&(nn.$$scope={dirty:f,ctx:r}),Rt.$set(nn);const Aa={};f&2&&(Aa.$$scope={dirty:f,ctx:r}),kt.$set(Aa);const Wa={};f&2&&(Wa.$$scope={dirty:f,ctx:r}),Ft.$set(Wa);const Xa={};f&2&&(Xa.$$scope={dirty:f,ctx:r}),xt.$set(Xa);const Va={};f&2&&(Va.$$scope={dirty:f,ctx:r}),jt.$set(Va);const rn={};f&2&&(rn.$$scope={dirty:f,ctx:r}),zt.$set(rn);const Ba={};f&2&&(Ba.$$scope={dirty:f,ctx:r}),Ut.$set(Ba);const Sa={};f&2&&(Sa.$$scope={dirty:f,ctx:r}),Et.$set(Sa)},i(r){wd||(M(i.$$.fragment,r),M(Bt.$$.fragment,r),M(Ht.$$.fragment,r),M(Lt.$$.fragment,r),M(Ot.$$.fragment,r),M(Qt.$$.fragment,r),M(Kt.$$.fragment,r),M(to.$$.fragment,r),M(oo.$$.fragment,r),M(no.$$.fragment,r),M(so.$$.fragment,r),M(ao.$$.fragment,r),M(io.$$.fragment,r),M(rt.$$.fragment,r),M(co.$$.fragment,r),M(lo.$$.fragment,r),M(po.$$.fragment,r),M(uo.$$.fragment,r),M(mo.$$.fragment,r),M(ct.$$.fragment,r),M(vo.$$.fragment,r),M(lt.$$.fragment,r),M(pt.$$.fragment,r),M(bo.$$.fragment,r),M(To.$$.fragment,r),M(ut.$$.fragment,r),M(Ro.$$.fragment,r),M(mt.$$.fragment,r),M(gt.$$.fragment,r),M(ko.$$.fragment,r),M(Fo.$$.fragment,r),M(xo.$$.fragment,r),M(vt.$$.fragment,r),M(zo.$$.fragment,r),M(bt.$$.fragment,r),M(Tt.$$.fragment,r),M(Uo.$$.fragment,r),M(Eo.$$.fragment,r),M($o.$$.fragment,r),M(Mt.$$.fragment,r),M(No.$$.fragment,r),M(Rt.$$.fragment,r),M(kt.$$.fragment,r),M(Ao.$$.fragment,r),M(Wo.$$.fragment,r),M(Ft.$$.fragment,r),M(So.$$.fragment,r),M(xt.$$.fragment,r),M(jt.$$.fragment,r),M(Po.$$.fragment,r),M(Lo.$$.fragment,r),M(Oo.$$.fragment,r),M(zt.$$.fragment,r),M(Ko.$$.fragment,r),M(Ut.$$.fragment,r),M(Et.$$.fragment,r),M(en.$$.fragment,r),wd=!0)},o(r){R(i.$$.fragment,r),R(Bt.$$.fragment,r),R(Ht.$$.fragment,r),R(Lt.$$.fragment,r),R(Ot.$$.fragment,r),R(Qt.$$.fragment,r),R(Kt.$$.fragment,r),R(to.$$.fragment,r),R(oo.$$.fragment,r),R(no.$$.fragment,r),R(so.$$.fragment,r),R(ao.$$.fragment,r),R(io.$$.fragment,r),R(rt.$$.fragment,r),R(co.$$.fragment,r),R(lo.$$.fragment,r),R(po.$$.fragment,r),R(uo.$$.fragment,r),R(mo.$$.fragment,r),R(ct.$$.fragment,r),R(vo.$$.fragment,r),R(lt.$$.fragment,r),R(pt.$$.fragment,r),R(bo.$$.fragment,r),R(To.$$.fragment,r),R(ut.$$.fragment,r),R(Ro.$$.fragment,r),R(mt.$$.fragment,r),R(gt.$$.fragment,r),R(ko.$$.fragment,r),R(Fo.$$.fragment,r),R(xo.$$.fragment,r),R(vt.$$.fragment,r),R(zo.$$.fragment,r),R(bt.$$.fragment,r),R(Tt.$$.fragment,r),R(Uo.$$.fragment,r),R(Eo.$$.fragment,r),R($o.$$.fragment,r),R(Mt.$$.fragment,r),R(No.$$.fragment,r),R(Rt.$$.fragment,r),R(kt.$$.fragment,r),R(Ao.$$.fragment,r),R(Wo.$$.fragment,r),R(Ft.$$.fragment,r),R(So.$$.fragment,r),R(xt.$$.fragment,r),R(jt.$$.fragment,r),R(Po.$$.fragment,r),R(Lo.$$.fragment,r),R(Oo.$$.fragment,r),R(zt.$$.fragment,r),R(Ko.$$.fragment,r),R(Ut.$$.fragment,r),R(Et.$$.fragment,r),R(en.$$.fragment,r),wd=!1},d(r){t(c),r&&t(b),r&&t(m),k(i),r&&t(Pa),r&&t(Vt),r&&t(Ha),r&&t(Me),k(Bt),r&&t(La),r&&t(pn),r&&t(Oa),r&&t(Ye),r&&t(Ya),r&&t(hn),r&&t(Qa),r&&t(un),r&&t(Da),r&&t(Qe),r&&t(Ka),r&&t(mn),r&&t(ed),r&&t(gn),r&&t(td),r&&t(Re),k(Ht),r&&t(od),r&&t(ee),k(Lt),k(Ot),k(Qt),r&&t(nd),r&&t(ke),k(Kt),r&&t(rd),r&&t(eo),k(to),r&&t(sd),r&&t(qe),k(oo),r&&t(ad),r&&t(Fe),k(no),r&&t(dd),r&&t(ro),k(so),r&&t(id),r&&t(xe),k(ao),r&&t(cd),r&&t(K),k(io),k(rt),k(co),k(lo),k(po),r&&t(ld),r&&t(Je),k(uo),r&&t(pd),r&&t(N),k(mo),k(ct),k(vo),k(lt),k(pt),r&&t(hd),r&&t(Ue),k(bo),r&&t(ud),r&&t(J),k(To),k(ut),k(Ro),k(mt),k(gt),k(ko),r&&t(md),r&&t(Ze),k(Fo),r&&t(gd),r&&t(G),k(xo),k(vt),k(zo),k(bt),k(Tt),k(Uo),r&&t(fd),r&&t(Ne),k(Eo),r&&t(_d),r&&t(Z),k($o),k(Mt),k(No),k(Rt),k(kt),r&&t(vd),r&&t(Xe),k(Ao),r&&t(bd),r&&t(x),k(Wo),k(Ft),k(So),k(xt),k(jt),k(Po),r&&t(Td),r&&t(Se),k(Lo),r&&t(yd),r&&t(j),k(Oo),k(zt),k(Ko),k(Ut),k(Et),k(en)}}}const pT={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 hT(F){return Bb(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class bT extends Nb{constructor(c){super();Ab(this,c,hT,lT,Wb,{})}}export{bT as default,pT as metadata};
