Buckets:
| import{s as Ke,o as et,n as Fe}from"../chunks/scheduler.25b97de1.js";import{S as tt,i as ot,g as u,s as l,r as T,A as nt,h,f as s,c as i,j as He,u as M,x as b,k as Je,l as st,y as m,a as r,v,d as w,t as k,w as $}from"../chunks/index.d9030fc9.js";import{T as Qe}from"../chunks/Tip.baa67368.js";import{D as Ze}from"../chunks/Docstring.ffac8efa.js";import{C as Ee}from"../chunks/CodeBlock.e6cd0d95.js";import{F as at,M as Oe}from"../chunks/Markdown.7217f838.js";import{E as Pe}from"../chunks/ExampleCodeBlock.22dfe688.js";import{H as $e,E as rt}from"../chunks/EditOnGithub.91d95064.js";function lt(H){let t,g="Example:",o,a,_;return a=new Ee({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEh1YmVydE1vZGVsJTJDJTIwSHViZXJ0Q29uZmlnJTBBJTBBJTIzJTIwSW5pdGlhbGl6aW5nJTIwYSUyMEh1YmVydCUyMGZhY2Vib29rJTJGaHViZXJ0LWJhc2UtbHM5NjAlMjBzdHlsZSUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWd1cmF0aW9uJTIwJTNEJTIwSHViZXJ0Q29uZmlnKCklMEElMEElMjMlMjBJbml0aWFsaXppbmclMjBhJTIwbW9kZWwlMjBmcm9tJTIwdGhlJTIwZmFjZWJvb2slMkZodWJlcnQtYmFzZS1sczk2MCUyMHN0eWxlJTIwY29uZmlndXJhdGlvbiUwQW1vZGVsJTIwJTNEJTIwSHViZXJ0TW9kZWwoY29uZmlndXJhdGlvbiklMEElMEElMjMlMjBBY2Nlc3NpbmclMjB0aGUlMjBtb2RlbCUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWd1cmF0aW9uJTIwJTNEJTIwbW9kZWwuY29uZmln",highlighted:`<span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> HubertModel, HubertConfig | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># Initializing a Hubert facebook/hubert-base-ls960 style configuration</span> | |
| <span class="hljs-meta">>>> </span>configuration = HubertConfig() | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># Initializing a model from the facebook/hubert-base-ls960 style configuration</span> | |
| <span class="hljs-meta">>>> </span>model = HubertModel(configuration) | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># Accessing the model configuration</span> | |
| <span class="hljs-meta">>>> </span>configuration = model.config`,wrap:!1}}),{c(){t=u("p"),t.textContent=g,o=l(),T(a.$$.fragment)},l(n){t=h(n,"P",{"data-svelte-h":!0}),b(t)!=="svelte-11lpom8"&&(t.textContent=g),o=i(n),M(a.$$.fragment,n)},m(n,y){r(n,t,y),r(n,o,y),v(a,n,y),_=!0},p:Fe,i(n){_||(w(a.$$.fragment,n),_=!0)},o(n){k(a.$$.fragment,n),_=!1},d(n){n&&(s(t),s(o)),$(a,n)}}}function it(H){let t,g=`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=u("p"),t.innerHTML=g},l(o){t=h(o,"P",{"data-svelte-h":!0}),b(t)!=="svelte-fincs2"&&(t.innerHTML=g)},m(o,a){r(o,t,a)},p:Fe,d(o){o&&s(t)}}}function dt(H){let t,g="Example:",o,a,_;return a=new Ee({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Qcm9jZXNzb3IlMkMlMjBIdWJlcnRNb2RlbCUwQWZyb20lMjBkYXRhc2V0cyUyMGltcG9ydCUyMGxvYWRfZGF0YXNldCUwQWltcG9ydCUyMHNvdW5kZmlsZSUyMGFzJTIwc2YlMEElMEFwcm9jZXNzb3IlMjAlM0QlMjBBdXRvUHJvY2Vzc29yLmZyb21fcHJldHJhaW5lZCglMjJmYWNlYm9vayUyRmh1YmVydC1sYXJnZS1sczk2MC1mdCUyMiklMEFtb2RlbCUyMCUzRCUyMEh1YmVydE1vZGVsLmZyb21fcHJldHJhaW5lZCglMjJmYWNlYm9vayUyRmh1YmVydC1sYXJnZS1sczk2MC1mdCUyMiklMEElMEElMEFkZWYlMjBtYXBfdG9fYXJyYXkoYmF0Y2gpJTNBJTBBJTIwJTIwJTIwJTIwc3BlZWNoJTJDJTIwXyUyMCUzRCUyMHNmLnJlYWQoYmF0Y2glNUIlMjJmaWxlJTIyJTVEKSUwQSUyMCUyMCUyMCUyMGJhdGNoJTVCJTIyc3BlZWNoJTIyJTVEJTIwJTNEJTIwc3BlZWNoJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwYmF0Y2glMEElMEElMEFkcyUyMCUzRCUyMGxvYWRfZGF0YXNldCglMjJoZi1pbnRlcm5hbC10ZXN0aW5nJTJGbGlicmlzcGVlY2hfYXNyX2R1bW15JTIyJTJDJTIwJTIyY2xlYW4lMjIlMkMlMjBzcGxpdCUzRCUyMnZhbGlkYXRpb24lMjIpJTBBZHMlMjAlM0QlMjBkcy5tYXAobWFwX3RvX2FycmF5KSUwQSUwQWlucHV0X3ZhbHVlcyUyMCUzRCUyMHByb2Nlc3NvcihkcyU1QiUyMnNwZWVjaCUyMiU1RCU1QjAlNUQlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKS5pbnB1dF92YWx1ZXMlMjAlMjAlMjMlMjBCYXRjaCUyMHNpemUlMjAxJTBBaGlkZGVuX3N0YXRlcyUyMCUzRCUyMG1vZGVsKGlucHV0X3ZhbHVlcykubGFzdF9oaWRkZW5fc3RhdGU=",highlighted:`<span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoProcessor, HubertModel | |
| <span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset | |
| <span class="hljs-meta">>>> </span><span class="hljs-keyword">import</span> soundfile <span class="hljs-keyword">as</span> sf | |
| <span class="hljs-meta">>>> </span>processor = AutoProcessor.from_pretrained(<span class="hljs-string">"facebook/hubert-large-ls960-ft"</span>) | |
| <span class="hljs-meta">>>> </span>model = HubertModel.from_pretrained(<span class="hljs-string">"facebook/hubert-large-ls960-ft"</span>) | |
| <span class="hljs-meta">>>> </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">map_to_array</span>(<span class="hljs-params">batch</span>): | |
| <span class="hljs-meta">... </span> speech, _ = sf.read(batch[<span class="hljs-string">"file"</span>]) | |
| <span class="hljs-meta">... </span> batch[<span class="hljs-string">"speech"</span>] = speech | |
| <span class="hljs-meta">... </span> <span class="hljs-keyword">return</span> batch | |
| <span class="hljs-meta">>>> </span>ds = load_dataset(<span class="hljs-string">"hf-internal-testing/librispeech_asr_dummy"</span>, <span class="hljs-string">"clean"</span>, split=<span class="hljs-string">"validation"</span>) | |
| <span class="hljs-meta">>>> </span>ds = ds.<span class="hljs-built_in">map</span>(map_to_array) | |
| <span class="hljs-meta">>>> </span>input_values = processor(ds[<span class="hljs-string">"speech"</span>][<span class="hljs-number">0</span>], return_tensors=<span class="hljs-string">"pt"</span>).input_values <span class="hljs-comment"># Batch size 1</span> | |
| <span class="hljs-meta">>>> </span>hidden_states = model(input_values).last_hidden_state`,wrap:!1}}),{c(){t=u("p"),t.textContent=g,o=l(),T(a.$$.fragment)},l(n){t=h(n,"P",{"data-svelte-h":!0}),b(t)!=="svelte-11lpom8"&&(t.textContent=g),o=i(n),M(a.$$.fragment,n)},m(n,y){r(n,t,y),r(n,o,y),v(a,n,y),_=!0},p:Fe,i(n){_||(w(a.$$.fragment,n),_=!0)},o(n){k(a.$$.fragment,n),_=!1},d(n){n&&(s(t),s(o)),$(a,n)}}}function ct(H){let t,g=`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=u("p"),t.innerHTML=g},l(o){t=h(o,"P",{"data-svelte-h":!0}),b(t)!=="svelte-fincs2"&&(t.innerHTML=g)},m(o,a){r(o,t,a)},p:Fe,d(o){o&&s(t)}}}function pt(H){let t,g="Example:",o,a,_;return a=new Ee({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Qcm9jZXNzb3IlMkMlMjBIdWJlcnRGb3JDVEMlMEFmcm9tJTIwZGF0YXNldHMlMjBpbXBvcnQlMjBsb2FkX2RhdGFzZXQlMEFpbXBvcnQlMjB0b3JjaCUwQSUwQWRhdGFzZXQlMjAlM0QlMjBsb2FkX2RhdGFzZXQoJTIyaGYtaW50ZXJuYWwtdGVzdGluZyUyRmxpYnJpc3BlZWNoX2Fzcl9kZW1vJTIyJTJDJTIwJTIyY2xlYW4lMjIlMkMlMjBzcGxpdCUzRCUyMnZhbGlkYXRpb24lMjIlMkMlMjB0cnVzdF9yZW1vdGVfY29kZSUzRFRydWUpJTBBZGF0YXNldCUyMCUzRCUyMGRhdGFzZXQuc29ydCglMjJpZCUyMiklMEFzYW1wbGluZ19yYXRlJTIwJTNEJTIwZGF0YXNldC5mZWF0dXJlcyU1QiUyMmF1ZGlvJTIyJTVELnNhbXBsaW5nX3JhdGUlMEElMEFwcm9jZXNzb3IlMjAlM0QlMjBBdXRvUHJvY2Vzc29yLmZyb21fcHJldHJhaW5lZCglMjJmYWNlYm9vayUyRmh1YmVydC1sYXJnZS1sczk2MC1mdCUyMiklMEFtb2RlbCUyMCUzRCUyMEh1YmVydEZvckNUQy5mcm9tX3ByZXRyYWluZWQoJTIyZmFjZWJvb2slMkZodWJlcnQtbGFyZ2UtbHM5NjAtZnQlMjIpJTBBJTBBJTIzJTIwYXVkaW8lMjBmaWxlJTIwaXMlMjBkZWNvZGVkJTIwb24lMjB0aGUlMjBmbHklMEFpbnB1dHMlMjAlM0QlMjBwcm9jZXNzb3IoZGF0YXNldCU1QjAlNUQlNUIlMjJhdWRpbyUyMiU1RCU1QiUyMmFycmF5JTIyJTVEJTJDJTIwc2FtcGxpbmdfcmF0ZSUzRHNhbXBsaW5nX3JhdGUlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQXdpdGglMjB0b3JjaC5ub19ncmFkKCklM0ElMEElMjAlMjAlMjAlMjBsb2dpdHMlMjAlM0QlMjBtb2RlbCgqKmlucHV0cykubG9naXRzJTBBcHJlZGljdGVkX2lkcyUyMCUzRCUyMHRvcmNoLmFyZ21heChsb2dpdHMlMkMlMjBkaW0lM0QtMSklMEElMEElMjMlMjB0cmFuc2NyaWJlJTIwc3BlZWNoJTBBdHJhbnNjcmlwdGlvbiUyMCUzRCUyMHByb2Nlc3Nvci5iYXRjaF9kZWNvZGUocHJlZGljdGVkX2lkcyklMEF0cmFuc2NyaXB0aW9uJTVCMCU1RCUwQSUwQWlucHV0cyU1QiUyMmxhYmVscyUyMiU1RCUyMCUzRCUyMHByb2Nlc3Nvcih0ZXh0JTNEZGF0YXNldCU1QjAlNUQlNUIlMjJ0ZXh0JTIyJTVEJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMikuaW5wdXRfaWRzJTBBJTBBJTIzJTIwY29tcHV0ZSUyMGxvc3MlMEFsb3NzJTIwJTNEJTIwbW9kZWwoKippbnB1dHMpLmxvc3MlMEFyb3VuZChsb3NzLml0ZW0oKSUyQyUyMDIp",highlighted:`<span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoProcessor, HubertForCTC | |
| <span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset | |
| <span class="hljs-meta">>>> </span><span class="hljs-keyword">import</span> torch | |
| <span class="hljs-meta">>>> </span>dataset = load_dataset(<span class="hljs-string">"hf-internal-testing/librispeech_asr_demo"</span>, <span class="hljs-string">"clean"</span>, split=<span class="hljs-string">"validation"</span>, trust_remote_code=<span class="hljs-literal">True</span>) | |
| <span class="hljs-meta">>>> </span>dataset = dataset.sort(<span class="hljs-string">"id"</span>) | |
| <span class="hljs-meta">>>> </span>sampling_rate = dataset.features[<span class="hljs-string">"audio"</span>].sampling_rate | |
| <span class="hljs-meta">>>> </span>processor = AutoProcessor.from_pretrained(<span class="hljs-string">"facebook/hubert-large-ls960-ft"</span>) | |
| <span class="hljs-meta">>>> </span>model = HubertForCTC.from_pretrained(<span class="hljs-string">"facebook/hubert-large-ls960-ft"</span>) | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># audio file is decoded on the fly</span> | |
| <span class="hljs-meta">>>> </span>inputs = processor(dataset[<span class="hljs-number">0</span>][<span class="hljs-string">"audio"</span>][<span class="hljs-string">"array"</span>], sampling_rate=sampling_rate, return_tensors=<span class="hljs-string">"pt"</span>) | |
| <span class="hljs-meta">>>> </span><span class="hljs-keyword">with</span> torch.no_grad(): | |
| <span class="hljs-meta">... </span> logits = model(**inputs).logits | |
| <span class="hljs-meta">>>> </span>predicted_ids = torch.argmax(logits, dim=-<span class="hljs-number">1</span>) | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># transcribe speech</span> | |
| <span class="hljs-meta">>>> </span>transcription = processor.batch_decode(predicted_ids) | |
| <span class="hljs-meta">>>> </span>transcription[<span class="hljs-number">0</span>] | |
| <span class="hljs-string">'MISTER QUILTER IS THE APOSTLE OF THE MIDDLE CLASSES AND WE ARE GLAD TO WELCOME HIS GOSPEL'</span> | |
| <span class="hljs-meta">>>> </span>inputs[<span class="hljs-string">"labels"</span>] = processor(text=dataset[<span class="hljs-number">0</span>][<span class="hljs-string">"text"</span>], return_tensors=<span class="hljs-string">"pt"</span>).input_ids | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># compute loss</span> | |
| <span class="hljs-meta">>>> </span>loss = model(**inputs).loss | |
| <span class="hljs-meta">>>> </span><span class="hljs-built_in">round</span>(loss.item(), <span class="hljs-number">2</span>) | |
| <span class="hljs-number">22.68</span>`,wrap:!1}}),{c(){t=u("p"),t.textContent=g,o=l(),T(a.$$.fragment)},l(n){t=h(n,"P",{"data-svelte-h":!0}),b(t)!=="svelte-11lpom8"&&(t.textContent=g),o=i(n),M(a.$$.fragment,n)},m(n,y){r(n,t,y),r(n,o,y),v(a,n,y),_=!0},p:Fe,i(n){_||(w(a.$$.fragment,n),_=!0)},o(n){k(a.$$.fragment,n),_=!1},d(n){n&&(s(t),s(o)),$(a,n)}}}function mt(H){let t,g=`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=u("p"),t.innerHTML=g},l(o){t=h(o,"P",{"data-svelte-h":!0}),b(t)!=="svelte-fincs2"&&(t.innerHTML=g)},m(o,a){r(o,t,a)},p:Fe,d(o){o&&s(t)}}}function ut(H){let t,g="Example:",o,a,_;return a=new Ee({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9GZWF0dXJlRXh0cmFjdG9yJTJDJTIwSHViZXJ0Rm9yU2VxdWVuY2VDbGFzc2lmaWNhdGlvbiUwQWZyb20lMjBkYXRhc2V0cyUyMGltcG9ydCUyMGxvYWRfZGF0YXNldCUwQWltcG9ydCUyMHRvcmNoJTBBJTBBZGF0YXNldCUyMCUzRCUyMGxvYWRfZGF0YXNldCglMjJoZi1pbnRlcm5hbC10ZXN0aW5nJTJGbGlicmlzcGVlY2hfYXNyX2RlbW8lMjIlMkMlMjAlMjJjbGVhbiUyMiUyQyUyMHNwbGl0JTNEJTIydmFsaWRhdGlvbiUyMiUyQyUyMHRydXN0X3JlbW90ZV9jb2RlJTNEVHJ1ZSklMEFkYXRhc2V0JTIwJTNEJTIwZGF0YXNldC5zb3J0KCUyMmlkJTIyKSUwQXNhbXBsaW5nX3JhdGUlMjAlM0QlMjBkYXRhc2V0LmZlYXR1cmVzJTVCJTIyYXVkaW8lMjIlNUQuc2FtcGxpbmdfcmF0ZSUwQSUwQWZlYXR1cmVfZXh0cmFjdG9yJTIwJTNEJTIwQXV0b0ZlYXR1cmVFeHRyYWN0b3IuZnJvbV9wcmV0cmFpbmVkKCUyMnN1cGVyYiUyRmh1YmVydC1iYXNlLXN1cGVyYi1rcyUyMiklMEFtb2RlbCUyMCUzRCUyMEh1YmVydEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24uZnJvbV9wcmV0cmFpbmVkKCUyMnN1cGVyYiUyRmh1YmVydC1iYXNlLXN1cGVyYi1rcyUyMiklMEElMEElMjMlMjBhdWRpbyUyMGZpbGUlMjBpcyUyMGRlY29kZWQlMjBvbiUyMHRoZSUyMGZseSUwQWlucHV0cyUyMCUzRCUyMGZlYXR1cmVfZXh0cmFjdG9yKGRhdGFzZXQlNUIwJTVEJTVCJTIyYXVkaW8lMjIlNUQlNUIlMjJhcnJheSUyMiU1RCUyQyUyMHNhbXBsaW5nX3JhdGUlM0RzYW1wbGluZ19yYXRlJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiklMEElMEF3aXRoJTIwdG9yY2gubm9fZ3JhZCgpJTNBJTBBJTIwJTIwJTIwJTIwbG9naXRzJTIwJTNEJTIwbW9kZWwoKippbnB1dHMpLmxvZ2l0cyUwQSUwQXByZWRpY3RlZF9jbGFzc19pZHMlMjAlM0QlMjB0b3JjaC5hcmdtYXgobG9naXRzJTJDJTIwZGltJTNELTEpLml0ZW0oKSUwQXByZWRpY3RlZF9sYWJlbCUyMCUzRCUyMG1vZGVsLmNvbmZpZy5pZDJsYWJlbCU1QnByZWRpY3RlZF9jbGFzc19pZHMlNUQlMEFwcmVkaWN0ZWRfbGFiZWwlMEElMEElMjMlMjBjb21wdXRlJTIwbG9zcyUyMC0lMjB0YXJnZXRfbGFiZWwlMjBpcyUyMGUuZy4lMjAlMjJkb3duJTIyJTBBdGFyZ2V0X2xhYmVsJTIwJTNEJTIwbW9kZWwuY29uZmlnLmlkMmxhYmVsJTVCMCU1RCUwQWlucHV0cyU1QiUyMmxhYmVscyUyMiU1RCUyMCUzRCUyMHRvcmNoLnRlbnNvciglNUJtb2RlbC5jb25maWcubGFiZWwyaWQlNUJ0YXJnZXRfbGFiZWwlNUQlNUQpJTBBbG9zcyUyMCUzRCUyMG1vZGVsKCoqaW5wdXRzKS5sb3NzJTBBcm91bmQobG9zcy5pdGVtKCklMkMlMjAyKQ==",highlighted:`<span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoFeatureExtractor, HubertForSequenceClassification | |
| <span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset | |
| <span class="hljs-meta">>>> </span><span class="hljs-keyword">import</span> torch | |
| <span class="hljs-meta">>>> </span>dataset = load_dataset(<span class="hljs-string">"hf-internal-testing/librispeech_asr_demo"</span>, <span class="hljs-string">"clean"</span>, split=<span class="hljs-string">"validation"</span>, trust_remote_code=<span class="hljs-literal">True</span>) | |
| <span class="hljs-meta">>>> </span>dataset = dataset.sort(<span class="hljs-string">"id"</span>) | |
| <span class="hljs-meta">>>> </span>sampling_rate = dataset.features[<span class="hljs-string">"audio"</span>].sampling_rate | |
| <span class="hljs-meta">>>> </span>feature_extractor = AutoFeatureExtractor.from_pretrained(<span class="hljs-string">"superb/hubert-base-superb-ks"</span>) | |
| <span class="hljs-meta">>>> </span>model = HubertForSequenceClassification.from_pretrained(<span class="hljs-string">"superb/hubert-base-superb-ks"</span>) | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># audio file is decoded on the fly</span> | |
| <span class="hljs-meta">>>> </span>inputs = feature_extractor(dataset[<span class="hljs-number">0</span>][<span class="hljs-string">"audio"</span>][<span class="hljs-string">"array"</span>], sampling_rate=sampling_rate, return_tensors=<span class="hljs-string">"pt"</span>) | |
| <span class="hljs-meta">>>> </span><span class="hljs-keyword">with</span> torch.no_grad(): | |
| <span class="hljs-meta">... </span> logits = model(**inputs).logits | |
| <span class="hljs-meta">>>> </span>predicted_class_ids = torch.argmax(logits, dim=-<span class="hljs-number">1</span>).item() | |
| <span class="hljs-meta">>>> </span>predicted_label = model.config.id2label[predicted_class_ids] | |
| <span class="hljs-meta">>>> </span>predicted_label | |
| <span class="hljs-string">'_unknown_'</span> | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># compute loss - target_label is e.g. "down"</span> | |
| <span class="hljs-meta">>>> </span>target_label = model.config.id2label[<span class="hljs-number">0</span>] | |
| <span class="hljs-meta">>>> </span>inputs[<span class="hljs-string">"labels"</span>] = torch.tensor([model.config.label2id[target_label]]) | |
| <span class="hljs-meta">>>> </span>loss = model(**inputs).loss | |
| <span class="hljs-meta">>>> </span><span class="hljs-built_in">round</span>(loss.item(), <span class="hljs-number">2</span>) | |
| <span class="hljs-number">8.53</span>`,wrap:!1}}),{c(){t=u("p"),t.textContent=g,o=l(),T(a.$$.fragment)},l(n){t=h(n,"P",{"data-svelte-h":!0}),b(t)!=="svelte-11lpom8"&&(t.textContent=g),o=i(n),M(a.$$.fragment,n)},m(n,y){r(n,t,y),r(n,o,y),v(a,n,y),_=!0},p:Fe,i(n){_||(w(a.$$.fragment,n),_=!0)},o(n){k(a.$$.fragment,n),_=!1},d(n){n&&(s(t),s(o)),$(a,n)}}}function ht(H){let t,g,o,a,_,n,y=`The bare Hubert Model transformer outputting raw hidden-states without any specific head on top. | |
| Hubert was proposed in <a href="https://arxiv.org/abs/2106.07447" rel="nofollow">HuBERT: Self-Supervised Speech Representation Learning by Masked Prediction of Hidden | |
| Units</a> by Wei-Ning Hsu, Benjamin Bolte, Yao-Hung Hubert Tsai, Kushal Lakhotia, | |
| Ruslan Salakhutdinov, Abdelrahman Mohamed.`,ee,F,z=`This model inherits from <a href="/docs/transformers/pr_36095/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 etc.).`,te,x,B=`This model is a PyTorch <a href="https://pytorch.org/docs/stable/nn.html#torch.nn.Module" rel="nofollow">torch.nn.Module</a> sub-class. Use | |
| it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and | |
| behavior.`,oe,p,J,E,X,Be='The <a href="/docs/transformers/pr_36095/en/model_doc/hubert#transformers.HubertModel">HubertModel</a> forward method, overrides the <code>__call__</code> special method.',_e,A,xe,I,Ue,L,ae,Z,S,N,D,ve=`Hubert Model with a <code>language modeling</code> head on top for Connectionist Temporal Classification (CTC). | |
| Hubert was proposed in <a href="https://arxiv.org/abs/2106.07447" rel="nofollow">HuBERT: Self-Supervised Speech Representation Learning by Masked Prediction of Hidden | |
| Units</a> by Wei-Ning Hsu, Benjamin Bolte, Yao-Hung Hubert Tsai, Kushal Lakhotia, | |
| Ruslan Salakhutdinov, Abdelrahman Mohamed.`,be,re,Ne=`This model inherits from <a href="/docs/transformers/pr_36095/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 etc.).`,ye,le,Re=`This model is a PyTorch <a href="https://pytorch.org/docs/stable/nn.html#torch.nn.Module" rel="nofollow">torch.nn.Module</a> sub-class. Use | |
| it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and | |
| behavior.`,Te,R,ue,Q,Me,G='The <a href="/docs/transformers/pr_36095/en/model_doc/hubert#transformers.HubertForCTC">HubertForCTC</a> forward method, overrides the <code>__call__</code> special method.',we,ie,ne,he,fe,Y,ge,U,de,f,C,O=`Hubert Model with a sequence classification head on top (a linear layer over the pooled output) for tasks like | |
| SUPERB Keyword Spotting.`,W,q,Ce=`Hubert was proposed in <a href="https://arxiv.org/abs/2106.07447" rel="nofollow">HuBERT: Self-Supervised Speech Representation Learning by Masked Prediction of Hidden | |
| Units</a> by Wei-Ning Hsu, Benjamin Bolte, Yao-Hung Hubert Tsai, Kushal Lakhotia, | |
| Ruslan Salakhutdinov, Abdelrahman Mohamed.`,Ge,ke,We=`This model inherits from <a href="/docs/transformers/pr_36095/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 etc.).`,Ve,P,Ie=`This model is a PyTorch <a href="https://pytorch.org/docs/stable/nn.html#torch.nn.Module" rel="nofollow">torch.nn.Module</a> sub-class. Use | |
| it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and | |
| behavior.`,Le,K,ze,Ye,je,Ae='The <a href="/docs/transformers/pr_36095/en/model_doc/hubert#transformers.HubertForSequenceClassification">HubertForSequenceClassification</a> forward method, overrides the <code>__call__</code> special method.',Se,ce,Xe,pe,qe;return t=new $e({props:{title:"HubertModel",local:"transformers.HubertModel",headingTag:"h2"}}),a=new Ze({props:{name:"class transformers.HubertModel",anchor:"transformers.HubertModel",parameters:[{name:"config",val:": HubertConfig"}],parametersDescription:[{anchor:"transformers.HubertModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_36095/en/model_doc/hubert#transformers.HubertConfig">HubertConfig</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_36095/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_36095/src/transformers/models/hubert/modeling_hubert.py#L1231"}}),J=new Ze({props:{name:"forward",anchor:"transformers.HubertModel.forward",parameters:[{name:"input_values",val:": typing.Optional[torch.Tensor]"},{name:"attention_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"mask_time_indices",val:": typing.Optional[torch.FloatTensor] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.HubertModel.forward.input_values",description:`<strong>input_values</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code>) — | |
| Float values of input raw speech waveform. Values can be obtained by loading a <code>.flac</code> or <code>.wav</code> audio file | |
| into an array of type <code>List[float]</code> or a <code>numpy.ndarray</code>, <em>e.g.</em> via the soundfile library (<code>pip install soundfile</code>). To prepare the array into <code>input_values</code>, the <a href="/docs/transformers/pr_36095/en/model_doc/auto#transformers.AutoProcessor">AutoProcessor</a> should be used for padding and | |
| conversion into a tensor of type <code>torch.FloatTensor</code>. See <a href="/docs/transformers/pr_36095/en/model_doc/wav2vec2#transformers.Wav2Vec2Processor.__call__">Wav2Vec2Processor.<strong>call</strong>()</a> for details.`,name:"input_values"},{anchor:"transformers.HubertModel.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) — | |
| Mask to avoid performing convolution and 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></p> | |
| <div class="course-tip course-tip-orange bg-gradient-to-br dark:bg-gradient-to-r before:border-orange-500 dark:before:border-orange-800 from-orange-50 dark:from-gray-900 to-white dark:to-gray-950 border border-orange-50 text-orange-700 dark:text-gray-400"> | |
| <p><code>attention_mask</code> should only be passed if the corresponding processor has <code>config.return_attention_mask == True</code>. For all models whose processor has <code>config.return_attention_mask == False</code>, such as | |
| <a href="https://huggingface.co/facebook/hubert-base-ls960" rel="nofollow">hubert-base</a>, <code>attention_mask</code> should <strong>not</strong> be passed | |
| to avoid degraded performance when doing batched inference. For such models <code>input_values</code> should simply be | |
| padded with 0 and passed without <code>attention_mask</code>. Be aware that these models also yield slightly different | |
| results depending on whether <code>input_values</code> is padded or not.</p> | |
| </div>`,name:"attention_mask"},{anchor:"transformers.HubertModel.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) — | |
| 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.HubertModel.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) — | |
| 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.HubertModel.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) — | |
| Whether or not to return a <a href="/docs/transformers/pr_36095/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/vr_36095/src/transformers/models/hubert/modeling_hubert.py#L1300",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>A <a | |
| href="/docs/transformers/pr_36095/en/main_classes/output#transformers.modeling_outputs.BaseModelOutput" | |
| >transformers.modeling_outputs.BaseModelOutput</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_36095/en/model_doc/hubert#transformers.HubertConfig" | |
| >HubertConfig</a>) and inputs.</p> | |
| <ul> | |
| <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> | |
| </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> | |
| </ul> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><a | |
| href="/docs/transformers/pr_36095/en/main_classes/output#transformers.modeling_outputs.BaseModelOutput" | |
| >transformers.modeling_outputs.BaseModelOutput</a> or <code>tuple(torch.FloatTensor)</code></p> | |
| `}}),A=new Qe({props:{$$slots:{default:[it]},$$scope:{ctx:H}}}),I=new Pe({props:{anchor:"transformers.HubertModel.forward.example",$$slots:{default:[dt]},$$scope:{ctx:H}}}),L=new $e({props:{title:"HubertForCTC",local:"transformers.HubertForCTC",headingTag:"h2"}}),S=new Ze({props:{name:"class transformers.HubertForCTC",anchor:"transformers.HubertForCTC",parameters:[{name:"config",val:""},{name:"target_lang",val:": typing.Optional[str] = None"}],parametersDescription:[{anchor:"transformers.HubertForCTC.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_36095/en/model_doc/hubert#transformers.HubertConfig">HubertConfig</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_36095/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_36095/src/transformers/models/hubert/modeling_hubert.py#L1374"}}),ue=new Ze({props:{name:"forward",anchor:"transformers.HubertForCTC.forward",parameters:[{name:"input_values",val:": typing.Optional[torch.Tensor]"},{name:"attention_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"},{name:"labels",val:": typing.Optional[torch.Tensor] = None"}],parametersDescription:[{anchor:"transformers.HubertForCTC.forward.input_values",description:`<strong>input_values</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code>) — | |
| Float values of input raw speech waveform. Values can be obtained by loading a <code>.flac</code> or <code>.wav</code> audio file | |
| into an array of type <code>List[float]</code> or a <code>numpy.ndarray</code>, <em>e.g.</em> via the soundfile library (<code>pip install soundfile</code>). To prepare the array into <code>input_values</code>, the <a href="/docs/transformers/pr_36095/en/model_doc/auto#transformers.AutoProcessor">AutoProcessor</a> should be used for padding and | |
| conversion into a tensor of type <code>torch.FloatTensor</code>. See <a href="/docs/transformers/pr_36095/en/model_doc/wav2vec2#transformers.Wav2Vec2Processor.__call__">Wav2Vec2Processor.<strong>call</strong>()</a> for details.`,name:"input_values"},{anchor:"transformers.HubertForCTC.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) — | |
| Mask to avoid performing convolution and 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></p> | |
| <div class="course-tip course-tip-orange bg-gradient-to-br dark:bg-gradient-to-r before:border-orange-500 dark:before:border-orange-800 from-orange-50 dark:from-gray-900 to-white dark:to-gray-950 border border-orange-50 text-orange-700 dark:text-gray-400"> | |
| <p><code>attention_mask</code> should only be passed if the corresponding processor has <code>config.return_attention_mask == True</code>. For all models whose processor has <code>config.return_attention_mask == False</code>, such as | |
| <a href="https://huggingface.co/facebook/hubert-base-ls960" rel="nofollow">hubert-base</a>, <code>attention_mask</code> should <strong>not</strong> be passed | |
| to avoid degraded performance when doing batched inference. For such models <code>input_values</code> should simply be | |
| padded with 0 and passed without <code>attention_mask</code>. Be aware that these models also yield slightly different | |
| results depending on whether <code>input_values</code> is padded or not.</p> | |
| </div>`,name:"attention_mask"},{anchor:"transformers.HubertForCTC.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) — | |
| 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.HubertForCTC.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) — | |
| 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.HubertForCTC.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) — | |
| Whether or not to return a <a href="/docs/transformers/pr_36095/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.HubertForCTC.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, target_length)</code>, <em>optional</em>) — | |
| Labels for connectionist temporal classification. Note that <code>target_length</code> has to be smaller or equal to | |
| the sequence length of the output logits. Indices are selected in <code>[-100, 0, ..., config.vocab_size - 1]</code>. | |
| All labels set to <code>-100</code> are ignored (masked), the loss is only computed for labels in <code>[0, ..., config.vocab_size - 1]</code>.`,name:"labels"}],source:"https://github.com/huggingface/transformers/blob/vr_36095/src/transformers/models/hubert/modeling_hubert.py#L1451",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>A <a | |
| href="/docs/transformers/pr_36095/en/main_classes/output#transformers.modeling_outputs.CausalLMOutput" | |
| >transformers.modeling_outputs.CausalLMOutput</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_36095/en/model_doc/hubert#transformers.HubertConfig" | |
| >HubertConfig</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) — 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>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> | |
| </ul> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><a | |
| href="/docs/transformers/pr_36095/en/main_classes/output#transformers.modeling_outputs.CausalLMOutput" | |
| >transformers.modeling_outputs.CausalLMOutput</a> or <code>tuple(torch.FloatTensor)</code></p> | |
| `}}),ie=new Qe({props:{$$slots:{default:[ct]},$$scope:{ctx:H}}}),he=new Pe({props:{anchor:"transformers.HubertForCTC.forward.example",$$slots:{default:[pt]},$$scope:{ctx:H}}}),Y=new $e({props:{title:"HubertForSequenceClassification",local:"transformers.HubertForSequenceClassification",headingTag:"h2"}}),de=new Ze({props:{name:"class transformers.HubertForSequenceClassification",anchor:"transformers.HubertForSequenceClassification",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.HubertForSequenceClassification.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_36095/en/model_doc/hubert#transformers.HubertConfig">HubertConfig</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_36095/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_36095/src/transformers/models/hubert/modeling_hubert.py#L1530"}}),ze=new Ze({props:{name:"forward",anchor:"transformers.HubertForSequenceClassification.forward",parameters:[{name:"input_values",val:": typing.Optional[torch.Tensor]"},{name:"attention_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"},{name:"labels",val:": typing.Optional[torch.Tensor] = None"}],parametersDescription:[{anchor:"transformers.HubertForSequenceClassification.forward.input_values",description:`<strong>input_values</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code>) — | |
| Float values of input raw speech waveform. Values can be obtained by loading a <code>.flac</code> or <code>.wav</code> audio file | |
| into an array of type <code>List[float]</code> or a <code>numpy.ndarray</code>, <em>e.g.</em> via the soundfile library (<code>pip install soundfile</code>). To prepare the array into <code>input_values</code>, the <a href="/docs/transformers/pr_36095/en/model_doc/auto#transformers.AutoProcessor">AutoProcessor</a> should be used for padding and | |
| conversion into a tensor of type <code>torch.FloatTensor</code>. See <a href="/docs/transformers/pr_36095/en/model_doc/wav2vec2#transformers.Wav2Vec2Processor.__call__">Wav2Vec2Processor.<strong>call</strong>()</a> for details.`,name:"input_values"},{anchor:"transformers.HubertForSequenceClassification.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) — | |
| Mask to avoid performing convolution and 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></p> | |
| <div class="course-tip course-tip-orange bg-gradient-to-br dark:bg-gradient-to-r before:border-orange-500 dark:before:border-orange-800 from-orange-50 dark:from-gray-900 to-white dark:to-gray-950 border border-orange-50 text-orange-700 dark:text-gray-400"> | |
| <p><code>attention_mask</code> should only be passed if the corresponding processor has <code>config.return_attention_mask == True</code>. For all models whose processor has <code>config.return_attention_mask == False</code>, such as | |
| <a href="https://huggingface.co/facebook/hubert-base-ls960" rel="nofollow">hubert-base</a>, <code>attention_mask</code> should <strong>not</strong> be passed | |
| to avoid degraded performance when doing batched inference. For such models <code>input_values</code> should simply be | |
| padded with 0 and passed without <code>attention_mask</code>. Be aware that these models also yield slightly different | |
| results depending on whether <code>input_values</code> is padded or not.</p> | |
| </div>`,name:"attention_mask"},{anchor:"transformers.HubertForSequenceClassification.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) — | |
| 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.HubertForSequenceClassification.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) — | |
| 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.HubertForSequenceClassification.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) — | |
| Whether or not to return a <a href="/docs/transformers/pr_36095/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.HubertForSequenceClassification.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size,)</code>, <em>optional</em>) — | |
| Labels for computing the sequence classification/regression loss. Indices should be in <code>[0, ..., config.num_labels - 1]</code>. If <code>config.num_labels == 1</code> a regression loss is computed (Mean-Square loss), If | |
| <code>config.num_labels > 1</code> a classification loss is computed (Cross-Entropy).`,name:"labels"}],source:"https://github.com/huggingface/transformers/blob/vr_36095/src/transformers/models/hubert/modeling_hubert.py#L1583",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>A <a | |
| href="/docs/transformers/pr_36095/en/main_classes/output#transformers.modeling_outputs.SequenceClassifierOutput" | |
| >transformers.modeling_outputs.SequenceClassifierOutput</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_36095/en/model_doc/hubert#transformers.HubertConfig" | |
| >HubertConfig</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) — Classification (or regression if config.num_labels==1) loss.</p> | |
| </li> | |
| <li> | |
| <p><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, config.num_labels)</code>) — Classification (or regression if config.num_labels==1) scores (before SoftMax).</p> | |
| </li> | |
| <li> | |
| <p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) — 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> | |
| </ul> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><a | |
| href="/docs/transformers/pr_36095/en/main_classes/output#transformers.modeling_outputs.SequenceClassifierOutput" | |
| >transformers.modeling_outputs.SequenceClassifierOutput</a> or <code>tuple(torch.FloatTensor)</code></p> | |
| `}}),ce=new Qe({props:{$$slots:{default:[mt]},$$scope:{ctx:H}}}),pe=new Pe({props:{anchor:"transformers.HubertForSequenceClassification.forward.example",$$slots:{default:[ut]},$$scope:{ctx:H}}}),{c(){T(t.$$.fragment),g=l(),o=u("div"),T(a.$$.fragment),_=l(),n=u("p"),n.innerHTML=y,ee=l(),F=u("p"),F.innerHTML=z,te=l(),x=u("p"),x.innerHTML=B,oe=l(),p=u("div"),T(J.$$.fragment),E=l(),X=u("p"),X.innerHTML=Be,_e=l(),T(A.$$.fragment),xe=l(),T(I.$$.fragment),Ue=l(),T(L.$$.fragment),ae=l(),Z=u("div"),T(S.$$.fragment),N=l(),D=u("p"),D.innerHTML=ve,be=l(),re=u("p"),re.innerHTML=Ne,ye=l(),le=u("p"),le.innerHTML=Re,Te=l(),R=u("div"),T(ue.$$.fragment),Q=l(),Me=u("p"),Me.innerHTML=G,we=l(),T(ie.$$.fragment),ne=l(),T(he.$$.fragment),fe=l(),T(Y.$$.fragment),ge=l(),U=u("div"),T(de.$$.fragment),f=l(),C=u("p"),C.textContent=O,W=l(),q=u("p"),q.innerHTML=Ce,Ge=l(),ke=u("p"),ke.innerHTML=We,Ve=l(),P=u("p"),P.innerHTML=Ie,Le=l(),K=u("div"),T(ze.$$.fragment),Ye=l(),je=u("p"),je.innerHTML=Ae,Se=l(),T(ce.$$.fragment),Xe=l(),T(pe.$$.fragment),this.h()},l(c){M(t.$$.fragment,c),g=i(c),o=h(c,"DIV",{class:!0});var j=He(o);M(a.$$.fragment,j),_=i(j),n=h(j,"P",{"data-svelte-h":!0}),b(n)!=="svelte-n0pdh6"&&(n.innerHTML=y),ee=i(j),F=h(j,"P",{"data-svelte-h":!0}),b(F)!=="svelte-17liqmf"&&(F.innerHTML=z),te=i(j),x=h(j,"P",{"data-svelte-h":!0}),b(x)!=="svelte-68lg8f"&&(x.innerHTML=B),oe=i(j),p=h(j,"DIV",{class:!0});var me=He(p);M(J.$$.fragment,me),E=i(me),X=h(me,"P",{"data-svelte-h":!0}),b(X)!=="svelte-1r2dl9g"&&(X.innerHTML=Be),_e=i(me),M(A.$$.fragment,me),xe=i(me),M(I.$$.fragment,me),me.forEach(s),j.forEach(s),Ue=i(c),M(L.$$.fragment,c),ae=i(c),Z=h(c,"DIV",{class:!0});var se=He(Z);M(S.$$.fragment,se),N=i(se),D=h(se,"P",{"data-svelte-h":!0}),b(D)!=="svelte-x5vqgb"&&(D.innerHTML=ve),be=i(se),re=h(se,"P",{"data-svelte-h":!0}),b(re)!=="svelte-17liqmf"&&(re.innerHTML=Ne),ye=i(se),le=h(se,"P",{"data-svelte-h":!0}),b(le)!=="svelte-68lg8f"&&(le.innerHTML=Re),Te=i(se),R=h(se,"DIV",{class:!0});var e=He(R);M(ue.$$.fragment,e),Q=i(e),Me=h(e,"P",{"data-svelte-h":!0}),b(Me)!=="svelte-cgnbdi"&&(Me.innerHTML=G),we=i(e),M(ie.$$.fragment,e),ne=i(e),M(he.$$.fragment,e),e.forEach(s),se.forEach(s),fe=i(c),M(Y.$$.fragment,c),ge=i(c),U=h(c,"DIV",{class:!0});var d=He(U);M(de.$$.fragment,d),f=i(d),C=h(d,"P",{"data-svelte-h":!0}),b(C)!=="svelte-1c2qyra"&&(C.textContent=O),W=i(d),q=h(d,"P",{"data-svelte-h":!0}),b(q)!=="svelte-1y6szhx"&&(q.innerHTML=Ce),Ge=i(d),ke=h(d,"P",{"data-svelte-h":!0}),b(ke)!=="svelte-17liqmf"&&(ke.innerHTML=We),Ve=i(d),P=h(d,"P",{"data-svelte-h":!0}),b(P)!=="svelte-68lg8f"&&(P.innerHTML=Ie),Le=i(d),K=h(d,"DIV",{class:!0});var V=He(K);M(ze.$$.fragment,V),Ye=i(V),je=h(V,"P",{"data-svelte-h":!0}),b(je)!=="svelte-1lvp69s"&&(je.innerHTML=Ae),Se=i(V),M(ce.$$.fragment,V),Xe=i(V),M(pe.$$.fragment,V),V.forEach(s),d.forEach(s),this.h()},h(){Je(p,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),Je(o,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),Je(R,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),Je(Z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),Je(K,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),Je(U,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(c,j){v(t,c,j),r(c,g,j),r(c,o,j),v(a,o,null),m(o,_),m(o,n),m(o,ee),m(o,F),m(o,te),m(o,x),m(o,oe),m(o,p),v(J,p,null),m(p,E),m(p,X),m(p,_e),v(A,p,null),m(p,xe),v(I,p,null),r(c,Ue,j),v(L,c,j),r(c,ae,j),r(c,Z,j),v(S,Z,null),m(Z,N),m(Z,D),m(Z,be),m(Z,re),m(Z,ye),m(Z,le),m(Z,Te),m(Z,R),v(ue,R,null),m(R,Q),m(R,Me),m(R,we),v(ie,R,null),m(R,ne),v(he,R,null),r(c,fe,j),v(Y,c,j),r(c,ge,j),r(c,U,j),v(de,U,null),m(U,f),m(U,C),m(U,W),m(U,q),m(U,Ge),m(U,ke),m(U,Ve),m(U,P),m(U,Le),m(U,K),v(ze,K,null),m(K,Ye),m(K,je),m(K,Se),v(ce,K,null),m(K,Xe),v(pe,K,null),qe=!0},p(c,j){const me={};j&2&&(me.$$scope={dirty:j,ctx:c}),A.$set(me);const se={};j&2&&(se.$$scope={dirty:j,ctx:c}),I.$set(se);const e={};j&2&&(e.$$scope={dirty:j,ctx:c}),ie.$set(e);const d={};j&2&&(d.$$scope={dirty:j,ctx:c}),he.$set(d);const V={};j&2&&(V.$$scope={dirty:j,ctx:c}),ce.$set(V);const De={};j&2&&(De.$$scope={dirty:j,ctx:c}),pe.$set(De)},i(c){qe||(w(t.$$.fragment,c),w(a.$$.fragment,c),w(J.$$.fragment,c),w(A.$$.fragment,c),w(I.$$.fragment,c),w(L.$$.fragment,c),w(S.$$.fragment,c),w(ue.$$.fragment,c),w(ie.$$.fragment,c),w(he.$$.fragment,c),w(Y.$$.fragment,c),w(de.$$.fragment,c),w(ze.$$.fragment,c),w(ce.$$.fragment,c),w(pe.$$.fragment,c),qe=!0)},o(c){k(t.$$.fragment,c),k(a.$$.fragment,c),k(J.$$.fragment,c),k(A.$$.fragment,c),k(I.$$.fragment,c),k(L.$$.fragment,c),k(S.$$.fragment,c),k(ue.$$.fragment,c),k(ie.$$.fragment,c),k(he.$$.fragment,c),k(Y.$$.fragment,c),k(de.$$.fragment,c),k(ze.$$.fragment,c),k(ce.$$.fragment,c),k(pe.$$.fragment,c),qe=!1},d(c){c&&(s(g),s(o),s(Ue),s(ae),s(Z),s(fe),s(ge),s(U)),$(t,c),$(a),$(J),$(A),$(I),$(L,c),$(S),$(ue),$(ie),$(he),$(Y,c),$(de),$(ze),$(ce),$(pe)}}}function ft(H){let t,g;return t=new Oe({props:{$$slots:{default:[ht]},$$scope:{ctx:H}}}),{c(){T(t.$$.fragment)},l(o){M(t.$$.fragment,o)},m(o,a){v(t,o,a),g=!0},p(o,a){const _={};a&2&&(_.$$scope={dirty:a,ctx:o}),t.$set(_)},i(o){g||(w(t.$$.fragment,o),g=!0)},o(o){k(t.$$.fragment,o),g=!1},d(o){$(t,o)}}}function gt(H){let t,g="TensorFlow models and layers in <code>transformers</code> accept two formats as input:",o,a,_="<li>having all inputs as keyword arguments (like PyTorch models), or</li> <li>having all inputs as a list, tuple or dict in the first positional argument.</li>",n,y,ee=`The reason the second format is supported is that Keras methods prefer this format when passing inputs to models | |
| and layers. Because of this support, when using methods like <code>model.fit()</code> things should “just work” for you - just | |
| pass your inputs and labels in any format that <code>model.fit()</code> supports! If, however, you want to use the second | |
| format outside of Keras methods like <code>fit()</code> and <code>predict()</code>, such as when creating your own layers or models with | |
| the Keras <code>Functional</code> API, there are three possibilities you can use to gather all the input Tensors in the first | |
| positional argument:`,F,z,te=`<li>a single Tensor with <code>input_values</code> only and nothing else: <code>model(input_values)</code></li> <li>a list of varying length with one or several input Tensors IN THE ORDER given in the docstring: | |
| <code>model([input_values, attention_mask])</code> or <code>model([input_values, attention_mask, token_type_ids])</code></li> <li>a dictionary with one or several input Tensors associated to the input names given in the docstring: | |
| <code>model({"input_values": input_values, "token_type_ids": token_type_ids})</code></li>`,x,B,oe=`Note that when creating models and layers with | |
| <a href="https://keras.io/guides/making_new_layers_and_models_via_subclassing/" rel="nofollow">subclassing</a> then you don’t need to worry | |
| about any of this, as you can just pass inputs like you would to any other Python function!`;return{c(){t=u("p"),t.innerHTML=g,o=l(),a=u("ul"),a.innerHTML=_,n=l(),y=u("p"),y.innerHTML=ee,F=l(),z=u("ul"),z.innerHTML=te,x=l(),B=u("p"),B.innerHTML=oe},l(p){t=h(p,"P",{"data-svelte-h":!0}),b(t)!=="svelte-1ajbfxg"&&(t.innerHTML=g),o=i(p),a=h(p,"UL",{"data-svelte-h":!0}),b(a)!=="svelte-qm1t26"&&(a.innerHTML=_),n=i(p),y=h(p,"P",{"data-svelte-h":!0}),b(y)!=="svelte-1v9qsc5"&&(y.innerHTML=ee),F=i(p),z=h(p,"UL",{"data-svelte-h":!0}),b(z)!=="svelte-1x9eg56"&&(z.innerHTML=te),x=i(p),B=h(p,"P",{"data-svelte-h":!0}),b(B)!=="svelte-1an3odd"&&(B.innerHTML=oe)},m(p,J){r(p,t,J),r(p,o,J),r(p,a,J),r(p,n,J),r(p,y,J),r(p,F,J),r(p,z,J),r(p,x,J),r(p,B,J)},p:Fe,d(p){p&&(s(t),s(o),s(a),s(n),s(y),s(F),s(z),s(x),s(B))}}}function _t(H){let t,g=`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=u("p"),t.innerHTML=g},l(o){t=h(o,"P",{"data-svelte-h":!0}),b(t)!=="svelte-fincs2"&&(t.innerHTML=g)},m(o,a){r(o,t,a)},p:Fe,d(o){o&&s(t)}}}function bt(H){let t,g="Example:",o,a,_;return a=new Ee({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Qcm9jZXNzb3IlMkMlMjBURkh1YmVydE1vZGVsJTBBZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBaW1wb3J0JTIwc291bmRmaWxlJTIwYXMlMjBzZiUwQSUwQXByb2Nlc3NvciUyMCUzRCUyMEF1dG9Qcm9jZXNzb3IuZnJvbV9wcmV0cmFpbmVkKCUyMmZhY2Vib29rJTJGaHViZXJ0LWxhcmdlLWxzOTYwLWZ0JTIyKSUwQW1vZGVsJTIwJTNEJTIwVEZIdWJlcnRNb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIyZmFjZWJvb2slMkZodWJlcnQtbGFyZ2UtbHM5NjAtZnQlMjIpJTBBJTBBJTBBZGVmJTIwbWFwX3RvX2FycmF5KGJhdGNoKSUzQSUwQSUyMCUyMCUyMCUyMHNwZWVjaCUyQyUyMF8lMjAlM0QlMjBzZi5yZWFkKGJhdGNoJTVCJTIyZmlsZSUyMiU1RCklMEElMjAlMjAlMjAlMjBiYXRjaCU1QiUyMnNwZWVjaCUyMiU1RCUyMCUzRCUyMHNwZWVjaCUwQSUyMCUyMCUyMCUyMHJldHVybiUyMGJhdGNoJTBBJTBBJTBBZHMlMjAlM0QlMjBsb2FkX2RhdGFzZXQoJTIyaGYtaW50ZXJuYWwtdGVzdGluZyUyRmxpYnJpc3BlZWNoX2Fzcl9kdW1teSUyMiUyQyUyMCUyMmNsZWFuJTIyJTJDJTIwc3BsaXQlM0QlMjJ2YWxpZGF0aW9uJTIyKSUwQWRzJTIwJTNEJTIwZHMubWFwKG1hcF90b19hcnJheSklMEElMEFpbnB1dF92YWx1ZXMlMjAlM0QlMjBwcm9jZXNzb3IoZHMlNUIlMjJzcGVlY2glMjIlNUQlNUIwJTVEJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJ0ZiUyMikuaW5wdXRfdmFsdWVzJTIwJTIwJTIzJTIwQmF0Y2glMjBzaXplJTIwMSUwQWhpZGRlbl9zdGF0ZXMlMjAlM0QlMjBtb2RlbChpbnB1dF92YWx1ZXMpLmxhc3RfaGlkZGVuX3N0YXRl",highlighted:`<span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoProcessor, TFHubertModel | |
| <span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset | |
| <span class="hljs-meta">>>> </span><span class="hljs-keyword">import</span> soundfile <span class="hljs-keyword">as</span> sf | |
| <span class="hljs-meta">>>> </span>processor = AutoProcessor.from_pretrained(<span class="hljs-string">"facebook/hubert-large-ls960-ft"</span>) | |
| <span class="hljs-meta">>>> </span>model = TFHubertModel.from_pretrained(<span class="hljs-string">"facebook/hubert-large-ls960-ft"</span>) | |
| <span class="hljs-meta">>>> </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">map_to_array</span>(<span class="hljs-params">batch</span>): | |
| <span class="hljs-meta">... </span> speech, _ = sf.read(batch[<span class="hljs-string">"file"</span>]) | |
| <span class="hljs-meta">... </span> batch[<span class="hljs-string">"speech"</span>] = speech | |
| <span class="hljs-meta">... </span> <span class="hljs-keyword">return</span> batch | |
| <span class="hljs-meta">>>> </span>ds = load_dataset(<span class="hljs-string">"hf-internal-testing/librispeech_asr_dummy"</span>, <span class="hljs-string">"clean"</span>, split=<span class="hljs-string">"validation"</span>) | |
| <span class="hljs-meta">>>> </span>ds = ds.<span class="hljs-built_in">map</span>(map_to_array) | |
| <span class="hljs-meta">>>> </span>input_values = processor(ds[<span class="hljs-string">"speech"</span>][<span class="hljs-number">0</span>], return_tensors=<span class="hljs-string">"tf"</span>).input_values <span class="hljs-comment"># Batch size 1</span> | |
| <span class="hljs-meta">>>> </span>hidden_states = model(input_values).last_hidden_state`,wrap:!1}}),{c(){t=u("p"),t.textContent=g,o=l(),T(a.$$.fragment)},l(n){t=h(n,"P",{"data-svelte-h":!0}),b(t)!=="svelte-11lpom8"&&(t.textContent=g),o=i(n),M(a.$$.fragment,n)},m(n,y){r(n,t,y),r(n,o,y),v(a,n,y),_=!0},p:Fe,i(n){_||(w(a.$$.fragment,n),_=!0)},o(n){k(a.$$.fragment,n),_=!1},d(n){n&&(s(t),s(o)),$(a,n)}}}function yt(H){let t,g="TensorFlow models and layers in <code>transformers</code> accept two formats as input:",o,a,_="<li>having all inputs as keyword arguments (like PyTorch models), or</li> <li>having all inputs as a list, tuple or dict in the first positional argument.</li>",n,y,ee=`The reason the second format is supported is that Keras methods prefer this format when passing inputs to models | |
| and layers. Because of this support, when using methods like <code>model.fit()</code> things should “just work” for you - just | |
| pass your inputs and labels in any format that <code>model.fit()</code> supports! If, however, you want to use the second | |
| format outside of Keras methods like <code>fit()</code> and <code>predict()</code>, such as when creating your own layers or models with | |
| the Keras <code>Functional</code> API, there are three possibilities you can use to gather all the input Tensors in the first | |
| positional argument:`,F,z,te=`<li>a single Tensor with <code>input_values</code> only and nothing else: <code>model(input_values)</code></li> <li>a list of varying length with one or several input Tensors IN THE ORDER given in the docstring: | |
| <code>model([input_values, attention_mask])</code> or <code>model([input_values, attention_mask, token_type_ids])</code></li> <li>a dictionary with one or several input Tensors associated to the input names given in the docstring: | |
| <code>model({"input_values": input_values, "token_type_ids": token_type_ids})</code></li>`,x,B,oe=`Note that when creating models and layers with | |
| <a href="https://keras.io/guides/making_new_layers_and_models_via_subclassing/" rel="nofollow">subclassing</a> then you don’t need to worry | |
| about any of this, as you can just pass inputs like you would to any other Python function!`;return{c(){t=u("p"),t.innerHTML=g,o=l(),a=u("ul"),a.innerHTML=_,n=l(),y=u("p"),y.innerHTML=ee,F=l(),z=u("ul"),z.innerHTML=te,x=l(),B=u("p"),B.innerHTML=oe},l(p){t=h(p,"P",{"data-svelte-h":!0}),b(t)!=="svelte-1ajbfxg"&&(t.innerHTML=g),o=i(p),a=h(p,"UL",{"data-svelte-h":!0}),b(a)!=="svelte-qm1t26"&&(a.innerHTML=_),n=i(p),y=h(p,"P",{"data-svelte-h":!0}),b(y)!=="svelte-1v9qsc5"&&(y.innerHTML=ee),F=i(p),z=h(p,"UL",{"data-svelte-h":!0}),b(z)!=="svelte-1x9eg56"&&(z.innerHTML=te),x=i(p),B=h(p,"P",{"data-svelte-h":!0}),b(B)!=="svelte-1an3odd"&&(B.innerHTML=oe)},m(p,J){r(p,t,J),r(p,o,J),r(p,a,J),r(p,n,J),r(p,y,J),r(p,F,J),r(p,z,J),r(p,x,J),r(p,B,J)},p:Fe,d(p){p&&(s(t),s(o),s(a),s(n),s(y),s(F),s(z),s(x),s(B))}}}function Tt(H){let t,g=`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=u("p"),t.innerHTML=g},l(o){t=h(o,"P",{"data-svelte-h":!0}),b(t)!=="svelte-fincs2"&&(t.innerHTML=g)},m(o,a){r(o,t,a)},p:Fe,d(o){o&&s(t)}}}function Mt(H){let t,g="Example:",o,a,_;return a=new Ee({props:{code:"aW1wb3J0JTIwdGVuc29yZmxvdyUyMGFzJTIwdGYlMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b1Byb2Nlc3NvciUyQyUyMFRGSHViZXJ0Rm9yQ1RDJTBBZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBaW1wb3J0JTIwc291bmRmaWxlJTIwYXMlMjBzZiUwQSUwQXByb2Nlc3NvciUyMCUzRCUyMEF1dG9Qcm9jZXNzb3IuZnJvbV9wcmV0cmFpbmVkKCUyMmZhY2Vib29rJTJGaHViZXJ0LWxhcmdlLWxzOTYwLWZ0JTIyKSUwQW1vZGVsJTIwJTNEJTIwVEZIdWJlcnRGb3JDVEMuZnJvbV9wcmV0cmFpbmVkKCUyMmZhY2Vib29rJTJGaHViZXJ0LWxhcmdlLWxzOTYwLWZ0JTIyKSUwQSUwQSUwQWRlZiUyMG1hcF90b19hcnJheShiYXRjaCklM0ElMEElMjAlMjAlMjAlMjBzcGVlY2glMkMlMjBfJTIwJTNEJTIwc2YucmVhZChiYXRjaCU1QiUyMmZpbGUlMjIlNUQpJTBBJTIwJTIwJTIwJTIwYmF0Y2glNUIlMjJzcGVlY2glMjIlNUQlMjAlM0QlMjBzcGVlY2glMEElMjAlMjAlMjAlMjByZXR1cm4lMjBiYXRjaCUwQSUwQSUwQWRzJTIwJTNEJTIwbG9hZF9kYXRhc2V0KCUyMmhmLWludGVybmFsLXRlc3RpbmclMkZsaWJyaXNwZWVjaF9hc3JfZHVtbXklMjIlMkMlMjAlMjJjbGVhbiUyMiUyQyUyMHNwbGl0JTNEJTIydmFsaWRhdGlvbiUyMiklMEFkcyUyMCUzRCUyMGRzLm1hcChtYXBfdG9fYXJyYXkpJTBBJTBBaW5wdXRfdmFsdWVzJTIwJTNEJTIwcHJvY2Vzc29yKGRzJTVCJTIyc3BlZWNoJTIyJTVEJTVCMCU1RCUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIydGYlMjIpLmlucHV0X3ZhbHVlcyUyMCUyMCUyMyUyMEJhdGNoJTIwc2l6ZSUyMDElMEFsb2dpdHMlMjAlM0QlMjBtb2RlbChpbnB1dF92YWx1ZXMpLmxvZ2l0cyUwQXByZWRpY3RlZF9pZHMlMjAlM0QlMjB0Zi5hcmdtYXgobG9naXRzJTJDJTIwYXhpcyUzRC0xKSUwQSUwQXRyYW5zY3JpcHRpb24lMjAlM0QlMjBwcm9jZXNzb3IuZGVjb2RlKHByZWRpY3RlZF9pZHMlNUIwJTVEKSUwQSUwQSUyMyUyMGNvbXB1dGUlMjBsb3NzJTBBdGFyZ2V0X3RyYW5zY3JpcHRpb24lMjAlM0QlMjAlMjJBJTIwTUFOJTIwU0FJRCUyMFRPJTIwVEhFJTIwVU5JVkVSU0UlMjBTSVIlMjBJJTIwRVhJU1QlMjIlMEElMEElMjMlMjBQYXNzJTIwdGhlJTIwdHJhbnNjcmlwdGlvbiUyMGFzJTIwdGV4dCUyMHRvJTIwZW5jb2RlJTIwbGFiZWxzJTBBbGFiZWxzJTIwJTNEJTIwcHJvY2Vzc29yKHRleHQlM0R0cmFuc2NyaXB0aW9uJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJ0ZiUyMikuaW5wdXRfdmFsdWVzJTBBJTBBbG9zcyUyMCUzRCUyMG1vZGVsKGlucHV0X3ZhbHVlcyUyQyUyMGxhYmVscyUzRGxhYmVscykubG9zcw==",highlighted:`<span class="hljs-meta">>>> </span><span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf | |
| <span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoProcessor, TFHubertForCTC | |
| <span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset | |
| <span class="hljs-meta">>>> </span><span class="hljs-keyword">import</span> soundfile <span class="hljs-keyword">as</span> sf | |
| <span class="hljs-meta">>>> </span>processor = AutoProcessor.from_pretrained(<span class="hljs-string">"facebook/hubert-large-ls960-ft"</span>) | |
| <span class="hljs-meta">>>> </span>model = TFHubertForCTC.from_pretrained(<span class="hljs-string">"facebook/hubert-large-ls960-ft"</span>) | |
| <span class="hljs-meta">>>> </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">map_to_array</span>(<span class="hljs-params">batch</span>): | |
| <span class="hljs-meta">... </span> speech, _ = sf.read(batch[<span class="hljs-string">"file"</span>]) | |
| <span class="hljs-meta">... </span> batch[<span class="hljs-string">"speech"</span>] = speech | |
| <span class="hljs-meta">... </span> <span class="hljs-keyword">return</span> batch | |
| <span class="hljs-meta">>>> </span>ds = load_dataset(<span class="hljs-string">"hf-internal-testing/librispeech_asr_dummy"</span>, <span class="hljs-string">"clean"</span>, split=<span class="hljs-string">"validation"</span>) | |
| <span class="hljs-meta">>>> </span>ds = ds.<span class="hljs-built_in">map</span>(map_to_array) | |
| <span class="hljs-meta">>>> </span>input_values = processor(ds[<span class="hljs-string">"speech"</span>][<span class="hljs-number">0</span>], return_tensors=<span class="hljs-string">"tf"</span>).input_values <span class="hljs-comment"># Batch size 1</span> | |
| <span class="hljs-meta">>>> </span>logits = model(input_values).logits | |
| <span class="hljs-meta">>>> </span>predicted_ids = tf.argmax(logits, axis=-<span class="hljs-number">1</span>) | |
| <span class="hljs-meta">>>> </span>transcription = processor.decode(predicted_ids[<span class="hljs-number">0</span>]) | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># compute loss</span> | |
| <span class="hljs-meta">>>> </span>target_transcription = <span class="hljs-string">"A MAN SAID TO THE UNIVERSE SIR I EXIST"</span> | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># Pass the transcription as text to encode labels</span> | |
| <span class="hljs-meta">>>> </span>labels = processor(text=transcription, return_tensors=<span class="hljs-string">"tf"</span>).input_values | |
| <span class="hljs-meta">>>> </span>loss = model(input_values, labels=labels).loss`,wrap:!1}}),{c(){t=u("p"),t.textContent=g,o=l(),T(a.$$.fragment)},l(n){t=h(n,"P",{"data-svelte-h":!0}),b(t)!=="svelte-11lpom8"&&(t.textContent=g),o=i(n),M(a.$$.fragment,n)},m(n,y){r(n,t,y),r(n,o,y),v(a,n,y),_=!0},p:Fe,i(n){_||(w(a.$$.fragment,n),_=!0)},o(n){k(a.$$.fragment,n),_=!1},d(n){n&&(s(t),s(o)),$(a,n)}}}function vt(H){let t,g,o,a,_,n,y="The bare TFHubert Model transformer outputing raw hidden-states without any specific head on top.",ee,F,z=`This model inherits from <a href="/docs/transformers/pr_36095/en/main_classes/model#transformers.TFPreTrainedModel">TFPreTrainedModel</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.)`,te,x,B=`This model is also a <a href="https://www.tensorflow.org/api_docs/python/tf/keras/Model" rel="nofollow">keras.Model</a> 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.`,oe,p,J,E,X,Be,_e,A='The <a href="/docs/transformers/pr_36095/en/model_doc/hubert#transformers.TFHubertModel">TFHubertModel</a> forward method, overrides the <code>__call__</code> special method.',xe,I,Ue,L,ae,Z,S,N,D,ve,be,re="TFHubert Model with a <code>language modeling</code> head on top for Connectionist Temporal Classification (CTC).",Ne,ye,le=`This model inherits from <a href="/docs/transformers/pr_36095/en/main_classes/model#transformers.TFPreTrainedModel">TFPreTrainedModel</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.)`,Re,Te,R=`This model is also a <a href="https://www.tensorflow.org/api_docs/python/tf/keras/Model" rel="nofollow">keras.Model</a> 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.`,ue,Q,Me,G,we,ie,ne,he='The <a href="/docs/transformers/pr_36095/en/model_doc/hubert#transformers.TFHubertForCTC">TFHubertForCTC</a> forward method, overrides the <code>__call__</code> special method.',fe,Y,ge,U,de;return t=new $e({props:{title:"TFHubertModel",local:"transformers.TFHubertModel",headingTag:"h2"}}),a=new Ze({props:{name:"class transformers.TFHubertModel",anchor:"transformers.TFHubertModel",parameters:[{name:"config",val:": HubertConfig"},{name:"*inputs",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.TFHubertModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_36095/en/model_doc/hubert#transformers.HubertConfig">HubertConfig</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_36095/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_36095/src/transformers/models/hubert/modeling_tf_hubert.py#L1427"}}),p=new Qe({props:{$$slots:{default:[gt]},$$scope:{ctx:H}}}),X=new Ze({props:{name:"call",anchor:"transformers.TFHubertModel.call",parameters:[{name:"input_values",val:": tf.Tensor"},{name:"attention_mask",val:": tf.Tensor | None = None"},{name:"token_type_ids",val:": tf.Tensor | None = None"},{name:"position_ids",val:": tf.Tensor | None = None"},{name:"head_mask",val:": tf.Tensor | None = None"},{name:"inputs_embeds",val:": tf.Tensor | None = None"},{name:"output_attentions",val:": Optional[bool] = None"},{name:"output_hidden_states",val:": Optional[bool] = None"},{name:"return_dict",val:": Optional[bool] = None"},{name:"training",val:": bool = False"}],parametersDescription:[{anchor:"transformers.TFHubertModel.call.input_values",description:`<strong>input_values</strong> (<code>np.ndarray</code>, <code>tf.Tensor</code>, <code>List[tf.Tensor]</code> <code>Dict[str, tf.Tensor]</code> or <code>Dict[str, np.ndarray]</code> and each example must have the shape <code>({0})</code>) — | |
| Indices of input sequence tokens in the vocabulary.</p> | |
| <p>Indices can be obtained using <a href="/docs/transformers/pr_36095/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/pr_36095/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> and | |
| <a href="/docs/transformers/pr_36095/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> for details.</p> | |
| <p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_values"},{anchor:"transformers.TFHubertModel.call.attention_mask",description:`<strong>attention_mask</strong> (<code>np.ndarray</code> or <code>tf.Tensor</code> of shape <code>({0})</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.TFHubertModel.call.token_type_ids",description:`<strong>token_type_ids</strong> (<code>np.ndarray</code> or <code>tf.Tensor</code> of shape <code>({0})</code>, <em>optional</em>) — | |
| Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:</p> | |
| <ul> | |
| <li>0 corresponds to a <em>sentence A</em> token,</li> | |
| <li>1 corresponds to a <em>sentence B</em> token.</li> | |
| </ul> | |
| <p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.TFHubertModel.call.position_ids",description:`<strong>position_ids</strong> (<code>np.ndarray</code> or <code>tf.Tensor</code> of shape <code>({0})</code>, <em>optional</em>) — | |
| Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.max_position_embeddings - 1]</code>.</p> | |
| <p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.TFHubertModel.call.head_mask",description:`<strong>head_mask</strong> (<code>np.ndarray</code> or <code>tf.Tensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) — | |
| Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p> | |
| <ul> | |
| <li>1 indicates the head is <strong>not masked</strong>,</li> | |
| <li>0 indicates the head is <strong>masked</strong>.</li> | |
| </ul>`,name:"head_mask"},{anchor:"transformers.TFHubertModel.call.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>np.ndarray</code> or <code>tf.Tensor</code> of shape <code>({0}, hidden_size)</code>, <em>optional</em>) — | |
| Optionally, instead of passing <code>input_values</code> you can choose to directly pass an embedded representation. | |
| This is useful if you want more control over how to convert <code>input_values</code> indices into associated vectors | |
| than the model’s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.TFHubertModel.call.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) — | |
| Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned | |
| tensors for more detail. This argument can be used only in eager mode, in graph mode the value in the | |
| config will be used instead.`,name:"output_attentions"},{anchor:"transformers.TFHubertModel.call.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) — | |
| Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for | |
| more detail. This argument can be used only in eager mode, in graph mode the value in the config will be | |
| used instead.`,name:"output_hidden_states"},{anchor:"transformers.TFHubertModel.call.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) — | |
| Whether or not to return a <a href="/docs/transformers/pr_36095/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple. This argument can be used in | |
| eager mode, in graph mode the value will always be set to True.`,name:"return_dict"},{anchor:"transformers.TFHubertModel.call.training",description:`<strong>training</strong> (<code>bool</code>, <em>optional</em>, defaults to \`False“) — | |
| Whether or not to use the model in training mode (some modules like dropout modules have different | |
| behaviors between training and evaluation).`,name:"training"}],source:"https://github.com/huggingface/transformers/blob/vr_36095/src/transformers/models/hubert/modeling_tf_hubert.py#L1437",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>A <a | |
| href="/docs/transformers/pr_36095/en/main_classes/output#transformers.modeling_tf_outputs.TFBaseModelOutput" | |
| >transformers.modeling_tf_outputs.TFBaseModelOutput</a> 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/pr_36095/en/model_doc/hubert#transformers.HubertConfig" | |
| >HubertConfig</a>) and inputs.</p> | |
| <ul> | |
| <li> | |
| <p><strong>last_hidden_state</strong> (<code>tf.Tensor</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> | |
| </li> | |
| <li> | |
| <p><strong>hidden_states</strong> (<code>tuple(tf.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>tf.Tensor</code> (one for the output of the embeddings + one for the output of each layer) of shape | |
| <code>(batch_size, sequence_length, hidden_size)</code>.</p> | |
| <p>Hidden-states of the model at the output of each layer plus the initial embedding outputs.</p> | |
| </li> | |
| <li> | |
| <p><strong>attentions</strong> (<code>tuple(tf.Tensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) — 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 after the attention softmax, used to compute the weighted average in the self-attention | |
| heads.</p> | |
| </li> | |
| </ul> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><a | |
| href="/docs/transformers/pr_36095/en/main_classes/output#transformers.modeling_tf_outputs.TFBaseModelOutput" | |
| >transformers.modeling_tf_outputs.TFBaseModelOutput</a> or <code>tuple(tf.Tensor)</code></p> | |
| `}}),I=new Qe({props:{$$slots:{default:[_t]},$$scope:{ctx:H}}}),L=new Pe({props:{anchor:"transformers.TFHubertModel.call.example",$$slots:{default:[bt]},$$scope:{ctx:H}}}),Z=new $e({props:{title:"TFHubertForCTC",local:"transformers.TFHubertForCTC",headingTag:"h2"}}),D=new Ze({props:{name:"class transformers.TFHubertForCTC",anchor:"transformers.TFHubertForCTC",parameters:[{name:"config",val:": HubertConfig"},{name:"*inputs",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.TFHubertForCTC.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_36095/en/model_doc/hubert#transformers.HubertConfig">HubertConfig</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_36095/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_36095/src/transformers/models/hubert/modeling_tf_hubert.py#L1509"}}),Q=new Qe({props:{$$slots:{default:[yt]},$$scope:{ctx:H}}}),we=new Ze({props:{name:"call",anchor:"transformers.TFHubertForCTC.call",parameters:[{name:"input_values",val:": tf.Tensor"},{name:"attention_mask",val:": tf.Tensor | None = None"},{name:"token_type_ids",val:": tf.Tensor | None = None"},{name:"position_ids",val:": tf.Tensor | None = None"},{name:"head_mask",val:": tf.Tensor | None = None"},{name:"inputs_embeds",val:": tf.Tensor | None = None"},{name:"output_attentions",val:": Optional[bool] = None"},{name:"labels",val:": tf.Tensor | None = None"},{name:"output_hidden_states",val:": Optional[bool] = None"},{name:"return_dict",val:": Optional[bool] = None"},{name:"training",val:": Optional[bool] = False"}],parametersDescription:[{anchor:"transformers.TFHubertForCTC.call.input_values",description:`<strong>input_values</strong> (<code>np.ndarray</code>, <code>tf.Tensor</code>, <code>List[tf.Tensor]</code> <code>Dict[str, tf.Tensor]</code> or <code>Dict[str, np.ndarray]</code> and each example must have the shape <code>({0})</code>) — | |
| Indices of input sequence tokens in the vocabulary.</p> | |
| <p>Indices can be obtained using <a href="/docs/transformers/pr_36095/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/pr_36095/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> and | |
| <a href="/docs/transformers/pr_36095/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> for details.</p> | |
| <p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_values"},{anchor:"transformers.TFHubertForCTC.call.attention_mask",description:`<strong>attention_mask</strong> (<code>np.ndarray</code> or <code>tf.Tensor</code> of shape <code>({0})</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.TFHubertForCTC.call.token_type_ids",description:`<strong>token_type_ids</strong> (<code>np.ndarray</code> or <code>tf.Tensor</code> of shape <code>({0})</code>, <em>optional</em>) — | |
| Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:</p> | |
| <ul> | |
| <li>0 corresponds to a <em>sentence A</em> token,</li> | |
| <li>1 corresponds to a <em>sentence B</em> token.</li> | |
| </ul> | |
| <p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.TFHubertForCTC.call.position_ids",description:`<strong>position_ids</strong> (<code>np.ndarray</code> or <code>tf.Tensor</code> of shape <code>({0})</code>, <em>optional</em>) — | |
| Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.max_position_embeddings - 1]</code>.</p> | |
| <p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.TFHubertForCTC.call.head_mask",description:`<strong>head_mask</strong> (<code>np.ndarray</code> or <code>tf.Tensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) — | |
| Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p> | |
| <ul> | |
| <li>1 indicates the head is <strong>not masked</strong>,</li> | |
| <li>0 indicates the head is <strong>masked</strong>.</li> | |
| </ul>`,name:"head_mask"},{anchor:"transformers.TFHubertForCTC.call.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>np.ndarray</code> or <code>tf.Tensor</code> of shape <code>({0}, hidden_size)</code>, <em>optional</em>) — | |
| Optionally, instead of passing <code>input_values</code> you can choose to directly pass an embedded representation. | |
| This is useful if you want more control over how to convert <code>input_values</code> indices into associated vectors | |
| than the model’s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.TFHubertForCTC.call.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) — | |
| Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned | |
| tensors for more detail. This argument can be used only in eager mode, in graph mode the value in the | |
| config will be used instead.`,name:"output_attentions"},{anchor:"transformers.TFHubertForCTC.call.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) — | |
| Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for | |
| more detail. This argument can be used only in eager mode, in graph mode the value in the config will be | |
| used instead.`,name:"output_hidden_states"},{anchor:"transformers.TFHubertForCTC.call.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) — | |
| Whether or not to return a <a href="/docs/transformers/pr_36095/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple. This argument can be used in | |
| eager mode, in graph mode the value will always be set to True.`,name:"return_dict"},{anchor:"transformers.TFHubertForCTC.call.training",description:`<strong>training</strong> (<code>bool</code>, <em>optional</em>, defaults to \`False“) — | |
| Whether or not to use the model in training mode (some modules like dropout modules have different | |
| behaviors between training and evaluation).`,name:"training"},{anchor:"transformers.TFHubertForCTC.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>) — | |
| Labels for computing the masked language modeling loss. Indices should be in <code>[-100, 0, ..., config.vocab_size]</code> (see <code>input_values</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"}],source:"https://github.com/huggingface/transformers/blob/vr_36095/src/transformers/models/hubert/modeling_tf_hubert.py#L1543",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>A <a | |
| href="/docs/transformers/pr_36095/en/main_classes/output#transformers.modeling_tf_outputs.TFCausalLMOutput" | |
| >transformers.modeling_tf_outputs.TFCausalLMOutput</a> 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/pr_36095/en/model_doc/hubert#transformers.HubertConfig" | |
| >HubertConfig</a>) and inputs.</p> | |
| <ul> | |
| <li> | |
| <p><strong>loss</strong> (<code>tf.Tensor</code> of shape <code>(n,)</code>, <em>optional</em>, where n is the number of non-masked labels, returned when <code>labels</code> is provided) — Language modeling loss (for next-token prediction).</p> | |
| </li> | |
| <li> | |
| <p><strong>logits</strong> (<code>tf.Tensor</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>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>) — Tuple of <code>tf.Tensor</code> (one for the output of the embeddings + one for the output of each layer) of shape | |
| <code>(batch_size, sequence_length, hidden_size)</code>.</p> | |
| <p>Hidden-states of the model at the output of each layer plus the initial embedding outputs.</p> | |
| </li> | |
| <li> | |
| <p><strong>attentions</strong> (<code>tuple(tf.Tensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) — 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 after the attention softmax, used to compute the weighted average in the self-attention | |
| heads.</p> | |
| </li> | |
| </ul> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><a | |
| href="/docs/transformers/pr_36095/en/main_classes/output#transformers.modeling_tf_outputs.TFCausalLMOutput" | |
| >transformers.modeling_tf_outputs.TFCausalLMOutput</a> or <code>tuple(tf.Tensor)</code></p> | |
| `}}),Y=new Qe({props:{$$slots:{default:[Tt]},$$scope:{ctx:H}}}),U=new Pe({props:{anchor:"transformers.TFHubertForCTC.call.example",$$slots:{default:[Mt]},$$scope:{ctx:H}}}),{c(){T(t.$$.fragment),g=l(),o=u("div"),T(a.$$.fragment),_=l(),n=u("p"),n.textContent=y,ee=l(),F=u("p"),F.innerHTML=z,te=l(),x=u("p"),x.innerHTML=B,oe=l(),T(p.$$.fragment),J=l(),E=u("div"),T(X.$$.fragment),Be=l(),_e=u("p"),_e.innerHTML=A,xe=l(),T(I.$$.fragment),Ue=l(),T(L.$$.fragment),ae=l(),T(Z.$$.fragment),S=l(),N=u("div"),T(D.$$.fragment),ve=l(),be=u("p"),be.innerHTML=re,Ne=l(),ye=u("p"),ye.innerHTML=le,Re=l(),Te=u("p"),Te.innerHTML=R,ue=l(),T(Q.$$.fragment),Me=l(),G=u("div"),T(we.$$.fragment),ie=l(),ne=u("p"),ne.innerHTML=he,fe=l(),T(Y.$$.fragment),ge=l(),T(U.$$.fragment),this.h()},l(f){M(t.$$.fragment,f),g=i(f),o=h(f,"DIV",{class:!0});var C=He(o);M(a.$$.fragment,C),_=i(C),n=h(C,"P",{"data-svelte-h":!0}),b(n)!=="svelte-1241ewv"&&(n.textContent=y),ee=i(C),F=h(C,"P",{"data-svelte-h":!0}),b(F)!=="svelte-hja9td"&&(F.innerHTML=z),te=i(C),x=h(C,"P",{"data-svelte-h":!0}),b(x)!=="svelte-1be7e3c"&&(x.innerHTML=B),oe=i(C),M(p.$$.fragment,C),J=i(C),E=h(C,"DIV",{class:!0});var O=He(E);M(X.$$.fragment,O),Be=i(O),_e=h(O,"P",{"data-svelte-h":!0}),b(_e)!=="svelte-1qiq5s8"&&(_e.innerHTML=A),xe=i(O),M(I.$$.fragment,O),Ue=i(O),M(L.$$.fragment,O),O.forEach(s),C.forEach(s),ae=i(f),M(Z.$$.fragment,f),S=i(f),N=h(f,"DIV",{class:!0});var W=He(N);M(D.$$.fragment,W),ve=i(W),be=h(W,"P",{"data-svelte-h":!0}),b(be)!=="svelte-1qjnsya"&&(be.innerHTML=re),Ne=i(W),ye=h(W,"P",{"data-svelte-h":!0}),b(ye)!=="svelte-hja9td"&&(ye.innerHTML=le),Re=i(W),Te=h(W,"P",{"data-svelte-h":!0}),b(Te)!=="svelte-1be7e3c"&&(Te.innerHTML=R),ue=i(W),M(Q.$$.fragment,W),Me=i(W),G=h(W,"DIV",{class:!0});var q=He(G);M(we.$$.fragment,q),ie=i(q),ne=h(q,"P",{"data-svelte-h":!0}),b(ne)!=="svelte-1b96si2"&&(ne.innerHTML=he),fe=i(q),M(Y.$$.fragment,q),ge=i(q),M(U.$$.fragment,q),q.forEach(s),W.forEach(s),this.h()},h(){Je(E,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),Je(o,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),Je(G,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),Je(N,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(f,C){v(t,f,C),r(f,g,C),r(f,o,C),v(a,o,null),m(o,_),m(o,n),m(o,ee),m(o,F),m(o,te),m(o,x),m(o,oe),v(p,o,null),m(o,J),m(o,E),v(X,E,null),m(E,Be),m(E,_e),m(E,xe),v(I,E,null),m(E,Ue),v(L,E,null),r(f,ae,C),v(Z,f,C),r(f,S,C),r(f,N,C),v(D,N,null),m(N,ve),m(N,be),m(N,Ne),m(N,ye),m(N,Re),m(N,Te),m(N,ue),v(Q,N,null),m(N,Me),m(N,G),v(we,G,null),m(G,ie),m(G,ne),m(G,fe),v(Y,G,null),m(G,ge),v(U,G,null),de=!0},p(f,C){const O={};C&2&&(O.$$scope={dirty:C,ctx:f}),p.$set(O);const W={};C&2&&(W.$$scope={dirty:C,ctx:f}),I.$set(W);const q={};C&2&&(q.$$scope={dirty:C,ctx:f}),L.$set(q);const Ce={};C&2&&(Ce.$$scope={dirty:C,ctx:f}),Q.$set(Ce);const Ge={};C&2&&(Ge.$$scope={dirty:C,ctx:f}),Y.$set(Ge);const ke={};C&2&&(ke.$$scope={dirty:C,ctx:f}),U.$set(ke)},i(f){de||(w(t.$$.fragment,f),w(a.$$.fragment,f),w(p.$$.fragment,f),w(X.$$.fragment,f),w(I.$$.fragment,f),w(L.$$.fragment,f),w(Z.$$.fragment,f),w(D.$$.fragment,f),w(Q.$$.fragment,f),w(we.$$.fragment,f),w(Y.$$.fragment,f),w(U.$$.fragment,f),de=!0)},o(f){k(t.$$.fragment,f),k(a.$$.fragment,f),k(p.$$.fragment,f),k(X.$$.fragment,f),k(I.$$.fragment,f),k(L.$$.fragment,f),k(Z.$$.fragment,f),k(D.$$.fragment,f),k(Q.$$.fragment,f),k(we.$$.fragment,f),k(Y.$$.fragment,f),k(U.$$.fragment,f),de=!1},d(f){f&&(s(g),s(o),s(ae),s(S),s(N)),$(t,f),$(a),$(p),$(X),$(I),$(L),$(Z,f),$(D),$(Q),$(we),$(Y),$(U)}}}function wt(H){let t,g;return t=new Oe({props:{$$slots:{default:[vt]},$$scope:{ctx:H}}}),{c(){T(t.$$.fragment)},l(o){M(t.$$.fragment,o)},m(o,a){v(t,o,a),g=!0},p(o,a){const _={};a&2&&(_.$$scope={dirty:a,ctx:o}),t.$set(_)},i(o){g||(w(t.$$.fragment,o),g=!0)},o(o){k(t.$$.fragment,o),g=!1},d(o){$(t,o)}}}function kt(H){let t,g,o,a,_,n,y,ee,F,z=`Hubert was proposed in <a href="https://arxiv.org/abs/2106.07447" rel="nofollow">HuBERT: Self-Supervised Speech Representation Learning by Masked Prediction of Hidden Units</a> by Wei-Ning Hsu, Benjamin Bolte, Yao-Hung Hubert Tsai, Kushal Lakhotia, Ruslan | |
| Salakhutdinov, Abdelrahman Mohamed.`,te,x,B="The abstract from the paper is the following:",oe,p,J=`<em>Self-supervised approaches for speech representation learning are challenged by three unique problems: (1) there are | |
| multiple sound units in each input utterance, (2) there is no lexicon of input sound units during the pre-training | |
| phase, and (3) sound units have variable lengths with no explicit segmentation. To deal with these three problems, we | |
| propose the Hidden-Unit BERT (HuBERT) approach for self-supervised speech representation learning, which utilizes an | |
| offline clustering step to provide aligned target labels for a BERT-like prediction loss. A key ingredient of our | |
| approach is applying the prediction loss over the masked regions only, which forces the model to learn a combined | |
| acoustic and language model over the continuous inputs. HuBERT relies primarily on the consistency of the unsupervised | |
| clustering step rather than the intrinsic quality of the assigned cluster labels. Starting with a simple k-means | |
| teacher of 100 clusters, and using two iterations of clustering, the HuBERT model either matches or improves upon the | |
| state-of-the-art wav2vec 2.0 performance on the Librispeech (960h) and Libri-light (60,000h) benchmarks with 10min, 1h, | |
| 10h, 100h, and 960h fine-tuning subsets. Using a 1B parameter model, HuBERT shows up to 19% and 13% relative WER | |
| reduction on the more challenging dev-other and test-other evaluation subsets.</em>`,E,X,Be='This model was contributed by <a href="https://huggingface.co/patrickvonplaten" rel="nofollow">patrickvonplaten</a>.',_e,A,xe,I,Ue=`<li>Hubert is a speech model that accepts a float array corresponding to the raw waveform of the speech signal.</li> <li>Hubert model was fine-tuned using connectionist temporal classification (CTC) so the model output has to be decoded | |
| using <a href="/docs/transformers/pr_36095/en/model_doc/wav2vec2#transformers.Wav2Vec2CTCTokenizer">Wav2Vec2CTCTokenizer</a>.</li>`,L,ae,Z,S,N="Flash Attention 2 is an faster, optimized version of the model.",D,ve,be,re,Ne='First, check whether your hardware is compatible with Flash Attention 2. The latest list of compatible hardware can be found in the <a href="https://github.com/Dao-AILab/flash-attention#installation-and-features" rel="nofollow">official documentation</a>. If your hardware is not compatible with Flash Attention 2, you can still benefit from attention kernel optimisations through Better Transformer support covered <a href="https://huggingface.co/docs/transformers/main/en/model_doc/bark#using-better-transformer" rel="nofollow">above</a>.',ye,le,Re='Next, <a href="https://github.com/Dao-AILab/flash-attention#installation-and-features" rel="nofollow">install</a> the latest version of Flash Attention 2:',Te,R,ue,Q,Me,G,we="Below is an expected speedup diagram comparing the pure inference time between the native implementation in transformers of <code>facebook/hubert-large-ls960-ft</code>, the flash-attention-2 and the sdpa (scale-dot-product-attention) version. We show the average speedup obtained on the <code>librispeech_asr</code> <code>clean</code> validation split:",ie,ne,he,fe,Y,ge,U="Below is an expected speedup diagram comparing the pure inference time between the native implementation in transformers of the <code>facebook/hubert-large-ls960-ft</code> model and the flash-attention-2 and sdpa (scale-dot-product-attention) versions. . We show the average speedup obtained on the <code>librispeech_asr</code> <code>clean</code> validation split:",de,f,C='<img src="https://huggingface.co/datasets/kamilakesbi/transformers_image_doc/resolve/main/data/Hubert_speedup.png"/>',O,W,q,Ce,Ge='<li><a href="../tasks/audio_classification">Audio classification task guide</a></li> <li><a href="../tasks/asr">Automatic speech recognition task guide</a></li>',ke,We,Ve,P,Ie,Le,K,ze=`This is the configuration class to store the configuration of a <a href="/docs/transformers/pr_36095/en/model_doc/hubert#transformers.HubertModel">HubertModel</a>. It is used to instantiate an | |
| Hubert 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 Hubert | |
| <a href="https://huggingface.co/facebook/hubert-base-ls960" rel="nofollow">facebook/hubert-base-ls960</a> architecture.`,Ye,je,Ae=`Configuration objects inherit from <a href="/docs/transformers/pr_36095/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_36095/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a> for more information.`,Se,ce,Xe,pe,qe,c,j,me,se;return _=new $e({props:{title:"Hubert",local:"hubert",headingTag:"h1"}}),y=new $e({props:{title:"Overview",local:"overview",headingTag:"h2"}}),A=new $e({props:{title:"Usage tips",local:"usage-tips",headingTag:"h1"}}),ae=new $e({props:{title:"Using Flash Attention 2",local:"using-flash-attention-2",headingTag:"h2"}}),ve=new $e({props:{title:"Installation",local:"installation",headingTag:"h3"}}),R=new Ee({props:{code:"cGlwJTIwaW5zdGFsbCUyMC1VJTIwZmxhc2gtYXR0biUyMC0tbm8tYnVpbGQtaXNvbGF0aW9u",highlighted:"pip install -U flash-attn --no-build-isolation",wrap:!1}}),Q=new $e({props:{title:"Usage",local:"usage",headingTag:"h3"}}),ne=new Ee({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFdhdjJWZWMyTW9kZWwlMEE=",highlighted:`<span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> Wav2Vec2Model | |
| model = Wav2Vec2Model.from_pretrained(<span class="hljs-string">"facebook/hubert-large-ls960-ft"</span>, torch_dtype=torch.float16, attn_implementation=<span class="hljs-string">"flash_attention_2"</span>).to(device) | |
| ...`,wrap:!1}}),fe=new $e({props:{title:"Expected speedups",local:"expected-speedups",headingTag:"h3"}}),W=new $e({props:{title:"Resources",local:"resources",headingTag:"h2"}}),We=new $e({props:{title:"HubertConfig",local:"transformers.HubertConfig",headingTag:"h2"}}),Ie=new Ze({props:{name:"class transformers.HubertConfig",anchor:"transformers.HubertConfig",parameters:[{name:"vocab_size",val:" = 32"},{name:"hidden_size",val:" = 768"},{name:"num_hidden_layers",val:" = 12"},{name:"num_attention_heads",val:" = 12"},{name:"intermediate_size",val:" = 3072"},{name:"hidden_act",val:" = 'gelu'"},{name:"hidden_dropout",val:" = 0.1"},{name:"activation_dropout",val:" = 0.1"},{name:"attention_dropout",val:" = 0.1"},{name:"feat_proj_layer_norm",val:" = True"},{name:"feat_proj_dropout",val:" = 0.0"},{name:"final_dropout",val:" = 0.1"},{name:"layerdrop",val:" = 0.1"},{name:"initializer_range",val:" = 0.02"},{name:"layer_norm_eps",val:" = 1e-05"},{name:"feat_extract_norm",val:" = 'group'"},{name:"feat_extract_activation",val:" = 'gelu'"},{name:"conv_dim",val:" = (512, 512, 512, 512, 512, 512, 512)"},{name:"conv_stride",val:" = (5, 2, 2, 2, 2, 2, 2)"},{name:"conv_kernel",val:" = (10, 3, 3, 3, 3, 2, 2)"},{name:"conv_bias",val:" = False"},{name:"num_conv_pos_embeddings",val:" = 128"},{name:"num_conv_pos_embedding_groups",val:" = 16"},{name:"conv_pos_batch_norm",val:" = False"},{name:"do_stable_layer_norm",val:" = False"},{name:"apply_spec_augment",val:" = True"},{name:"mask_time_prob",val:" = 0.05"},{name:"mask_time_length",val:" = 10"},{name:"mask_time_min_masks",val:" = 2"},{name:"mask_feature_prob",val:" = 0.0"},{name:"mask_feature_length",val:" = 10"},{name:"mask_feature_min_masks",val:" = 0"},{name:"ctc_loss_reduction",val:" = 'sum'"},{name:"ctc_zero_infinity",val:" = False"},{name:"use_weighted_layer_sum",val:" = False"},{name:"classifier_proj_size",val:" = 256"},{name:"pad_token_id",val:" = 0"},{name:"bos_token_id",val:" = 1"},{name:"eos_token_id",val:" = 2"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.HubertConfig.vocab_size",description:`<strong>vocab_size</strong> (<code>int</code>, <em>optional</em>, defaults to 32) — | |
| Vocabulary size of the Hubert model. Defines the number of different tokens that can be represented by the | |
| <code>inputs_ids</code> passed when calling <a href="/docs/transformers/pr_36095/en/model_doc/hubert#transformers.HubertModel">HubertModel</a>. Vocabulary size of the model. Defines the different | |
| tokens that can be represented by the <em>inputs_ids</em> passed to the forward method of <a href="/docs/transformers/pr_36095/en/model_doc/hubert#transformers.HubertModel">HubertModel</a>.`,name:"vocab_size"},{anchor:"transformers.HubertConfig.hidden_size",description:`<strong>hidden_size</strong> (<code>int</code>, <em>optional</em>, defaults to 768) — | |
| Dimensionality of the encoder layers and the pooler layer.`,name:"hidden_size"},{anchor:"transformers.HubertConfig.num_hidden_layers",description:`<strong>num_hidden_layers</strong> (<code>int</code>, <em>optional</em>, defaults to 12) — | |
| Number of hidden layers in the Transformer encoder.`,name:"num_hidden_layers"},{anchor:"transformers.HubertConfig.num_attention_heads",description:`<strong>num_attention_heads</strong> (<code>int</code>, <em>optional</em>, defaults to 12) — | |
| Number of attention heads for each attention layer in the Transformer encoder.`,name:"num_attention_heads"},{anchor:"transformers.HubertConfig.intermediate_size",description:`<strong>intermediate_size</strong> (<code>int</code>, <em>optional</em>, defaults to 3072) — | |
| Dimensionality of the “intermediate” (i.e., feed-forward) layer in the Transformer encoder.`,name:"intermediate_size"},{anchor:"transformers.HubertConfig.hidden_act",description:`<strong>hidden_act</strong> (<code>str</code> or <code>function</code>, <em>optional</em>, defaults to <code>"gelu"</code>) — | |
| The non-linear activation function (function or string) in the encoder and pooler. If string, <code>"gelu"</code>, | |
| <code>"relu"</code>, <code>"selu"</code> and <code>"gelu_new"</code> are supported.`,name:"hidden_act"},{anchor:"transformers.HubertConfig.hidden_dropout(float,",description:`<strong>hidden_dropout(<code>float</code>,</strong> <em>optional</em>, defaults to 0.1) — | |
| The dropout probability for all fully connected layers in the embeddings, encoder, and pooler.`,name:"hidden_dropout(float,"},{anchor:"transformers.HubertConfig.activation_dropout",description:`<strong>activation_dropout</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) — | |
| The dropout ratio for activations inside the fully connected layer.`,name:"activation_dropout"},{anchor:"transformers.HubertConfig.attention_dropout(float,",description:`<strong>attention_dropout(<code>float</code>,</strong> <em>optional</em>, defaults to 0.1) — | |
| The dropout ratio for the attention probabilities.`,name:"attention_dropout(float,"},{anchor:"transformers.HubertConfig.final_dropout",description:`<strong>final_dropout</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) — | |
| The dropout probability for the final projection layer of <a href="/docs/transformers/pr_36095/en/model_doc/wav2vec2#transformers.Wav2Vec2ForCTC">Wav2Vec2ForCTC</a>.`,name:"final_dropout"},{anchor:"transformers.HubertConfig.layerdrop",description:`<strong>layerdrop</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) — | |
| The LayerDrop probability. See the [LayerDrop paper](see <a href="https://arxiv.org/abs/1909.11556" rel="nofollow">https://arxiv.org/abs/1909.11556</a>) for more | |
| details.`,name:"layerdrop"},{anchor:"transformers.HubertConfig.initializer_range",description:`<strong>initializer_range</strong> (<code>float</code>, <em>optional</em>, defaults to 0.02) — | |
| The standard deviation of the truncated_normal_initializer for initializing all weight matrices.`,name:"initializer_range"},{anchor:"transformers.HubertConfig.layer_norm_eps",description:`<strong>layer_norm_eps</strong> (<code>float</code>, <em>optional</em>, defaults to 1e-12) — | |
| The epsilon used by the layer normalization layers.`,name:"layer_norm_eps"},{anchor:"transformers.HubertConfig.feat_extract_norm",description:`<strong>feat_extract_norm</strong> (<code>str</code>, <em>optional</em>, defaults to <code>"group"</code>) — | |
| The norm to be applied to 1D convolutional layers in feature encoder. One of <code>"group"</code> for group | |
| normalization of only the first 1D convolutional layer or <code>"layer"</code> for layer normalization of all 1D | |
| convolutional layers.`,name:"feat_extract_norm"},{anchor:"transformers.HubertConfig.feat_proj_dropout",description:`<strong>feat_proj_dropout</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) — | |
| The dropout probability for output of the feature encoder.`,name:"feat_proj_dropout"},{anchor:"transformers.HubertConfig.feat_proj_layer_norm",description:`<strong>feat_proj_layer_norm</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) — | |
| Whether to apply LayerNorm to the output of the feature encoder.`,name:"feat_proj_layer_norm"},{anchor:"transformers.HubertConfig.feat_extract_activation",description:"<strong>feat_extract_activation</strong> (<code>str, </code>optional<code>, defaults to </code>“gelu”<code>) -- The non-linear activation function (function or string) in the 1D convolutional layers of the feature extractor. If string, </code>“gelu”<code>, </code>“relu”<code>, </code>“selu”<code>and</code>“gelu_new”` are supported.",name:"feat_extract_activation"},{anchor:"transformers.HubertConfig.conv_dim",description:`<strong>conv_dim</strong> (<code>Tuple[int]</code>, <em>optional</em>, defaults to <code>(512, 512, 512, 512, 512, 512, 512)</code>) — | |
| A tuple of integers defining the number of input and output channels of each 1D convolutional layer in the | |
| feature encoder. The length of <em>conv_dim</em> defines the number of 1D convolutional layers.`,name:"conv_dim"},{anchor:"transformers.HubertConfig.conv_stride",description:`<strong>conv_stride</strong> (<code>Tuple[int]</code>, <em>optional</em>, defaults to <code>(5, 2, 2, 2, 2, 2, 2)</code>) — | |
| A tuple of integers defining the stride of each 1D convolutional layer in the feature encoder. The length | |
| of <em>conv_stride</em> defines the number of convolutional layers and has to match the length of <em>conv_dim</em>.`,name:"conv_stride"},{anchor:"transformers.HubertConfig.conv_kernel",description:`<strong>conv_kernel</strong> (<code>Tuple[int]</code>, <em>optional</em>, defaults to <code>(10, 3, 3, 3, 3, 3, 3)</code>) — | |
| A tuple of integers defining the kernel size of each 1D convolutional layer in the feature encoder. The | |
| length of <em>conv_kernel</em> defines the number of convolutional layers and has to match the length of | |
| <em>conv_dim</em>.`,name:"conv_kernel"},{anchor:"transformers.HubertConfig.conv_bias",description:`<strong>conv_bias</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| Whether the 1D convolutional layers have a bias.`,name:"conv_bias"},{anchor:"transformers.HubertConfig.num_conv_pos_embeddings",description:`<strong>num_conv_pos_embeddings</strong> (<code>int</code>, <em>optional</em>, defaults to 128) — | |
| Number of convolutional positional embeddings. Defines the kernel size of 1D convolutional positional | |
| embeddings layer.`,name:"num_conv_pos_embeddings"},{anchor:"transformers.HubertConfig.num_conv_pos_embedding_groups",description:`<strong>num_conv_pos_embedding_groups</strong> (<code>int</code>, <em>optional</em>, defaults to 16) — | |
| Number of groups of 1D convolutional positional embeddings layer.`,name:"num_conv_pos_embedding_groups"},{anchor:"transformers.HubertConfig.conv_pos_batch_norm",description:`<strong>conv_pos_batch_norm</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| Whether to use batch norm instead of weight norm in conv_pos`,name:"conv_pos_batch_norm"},{anchor:"transformers.HubertConfig.do_stable_layer_norm",description:`<strong>do_stable_layer_norm</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| Whether do apply <em>stable</em> layer norm architecture of the Transformer encoder. <code>do_stable_layer_norm is True</code> corresponds to applying layer norm before the attention layer, whereas <code>do_stable_layer_norm is False</code> corresponds to applying layer norm after the attention layer.`,name:"do_stable_layer_norm"},{anchor:"transformers.HubertConfig.apply_spec_augment",description:`<strong>apply_spec_augment</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) — | |
| Whether to apply <em>SpecAugment</em> data augmentation to the outputs of the feature encoder. For reference see | |
| <a href="https://arxiv.org/abs/1904.08779" rel="nofollow">SpecAugment: A Simple Data Augmentation Method for Automatic Speech | |
| Recognition</a>.`,name:"apply_spec_augment"},{anchor:"transformers.HubertConfig.mask_time_prob",description:`<strong>mask_time_prob</strong> (<code>float</code>, <em>optional</em>, defaults to 0.05) — | |
| Percentage (between 0 and 1) of all feature vectors along the time axis which will be masked. The masking | |
| procecure generates ”mask_time_prob<em>len(time_axis)/mask_time_length” independent masks over the axis. If | |
| reasoning from the propability of each feature vector to be chosen as the start of the vector span to be | |
| masked, </em>mask_time_prob<em> should be \`prob_vector_start</em>mask_time_length<code>. Note that overlap may decrease the actual percentage of masked vectors. This is only relevant if </code>apply_spec_augment is True\`.`,name:"mask_time_prob"},{anchor:"transformers.HubertConfig.mask_time_length",description:`<strong>mask_time_length</strong> (<code>int</code>, <em>optional</em>, defaults to 10) — | |
| Length of vector span along the time axis.`,name:"mask_time_length"},{anchor:"transformers.HubertConfig.mask_time_min_masks",description:`<strong>mask_time_min_masks</strong> (<code>int</code>, <em>optional</em>, defaults to 2), — | |
| The minimum number of masks of length <code>mask_feature_length</code> generated along the time axis, each time step, | |
| irrespectively of <code>mask_feature_prob</code>. Only relevant if ”mask_time_prob*len(time_axis)/mask_time_length < | |
| mask_time_min_masks”`,name:"mask_time_min_masks"},{anchor:"transformers.HubertConfig.mask_feature_prob",description:`<strong>mask_feature_prob</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) — | |
| Percentage (between 0 and 1) of all feature vectors along the feature axis which will be masked. The | |
| masking procecure generates ”mask_feature_prob<em>len(feature_axis)/mask_time_length” independent masks over | |
| the axis. If reasoning from the propability of each feature vector to be chosen as the start of the vector | |
| span to be masked, </em>mask_feature_prob<em> should be \`prob_vector_start</em>mask_feature_length<code>. Note that overlap may decrease the actual percentage of masked vectors. This is only relevant if </code>apply_spec_augment is | |
| True\`.`,name:"mask_feature_prob"},{anchor:"transformers.HubertConfig.mask_feature_length",description:`<strong>mask_feature_length</strong> (<code>int</code>, <em>optional</em>, defaults to 10) — | |
| Length of vector span along the feature axis.`,name:"mask_feature_length"},{anchor:"transformers.HubertConfig.mask_feature_min_masks",description:`<strong>mask_feature_min_masks</strong> (<code>int</code>, <em>optional</em>, defaults to 0), — | |
| The minimum number of masks of length <code>mask_feature_length</code> generated along the feature axis, each time | |
| step, irrespectively of <code>mask_feature_prob</code>. Only relevant if | |
| ”mask_feature_prob*len(feature_axis)/mask_feature_length < mask_feature_min_masks”`,name:"mask_feature_min_masks"},{anchor:"transformers.HubertConfig.ctc_loss_reduction",description:`<strong>ctc_loss_reduction</strong> (<code>str</code>, <em>optional</em>, defaults to <code>"sum"</code>) — | |
| Specifies the reduction to apply to the output of <code>torch.nn.CTCLoss</code>. Only relevant when training an | |
| instance of <a href="/docs/transformers/pr_36095/en/model_doc/hubert#transformers.HubertForCTC">HubertForCTC</a>.`,name:"ctc_loss_reduction"},{anchor:"transformers.HubertConfig.ctc_zero_infinity",description:`<strong>ctc_zero_infinity</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| Whether to zero infinite losses and the associated gradients of <code>torch.nn.CTCLoss</code>. Infinite losses mainly | |
| occur when the inputs are too short to be aligned to the targets. Only relevant when training an instance | |
| of <a href="/docs/transformers/pr_36095/en/model_doc/hubert#transformers.HubertForCTC">HubertForCTC</a>.`,name:"ctc_zero_infinity"},{anchor:"transformers.HubertConfig.use_weighted_layer_sum",description:`<strong>use_weighted_layer_sum</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| Whether to use a weighted average of layer outputs with learned weights. Only relevant when using an | |
| instance of <a href="/docs/transformers/pr_36095/en/model_doc/hubert#transformers.HubertForSequenceClassification">HubertForSequenceClassification</a>.`,name:"use_weighted_layer_sum"},{anchor:"transformers.HubertConfig.classifier_proj_size",description:`<strong>classifier_proj_size</strong> (<code>int</code>, <em>optional</em>, defaults to 256) — | |
| Dimensionality of the projection before token mean-pooling for classification.`,name:"classifier_proj_size"}],source:"https://github.com/huggingface/transformers/blob/vr_36095/src/transformers/models/hubert/configuration_hubert.py#L27"}}),ce=new Pe({props:{anchor:"transformers.HubertConfig.example",$$slots:{default:[lt]},$$scope:{ctx:H}}}),pe=new at({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[wt],pytorch:[ft]},$$scope:{ctx:H}}}),c=new rt({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/model_doc/hubert.md"}}),{c(){t=u("meta"),g=l(),o=u("p"),a=l(),T(_.$$.fragment),n=l(),T(y.$$.fragment),ee=l(),F=u("p"),F.innerHTML=z,te=l(),x=u("p"),x.textContent=B,oe=l(),p=u("p"),p.innerHTML=J,E=l(),X=u("p"),X.innerHTML=Be,_e=l(),T(A.$$.fragment),xe=l(),I=u("ul"),I.innerHTML=Ue,L=l(),T(ae.$$.fragment),Z=l(),S=u("p"),S.textContent=N,D=l(),T(ve.$$.fragment),be=l(),re=u("p"),re.innerHTML=Ne,ye=l(),le=u("p"),le.innerHTML=Re,Te=l(),T(R.$$.fragment),ue=l(),T(Q.$$.fragment),Me=l(),G=u("p"),G.innerHTML=we,ie=l(),T(ne.$$.fragment),he=l(),T(fe.$$.fragment),Y=l(),ge=u("p"),ge.innerHTML=U,de=l(),f=u("div"),f.innerHTML=C,O=l(),T(W.$$.fragment),q=l(),Ce=u("ul"),Ce.innerHTML=Ge,ke=l(),T(We.$$.fragment),Ve=l(),P=u("div"),T(Ie.$$.fragment),Le=l(),K=u("p"),K.innerHTML=ze,Ye=l(),je=u("p"),je.innerHTML=Ae,Se=l(),T(ce.$$.fragment),Xe=l(),T(pe.$$.fragment),qe=l(),T(c.$$.fragment),j=l(),me=u("p"),this.h()},l(e){const d=nt("svelte-u9bgzb",document.head);t=h(d,"META",{name:!0,content:!0}),d.forEach(s),g=i(e),o=h(e,"P",{}),He(o).forEach(s),a=i(e),M(_.$$.fragment,e),n=i(e),M(y.$$.fragment,e),ee=i(e),F=h(e,"P",{"data-svelte-h":!0}),b(F)!=="svelte-1co7rq7"&&(F.innerHTML=z),te=i(e),x=h(e,"P",{"data-svelte-h":!0}),b(x)!=="svelte-vfdo9a"&&(x.textContent=B),oe=i(e),p=h(e,"P",{"data-svelte-h":!0}),b(p)!=="svelte-lape3m"&&(p.innerHTML=J),E=i(e),X=h(e,"P",{"data-svelte-h":!0}),b(X)!=="svelte-1t6iyb9"&&(X.innerHTML=Be),_e=i(e),M(A.$$.fragment,e),xe=i(e),I=h(e,"UL",{"data-svelte-h":!0}),b(I)!=="svelte-1qyllbb"&&(I.innerHTML=Ue),L=i(e),M(ae.$$.fragment,e),Z=i(e),S=h(e,"P",{"data-svelte-h":!0}),b(S)!=="svelte-1r79v6g"&&(S.textContent=N),D=i(e),M(ve.$$.fragment,e),be=i(e),re=h(e,"P",{"data-svelte-h":!0}),b(re)!=="svelte-ib5l43"&&(re.innerHTML=Ne),ye=i(e),le=h(e,"P",{"data-svelte-h":!0}),b(le)!=="svelte-1pp3dkd"&&(le.innerHTML=Re),Te=i(e),M(R.$$.fragment,e),ue=i(e),M(Q.$$.fragment,e),Me=i(e),G=h(e,"P",{"data-svelte-h":!0}),b(G)!=="svelte-1ulfaf5"&&(G.innerHTML=we),ie=i(e),M(ne.$$.fragment,e),he=i(e),M(fe.$$.fragment,e),Y=i(e),ge=h(e,"P",{"data-svelte-h":!0}),b(ge)!=="svelte-s11kpo"&&(ge.innerHTML=U),de=i(e),f=h(e,"DIV",{style:!0,"data-svelte-h":!0}),b(f)!=="svelte-10r3n4"&&(f.innerHTML=C),O=i(e),M(W.$$.fragment,e),q=i(e),Ce=h(e,"UL",{"data-svelte-h":!0}),b(Ce)!=="svelte-11qmliz"&&(Ce.innerHTML=Ge),ke=i(e),M(We.$$.fragment,e),Ve=i(e),P=h(e,"DIV",{class:!0});var V=He(P);M(Ie.$$.fragment,V),Le=i(V),K=h(V,"P",{"data-svelte-h":!0}),b(K)!=="svelte-m0axdw"&&(K.innerHTML=ze),Ye=i(V),je=h(V,"P",{"data-svelte-h":!0}),b(je)!=="svelte-1bguvyz"&&(je.innerHTML=Ae),Se=i(V),M(ce.$$.fragment,V),V.forEach(s),Xe=i(e),M(pe.$$.fragment,e),qe=i(e),M(c.$$.fragment,e),j=i(e),me=h(e,"P",{}),He(me).forEach(s),this.h()},h(){Je(t,"name","hf:doc:metadata"),Je(t,"content",$t),st(f,"text-align","center"),Je(P,"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,d){m(document.head,t),r(e,g,d),r(e,o,d),r(e,a,d),v(_,e,d),r(e,n,d),v(y,e,d),r(e,ee,d),r(e,F,d),r(e,te,d),r(e,x,d),r(e,oe,d),r(e,p,d),r(e,E,d),r(e,X,d),r(e,_e,d),v(A,e,d),r(e,xe,d),r(e,I,d),r(e,L,d),v(ae,e,d),r(e,Z,d),r(e,S,d),r(e,D,d),v(ve,e,d),r(e,be,d),r(e,re,d),r(e,ye,d),r(e,le,d),r(e,Te,d),v(R,e,d),r(e,ue,d),v(Q,e,d),r(e,Me,d),r(e,G,d),r(e,ie,d),v(ne,e,d),r(e,he,d),v(fe,e,d),r(e,Y,d),r(e,ge,d),r(e,de,d),r(e,f,d),r(e,O,d),v(W,e,d),r(e,q,d),r(e,Ce,d),r(e,ke,d),v(We,e,d),r(e,Ve,d),r(e,P,d),v(Ie,P,null),m(P,Le),m(P,K),m(P,Ye),m(P,je),m(P,Se),v(ce,P,null),r(e,Xe,d),v(pe,e,d),r(e,qe,d),v(c,e,d),r(e,j,d),r(e,me,d),se=!0},p(e,[d]){const V={};d&2&&(V.$$scope={dirty:d,ctx:e}),ce.$set(V);const De={};d&2&&(De.$$scope={dirty:d,ctx:e}),pe.$set(De)},i(e){se||(w(_.$$.fragment,e),w(y.$$.fragment,e),w(A.$$.fragment,e),w(ae.$$.fragment,e),w(ve.$$.fragment,e),w(R.$$.fragment,e),w(Q.$$.fragment,e),w(ne.$$.fragment,e),w(fe.$$.fragment,e),w(W.$$.fragment,e),w(We.$$.fragment,e),w(Ie.$$.fragment,e),w(ce.$$.fragment,e),w(pe.$$.fragment,e),w(c.$$.fragment,e),se=!0)},o(e){k(_.$$.fragment,e),k(y.$$.fragment,e),k(A.$$.fragment,e),k(ae.$$.fragment,e),k(ve.$$.fragment,e),k(R.$$.fragment,e),k(Q.$$.fragment,e),k(ne.$$.fragment,e),k(fe.$$.fragment,e),k(W.$$.fragment,e),k(We.$$.fragment,e),k(Ie.$$.fragment,e),k(ce.$$.fragment,e),k(pe.$$.fragment,e),k(c.$$.fragment,e),se=!1},d(e){e&&(s(g),s(o),s(a),s(n),s(ee),s(F),s(te),s(x),s(oe),s(p),s(E),s(X),s(_e),s(xe),s(I),s(L),s(Z),s(S),s(D),s(be),s(re),s(ye),s(le),s(Te),s(ue),s(Me),s(G),s(ie),s(he),s(Y),s(ge),s(de),s(f),s(O),s(q),s(Ce),s(ke),s(Ve),s(P),s(Xe),s(qe),s(j),s(me)),s(t),$(_,e),$(y,e),$(A,e),$(ae,e),$(ve,e),$(R,e),$(Q,e),$(ne,e),$(fe,e),$(W,e),$(We,e),$(Ie),$(ce),$(pe,e),$(c,e)}}}const $t='{"title":"Hubert","local":"hubert","sections":[{"title":"Overview","local":"overview","sections":[],"depth":2}],"depth":1}';function Ct(H){return et(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class It extends tt{constructor(t){super(),ot(this,t,Ct,kt,Ke,{})}}export{It as component}; | |
Xet Storage Details
- Size:
- 117 kB
- Xet hash:
- bff266608cb7fc8e1ff0ac004c8310aea8cd7eb2d15240e77abd085c9f0797fb
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.