Buckets:
| import{s as Po,o as Do,n as S}from"../chunks/scheduler.31fdf58d.js";import{S as Ko,i as Oo,e as d,s,c as g,h as en,a as c,d as r,b as a,f as X,j as f,g as _,k as q,w as tn,l,m as i,n as y,t as M,o as T,p as b}from"../chunks/index.2f76fdf0.js";import{T as ho}from"../chunks/Tip.8d349121.js";import{C as on}from"../chunks/CopyLLMTxtMenu.53b607bf.js";import{D as ne}from"../chunks/Docstring.7acc6835.js";import{C as E}from"../chunks/CodeBlock.e52df5d6.js";import{E as nt}from"../chunks/ExampleCodeBlock.f9704f52.js";import{H as et,E as nn}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.08750ec0.js";import{H as sn,a as uo}from"../chunks/HfOption.fb051768.js";function an(J){let t,p;return t=new E({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMHBpcGVsaW5lJTBBJTBBJTBBcGlwZWxpbmUlMjAlM0QlMjBwaXBlbGluZSglMEElMjAlMjAlMjAlMjB0YXNrJTNEJTIydGV4dC1nZW5lcmF0aW9uJTIyJTJDJTBBJTIwJTIwJTIwJTIwbW9kZWwlM0QlMjJDb2hlcmVGb3JBSSUyRmM0YWktY29tbWFuZC1yLXYwMSUyMiUyQyUwQSUyMCUyMCUyMCUyMGRldmljZSUzRDAlMEEpJTBBcGlwZWxpbmUoJTIyUGxhbnRzJTIwY3JlYXRlJTIwZW5lcmd5JTIwdGhyb3VnaCUyMGElMjBwcm9jZXNzJTIwa25vd24lMjBhcyUyMik=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline | |
| pipeline = pipeline( | |
| task=<span class="hljs-string">"text-generation"</span>, | |
| model=<span class="hljs-string">"CohereForAI/c4ai-command-r-v01"</span>, | |
| device=<span class="hljs-number">0</span> | |
| ) | |
| pipeline(<span class="hljs-string">"Plants create energy through a process known as"</span>)`,lang:"python",wrap:!1}}),{c(){g(t.$$.fragment)},l(o){_(t.$$.fragment,o)},m(o,h){y(t,o,h),p=!0},p:S,i(o){p||(M(t.$$.fragment,o),p=!0)},o(o){T(t.$$.fragment,o),p=!1},d(o){b(t,o)}}}function rn(J){let t,p;return t=new E({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNJTJDJTIwQXV0b1Rva2VuaXplciUwQSUwQSUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKCUyMkNvaGVyZUZvckFJJTJGYzRhaS1jb21tYW5kLXItdjAxJTIyKSUwQW1vZGVsJTIwJTNEJTIwQXV0b01vZGVsRm9yQ2F1c2FsTE0uZnJvbV9wcmV0cmFpbmVkKCUyMkNvaGVyZUZvckFJJTJGYzRhaS1jb21tYW5kLXItdjAxJTIyJTJDJTIwZGV2aWNlX21hcCUzRCUyMmF1dG8lMjIlMkMlMjBhdHRuX2ltcGxlbWVudGF0aW9uJTNEJTIyc2RwYSUyMiklMEElMEElMjMlMjBmb3JtYXQlMjBtZXNzYWdlJTIwd2l0aCUyMHRoZSUyMENvbW1hbmQtUiUyMGNoYXQlMjB0ZW1wbGF0ZSUwQW1lc3NhZ2VzJTIwJTNEJTIwJTVCJTdCJTIycm9sZSUyMiUzQSUyMCUyMnVzZXIlMjIlMkMlMjAlMjJjb250ZW50JTIyJTNBJTIwJTIySG93JTIwZG8lMjBwbGFudHMlMjBtYWtlJTIwZW5lcmd5JTNGJTIyJTdEJTVEJTBBaW5wdXRfaWRzJTIwJTNEJTIwdG9rZW5pemVyLmFwcGx5X2NoYXRfdGVtcGxhdGUobWVzc2FnZXMlMkMlMjB0b2tlbml6ZSUzRFRydWUlMkMlMjBhZGRfZ2VuZXJhdGlvbl9wcm9tcHQlM0RUcnVlJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMikudG8obW9kZWwuZGV2aWNlKSUwQW91dHB1dCUyMCUzRCUyMG1vZGVsLmdlbmVyYXRlKCUwQSUyMCUyMCUyMCUyMGlucHV0X2lkcyUyQyUwQSUyMCUyMCUyMCUyMG1heF9uZXdfdG9rZW5zJTNEMTAwJTJDJTBBJTIwJTIwJTIwJTIwZG9fc2FtcGxlJTNEVHJ1ZSUyQyUwQSUyMCUyMCUyMCUyMHRlbXBlcmF0dXJlJTNEMC4zJTJDJTBBJTIwJTIwJTIwJTIwY2FjaGVfaW1wbGVtZW50YXRpb24lM0QlMjJzdGF0aWMlMjIlMkMlMEEpJTBBcHJpbnQodG9rZW5pemVyLmRlY29kZShvdXRwdXQlNUIwJTVEJTJDJTIwc2tpcF9zcGVjaWFsX3Rva2VucyUzRFRydWUpKQ==",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM, AutoTokenizer | |
| tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">"CohereForAI/c4ai-command-r-v01"</span>) | |
| model = AutoModelForCausalLM.from_pretrained(<span class="hljs-string">"CohereForAI/c4ai-command-r-v01"</span>, device_map=<span class="hljs-string">"auto"</span>, attn_implementation=<span class="hljs-string">"sdpa"</span>) | |
| <span class="hljs-comment"># format message with the Command-R chat template</span> | |
| messages = [{<span class="hljs-string">"role"</span>: <span class="hljs-string">"user"</span>, <span class="hljs-string">"content"</span>: <span class="hljs-string">"How do plants make energy?"</span>}] | |
| input_ids = tokenizer.apply_chat_template(messages, tokenize=<span class="hljs-literal">True</span>, add_generation_prompt=<span class="hljs-literal">True</span>, return_tensors=<span class="hljs-string">"pt"</span>).to(model.device) | |
| output = model.generate( | |
| input_ids, | |
| max_new_tokens=<span class="hljs-number">100</span>, | |
| do_sample=<span class="hljs-literal">True</span>, | |
| temperature=<span class="hljs-number">0.3</span>, | |
| cache_implementation=<span class="hljs-string">"static"</span>, | |
| ) | |
| <span class="hljs-built_in">print</span>(tokenizer.decode(output[<span class="hljs-number">0</span>], skip_special_tokens=<span class="hljs-literal">True</span>))`,lang:"python",wrap:!1}}),{c(){g(t.$$.fragment)},l(o){_(t.$$.fragment,o)},m(o,h){y(t,o,h),p=!0},p:S,i(o){p||(M(t.$$.fragment,o),p=!0)},o(o){T(t.$$.fragment,o),p=!1},d(o){b(t,o)}}}function ln(J){let t,p;return t=new E({props:{code:"JTIzJTIwcGlwJTIwaW5zdGFsbCUyMC1VJTIwZmxhc2gtYXR0biUyMC0tbm8tYnVpbGQtaXNvbGF0aW9uJTBBdHJhbnNmb3JtZXJzJTIwY2hhdCUyMENvaGVyZUZvckFJJTJGYzRhaS1jb21tYW5kLXItdjAxJTIwLS1kdHlwZSUyMGF1dG8lMjAtLWF0dG5faW1wbGVtZW50YXRpb24lMjBmbGFzaF9hdHRlbnRpb25fMg==",highlighted:`<span class="hljs-comment"># pip install -U flash-attn --no-build-isolation</span> | |
| transformers chat CohereForAI/c4ai-command-r-v01 --dtype auto --attn_implementation flash_attention_2`,lang:"bash",wrap:!1}}),{c(){g(t.$$.fragment)},l(o){_(t.$$.fragment,o)},m(o,h){y(t,o,h),p=!0},p:S,i(o){p||(M(t.$$.fragment,o),p=!0)},o(o){T(t.$$.fragment,o),p=!1},d(o){b(t,o)}}}function dn(J){let t,p,o,h,w,m;return t=new uo({props:{id:"usage",option:"Pipeline",$$slots:{default:[an]},$$scope:{ctx:J}}}),o=new uo({props:{id:"usage",option:"AutoModel",$$slots:{default:[rn]},$$scope:{ctx:J}}}),w=new uo({props:{id:"usage",option:"transformers CLI",$$slots:{default:[ln]},$$scope:{ctx:J}}}),{c(){g(t.$$.fragment),p=s(),g(o.$$.fragment),h=s(),g(w.$$.fragment)},l(u){_(t.$$.fragment,u),p=a(u),_(o.$$.fragment,u),h=a(u),_(w.$$.fragment,u)},m(u,U){y(t,u,U),i(u,p,U),y(o,u,U),i(u,h,U),y(w,u,U),m=!0},p(u,U){const se={};U&2&&(se.$$scope={dirty:U,ctx:u}),t.$set(se);const B={};U&2&&(B.$$scope={dirty:U,ctx:u}),o.$set(B);const tt={};U&2&&(tt.$$scope={dirty:U,ctx:u}),w.$set(tt)},i(u){m||(M(t.$$.fragment,u),M(o.$$.fragment,u),M(w.$$.fragment,u),m=!0)},o(u){T(t.$$.fragment,u),T(o.$$.fragment,u),T(w.$$.fragment,u),m=!1},d(u){u&&(r(p),r(h)),b(t,u),b(o,u),b(w,u)}}}function cn(J){let t,p;return t=new E({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMENvaGVyZU1vZGVsJTJDJTIwQ29oZXJlQ29uZmlnJTBBJTBBJTIzJTIwSW5pdGlhbGl6aW5nJTIwYSUyMENvaGVyZSUyMG1vZGVsJTIwY29uZmlndXJhdGlvbiUwQWNvbmZpZ3VyYXRpb24lMjAlM0QlMjBDb2hlcmVDb25maWcoKSUwQSUwQSUyMyUyMEluaXRpYWxpemluZyUyMGElMjBtb2RlbCUyMGZyb20lMjB0aGUlMjBDb2hlcmUlMjBjb25maWd1cmF0aW9uJTBBbW9kZWwlMjAlM0QlMjBDb2hlcmVNb2RlbChjb25maWd1cmF0aW9uKSUwQSUyMyUyMEFjY2Vzc2luZyUyMHRoZSUyMG1vZGVsJTIwY29uZmlndXJhdGlvbiUwQWNvbmZpZ3VyYXRpb24lMjAlM0QlMjBtb2RlbC5jb25maWc=",highlighted:`<span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> CohereModel, CohereConfig | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># Initializing a Cohere model configuration</span> | |
| <span class="hljs-meta">>>> </span>configuration = CohereConfig() | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># Initializing a model from the Cohere configuration</span> | |
| <span class="hljs-meta">>>> </span>model = CohereModel(configuration) | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># Accessing the model configuration</span> | |
| <span class="hljs-meta">>>> </span>configuration = model.config`,lang:"python",wrap:!1}}),{c(){g(t.$$.fragment)},l(o){_(t.$$.fragment,o)},m(o,h){y(t,o,h),p=!0},p:S,i(o){p||(M(t.$$.fragment,o),p=!0)},o(o){T(t.$$.fragment,o),p=!1},d(o){b(t,o)}}}function pn(J){let t,p;return t=new E({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJDb2hlcmVGb3JBSSUyRmM0YWktY29tbWFuZC1yLXYwMSUyMiklMEF0b2tlbml6ZXIuZW5jb2RlKCUyMkhlbGxvJTIwdGhpcyUyMGlzJTIwYSUyMHRlc3QlMjIp",highlighted:`<span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer | |
| <span class="hljs-meta">>>> </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">"CohereForAI/c4ai-command-r-v01"</span>) | |
| <span class="hljs-meta">>>> </span>tokenizer.encode(<span class="hljs-string">"Hello this is a test"</span>) | |
| [<span class="hljs-number">5</span>, <span class="hljs-number">28339</span>, <span class="hljs-number">2075</span>, <span class="hljs-number">1801</span>, <span class="hljs-number">1671</span>, <span class="hljs-number">3282</span>]`,lang:"python",wrap:!1}}),{c(){g(t.$$.fragment)},l(o){_(t.$$.fragment,o)},m(o,h){y(t,o,h),p=!0},p:S,i(o){p||(M(t.$$.fragment,o),p=!0)},o(o){T(t.$$.fragment,o),p=!1},d(o){b(t,o)}}}function mn(J){let t,p="When used with <code>is_split_into_words=True</code>, this tokenizer needs to be instantiated with <code>add_prefix_space=True</code>.";return{c(){t=d("p"),t.innerHTML=p},l(o){t=c(o,"P",{"data-svelte-h":!0}),f(t)!=="svelte-9gg91e"&&(t.innerHTML=p)},m(o,h){i(o,t,h)},p:S,d(o){o&&r(t)}}}function hn(J){let t,p="Examples:",o,h,w;return h=new E({props:{code:"JTNFJTNFJTIwdG9rZW5pemVyJTIwJTNEJTIwQ29oZXJlVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCgnQ29oZXJlRm9yQUklMkZjNGFpLWNvbW1hbmQtci12MDEnKSUwQSUwQSUzRSUzRSUyMCUyMyUyMGRlZmluZSUyMGRvY3VtZW50cyUzQSUwQSUzRSUzRSUyMGRvY3VtZW50cyUyMCUzRCUyMCU1QiUwQSUyMCUyMCUyMCUyMCU3QiUyMCUyMnRpdGxlJTIyJTNBJTIwJTIyVGFsbCUyMHBlbmd1aW5zJTIyJTJDJTIwJTIydGV4dCUyMiUzQSUyMCUyMkVtcGVyb3IlMjBwZW5ndWlucyUyMGFyZSUyMHRoZSUyMHRhbGxlc3QuJTIyJTIwJTdEJTJDJTBBJTIwJTIwJTIwJTIwJTdCJTIwJTIydGl0bGUlMjIlM0ElMjAlMjJQZW5ndWluJTIwaGFiaXRhdHMlMjIlMkMlMjAlMjJ0ZXh0JTIyJTNBJTIwJTIyRW1wZXJvciUyMHBlbmd1aW5zJTIwb25seSUyMGxpdmUlMjBpbiUyMEFudGFyY3RpY2EuJTIyJTdEJTBBJTVEJTBBJTNFJTNFJTIwJTIzJTIwZGVmaW5lJTIwYSUyMGNvbnZlcnNhdGlvbiUzQSUwQSUzRSUzRSUyMGNvbnZlcnNhdGlvbiUyMCUzRCUyMCU1QiUwQSUyMCUyMCUyMCUyMCU3QiUyMnJvbGUlMjIlM0ElMjAlMjJ1c2VyJTIyJTJDJTIwJTIyY29udGVudCUyMiUzQSUyMCUyMldoYXRzJTIwdGhlJTIwYmlnZ2VzdCUyMHBlbmd1aW4lMjBpbiUyMHRoZSUyMHdvcmxkJTNGJTIyJTdEJTBBJTVEJTBBJTNFJTNFJTIwJTIzJTIwcmVuZGVyJTIwdGhlJTIwcHJvbXB0JTJDJTIwcmVhZHklMjBmb3IlMjB1c2VyJTIwdG8lMjBpbnNwZWN0JTJDJTIwb3IlMjBmb3IlMjBpbnB1dCUyMGludG8lMjB0aGUlMjBtb2RlbCUzQSUwQSUzRSUzRSUyMGdyb3VuZGVkX2dlbmVyYXRpb25fcHJvbXB0JTIwJTNEJTIwdG9rZW5pemVyLmFwcGx5X2dyb3VuZGVkX2dlbmVyYXRpb25fdGVtcGxhdGUoY29udmVyc2F0aW9uJTJDJTIwZG9jdW1lbnRzJTNEZG9jdW1lbnRzJTJDJTIwdG9rZW5pemUlM0RGYWxzZSUyQyUyMGFkZF9nZW5lcmF0aW9uX3Byb21wdCUzRFRydWUpJTBBJTNFJTNFJTIwcHJpbnQoZ3JvdW5kZWRfZ2VuZXJhdGlvbl9wcm9tcHQpJTBBJTNFJTNFJTIwaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyLmVuY29kZShwcm9tcHQlMkMlMjBhZGRfc3BlY2lhbF90b2tlbnMlM0RGYWxzZSUyQyUyMHJldHVybl90ZW5zb3JzJTNEJ3B0JyklMEElM0UlM0UlMjBvdXRwdXRzJTIwJTNEJTIwbW9kZWwuZ2VuZXJhdGUoaW5wdXRzJTJDJTIwbWF4X25ld190b2tlbnMlM0QxMjgpJTBBJTNFJTNFJTIwcHJpbnQodG9rZW5pemVyLmRlY29kZShvdXRwdXRzJTVCMCU1RCkp",highlighted:`>> tokenizer = CohereTokenizer.from_pretrained(<span class="hljs-string">'CohereForAI/c4ai-command-r-v01'</span>) | |
| >> <span class="hljs-comment"># define documents:</span> | |
| >> documents = [ | |
| { <span class="hljs-string">"title"</span>: <span class="hljs-string">"Tall penguins"</span>, <span class="hljs-string">"text"</span>: <span class="hljs-string">"Emperor penguins are the tallest."</span> }, | |
| { <span class="hljs-string">"title"</span>: <span class="hljs-string">"Penguin habitats"</span>, <span class="hljs-string">"text"</span>: <span class="hljs-string">"Emperor penguins only live in Antarctica."</span>} | |
| ] | |
| >> <span class="hljs-comment"># define a conversation:</span> | |
| >> conversation = [ | |
| {<span class="hljs-string">"role"</span>: <span class="hljs-string">"user"</span>, <span class="hljs-string">"content"</span>: <span class="hljs-string">"Whats the biggest penguin in the world?"</span>} | |
| ] | |
| >> <span class="hljs-comment"># render the prompt, ready for user to inspect, or for input into the model:</span> | |
| >> grounded_generation_prompt = tokenizer.apply_grounded_generation_template(conversation, documents=documents, tokenize=<span class="hljs-literal">False</span>, add_generation_prompt=<span class="hljs-literal">True</span>) | |
| >> <span class="hljs-built_in">print</span>(grounded_generation_prompt) | |
| >> inputs = tokenizer.encode(prompt, add_special_tokens=<span class="hljs-literal">False</span>, return_tensors=<span class="hljs-string">'pt'</span>) | |
| >> outputs = model.generate(inputs, max_new_tokens=<span class="hljs-number">128</span>) | |
| >> <span class="hljs-built_in">print</span>(tokenizer.decode(outputs[<span class="hljs-number">0</span>]))`,lang:"python",wrap:!1}}),{c(){t=d("p"),t.textContent=p,o=s(),g(h.$$.fragment)},l(m){t=c(m,"P",{"data-svelte-h":!0}),f(t)!=="svelte-kvfsh7"&&(t.textContent=p),o=a(m),_(h.$$.fragment,m)},m(m,u){i(m,t,u),i(m,o,u),y(h,m,u),w=!0},p:S,i(m){w||(M(h.$$.fragment,m),w=!0)},o(m){T(h.$$.fragment,m),w=!1},d(m){m&&(r(t),r(o)),b(h,m)}}}function un(J){let t,p="Examples:",o,h,w;return h=new E({props:{code:"JTNFJTNFJTIwdG9rZW5pemVyJTIwJTNEJTIwQ29oZXJlVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJDb2hlcmVGb3JBSSUyRmM0YWktY29tbWFuZC1yLXYwMSUyMiklMEElM0UlM0UlMjB0b29scyUyMCUzRCUyMCU1QiUwQSUyMCUyMCUyMCUyMCU3QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMm5hbWUlMjIlM0ElMjAlMjJpbnRlcm5ldF9zZWFyY2glMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJkZXNjcmlwdGlvbiUyMiUzQSUyMCUyMlJldHVybnMlMjBhJTIwbGlzdCUyMG9mJTIwcmVsZXZhbnQlMjBkb2N1bWVudCUyMHNuaXBwZXRzJTIwZm9yJTIwYSUyMHRleHR1YWwlMjBxdWVyeSUyMHJldHJpZXZlZCUyMGZyb20lMjB0aGUlMjBpbnRlcm5ldCUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMnBhcmFtZXRlcl9kZWZpbml0aW9ucyUyMiUzQSUyMCU3QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMnF1ZXJ5JTIyJTNBJTIwJTdCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyZGVzY3JpcHRpb24lMjIlM0ElMjAlMjJRdWVyeSUyMHRvJTIwc2VhcmNoJTIwdGhlJTIwaW50ZXJuZXQlMjB3aXRoJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIydHlwZSUyMiUzQSUyMCUyMnN0ciUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMnJlcXVpcmVkJTIyJTNBJTIwVHJ1ZSUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU3RCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU3RCUyQyUwQSUyMCUyMCUyMCUyMCU3RCUyQyUwQSUyMCUyMCUyMCUyMCU3QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMm5hbWUlMjIlM0ElMjAlMjJkaXJlY3RseV9hbnN3ZXIlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJkZXNjcmlwdGlvbiUyMiUzQSUyMCUyMkNhbGxzJTIwYSUyMHN0YW5kYXJkJTIwKHVuLWF1Z21lbnRlZCklMjBBSSUyMGNoYXRib3QlMjB0byUyMGdlbmVyYXRlJTIwYSUyMHJlc3BvbnNlJTIwZ2l2ZW4lMjB0aGUlMjBjb252ZXJzYXRpb24lMjBoaXN0b3J5JTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIycGFyYW1ldGVyX2RlZmluaXRpb25zJTIyJTNBJTIwJTdCJTdEJTJDJTBBJTIwJTIwJTIwJTIwJTdEJTJDJTBBJTVEJTBBJTNFJTNFJTIwY29udmVyc2F0aW9uJTIwJTNEJTIwJTVCJTBBJTIwJTIwJTIwJTIwJTdCJTIycm9sZSUyMiUzQSUyMCUyMnVzZXIlMjIlMkMlMjAlMjJjb250ZW50JTIyJTNBJTIwJTIyV2hhdHMlMjB0aGUlMjBiaWdnZXN0JTIwcGVuZ3VpbiUyMGluJTIwdGhlJTIwd29ybGQlM0YlMjIlN0QlMkMlMEElNUQlMEElM0UlM0UlMjAlMjMlMjBSZW5kZXIlMjB0aGUlMjBwcm9tcHQlMkMlMjByZWFkeSUyMGZvciUyMHVzZXIlMjB0byUyMGluc3BlY3QlMkMlMjBvciUyMGZvciUyMGlucHV0JTIwaW50byUyMHRoZSUyMG1vZGVsJTBBJTNFJTNFJTIwcHJvbXB0JTIwJTNEJTIwdG9rZW5pemVyLmFwcGx5X3Rvb2xfdXNlX3RlbXBsYXRlKGNvbnZlcnNhdGlvbiUyQyUyMHRvb2xzJTNEdG9vbHMlMkMlMjB0b2tlbml6ZSUzREZhbHNlJTJDJTIwYWRkX2dlbmVyYXRpb25fcHJvbXB0JTNEVHJ1ZSklMEElM0UlM0UlMjBwcmludChwcm9tcHQpJTBBJTNFJTNFJTIwaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyLmVuY29kZShncm91bmRlZF9nZW5lcmF0aW9uX3Byb21wdCUyQyUyMGFkZF9zcGVjaWFsX3Rva2VucyUzREZhbHNlJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QncHQnKSUwQSUzRSUzRSUyMG91dHB1dHMlMjAlM0QlMjBtb2RlbC5nZW5lcmF0ZShpbnB1dHMlMkMlMjBtYXhfbmV3X3Rva2VucyUzRDEyOCklMEElM0UlM0UlMjBwcmludCh0b2tlbml6ZXIuZGVjb2RlKG91dHB1dHMlNUIwJTVEKSklMEElNUIlMEElMjAlMjAlMjAlMjAlN0IlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJ0b29sX25hbWUlMjIlM0ElMjAlMjJpbnRlcm5ldF9zZWFyY2glMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJwYXJhbWV0ZXJzJTIyJTNBJTIwJTdCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIycXVlcnklMjIlM0ElMjAlMjJiaWdnZXN0JTIwcGVuZ3VpbiUyMGluJTIwdGhlJTIwd29ybGQlMjIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlN0QlMEElMjAlMjAlMjAlMjAlN0QlMEElNUQ=",highlighted:`>> tokenizer = CohereTokenizer.from_pretrained(<span class="hljs-string">"CohereForAI/c4ai-command-r-v01"</span>) | |
| >> tools = [ | |
| { | |
| <span class="hljs-string">"name"</span>: <span class="hljs-string">"internet_search"</span>, | |
| <span class="hljs-string">"description"</span>: <span class="hljs-string">"Returns a list of relevant document snippets for a textual query retrieved from the internet"</span>, | |
| <span class="hljs-string">"parameter_definitions"</span>: { | |
| <span class="hljs-string">"query"</span>: { | |
| <span class="hljs-string">"description"</span>: <span class="hljs-string">"Query to search the internet with"</span>, | |
| <span class="hljs-string">"type"</span>: <span class="hljs-string">"str"</span>, | |
| <span class="hljs-string">"required"</span>: <span class="hljs-literal">True</span>, | |
| } | |
| }, | |
| }, | |
| { | |
| <span class="hljs-string">"name"</span>: <span class="hljs-string">"directly_answer"</span>, | |
| <span class="hljs-string">"description"</span>: <span class="hljs-string">"Calls a standard (un-augmented) AI chatbot to generate a response given the conversation history"</span>, | |
| <span class="hljs-string">"parameter_definitions"</span>: {}, | |
| }, | |
| ] | |
| >> conversation = [ | |
| {<span class="hljs-string">"role"</span>: <span class="hljs-string">"user"</span>, <span class="hljs-string">"content"</span>: <span class="hljs-string">"Whats the biggest penguin in the world?"</span>}, | |
| ] | |
| >> <span class="hljs-comment"># Render the prompt, ready for user to inspect, or for input into the model</span> | |
| >> prompt = tokenizer.apply_tool_use_template(conversation, tools=tools, tokenize=<span class="hljs-literal">False</span>, add_generation_prompt=<span class="hljs-literal">True</span>) | |
| >> <span class="hljs-built_in">print</span>(prompt) | |
| >> inputs = tokenizer.encode(grounded_generation_prompt, add_special_tokens=<span class="hljs-literal">False</span>, return_tensors=<span class="hljs-string">'pt'</span>) | |
| >> outputs = model.generate(inputs, max_new_tokens=<span class="hljs-number">128</span>) | |
| >> <span class="hljs-built_in">print</span>(tokenizer.decode(outputs[<span class="hljs-number">0</span>])) | |
| [ | |
| { | |
| <span class="hljs-string">"tool_name"</span>: <span class="hljs-string">"internet_search"</span>, | |
| <span class="hljs-string">"parameters"</span>: { | |
| <span class="hljs-string">"query"</span>: <span class="hljs-string">"biggest penguin in the world"</span> | |
| } | |
| } | |
| ]`,lang:"python",wrap:!1}}),{c(){t=d("p"),t.textContent=p,o=s(),g(h.$$.fragment)},l(m){t=c(m,"P",{"data-svelte-h":!0}),f(t)!=="svelte-kvfsh7"&&(t.textContent=p),o=a(m),_(h.$$.fragment,m)},m(m,u){i(m,t,u),i(m,o,u),y(h,m,u),w=!0},p:S,i(m){w||(M(h.$$.fragment,m),w=!0)},o(m){T(h.$$.fragment,m),w=!1},d(m){m&&(r(t),r(o)),b(h,m)}}}function fn(J){let t,p=`Although the recipe for forward pass needs to be defined within this function, one should call the <code>Module</code> | |
| instance afterwards instead of this since the former takes care of running the pre and post processing steps while | |
| the latter silently ignores them.`;return{c(){t=d("p"),t.innerHTML=p},l(o){t=c(o,"P",{"data-svelte-h":!0}),f(t)!=="svelte-fincs2"&&(t.innerHTML=p)},m(o,h){i(o,t,h)},p:S,d(o){o&&r(t)}}}function gn(J){let t,p=`Although the recipe for forward pass needs to be defined within this function, one should call the <code>Module</code> | |
| instance afterwards instead of this since the former takes care of running the pre and post processing steps while | |
| the latter silently ignores them.`;return{c(){t=d("p"),t.innerHTML=p},l(o){t=c(o,"P",{"data-svelte-h":!0}),f(t)!=="svelte-fincs2"&&(t.innerHTML=p)},m(o,h){i(o,t,h)},p:S,d(o){o&&r(t)}}}function _n(J){let t,p="Example:",o,h,w;return h=new E({props:{code:"JTNFJTNFJTIwZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBDb2hlcmVGb3JDYXVzYWxMTSUwQSUwQSUzRSUzRSUyMG1vZGVsJTIwJTNEJTIwQ29oZXJlRm9yQ2F1c2FsTE0uZnJvbV9wcmV0cmFpbmVkKCUyMkNvaGVyZUZvckFJJTJGYzRhaS1jb21tYW5kLXItdjAxJTIyKSUwQSUzRSUzRSUyMHRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKCUyMkNvaGVyZUZvckFJJTJGYzRhaS1jb21tYW5kLXItdjAxJTIyKSUwQSUwQSUzRSUzRSUyMHByb21wdCUyMCUzRCUyMCUyMkhleSUyQyUyMGFyZSUyMHlvdSUyMGNvbnNjaW91cyUzRiUyMENhbiUyMHlvdSUyMHRhbGslMjB0byUyMG1lJTNGJTIyJTBBJTNFJTNFJTIwaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKHByb21wdCUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpJTBBJTBBJTNFJTNFJTIwJTIzJTIwR2VuZXJhdGUlMEElM0UlM0UlMjBnZW5lcmF0ZV9pZHMlMjAlM0QlMjBtb2RlbC5nZW5lcmF0ZShpbnB1dHMuaW5wdXRfaWRzJTJDJTIwbWF4X2xlbmd0aCUzRDMwKSUwQSUzRSUzRSUyMHRva2VuaXplci5iYXRjaF9kZWNvZGUoZ2VuZXJhdGVfaWRzJTJDJTIwc2tpcF9zcGVjaWFsX3Rva2VucyUzRFRydWUlMkMlMjBjbGVhbl91cF90b2tlbml6YXRpb25fc3BhY2VzJTNERmFsc2UpJTVCMCU1RCUwQSUyMkhleSUyQyUyMGFyZSUyMHlvdSUyMGNvbnNjaW91cyUzRiUyMENhbiUyMHlvdSUyMHRhbGslMjB0byUyMG1lJTNGJTVDbkknbSUyMG5vdCUyMGNvbnNjaW91cyUyQyUyMGJ1dCUyMEklMjBjYW4lMjB0YWxrJTIwdG8lMjB5b3UuJTIy",highlighted:`>> <span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, CohereForCausalLM | |
| >> model = CohereForCausalLM.from_pretrained(<span class="hljs-string">"CohereForAI/c4ai-command-r-v01"</span>) | |
| >> tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">"CohereForAI/c4ai-command-r-v01"</span>) | |
| >> prompt = <span class="hljs-string">"Hey, are you conscious? Can you talk to me?"</span> | |
| >> inputs = tokenizer(prompt, return_tensors=<span class="hljs-string">"pt"</span>) | |
| >> <span class="hljs-comment"># Generate</span> | |
| >> generate_ids = model.generate(inputs.input_ids, max_length=<span class="hljs-number">30</span>) | |
| >> tokenizer.batch_decode(generate_ids, skip_special_tokens=<span class="hljs-literal">True</span>, clean_up_tokenization_spaces=<span class="hljs-literal">False</span>)[<span class="hljs-number">0</span>] | |
| <span class="hljs-string">"Hey, are you conscious? Can you talk to me?\\nI'm not conscious, but I can talk to you."</span>`,lang:"python",wrap:!1}}),{c(){t=d("p"),t.textContent=p,o=s(),g(h.$$.fragment)},l(m){t=c(m,"P",{"data-svelte-h":!0}),f(t)!=="svelte-11lpom8"&&(t.textContent=p),o=a(m),_(h.$$.fragment,m)},m(m,u){i(m,t,u),i(m,o,u),y(h,m,u),w=!0},p:S,i(m){w||(M(h.$$.fragment,m),w=!0)},o(m){T(h.$$.fragment,m),w=!1},d(m){m&&(r(t),r(o)),b(h,m)}}}function yn(J){let t,p,o,h,w,m="<em>This model was contributed to Hugging Face Transformers on 2024-03-15.</em>",u,U,se,B,tt='<div class="flex flex-wrap space-x-1"><img alt="FlashAttention" src="https://img.shields.io/badge/%E2%9A%A1%EF%B8%8E%20FlashAttention-eae0c8?style=flat"/> <img alt="SDPA" src="https://img.shields.io/badge/SDPA-DE3412?style=flat&logo=pytorch&logoColor=white"/> <img alt="Tensor parallelism" src="https://img.shields.io/badge/Tensor%20parallelism-06b6d4?style=flat&logoColor=white"/></div>',st,ae,at,re,fo='Cohere <a href="https://cohere.com/blog/command-r" rel="nofollow">Command-R</a> is a 35B parameter multilingual large language model designed for long context tasks like retrieval-augmented generation (RAG) and calling external APIs and tools. The model is specifically trained for grounded generation and supports both single-step and multi-step tool use. It supports a context length of 128K tokens.',rt,le,go='You can find all the original Command-R checkpoints under the <a href="https://huggingface.co/collections/CohereForAI/command-models-67652b401665205e17b192ad" rel="nofollow">Command Models</a> collection.',lt,A,_o="<p>Click on the Cohere models in the right sidebar for more examples of how to apply Cohere to different language tasks.</p>",it,ie,yo='The example below demonstrates how to generate text with <a href="/docs/transformers/pr_43265/en/main_classes/pipelines#transformers.Pipeline">Pipeline</a> or the <a href="/docs/transformers/pr_43265/en/model_doc/auto#transformers.AutoModel">AutoModel</a>, and from the command line.',dt,Q,ct,de,Mo='Quantization reduces the memory burden of large models by representing the weights in a lower precision. Refer to the <a href="../quantization/overview">Quantization</a> overview for more available quantization backends.',pt,ce,To='The example below uses <a href="../quantization/bitsandbytes">bitsandbytes</a> to quantize the weights to 4-bits.',mt,pe,ht,me,bo='Use the <a href="https://github.com/huggingface/transformers/blob/beb9b5b02246b9b7ee81ddf938f93f44cfeaad19/src/transformers/utils/attention_visualizer.py#L139" rel="nofollow">AttentionMaskVisualizer</a> to better understand what tokens the model can and cannot attend to.',ut,he,ft,L,wo='<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/model_doc/cohere-attn-mask.png"/>',gt,ue,_t,fe,Jo='<li>Don’t use the dtype parameter in <a href="/docs/transformers/pr_43265/en/model_doc/auto#transformers.AutoModel.from_pretrained">from_pretrained()</a> if you’re using FlashAttention-2 because it only supports fp16 or bf16. You should use <a href="https://pytorch.org/tutorials/recipes/recipes/amp_recipe.html" rel="nofollow">Automatic Mixed Precision</a>, set fp16 or bf16 to True if using <a href="/docs/transformers/pr_43265/en/main_classes/trainer#transformers.Trainer">Trainer</a>, or use <a href="https://pytorch.org/docs/stable/amp.html#torch.autocast" rel="nofollow">torch.autocast</a>.</li>',yt,ge,Mt,G,_e,It,Ie,Co=`This is the configuration class to store the configuration of a CohereModel. It is used to instantiate a Cohere | |
| model according to the specified arguments, defining the model architecture. Instantiating a configuration with the | |
| defaults will yield a similar configuration to that of the <a href="https://huggingface.co/CohereForAI/c4ai-command-r-v01" rel="nofollow">CohereForAI/c4ai-command-r-v01</a>`,$t,$e,ko=`Configuration objects inherit from <a href="/docs/transformers/pr_43265/en/main_classes/configuration#transformers.PreTrainedConfig">PreTrainedConfig</a> and can be used to control the model outputs. Read the | |
| documentation from <a href="/docs/transformers/pr_43265/en/main_classes/configuration#transformers.PreTrainedConfig">PreTrainedConfig</a> for more information.`,zt,Y,Tt,ye,bt,C,Me,xt,ze,Uo="Construct a Cohere tokenizer. Based on byte-level Byte-Pair-Encoding.",Zt,xe,vo="This uses notably ByteFallback and NFC normalization.",Gt,P,Ft,Ze,jo=`If you want to change the <code>bos_token</code> or the <code>eos_token</code>, make sure to specify them when initializing the model, or | |
| call <code>tokenizer.update_post_processor()</code> to make sure that the post-processing is correctly done (otherwise the | |
| values of the first token and final token of an encoded sequence will not be correct). For more details, checkout | |
| [post-processors] (<a href="https://huggingface.co/docs/tokenizers/api/post-processors" rel="nofollow">https://huggingface.co/docs/tokenizers/api/post-processors</a>) documentation.`,Wt,Ge,Io=`You can get around that behavior by passing <code>add_prefix_space=True</code> when instantiating this tokenizer, but since | |
| the model was not pretrained this way, it might yield a decrease in performance.`,Nt,D,Rt,Fe,$o=`This tokenizer inherits from <a href="/docs/transformers/pr_43265/en/main_classes/tokenizer#transformers.TokenizersBackend">TokenizersBackend</a> which contains most of the main methods. Users should | |
| refer to this superclass for more information regarding those methods.`,qt,v,Te,Bt,We,zo="Create a Command-R grounded generation (aka RAG) prompt.",Vt,Ne,xo="Once rendered, the prompt instructs the model to generate a response with citations in, based on supplied documents.",Ht,Re,Zo=`Conceptually, this works in the same way as <code>apply_chat_format</code>, but takes additional <code>documents</code> | |
| and parameter <code>citation_mode</code> parameters.`,St,qe,Go=`Converts a list of dictionaries with <code>"role"</code> and <code>"content"</code> keys and a list of | |
| documents for the model to ground its response on into a prompt string, or a list of token ids. | |
| This method will use the tokenizer’s <code>grounded_generation_template</code> template specified at the class level. | |
| You can override the default template using the <code>grounded_generation_template</code> kwarg but the quality of your results may decrease.`,Xt,K,Et,j,be,At,Be,Fo="Create a Command-R tool-use prompt.",Qt,Ve,Wo=`Once rendered, the prompt instructs the model to generate a list of actions to perform on a set of user supplied tools | |
| to help carry out the user’s requests.`,Lt,He,No="Conceptually, this works in the same way as <code>apply_chat_format</code>, but takes an additional <code>tools</code> parameter.",Yt,Se,Ro=`Converts a chat in the form of a list of dictionaries with <code>"role"</code> and <code>"content"</code> keys and a list of available | |
| tools for the model to use into a prompt string, or a list of token ids. | |
| This method will use the tokenizer’s <code>default_tool_use_template</code> template specified at the class level. | |
| You can override the default template using the <code>tool_use_template</code> kwarg but the quality of your results may decrease.`,Pt,O,wt,we,Jt,I,Je,Dt,Xe,qo="The bare Cohere Model outputting raw hidden-states without any specific head on top.",Kt,Ee,Bo=`This model inherits from <a href="/docs/transformers/pr_43265/en/main_classes/model#transformers.PreTrainedModel">PreTrainedModel</a>. 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.)`,Ot,Ae,Vo=`This model is also a PyTorch <a href="https://pytorch.org/docs/stable/nn.html#torch.nn.Module" rel="nofollow">torch.nn.Module</a> subclass. | |
| Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage | |
| and behavior.`,eo,R,Ce,to,Qe,Ho='The <a href="/docs/transformers/pr_43265/en/model_doc/cohere#transformers.CohereModel">CohereModel</a> forward method, overrides the <code>__call__</code> special method.',oo,ee,no,Le,So=`<li><p><strong>last_hidden_state</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>) — Sequence of hidden-states at the output of the last layer of the model.</p> <p>If <code>past_key_values</code> is used only the last hidden-state of the sequences of shape <code>(batch_size, 1, hidden_size)</code> is output.</p></li> <li><p><strong>past_key_values</strong> (<code>Cache</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) — It is a <a href="/docs/transformers/pr_43265/en/internal/generation_utils#transformers.Cache">Cache</a> instance. For more details, see our <a href="https://huggingface.co/docs/transformers/en/kv_cache" rel="nofollow">kv cache guide</a>.</p> <p>Contains pre-computed hidden-states (key and values in the self-attention blocks and optionally if | |
| <code>config.is_encoder_decoder=True</code> in the cross-attention blocks) that can be used (see <code>past_key_values</code> | |
| input) to speed up sequential decoding.</p></li> <li><p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) — Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, if the model has an embedding layer, + | |
| one for the output of each layer) of shape <code>(batch_size, sequence_length, hidden_size)</code>.</p> <p>Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.</p></li> <li><p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) — Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p> <p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention | |
| heads.</p></li>`,Ct,ke,kt,$,Ue,so,Ye,Xo="The Cohere Model for causal language modeling.",ao,Pe,Eo=`This model inherits from <a href="/docs/transformers/pr_43265/en/main_classes/model#transformers.PreTrainedModel">PreTrainedModel</a>. 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.)`,ro,De,Ao=`This model is also a PyTorch <a href="https://pytorch.org/docs/stable/nn.html#torch.nn.Module" rel="nofollow">torch.nn.Module</a> subclass. | |
| Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage | |
| and behavior.`,lo,Z,ve,io,Ke,Qo='The <a href="/docs/transformers/pr_43265/en/model_doc/cohere#transformers.CohereForCausalLM">CohereForCausalLM</a> forward method, overrides the <code>__call__</code> special method.',co,te,po,Oe,Lo=`<li><p><strong>loss</strong> (<code>torch.FloatTensor</code> of shape <code>(1,)</code>, <em>optional</em>, returned when <code>labels</code> is provided) — Language modeling loss (for next-token prediction).</p></li> <li><p><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, config.vocab_size)</code>) — Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).</p></li> <li><p><strong>past_key_values</strong> (<code>Cache</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) — It is a <a href="/docs/transformers/pr_43265/en/internal/generation_utils#transformers.Cache">Cache</a> instance. For more details, see our <a href="https://huggingface.co/docs/transformers/en/kv_cache" rel="nofollow">kv cache guide</a>.</p> <p>Contains pre-computed hidden-states (key and values in the self-attention blocks) that can be used (see | |
| <code>past_key_values</code> input) to speed up sequential decoding.</p></li> <li><p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) — Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, if the model has an embedding layer, + | |
| one for the output of each layer) of shape <code>(batch_size, sequence_length, hidden_size)</code>.</p> <p>Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.</p></li> <li><p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) — Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p> <p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention | |
| heads.</p></li>`,mo,oe,Ut,je,vt,ot,jt;return U=new on({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),ae=new et({props:{title:"Cohere",local:"cohere",headingTag:"h1"}}),Q=new sn({props:{id:"usage",options:["Pipeline","AutoModel","transformers CLI"],$$slots:{default:[dn]},$$scope:{ctx:J}}}),pe=new E({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNJTJDJTIwQXV0b1Rva2VuaXplciUyQyUyMEJpdHNBbmRCeXRlc0NvbmZpZyUwQSUwQSUwQWJuYl9jb25maWclMjAlM0QlMjBCaXRzQW5kQnl0ZXNDb25maWcobG9hZF9pbl80Yml0JTNEVHJ1ZSklMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJDb2hlcmVGb3JBSSUyRmM0YWktY29tbWFuZC1yLXYwMSUyMiklMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNLmZyb21fcHJldHJhaW5lZCglMjJDb2hlcmVGb3JBSSUyRmM0YWktY29tbWFuZC1yLXYwMSUyMiUyQyUyMGRldmljZV9tYXAlM0QlMjJhdXRvJTIyJTJDJTIwcXVhbnRpemF0aW9uX2NvbmZpZyUzRGJuYl9jb25maWclMkMlMjBhdHRuX2ltcGxlbWVudGF0aW9uJTNEJTIyc2RwYSUyMiklMEElMEElMjMlMjBmb3JtYXQlMjBtZXNzYWdlJTIwd2l0aCUyMHRoZSUyMENvbW1hbmQtUiUyMGNoYXQlMjB0ZW1wbGF0ZSUwQW1lc3NhZ2VzJTIwJTNEJTIwJTVCJTdCJTIycm9sZSUyMiUzQSUyMCUyMnVzZXIlMjIlMkMlMjAlMjJjb250ZW50JTIyJTNBJTIwJTIySG93JTIwZG8lMjBwbGFudHMlMjBtYWtlJTIwZW5lcmd5JTNGJTIyJTdEJTVEJTBBaW5wdXRfaWRzJTIwJTNEJTIwdG9rZW5pemVyLmFwcGx5X2NoYXRfdGVtcGxhdGUobWVzc2FnZXMlMkMlMjB0b2tlbml6ZSUzRFRydWUlMkMlMjBhZGRfZ2VuZXJhdGlvbl9wcm9tcHQlM0RUcnVlJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMikudG8obW9kZWwuZGV2aWNlKSUwQW91dHB1dCUyMCUzRCUyMG1vZGVsLmdlbmVyYXRlKCUwQSUyMCUyMCUyMCUyMGlucHV0X2lkcyUyQyUwQSUyMCUyMCUyMCUyMG1heF9uZXdfdG9rZW5zJTNEMTAwJTJDJTBBJTIwJTIwJTIwJTIwZG9fc2FtcGxlJTNEVHJ1ZSUyQyUwQSUyMCUyMCUyMCUyMHRlbXBlcmF0dXJlJTNEMC4zJTJDJTBBJTIwJTIwJTIwJTIwY2FjaGVfaW1wbGVtZW50YXRpb24lM0QlMjJzdGF0aWMlMjIlMkMlMEEpJTBBcHJpbnQodG9rZW5pemVyLmRlY29kZShvdXRwdXQlNUIwJTVEJTJDJTIwc2tpcF9zcGVjaWFsX3Rva2VucyUzRFRydWUpKQ==",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig | |
| bnb_config = BitsAndBytesConfig(load_in_4bit=<span class="hljs-literal">True</span>) | |
| tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">"CohereForAI/c4ai-command-r-v01"</span>) | |
| model = AutoModelForCausalLM.from_pretrained(<span class="hljs-string">"CohereForAI/c4ai-command-r-v01"</span>, device_map=<span class="hljs-string">"auto"</span>, quantization_config=bnb_config, attn_implementation=<span class="hljs-string">"sdpa"</span>) | |
| <span class="hljs-comment"># format message with the Command-R chat template</span> | |
| messages = [{<span class="hljs-string">"role"</span>: <span class="hljs-string">"user"</span>, <span class="hljs-string">"content"</span>: <span class="hljs-string">"How do plants make energy?"</span>}] | |
| input_ids = tokenizer.apply_chat_template(messages, tokenize=<span class="hljs-literal">True</span>, add_generation_prompt=<span class="hljs-literal">True</span>, return_tensors=<span class="hljs-string">"pt"</span>).to(model.device) | |
| output = model.generate( | |
| input_ids, | |
| max_new_tokens=<span class="hljs-number">100</span>, | |
| do_sample=<span class="hljs-literal">True</span>, | |
| temperature=<span class="hljs-number">0.3</span>, | |
| cache_implementation=<span class="hljs-string">"static"</span>, | |
| ) | |
| <span class="hljs-built_in">print</span>(tokenizer.decode(output[<span class="hljs-number">0</span>], skip_special_tokens=<span class="hljs-literal">True</span>))`,lang:"python",wrap:!1}}),he=new E({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycy51dGlscy5hdHRlbnRpb25fdmlzdWFsaXplciUyMGltcG9ydCUyMEF0dGVudGlvbk1hc2tWaXN1YWxpemVyJTBBJTBBJTBBdmlzdWFsaXplciUyMCUzRCUyMEF0dGVudGlvbk1hc2tWaXN1YWxpemVyKCUyMkNvaGVyZUZvckFJJTJGYzRhaS1jb21tYW5kLXItdjAxJTIyKSUwQXZpc3VhbGl6ZXIoJTIyUGxhbnRzJTIwY3JlYXRlJTIwZW5lcmd5JTIwdGhyb3VnaCUyMGElMjBwcm9jZXNzJTIwa25vd24lMjBhcyUyMik=",highlighted:`<span class="hljs-keyword">from</span> transformers.utils.attention_visualizer <span class="hljs-keyword">import</span> AttentionMaskVisualizer | |
| visualizer = AttentionMaskVisualizer(<span class="hljs-string">"CohereForAI/c4ai-command-r-v01"</span>) | |
| visualizer(<span class="hljs-string">"Plants create energy through a process known as"</span>)`,lang:"python",wrap:!1}}),ue=new et({props:{title:"Notes",local:"notes",headingTag:"h2"}}),ge=new et({props:{title:"CohereConfig",local:"transformers.CohereConfig",headingTag:"h2"}}),_e=new ne({props:{name:"class transformers.CohereConfig",anchor:"transformers.CohereConfig",parameters:[{name:"transformers_version",val:": str | None = None"},{name:"architectures",val:": list[str] | None = None"},{name:"output_hidden_states",val:": bool | None = False"},{name:"return_dict",val:": bool | None = True"},{name:"dtype",val:": typing.Union[str, ForwardRef('torch.dtype'), NoneType] = None"},{name:"chunk_size_feed_forward",val:": int = 0"},{name:"is_encoder_decoder",val:": bool = False"},{name:"id2label",val:": dict[int, str] | dict[str, str] | None = None"},{name:"label2id",val:": dict[str, int] | dict[str, str] | None = None"},{name:"problem_type",val:": typing.Optional[typing.Literal['regression', 'single_label_classification', 'multi_label_classification']] = None"},{name:"vocab_size",val:": int = 256000"},{name:"hidden_size",val:": int = 8192"},{name:"intermediate_size",val:": int = 22528"},{name:"logit_scale",val:": float | None = 0.0625"},{name:"num_hidden_layers",val:": int = 40"},{name:"num_attention_heads",val:": int = 64"},{name:"num_key_value_heads",val:": int | None = None"},{name:"hidden_act",val:": str = 'silu'"},{name:"max_position_embeddings",val:": int = 8192"},{name:"initializer_range",val:": float = 0.02"},{name:"layer_norm_eps",val:": float | None = 1e-05"},{name:"use_cache",val:": bool = True"},{name:"pad_token_id",val:": int | None = 0"},{name:"bos_token_id",val:": int | None = 5"},{name:"eos_token_id",val:": int | list[int] | None = 255001"},{name:"tie_word_embeddings",val:": bool = True"},{name:"rope_parameters",val:": transformers.modeling_rope_utils.RopeParameters | dict | None = None"},{name:"attention_bias",val:": bool = False"},{name:"attention_dropout",val:": float | int | None = 0.0"},{name:"use_qk_norm",val:": bool | None = False"}],parametersDescription:[{anchor:"transformers.CohereConfig.vocab_size",description:`<strong>vocab_size</strong> (<code>int</code>, <em>optional</em>, defaults to <code>256000</code>) — | |
| Vocabulary size of the model. Defines the number of different tokens that can be represented by the <code>input_ids</code>.`,name:"vocab_size"},{anchor:"transformers.CohereConfig.hidden_size",description:`<strong>hidden_size</strong> (<code>int</code>, <em>optional</em>, defaults to <code>8192</code>) — | |
| Dimension of the hidden representations.`,name:"hidden_size"},{anchor:"transformers.CohereConfig.intermediate_size",description:`<strong>intermediate_size</strong> (<code>int</code>, <em>optional</em>, defaults to <code>22528</code>) — | |
| Dimension of the MLP representations.`,name:"intermediate_size"},{anchor:"transformers.CohereConfig.logit_scale",description:`<strong>logit_scale</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0625) — | |
| The scaling factor for the output logits.`,name:"logit_scale"},{anchor:"transformers.CohereConfig.num_hidden_layers",description:`<strong>num_hidden_layers</strong> (<code>int</code>, <em>optional</em>, defaults to <code>40</code>) — | |
| Number of hidden layers in the Transformer decoder.`,name:"num_hidden_layers"},{anchor:"transformers.CohereConfig.num_attention_heads",description:`<strong>num_attention_heads</strong> (<code>int</code>, <em>optional</em>, defaults to <code>64</code>) — | |
| Number of attention heads for each attention layer in the Transformer decoder.`,name:"num_attention_heads"},{anchor:"transformers.CohereConfig.num_key_value_heads",description:`<strong>num_key_value_heads</strong> (<code>int</code>, <em>optional</em>) — | |
| This is the number of key_value heads that should be used to implement Grouped Query Attention. If | |
| <code>num_key_value_heads=num_attention_heads</code>, the model will use Multi Head Attention (MHA), if | |
| <code>num_key_value_heads=1</code> the model will use Multi Query Attention (MQA) otherwise GQA is used. When | |
| converting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructed | |
| by meanpooling all the original heads within that group. For more details, check out <a href="https://huggingface.co/papers/2305.13245" rel="nofollow">this | |
| paper</a>. If it is not specified, will default to | |
| <code>num_attention_heads</code>.`,name:"num_key_value_heads"},{anchor:"transformers.CohereConfig.hidden_act",description:`<strong>hidden_act</strong> (<code>str</code>, <em>optional</em>, defaults to <code>silu</code>) — | |
| The non-linear activation function (function or string) in the decoder. For example, <code>"gelu"</code>, | |
| <code>"relu"</code>, <code>"silu"</code>, etc.`,name:"hidden_act"},{anchor:"transformers.CohereConfig.max_position_embeddings",description:`<strong>max_position_embeddings</strong> (<code>int</code>, <em>optional</em>, defaults to <code>8192</code>) — | |
| The maximum sequence length that this model might ever be used with.`,name:"max_position_embeddings"},{anchor:"transformers.CohereConfig.initializer_range",description:`<strong>initializer_range</strong> (<code>float</code>, <em>optional</em>, defaults to <code>0.02</code>) — | |
| The standard deviation of the truncated_normal_initializer for initializing all weight matrices.`,name:"initializer_range"},{anchor:"transformers.CohereConfig.layer_norm_eps",description:`<strong>layer_norm_eps</strong> (<code>float</code>, <em>optional</em>, defaults to <code>1e-05</code>) — | |
| The epsilon used by the layer normalization layers.`,name:"layer_norm_eps"},{anchor:"transformers.CohereConfig.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) — | |
| Whether or not the model should return the last key/values attentions (not used by all models). Only | |
| relevant if <code>config.is_decoder=True</code> or when the model is a decoder-only generative model.`,name:"use_cache"},{anchor:"transformers.CohereConfig.pad_token_id",description:`<strong>pad_token_id</strong> (<code>int</code>, <em>optional</em>, defaults to <code>0</code>) — | |
| Token id used for padding in the vocabulary.`,name:"pad_token_id"},{anchor:"transformers.CohereConfig.bos_token_id",description:`<strong>bos_token_id</strong> (<code>int</code>, <em>optional</em>, defaults to <code>5</code>) — | |
| Token id used for beginning-of-stream in the vocabulary.`,name:"bos_token_id"},{anchor:"transformers.CohereConfig.eos_token_id",description:`<strong>eos_token_id</strong> (<code>Union[int, list[int]]</code>, <em>optional</em>, defaults to <code>255001</code>) — | |
| Token id used for end-of-stream in the vocabulary.`,name:"eos_token_id"},{anchor:"transformers.CohereConfig.tie_word_embeddings",description:`<strong>tie_word_embeddings</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) — | |
| Whether to tie weight embeddings according to model’s <code>tied_weights_keys</code> mapping.`,name:"tie_word_embeddings"},{anchor:"transformers.CohereConfig.rope_parameters",description:`<strong>rope_parameters</strong> (<code>Union[~modeling_rope_utils.RopeParameters, dict]</code>, <em>optional</em>) — | |
| Dictionary containing the configuration parameters for the RoPE embeddings. The dictionary should contain | |
| a value for <code>rope_theta</code> and optionally parameters used for scaling in case you want to use RoPE | |
| with longer <code>max_position_embeddings</code>.`,name:"rope_parameters"},{anchor:"transformers.CohereConfig.attention_bias",description:`<strong>attention_bias</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| Whether to use a bias in the query, key, value and output projection layers during self-attention.`,name:"attention_bias"},{anchor:"transformers.CohereConfig.attention_dropout",description:`<strong>attention_dropout</strong> (<code>Union[float, int]</code>, <em>optional</em>, defaults to <code>0.0</code>) — | |
| The dropout ratio for the attention probabilities.`,name:"attention_dropout"},{anchor:"transformers.CohereConfig.use_qk_norm",description:`<strong>use_qk_norm</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| Whether to use query-key normalization in the attention.`,name:"use_qk_norm"}],source:"https://github.com/huggingface/transformers/blob/vr_43265/src/transformers/models/cohere/configuration_cohere.py#L30"}}),Y=new nt({props:{anchor:"transformers.CohereConfig.example",$$slots:{default:[cn]},$$scope:{ctx:J}}}),ye=new et({props:{title:"CohereTokenizer",local:"transformers.CohereTokenizer",headingTag:"h2"}}),Me=new ne({props:{name:"class transformers.CohereTokenizer",anchor:"transformers.CohereTokenizer",parameters:[{name:"vocab",val:": str | dict[str, int] | None = None"},{name:"merges",val:": str | list[str] | None = None"},{name:"errors",val:": str = 'replace'"},{name:"unk_token",val:": str = '<UNK>'"},{name:"bos_token",val:": str = '<BOS_TOKEN>'"},{name:"eos_token",val:": str = '<|END_OF_TURN_TOKEN|>'"},{name:"pad_token",val:": str = '<PAD>'"},{name:"cls_token",val:": str = '<CLS>'"},{name:"sep_token",val:": str = '<SEP>'"},{name:"mask_token",val:": str = '<MASK_TOKEN>'"},{name:"use_default_system_prompt",val:": bool = False"},{name:"add_prefix_space",val:": bool = False"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.CohereTokenizer.vocab_file",description:`<strong>vocab_file</strong> (<code>str</code>, <em>optional</em>) — | |
| Path to the vocabulary file.`,name:"vocab_file"},{anchor:"transformers.CohereTokenizer.merges_file",description:`<strong>merges_file</strong> (<code>str</code>, <em>optional</em>) — | |
| Path to the merges file.`,name:"merges_file"},{anchor:"transformers.CohereTokenizer.tokenizer_file",description:`<strong>tokenizer_file</strong> (<code>str</code>, <em>optional</em>) — | |
| <a href="https://github.com/huggingface/tokenizers" rel="nofollow">tokenizers</a> file (generally has a .json extension) that | |
| contains everything needed to load the tokenizer.`,name:"tokenizer_file"},{anchor:"transformers.CohereTokenizer.clean_up_tokenization_spaces",description:`<strong>clean_up_tokenization_spaces</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| Whether or not to cleanup spaces after decoding, cleanup consists in removing potential artifacts like | |
| extra spaces.`,name:"clean_up_tokenization_spaces"},{anchor:"transformers.CohereTokenizer.unk_token",description:`<strong>unk_token</strong> (<code>str</code> or <code>tokenizers.AddedToken</code>, <em>optional</em>, defaults to <code>"<UNK>"</code>) — | |
| The unknown token. A token that is not in the vocabulary cannot be converted to an ID and is set to be this | |
| token instead.`,name:"unk_token"},{anchor:"transformers.CohereTokenizer.bos_token",description:`<strong>bos_token</strong> (<code>str</code> or <code>tokenizers.AddedToken</code>, <em>optional</em>, defaults to <code>"<BOS_TOKEN>"</code>) — | |
| The beginning of sequence token that was used during pretraining. Can be used a sequence classifier token.`,name:"bos_token"},{anchor:"transformers.CohereTokenizer.eos_token",description:`<strong>eos_token</strong> (<code>str</code> or <code>tokenizers.AddedToken</code>, <em>optional</em>, defaults to <code>"<|END_OF_TURN_TOKEN|>"</code>) — | |
| The end of sequence token.`,name:"eos_token"},{anchor:"transformers.CohereTokenizer.add_bos_token",description:`<strong>add_bos_token</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) — | |
| Whether or not to add an <code>bos_token</code> at the start of sequences.`,name:"add_bos_token"},{anchor:"transformers.CohereTokenizer.add_eos_token",description:`<strong>add_eos_token</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| Whether or not to add an <code>eos_token</code> at the end of sequences.`,name:"add_eos_token"},{anchor:"transformers.CohereTokenizer.use_default_system_prompt",description:`<strong>use_default_system_prompt</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| Whether or not the default system prompt for Cohere tokenizer should be used.`,name:"use_default_system_prompt"},{anchor:"transformers.CohereTokenizer.add_prefix_space",description:`<strong>add_prefix_space</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| Whether or not the tokenizer should automatically add a prefix space`,name:"add_prefix_space"},{anchor:"transformers.CohereTokenizer.vocab",description:`<strong>vocab</strong> (<code>str</code>, <code>dict</code> or <code>list</code>, <em>optional</em>) — | |
| Custom vocabulary dictionary. If not provided, vocabulary is loaded from vocab_file.`,name:"vocab"},{anchor:"transformers.CohereTokenizer.merges",description:`<strong>merges</strong> (<code>str</code> or <code>list[str]</code>, <em>optional</em>) — | |
| Custom merges list. If not provided, merges are loaded from <code>merges_file</code>.`,name:"merges"}],source:"https://github.com/huggingface/transformers/blob/vr_43265/src/transformers/models/cohere/tokenization_cohere.py#L45"}}),P=new nt({props:{anchor:"transformers.CohereTokenizer.example",$$slots:{default:[pn]},$$scope:{ctx:J}}}),D=new ho({props:{$$slots:{default:[mn]},$$scope:{ctx:J}}}),Te=new ne({props:{name:"apply_grounded_generation_template",anchor:"transformers.CohereTokenizer.apply_grounded_generation_template",parameters:[{name:"conversation",val:": list"},{name:"documents",val:": list"},{name:"citation_mode",val:": typing.Literal['fast', 'accurate'] = 'accurate'"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.CohereTokenizer.apply_grounded_generation_template.conversation",description:`<strong>conversation</strong> (list[dict[str, str]]) — A list of dicts | |
| with “role” and “content” keys, representing the chat history so far.`,name:"conversation"},{anchor:"transformers.CohereTokenizer.apply_grounded_generation_template.documents",description:`<strong>documents</strong> (list[dict[str, str]) — A list of dicts, representing documents or tool outputs to ground your | |
| generation on. A document is a semistructured dict, with a string to string mapping. Common fields are | |
| <code>url</code>, <code>title</code>, <code>snippet</code> etc but should be descriptive of the key. They will get rendered into the prompt.`,name:"documents"},{anchor:"transformers.CohereTokenizer.apply_grounded_generation_template.citation_mode",description:`<strong>citation_mode</strong> — either “accurate” (prompt the model to generate an answer first, then rewrite it with citation | |
| spans in) or “fast”, where the prompt instructs the model to generate an answer with citations in directly. | |
| The former has higher quality citations, the latter requires fewer tokens to be generated.`,name:"citation_mode"},{anchor:"transformers.CohereTokenizer.apply_grounded_generation_template.add_generation_prompt",description:`<strong>add_generation_prompt</strong> (bool, <em>optional</em>) — Whether to end the prompt with the token(s) that indicate | |
| the start of an assistant message. This is useful when you want to generate a response from the model. | |
| Note that this argument will be passed to the chat template, and so it must be supported in the | |
| template for this argument to have any effect.`,name:"add_generation_prompt"},{anchor:"transformers.CohereTokenizer.apply_grounded_generation_template.tokenize",description:`<strong>tokenize</strong> (<code>bool</code>, defaults to <code>True</code>) — | |
| Whether to tokenize the output. If <code>False</code>, the output will be a string.`,name:"tokenize"},{anchor:"transformers.CohereTokenizer.apply_grounded_generation_template.padding",description:`<strong>padding</strong> (<code>bool</code>, defaults to <code>False</code>) — | |
| Whether to pad sequences to the maximum length. Has no effect if tokenize is <code>False</code>.`,name:"padding"},{anchor:"transformers.CohereTokenizer.apply_grounded_generation_template.truncation",description:`<strong>truncation</strong> (<code>bool</code>, defaults to <code>False</code>) — | |
| Whether to truncate sequences at the maximum length. Has no effect if tokenize is <code>False</code>.`,name:"truncation"},{anchor:"transformers.CohereTokenizer.apply_grounded_generation_template.max_length",description:`<strong>max_length</strong> (<code>int</code>, <em>optional</em>) — | |
| Maximum length (in tokens) to use for padding or truncation. Has no effect if tokenize is <code>False</code>. If | |
| not specified, the tokenizer’s <code>max_length</code> attribute will be used as a default.`,name:"max_length"},{anchor:"transformers.CohereTokenizer.apply_grounded_generation_template.return_tensors",description:`<strong>return_tensors</strong> (<code>str</code> or <a href="/docs/transformers/pr_43265/en/internal/file_utils#transformers.TensorType">TensorType</a>, <em>optional</em>) — | |
| If set, will return tensors of a particular framework. Has no effect if tokenize is <code>False</code>. Acceptable | |
| values are: | |
| <ul> | |
| <li><code>'pt'</code>: Return PyTorch <code>torch.Tensor</code> objects.</li> | |
| <li><code>'np'</code>: Return NumPy <code>np.ndarray</code> objects.</li> | |
| </ul>`,name:"return_tensors"},{anchor:"transformers.CohereTokenizer.apply_grounded_generation_template.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| Whether to return a dictionary with named outputs. Has no effect if tokenize is <code>False</code>.`,name:"return_dict"},{anchor:"transformers.CohereTokenizer.apply_grounded_generation_template.*tokenizer_kwargs",description:"*<strong>*tokenizer_kwargs</strong> — Additional kwargs to pass to the tokenizer.",name:"*tokenizer_kwargs"}],source:"https://github.com/huggingface/transformers/blob/vr_43265/src/transformers/models/cohere/tokenization_cohere.py#L297",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>A rendered prompt string. | |
| or if tokenize=True: | |
| <code>list[int]</code>: A list of token ids representing the tokenized chat so far, including control tokens. This | |
| output is ready to pass to the model, either directly or via methods like <code>generate()</code>.</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>str</code></p> | |
| `}}),K=new nt({props:{anchor:"transformers.CohereTokenizer.apply_grounded_generation_template.example",$$slots:{default:[hn]},$$scope:{ctx:J}}}),be=new ne({props:{name:"apply_tool_use_template",anchor:"transformers.CohereTokenizer.apply_tool_use_template",parameters:[{name:"conversation",val:": list"},{name:"tools",val:": list"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.CohereTokenizer.apply_tool_use_template.conversation",description:`<strong>conversation</strong> (list[dict[str, str]]) — A list of dicts | |
| with “role” and “content” keys, representing the chat history so far.`,name:"conversation"},{anchor:"transformers.CohereTokenizer.apply_tool_use_template.tools",description:`<strong>tools</strong> (list[Dict]) — a list of tools to render into the prompt for the model to choose from. | |
| See an example at the bottom of the docstring. | |
| The format should be: | |
| <ul> | |
| <li>name (str): The name of the tool to be called. Valid names contain only the characters a-z, | |
| A-Z, 0-9, _ and must not begin with a digit.</li> | |
| <li>description (str): The description of what the tool does, the model uses the description to | |
| choose when and how to call the function.</li> | |
| <li>parameter<em>definitions (list[Dict]): The input parameters of the tool. Accepts a dictionary | |
| where the key is the name of the parameter and the value is the parameter spec. | |
| Valid parameter names contain only the characters a-z, A-Z, 0-9, </em> and must not begin with a digit. | |
| Parameter specs are as follows: | |
| <ul> | |
| <li>description (str): The description of the parameter.</li> | |
| <li>type (str): the type of the parameter - most effective for python builtin data types, such as ‘str’, ‘bool’</li> | |
| <li>required: boolean: Denotes whether the parameter is always present (required) or not. Defaults to not required.</li> | |
| </ul> | |
| </li> | |
| </ul>`,name:"tools"},{anchor:"transformers.CohereTokenizer.apply_tool_use_template.add_generation_prompt",description:`<strong>add_generation_prompt</strong> (bool, <em>optional</em>) — Whether to end the prompt with the token(s) that indicate | |
| the start of an assistant message. This is useful when you want to generate a response from the model. | |
| Note that this argument will be passed to the chat template, and so it must be supported in the | |
| template for this argument to have any effect.`,name:"add_generation_prompt"},{anchor:"transformers.CohereTokenizer.apply_tool_use_template.tokenize",description:`<strong>tokenize</strong> (<code>bool</code>, defaults to <code>True</code>) — | |
| Whether to tokenize the output. If <code>False</code>, the output will be a string.`,name:"tokenize"},{anchor:"transformers.CohereTokenizer.apply_tool_use_template.padding",description:`<strong>padding</strong> (<code>bool</code>, defaults to <code>False</code>) — | |
| Whether to pad sequences to the maximum length. Has no effect if tokenize is <code>False</code>.`,name:"padding"},{anchor:"transformers.CohereTokenizer.apply_tool_use_template.truncation",description:`<strong>truncation</strong> (<code>bool</code>, defaults to <code>False</code>) — | |
| Whether to truncate sequences at the maximum length. Has no effect if tokenize is <code>False</code>.`,name:"truncation"},{anchor:"transformers.CohereTokenizer.apply_tool_use_template.max_length",description:`<strong>max_length</strong> (<code>int</code>, <em>optional</em>) — | |
| Maximum length (in tokens) to use for padding or truncation. Has no effect if tokenize is <code>False</code>. If | |
| not specified, the tokenizer’s <code>max_length</code> attribute will be used as a default.`,name:"max_length"},{anchor:"transformers.CohereTokenizer.apply_tool_use_template.return_tensors",description:`<strong>return_tensors</strong> (<code>str</code> or <a href="/docs/transformers/pr_43265/en/internal/file_utils#transformers.TensorType">TensorType</a>, <em>optional</em>) — | |
| If set, will return tensors of a particular framework. Has no effect if tokenize is <code>False</code>. Acceptable | |
| values are: | |
| <ul> | |
| <li><code>'pt'</code>: Return PyTorch <code>torch.Tensor</code> objects.</li> | |
| <li><code>'np'</code>: Return NumPy <code>np.ndarray</code> objects.</li> | |
| </ul>`,name:"return_tensors"},{anchor:"transformers.CohereTokenizer.apply_tool_use_template.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| Whether to return a dictionary with named outputs. Has no effect if tokenize is <code>False</code>.`,name:"return_dict"},{anchor:"transformers.CohereTokenizer.apply_tool_use_template.*tokenizer_kwargs",description:"*<strong>*tokenizer_kwargs</strong> — Additional kwargs to pass to the tokenizer.",name:"*tokenizer_kwargs"}],source:"https://github.com/huggingface/transformers/blob/vr_43265/src/transformers/models/cohere/tokenization_cohere.py#L186",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>A rendered prompt string. | |
| or if tokenize=True: | |
| <code>list[int]</code>: A list of token ids representing the tokenized chat so far, including control tokens. This | |
| output is ready to pass to the model, either directly or via methods like <code>generate()</code>.</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>str</code></p> | |
| `}}),O=new nt({props:{anchor:"transformers.CohereTokenizer.apply_tool_use_template.example",$$slots:{default:[un]},$$scope:{ctx:J}}}),we=new et({props:{title:"CohereModel",local:"transformers.CohereModel",headingTag:"h2"}}),Je=new ne({props:{name:"class transformers.CohereModel",anchor:"transformers.CohereModel",parameters:[{name:"config",val:": CohereConfig"}],parametersDescription:[{anchor:"transformers.CohereModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_43265/en/model_doc/cohere#transformers.CohereConfig">CohereConfig</a>) — | |
| 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/pr_43265/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/vr_43265/src/transformers/models/cohere/modeling_cohere.py#L379"}}),Ce=new ne({props:{name:"forward",anchor:"transformers.CohereModel.forward",parameters:[{name:"input_ids",val:": torch.LongTensor | None = None"},{name:"attention_mask",val:": torch.Tensor | None = None"},{name:"position_ids",val:": torch.LongTensor | None = None"},{name:"past_key_values",val:": transformers.cache_utils.Cache | None = None"},{name:"inputs_embeds",val:": torch.FloatTensor | None = None"},{name:"use_cache",val:": bool | None = None"},{name:"**kwargs",val:": typing_extensions.Unpack[transformers.utils.generic.TransformersKwargs]"}],parametersDescription:[{anchor:"transformers.CohereModel.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) — | |
| Indices of input sequence tokens in the vocabulary. Padding will be ignored by default.</p> | |
| <p>Indices can be obtained using <a href="/docs/transformers/pr_43265/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/pr_43265/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and | |
| <a href="/docs/transformers/pr_43265/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p> | |
| <p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.CohereModel.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) — | |
| 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.CohereModel.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) — | |
| Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.n_positions - 1]</code>.</p> | |
| <p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.CohereModel.forward.past_key_values",description:`<strong>past_key_values</strong> (<code>~cache_utils.Cache</code>, <em>optional</em>) — | |
| Pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention | |
| blocks) that can be used to speed up sequential decoding. This typically consists in the <code>past_key_values</code> | |
| returned by the model at a previous stage of decoding, when <code>use_cache=True</code> or <code>config.use_cache=True</code>.</p> | |
| <p>Only <a href="/docs/transformers/pr_43265/en/internal/generation_utils#transformers.Cache">Cache</a> instance is allowed as input, see our <a href="https://huggingface.co/docs/transformers/en/kv_cache" rel="nofollow">kv cache guide</a>. | |
| If no <code>past_key_values</code> are passed, <a href="/docs/transformers/pr_43265/en/internal/generation_utils#transformers.DynamicCache">DynamicCache</a> will be initialized by default.</p> | |
| <p>The model will output the same cache format that is fed as input.</p> | |
| <p>If <code>past_key_values</code> are used, the user is expected to input only unprocessed <code>input_ids</code> (those that don’t | |
| have their past key value states given to this model) of shape <code>(batch_size, unprocessed_length)</code> instead of all <code>input_ids</code> | |
| of shape <code>(batch_size, sequence_length)</code>.`,name:"past_key_values"},{anchor:"transformers.CohereModel.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) — | |
| Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This | |
| is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the | |
| model’s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.CohereModel.forward.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>) — | |
| 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"}],source:"https://github.com/huggingface/transformers/blob/vr_43265/src/transformers/models/cohere/modeling_cohere.py#L396",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>A <a | |
| href="/docs/transformers/pr_43265/en/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPast" | |
| >BaseModelOutputWithPast</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/pr_43265/en/model_doc/cohere#transformers.CohereConfig" | |
| >CohereConfig</a>) and inputs.</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><a | |
| href="/docs/transformers/pr_43265/en/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPast" | |
| >BaseModelOutputWithPast</a> or <code>tuple(torch.FloatTensor)</code></p> | |
| `}}),ee=new ho({props:{$$slots:{default:[fn]},$$scope:{ctx:J}}}),ke=new et({props:{title:"CohereForCausalLM",local:"transformers.CohereForCausalLM",headingTag:"h2"}}),Ue=new ne({props:{name:"class transformers.CohereForCausalLM",anchor:"transformers.CohereForCausalLM",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.CohereForCausalLM.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_43265/en/model_doc/cohere#transformers.CohereForCausalLM">CohereForCausalLM</a>) — | |
| 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/pr_43265/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/vr_43265/src/transformers/models/cohere/modeling_cohere.py#L453"}}),ve=new ne({props:{name:"forward",anchor:"transformers.CohereForCausalLM.forward",parameters:[{name:"input_ids",val:": torch.LongTensor | None = None"},{name:"attention_mask",val:": torch.Tensor | None = None"},{name:"position_ids",val:": torch.LongTensor | None = None"},{name:"past_key_values",val:": transformers.cache_utils.Cache | None = None"},{name:"inputs_embeds",val:": torch.FloatTensor | None = None"},{name:"labels",val:": torch.LongTensor | None = None"},{name:"use_cache",val:": bool | None = None"},{name:"logits_to_keep",val:": int | torch.Tensor = 0"},{name:"**kwargs",val:": typing_extensions.Unpack[transformers.utils.generic.TransformersKwargs]"}],parametersDescription:[{anchor:"transformers.CohereForCausalLM.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) — | |
| Indices of input sequence tokens in the vocabulary. Padding will be ignored by default.</p> | |
| <p>Indices can be obtained using <a href="/docs/transformers/pr_43265/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/pr_43265/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and | |
| <a href="/docs/transformers/pr_43265/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p> | |
| <p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.CohereForCausalLM.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) — | |
| 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.CohereForCausalLM.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) — | |
| Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.n_positions - 1]</code>.</p> | |
| <p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.CohereForCausalLM.forward.past_key_values",description:`<strong>past_key_values</strong> (<code>~cache_utils.Cache</code>, <em>optional</em>) — | |
| Pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention | |
| blocks) that can be used to speed up sequential decoding. This typically consists in the <code>past_key_values</code> | |
| returned by the model at a previous stage of decoding, when <code>use_cache=True</code> or <code>config.use_cache=True</code>.</p> | |
| <p>Only <a href="/docs/transformers/pr_43265/en/internal/generation_utils#transformers.Cache">Cache</a> instance is allowed as input, see our <a href="https://huggingface.co/docs/transformers/en/kv_cache" rel="nofollow">kv cache guide</a>. | |
| If no <code>past_key_values</code> are passed, <a href="/docs/transformers/pr_43265/en/internal/generation_utils#transformers.DynamicCache">DynamicCache</a> will be initialized by default.</p> | |
| <p>The model will output the same cache format that is fed as input.</p> | |
| <p>If <code>past_key_values</code> are used, the user is expected to input only unprocessed <code>input_ids</code> (those that don’t | |
| have their past key value states given to this model) of shape <code>(batch_size, unprocessed_length)</code> instead of all <code>input_ids</code> | |
| of shape <code>(batch_size, sequence_length)</code>.`,name:"past_key_values"},{anchor:"transformers.CohereForCausalLM.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) — | |
| Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This | |
| is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the | |
| model’s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.CohereForCausalLM.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) — | |
| Labels for computing the masked language modeling loss. Indices should either be in <code>[0, ..., config.vocab_size]</code> or -100 (see <code>input_ids</code> docstring). Tokens with indices set to <code>-100</code> are ignored | |
| (masked), the loss is only computed for the tokens with labels in <code>[0, ..., config.vocab_size]</code>.`,name:"labels"},{anchor:"transformers.CohereForCausalLM.forward.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>) — | |
| 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.CohereForCausalLM.forward.logits_to_keep",description:`<strong>logits_to_keep</strong> (<code>Union[int, torch.Tensor]</code>, <em>optional</em>, defaults to <code>0</code>) — | |
| If an <code>int</code>, compute logits for the last <code>logits_to_keep</code> tokens. If <code>0</code>, calculate logits for all | |
| <code>input_ids</code> (special case). Only last token logits are needed for generation, and calculating them only for that | |
| token can save memory, which becomes pretty significant for long sequences or large vocabulary size. | |
| If a <code>torch.Tensor</code>, must be 1D corresponding to the indices to keep in the sequence length dimension. | |
| This is useful when using packed tensor format (single dimension for batch and sequence length).`,name:"logits_to_keep"}],source:"https://github.com/huggingface/transformers/blob/vr_43265/src/transformers/models/cohere/modeling_cohere.py#L469",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>A <a | |
| href="/docs/transformers/pr_43265/en/main_classes/output#transformers.modeling_outputs.CausalLMOutputWithPast" | |
| >CausalLMOutputWithPast</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/pr_43265/en/model_doc/cohere#transformers.CohereConfig" | |
| >CohereConfig</a>) and inputs.</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><a | |
| href="/docs/transformers/pr_43265/en/main_classes/output#transformers.modeling_outputs.CausalLMOutputWithPast" | |
| >CausalLMOutputWithPast</a> or <code>tuple(torch.FloatTensor)</code></p> | |
| `}}),te=new ho({props:{$$slots:{default:[gn]},$$scope:{ctx:J}}}),oe=new nt({props:{anchor:"transformers.CohereForCausalLM.forward.example",$$slots:{default:[_n]},$$scope:{ctx:J}}}),je=new nn({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/model_doc/cohere.md"}}),{c(){t=d("meta"),p=s(),o=d("p"),h=s(),w=d("p"),w.innerHTML=m,u=s(),g(U.$$.fragment),se=s(),B=d("div"),B.innerHTML=tt,st=s(),g(ae.$$.fragment),at=s(),re=d("p"),re.innerHTML=fo,rt=s(),le=d("p"),le.innerHTML=go,lt=s(),A=d("blockquote"),A.innerHTML=_o,it=s(),ie=d("p"),ie.innerHTML=yo,dt=s(),g(Q.$$.fragment),ct=s(),de=d("p"),de.innerHTML=Mo,pt=s(),ce=d("p"),ce.innerHTML=To,mt=s(),g(pe.$$.fragment),ht=s(),me=d("p"),me.innerHTML=bo,ut=s(),g(he.$$.fragment),ft=s(),L=d("div"),L.innerHTML=wo,gt=s(),g(ue.$$.fragment),_t=s(),fe=d("ul"),fe.innerHTML=Jo,yt=s(),g(ge.$$.fragment),Mt=s(),G=d("div"),g(_e.$$.fragment),It=s(),Ie=d("p"),Ie.innerHTML=Co,$t=s(),$e=d("p"),$e.innerHTML=ko,zt=s(),g(Y.$$.fragment),Tt=s(),g(ye.$$.fragment),bt=s(),C=d("div"),g(Me.$$.fragment),xt=s(),ze=d("p"),ze.textContent=Uo,Zt=s(),xe=d("p"),xe.textContent=vo,Gt=s(),g(P.$$.fragment),Ft=s(),Ze=d("p"),Ze.innerHTML=jo,Wt=s(),Ge=d("p"),Ge.innerHTML=Io,Nt=s(),g(D.$$.fragment),Rt=s(),Fe=d("p"),Fe.innerHTML=$o,qt=s(),v=d("div"),g(Te.$$.fragment),Bt=s(),We=d("p"),We.textContent=zo,Vt=s(),Ne=d("p"),Ne.textContent=xo,Ht=s(),Re=d("p"),Re.innerHTML=Zo,St=s(),qe=d("p"),qe.innerHTML=Go,Xt=s(),g(K.$$.fragment),Et=s(),j=d("div"),g(be.$$.fragment),At=s(),Be=d("p"),Be.textContent=Fo,Qt=s(),Ve=d("p"),Ve.textContent=Wo,Lt=s(),He=d("p"),He.innerHTML=No,Yt=s(),Se=d("p"),Se.innerHTML=Ro,Pt=s(),g(O.$$.fragment),wt=s(),g(we.$$.fragment),Jt=s(),I=d("div"),g(Je.$$.fragment),Dt=s(),Xe=d("p"),Xe.textContent=qo,Kt=s(),Ee=d("p"),Ee.innerHTML=Bo,Ot=s(),Ae=d("p"),Ae.innerHTML=Vo,eo=s(),R=d("div"),g(Ce.$$.fragment),to=s(),Qe=d("p"),Qe.innerHTML=Ho,oo=s(),g(ee.$$.fragment),no=s(),Le=d("ul"),Le.innerHTML=So,Ct=s(),g(ke.$$.fragment),kt=s(),$=d("div"),g(Ue.$$.fragment),so=s(),Ye=d("p"),Ye.textContent=Xo,ao=s(),Pe=d("p"),Pe.innerHTML=Eo,ro=s(),De=d("p"),De.innerHTML=Ao,lo=s(),Z=d("div"),g(ve.$$.fragment),io=s(),Ke=d("p"),Ke.innerHTML=Qo,co=s(),g(te.$$.fragment),po=s(),Oe=d("ul"),Oe.innerHTML=Lo,mo=s(),g(oe.$$.fragment),Ut=s(),g(je.$$.fragment),vt=s(),ot=d("p"),this.h()},l(e){const n=en("svelte-u9bgzb",document.head);t=c(n,"META",{name:!0,content:!0}),n.forEach(r),p=a(e),o=c(e,"P",{}),X(o).forEach(r),h=a(e),w=c(e,"P",{"data-svelte-h":!0}),f(w)!=="svelte-1bnmcwb"&&(w.innerHTML=m),u=a(e),_(U.$$.fragment,e),se=a(e),B=c(e,"DIV",{style:!0,"data-svelte-h":!0}),f(B)!=="svelte-1d68sxl"&&(B.innerHTML=tt),st=a(e),_(ae.$$.fragment,e),at=a(e),re=c(e,"P",{"data-svelte-h":!0}),f(re)!=="svelte-zmdpgo"&&(re.innerHTML=fo),rt=a(e),le=c(e,"P",{"data-svelte-h":!0}),f(le)!=="svelte-1rlhpz"&&(le.innerHTML=go),lt=a(e),A=c(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),f(A)!=="svelte-18uxfcw"&&(A.innerHTML=_o),it=a(e),ie=c(e,"P",{"data-svelte-h":!0}),f(ie)!=="svelte-122tlzn"&&(ie.innerHTML=yo),dt=a(e),_(Q.$$.fragment,e),ct=a(e),de=c(e,"P",{"data-svelte-h":!0}),f(de)!=="svelte-nf5ooi"&&(de.innerHTML=Mo),pt=a(e),ce=c(e,"P",{"data-svelte-h":!0}),f(ce)!=="svelte-1ca5nhg"&&(ce.innerHTML=To),mt=a(e),_(pe.$$.fragment,e),ht=a(e),me=c(e,"P",{"data-svelte-h":!0}),f(me)!=="svelte-w3z5ks"&&(me.innerHTML=bo),ut=a(e),_(he.$$.fragment,e),ft=a(e),L=c(e,"DIV",{class:!0,"data-svelte-h":!0}),f(L)!=="svelte-1dgk9vs"&&(L.innerHTML=wo),gt=a(e),_(ue.$$.fragment,e),_t=a(e),fe=c(e,"UL",{"data-svelte-h":!0}),f(fe)!=="svelte-5hpch7"&&(fe.innerHTML=Jo),yt=a(e),_(ge.$$.fragment,e),Mt=a(e),G=c(e,"DIV",{class:!0});var V=X(G);_(_e.$$.fragment,V),It=a(V),Ie=c(V,"P",{"data-svelte-h":!0}),f(Ie)!=="svelte-1xjjsiu"&&(Ie.innerHTML=Co),$t=a(V),$e=c(V,"P",{"data-svelte-h":!0}),f($e)!=="svelte-1e8815j"&&($e.innerHTML=ko),zt=a(V),_(Y.$$.fragment,V),V.forEach(r),Tt=a(e),_(ye.$$.fragment,e),bt=a(e),C=c(e,"DIV",{class:!0});var k=X(C);_(Me.$$.fragment,k),xt=a(k),ze=c(k,"P",{"data-svelte-h":!0}),f(ze)!=="svelte-xb0zhn"&&(ze.textContent=Uo),Zt=a(k),xe=c(k,"P",{"data-svelte-h":!0}),f(xe)!=="svelte-8f5ey4"&&(xe.textContent=vo),Gt=a(k),_(P.$$.fragment,k),Ft=a(k),Ze=c(k,"P",{"data-svelte-h":!0}),f(Ze)!=="svelte-cnb6q1"&&(Ze.innerHTML=jo),Wt=a(k),Ge=c(k,"P",{"data-svelte-h":!0}),f(Ge)!=="svelte-1afeqmz"&&(Ge.innerHTML=Io),Nt=a(k),_(D.$$.fragment,k),Rt=a(k),Fe=c(k,"P",{"data-svelte-h":!0}),f(Fe)!=="svelte-n0kppq"&&(Fe.innerHTML=$o),qt=a(k),v=c(k,"DIV",{class:!0});var z=X(v);_(Te.$$.fragment,z),Bt=a(z),We=c(z,"P",{"data-svelte-h":!0}),f(We)!=="svelte-1qr3i4z"&&(We.textContent=zo),Vt=a(z),Ne=c(z,"P",{"data-svelte-h":!0}),f(Ne)!=="svelte-mcv28b"&&(Ne.textContent=xo),Ht=a(z),Re=c(z,"P",{"data-svelte-h":!0}),f(Re)!=="svelte-lcyshz"&&(Re.innerHTML=Zo),St=a(z),qe=c(z,"P",{"data-svelte-h":!0}),f(qe)!=="svelte-pea71a"&&(qe.innerHTML=Go),Xt=a(z),_(K.$$.fragment,z),z.forEach(r),Et=a(k),j=c(k,"DIV",{class:!0});var x=X(j);_(be.$$.fragment,x),At=a(x),Be=c(x,"P",{"data-svelte-h":!0}),f(Be)!=="svelte-kc13xj"&&(Be.textContent=Fo),Qt=a(x),Ve=c(x,"P",{"data-svelte-h":!0}),f(Ve)!=="svelte-17hueu1"&&(Ve.textContent=Wo),Lt=a(x),He=c(x,"P",{"data-svelte-h":!0}),f(He)!=="svelte-v8vbpm"&&(He.innerHTML=No),Yt=a(x),Se=c(x,"P",{"data-svelte-h":!0}),f(Se)!=="svelte-7a2giu"&&(Se.innerHTML=Ro),Pt=a(x),_(O.$$.fragment,x),x.forEach(r),k.forEach(r),wt=a(e),_(we.$$.fragment,e),Jt=a(e),I=c(e,"DIV",{class:!0});var F=X(I);_(Je.$$.fragment,F),Dt=a(F),Xe=c(F,"P",{"data-svelte-h":!0}),f(Xe)!=="svelte-jpshns"&&(Xe.textContent=qo),Kt=a(F),Ee=c(F,"P",{"data-svelte-h":!0}),f(Ee)!=="svelte-1gb3c10"&&(Ee.innerHTML=Bo),Ot=a(F),Ae=c(F,"P",{"data-svelte-h":!0}),f(Ae)!=="svelte-hswkmf"&&(Ae.innerHTML=Vo),eo=a(F),R=c(F,"DIV",{class:!0});var H=X(R);_(Ce.$$.fragment,H),to=a(H),Qe=c(H,"P",{"data-svelte-h":!0}),f(Qe)!=="svelte-165jkn3"&&(Qe.innerHTML=Ho),oo=a(H),_(ee.$$.fragment,H),no=a(H),Le=c(H,"UL",{"data-svelte-h":!0}),f(Le)!=="svelte-xardb3"&&(Le.innerHTML=So),H.forEach(r),F.forEach(r),Ct=a(e),_(ke.$$.fragment,e),kt=a(e),$=c(e,"DIV",{class:!0});var W=X($);_(Ue.$$.fragment,W),so=a(W),Ye=c(W,"P",{"data-svelte-h":!0}),f(Ye)!=="svelte-1tm3aen"&&(Ye.textContent=Xo),ao=a(W),Pe=c(W,"P",{"data-svelte-h":!0}),f(Pe)!=="svelte-1gb3c10"&&(Pe.innerHTML=Eo),ro=a(W),De=c(W,"P",{"data-svelte-h":!0}),f(De)!=="svelte-hswkmf"&&(De.innerHTML=Ao),lo=a(W),Z=c(W,"DIV",{class:!0});var N=X(Z);_(ve.$$.fragment,N),io=a(N),Ke=c(N,"P",{"data-svelte-h":!0}),f(Ke)!=="svelte-170xwmj"&&(Ke.innerHTML=Qo),co=a(N),_(te.$$.fragment,N),po=a(N),Oe=c(N,"UL",{"data-svelte-h":!0}),f(Oe)!=="svelte-1yb5o5x"&&(Oe.innerHTML=Lo),mo=a(N),_(oe.$$.fragment,N),N.forEach(r),W.forEach(r),Ut=a(e),_(je.$$.fragment,e),vt=a(e),ot=c(e,"P",{}),X(ot).forEach(r),this.h()},h(){q(t,"name","hf:doc:metadata"),q(t,"content",Mn),tn(B,"float","right"),q(A,"class","tip"),q(L,"class","flex justify-center"),q(G,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),q(v,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),q(j,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),q(C,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),q(R,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),q(I,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),q(Z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),q($,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(e,n){l(document.head,t),i(e,p,n),i(e,o,n),i(e,h,n),i(e,w,n),i(e,u,n),y(U,e,n),i(e,se,n),i(e,B,n),i(e,st,n),y(ae,e,n),i(e,at,n),i(e,re,n),i(e,rt,n),i(e,le,n),i(e,lt,n),i(e,A,n),i(e,it,n),i(e,ie,n),i(e,dt,n),y(Q,e,n),i(e,ct,n),i(e,de,n),i(e,pt,n),i(e,ce,n),i(e,mt,n),y(pe,e,n),i(e,ht,n),i(e,me,n),i(e,ut,n),y(he,e,n),i(e,ft,n),i(e,L,n),i(e,gt,n),y(ue,e,n),i(e,_t,n),i(e,fe,n),i(e,yt,n),y(ge,e,n),i(e,Mt,n),i(e,G,n),y(_e,G,null),l(G,It),l(G,Ie),l(G,$t),l(G,$e),l(G,zt),y(Y,G,null),i(e,Tt,n),y(ye,e,n),i(e,bt,n),i(e,C,n),y(Me,C,null),l(C,xt),l(C,ze),l(C,Zt),l(C,xe),l(C,Gt),y(P,C,null),l(C,Ft),l(C,Ze),l(C,Wt),l(C,Ge),l(C,Nt),y(D,C,null),l(C,Rt),l(C,Fe),l(C,qt),l(C,v),y(Te,v,null),l(v,Bt),l(v,We),l(v,Vt),l(v,Ne),l(v,Ht),l(v,Re),l(v,St),l(v,qe),l(v,Xt),y(K,v,null),l(C,Et),l(C,j),y(be,j,null),l(j,At),l(j,Be),l(j,Qt),l(j,Ve),l(j,Lt),l(j,He),l(j,Yt),l(j,Se),l(j,Pt),y(O,j,null),i(e,wt,n),y(we,e,n),i(e,Jt,n),i(e,I,n),y(Je,I,null),l(I,Dt),l(I,Xe),l(I,Kt),l(I,Ee),l(I,Ot),l(I,Ae),l(I,eo),l(I,R),y(Ce,R,null),l(R,to),l(R,Qe),l(R,oo),y(ee,R,null),l(R,no),l(R,Le),i(e,Ct,n),y(ke,e,n),i(e,kt,n),i(e,$,n),y(Ue,$,null),l($,so),l($,Ye),l($,ao),l($,Pe),l($,ro),l($,De),l($,lo),l($,Z),y(ve,Z,null),l(Z,io),l(Z,Ke),l(Z,co),y(te,Z,null),l(Z,po),l(Z,Oe),l(Z,mo),y(oe,Z,null),i(e,Ut,n),y(je,e,n),i(e,vt,n),i(e,ot,n),jt=!0},p(e,[n]){const V={};n&2&&(V.$$scope={dirty:n,ctx:e}),Q.$set(V);const k={};n&2&&(k.$$scope={dirty:n,ctx:e}),Y.$set(k);const z={};n&2&&(z.$$scope={dirty:n,ctx:e}),P.$set(z);const x={};n&2&&(x.$$scope={dirty:n,ctx:e}),D.$set(x);const F={};n&2&&(F.$$scope={dirty:n,ctx:e}),K.$set(F);const H={};n&2&&(H.$$scope={dirty:n,ctx:e}),O.$set(H);const W={};n&2&&(W.$$scope={dirty:n,ctx:e}),ee.$set(W);const N={};n&2&&(N.$$scope={dirty:n,ctx:e}),te.$set(N);const Yo={};n&2&&(Yo.$$scope={dirty:n,ctx:e}),oe.$set(Yo)},i(e){jt||(M(U.$$.fragment,e),M(ae.$$.fragment,e),M(Q.$$.fragment,e),M(pe.$$.fragment,e),M(he.$$.fragment,e),M(ue.$$.fragment,e),M(ge.$$.fragment,e),M(_e.$$.fragment,e),M(Y.$$.fragment,e),M(ye.$$.fragment,e),M(Me.$$.fragment,e),M(P.$$.fragment,e),M(D.$$.fragment,e),M(Te.$$.fragment,e),M(K.$$.fragment,e),M(be.$$.fragment,e),M(O.$$.fragment,e),M(we.$$.fragment,e),M(Je.$$.fragment,e),M(Ce.$$.fragment,e),M(ee.$$.fragment,e),M(ke.$$.fragment,e),M(Ue.$$.fragment,e),M(ve.$$.fragment,e),M(te.$$.fragment,e),M(oe.$$.fragment,e),M(je.$$.fragment,e),jt=!0)},o(e){T(U.$$.fragment,e),T(ae.$$.fragment,e),T(Q.$$.fragment,e),T(pe.$$.fragment,e),T(he.$$.fragment,e),T(ue.$$.fragment,e),T(ge.$$.fragment,e),T(_e.$$.fragment,e),T(Y.$$.fragment,e),T(ye.$$.fragment,e),T(Me.$$.fragment,e),T(P.$$.fragment,e),T(D.$$.fragment,e),T(Te.$$.fragment,e),T(K.$$.fragment,e),T(be.$$.fragment,e),T(O.$$.fragment,e),T(we.$$.fragment,e),T(Je.$$.fragment,e),T(Ce.$$.fragment,e),T(ee.$$.fragment,e),T(ke.$$.fragment,e),T(Ue.$$.fragment,e),T(ve.$$.fragment,e),T(te.$$.fragment,e),T(oe.$$.fragment,e),T(je.$$.fragment,e),jt=!1},d(e){e&&(r(p),r(o),r(h),r(w),r(u),r(se),r(B),r(st),r(at),r(re),r(rt),r(le),r(lt),r(A),r(it),r(ie),r(dt),r(ct),r(de),r(pt),r(ce),r(mt),r(ht),r(me),r(ut),r(ft),r(L),r(gt),r(_t),r(fe),r(yt),r(Mt),r(G),r(Tt),r(bt),r(C),r(wt),r(Jt),r(I),r(Ct),r(kt),r($),r(Ut),r(vt),r(ot)),r(t),b(U,e),b(ae,e),b(Q,e),b(pe,e),b(he,e),b(ue,e),b(ge,e),b(_e),b(Y),b(ye,e),b(Me),b(P),b(D),b(Te),b(K),b(be),b(O),b(we,e),b(Je),b(Ce),b(ee),b(ke,e),b(Ue),b(ve),b(te),b(oe),b(je,e)}}}const Mn='{"title":"Cohere","local":"cohere","sections":[{"title":"Notes","local":"notes","sections":[],"depth":2},{"title":"CohereConfig","local":"transformers.CohereConfig","sections":[],"depth":2},{"title":"CohereTokenizer","local":"transformers.CohereTokenizer","sections":[],"depth":2},{"title":"CohereModel","local":"transformers.CohereModel","sections":[],"depth":2},{"title":"CohereForCausalLM","local":"transformers.CohereForCausalLM","sections":[],"depth":2}],"depth":1}';function Tn(J){return Do(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class $n extends Ko{constructor(t){super(),Oo(this,t,Tn,yn,Po,{})}}export{$n as component}; | |
Xet Storage Details
- Size:
- 90.9 kB
- Xet hash:
- c7b25fe31b9446c36077d3381141e94e6a8cda8034b43175fe0fc56c72d5e427
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.