import{s as Is,o as gs,n as ks}from"../chunks/scheduler.37c15a92.js";import{S as As,i as Cs,g as U,s as u,r as d,A as Zs,h as J,f as i,c,j as ws,u as b,x as w,k as Ts,y as vs,a as r,v as j,t as o,b as D,d as M,w as f,p as X}from"../chunks/index.2bf4358c.js";import{T as hs}from"../chunks/Tip.363c041f.js";import{Y as _s}from"../chunks/Youtube.1e50a667.js";import{C as T}from"../chunks/CodeBlock.4e987730.js";import{C as $s}from"../chunks/CourseFloatingBanner.6add7356.js";import{F as Ns}from"../chunks/FrameworkSwitchCourse.8d4d4ab6.js";import{H as Re,E as Qs}from"../chunks/getInferenceSnippets.97e75ee2.js";function zs(m){let s,a;return s=new $s({props:{chapter:2,classNames:"absolute z-10 right-0 top-0",notebooks:[{label:"Google Colab",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/master/course/en/chapter2/section5_tf.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/en/chapter2/section5_tf.ipynb"}]}}),{c(){d(s.$$.fragment)},l(l){b(s.$$.fragment,l)},m(l,p){j(s,l,p),a=!0},i(l){a||(M(s.$$.fragment,l),a=!0)},o(l){o(s.$$.fragment,l),a=!1},d(l){f(s,l)}}}function Vs(m){let s,a;return s=new $s({props:{chapter:2,classNames:"absolute z-10 right-0 top-0",notebooks:[{label:"Google Colab",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/master/course/en/chapter2/section5_pt.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/en/chapter2/section5_pt.ipynb"}]}}),{c(){d(s.$$.fragment)},l(l){b(s.$$.fragment,l)},m(l,p){j(s,l,p),a=!0},i(l){a||(M(s.$$.fragment,l),a=!0)},o(l){o(s.$$.fragment,l),a=!1},d(l){f(s,l)}}}function Es(m){let s,a;return s=new _s({props:{id:"ROxrFOEbsQE"}}),{c(){d(s.$$.fragment)},l(l){b(s.$$.fragment,l)},m(l,p){j(s,l,p),a=!0},i(l){a||(M(s.$$.fragment,l),a=!0)},o(l){o(s.$$.fragment,l),a=!1},d(l){f(s,l)}}}function Ws(m){let s,a;return s=new _s({props:{id:"M6adb1j2jPI"}}),{c(){d(s.$$.fragment)},l(l){b(s.$$.fragment,l)},m(l,p){j(s,l,p),a=!0},i(l){a||(M(s.$$.fragment,l),a=!0)},o(l){o(s.$$.fragment,l),a=!1},d(l){f(s,l)}}}function Gs(m){let s,a,l,p;return s=new T({props:{code:"aW1wb3J0JTIwdGVuc29yZmxvdyUyMGFzJTIwdGYlMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b1Rva2VuaXplciUyQyUyMFRGQXV0b01vZGVsRm9yU2VxdWVuY2VDbGFzc2lmaWNhdGlvbiUwQSUwQWNoZWNrcG9pbnQlMjAlM0QlMjAlMjJkaXN0aWxiZXJ0LWJhc2UtdW5jYXNlZC1maW5ldHVuZWQtc3N0LTItZW5nbGlzaCUyMiUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKGNoZWNrcG9pbnQpJTBBbW9kZWwlMjAlM0QlMjBURkF1dG9Nb2RlbEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24uZnJvbV9wcmV0cmFpbmVkKGNoZWNrcG9pbnQpJTBBJTBBc2VxdWVuY2UlMjAlM0QlMjAlMjJJJ3ZlJTIwYmVlbiUyMHdhaXRpbmclMjBmb3IlMjBhJTIwSHVnZ2luZ0ZhY2UlMjBjb3Vyc2UlMjBteSUyMHdob2xlJTIwbGlmZS4lMjIlMEElMEF0b2tlbnMlMjAlM0QlMjB0b2tlbml6ZXIudG9rZW5pemUoc2VxdWVuY2UpJTBBaWRzJTIwJTNEJTIwdG9rZW5pemVyLmNvbnZlcnRfdG9rZW5zX3RvX2lkcyh0b2tlbnMpJTBBaW5wdXRfaWRzJTIwJTNEJTIwdGYuY29uc3RhbnQoaWRzKSUwQSUyMyUyMEFjZWFzdCVDNCU4MyUyMGxpbmllJTIwdmElMjBlJUM4JTk5dWEuJTBBbW9kZWwoaW5wdXRfaWRzKQ==",highlighted:`<span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, TFAutoModelForSequenceClassification

checkpoint = <span class="hljs-string">&quot;distilbert-base-uncased-finetuned-sst-2-english&quot;</span>
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
model = TFAutoModelForSequenceClassification.from_pretrained(checkpoint)

sequence = <span class="hljs-string">&quot;I&#x27;ve been waiting for a HuggingFace course my whole life.&quot;</span>

tokens = tokenizer.tokenize(sequence)
ids = tokenizer.convert_tokens_to_ids(tokens)
input_ids = tf.constant(ids)
<span class="hljs-comment"># Această linie va eșua.</span>
model(input_ids)`,wrap:!1}}),l=new T({props:{code:"SW52YWxpZEFyZ3VtZW50RXJyb3IlM0ElMjBJbnB1dCUyMHRvJTIwcmVzaGFwZSUyMGlzJTIwYSUyMHRlbnNvciUyMHdpdGglMjAxNCUyMHZhbHVlcyUyQyUyMGJ1dCUyMHRoZSUyMHJlcXVlc3RlZCUyMHNoYXBlJTIwaGFzJTIwMTk2JTIwJTVCT3AlM0FSZXNoYXBlJTVE",highlighted:'InvalidArgumentError: Input to reshape <span class="hljs-keyword">is</span> a tensor <span class="hljs-keyword">with</span> <span class="hljs-number">14</span> values, but the requested shape has <span class="hljs-number">196</span> [Op:Reshape]',wrap:!1}}),{c(){d(s.$$.fragment),a=u(),d(l.$$.fragment)},l(t){b(s.$$.fragment,t),a=c(t),b(l.$$.fragment,t)},m(t,y){j(s,t,y),r(t,a,y),j(l,t,y),p=!0},i(t){p||(M(s.$$.fragment,t),M(l.$$.fragment,t),p=!0)},o(t){o(s.$$.fragment,t),o(l.$$.fragment,t),p=!1},d(t){t&&i(a),f(s,t),f(l,t)}}}function Rs(m){let s,a,l,p;return s=new T({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b1Rva2VuaXplciUyQyUyMEF1dG9Nb2RlbEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24lMEElMEFjaGVja3BvaW50JTIwJTNEJTIwJTIyZGlzdGlsYmVydC1iYXNlLXVuY2FzZWQtZmluZXR1bmVkLXNzdC0yLWVuZ2xpc2glMjIlMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZChjaGVja3BvaW50KSUwQW1vZGVsJTIwJTNEJTIwQXV0b01vZGVsRm9yU2VxdWVuY2VDbGFzc2lmaWNhdGlvbi5mcm9tX3ByZXRyYWluZWQoY2hlY2twb2ludCklMEElMEFzZXF1ZW5jZSUyMCUzRCUyMCUyMkkndmUlMjBiZWVuJTIwd2FpdGluZyUyMGZvciUyMGElMjBIdWdnaW5nRmFjZSUyMGNvdXJzZSUyMG15JTIwd2hvbGUlMjBsaWZlLiUyMiUwQSUwQXRva2VucyUyMCUzRCUyMHRva2VuaXplci50b2tlbml6ZShzZXF1ZW5jZSklMEFpZHMlMjAlM0QlMjB0b2tlbml6ZXIuY29udmVydF90b2tlbnNfdG9faWRzKHRva2VucyklMEFpbnB1dF9pZHMlMjAlM0QlMjB0b3JjaC50ZW5zb3IoaWRzKSUwQSUyMyUyMEFjZWFzdCVDNCU4MyUyMGxpbmllJTIwdmElMjBlJUM4JTk5dWEuJTBBbW9kZWwoaW5wdXRfaWRzKQ==",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, AutoModelForSequenceClassification

checkpoint = <span class="hljs-string">&quot;distilbert-base-uncased-finetuned-sst-2-english&quot;</span>
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
model = AutoModelForSequenceClassification.from_pretrained(checkpoint)

sequence = <span class="hljs-string">&quot;I&#x27;ve been waiting for a HuggingFace course my whole life.&quot;</span>

tokens = tokenizer.tokenize(sequence)
ids = tokenizer.convert_tokens_to_ids(tokens)
input_ids = torch.tensor(ids)
<span class="hljs-comment"># Această linie va eșua.</span>
model(input_ids)`,wrap:!1}}),l=new T({props:{code:"SW5kZXhFcnJvciUzQSUyMERpbWVuc2lvbiUyMG91dCUyMG9mJTIwcmFuZ2UlMjAoZXhwZWN0ZWQlMjB0byUyMGJlJTIwaW4lMjByYW5nZSUyMG9mJTIwJTVCLTElMkMlMjAwJTVEJTJDJTIwYnV0JTIwZ290JTIwMSk=",highlighted:'IndexError: Dimension out of <span class="hljs-built_in">range</span> (expected to be <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span> of [-<span class="hljs-number">1</span>, <span class="hljs-number">0</span>], but got <span class="hljs-number">1</span>)',wrap:!1}}),{c(){d(s.$$.fragment),a=u(),d(l.$$.fragment)},l(t){b(s.$$.fragment,t),a=c(t),b(l.$$.fragment,t)},m(t,y){j(s,t,y),r(t,a,y),j(l,t,y),p=!0},i(t){p||(M(s.$$.fragment,t),M(l.$$.fragment,t),p=!0)},o(t){o(s.$$.fragment,t),o(l.$$.fragment,t),p=!1},d(t){t&&i(a),f(s,t),f(l,t)}}}function Ds(m){let s,a,l,p;return s=new T({props:{code:"dG9rZW5pemVkX2lucHV0cyUyMCUzRCUyMHRva2VuaXplcihzZXF1ZW5jZSUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIydGYlMjIpJTBBcHJpbnQodG9rZW5pemVkX2lucHV0cyU1QiUyMmlucHV0X2lkcyUyMiU1RCk=",highlighted:`tokenized_inputs = tokenizer(sequence, return_tensors=<span class="hljs-string">&quot;tf&quot;</span>)
<span class="hljs-built_in">print</span>(tokenized_inputs[<span class="hljs-string">&quot;input_ids&quot;</span>])`,wrap:!1}}),l=new T({props:{code:"JTNDdGYuVGVuc29yJTNBJTIwc2hhcGUlM0QoMSUyQyUyMDE2KSUyQyUyMGR0eXBlJTNEaW50MzIlMkMlMjBudW1weSUzRCUwQWFycmF5KCU1QiU1QiUyMCUyMDEwMSUyQyUyMCUyMDEwNDUlMkMlMjAlMjAxMDA1JTJDJTIwJTIwMjMxMCUyQyUyMCUyMDIwNDIlMkMlMjAlMjAzNDAzJTJDJTIwJTIwMjAwNSUyQyUyMCUyMDEwMzclMkMlMjAxNzY2MiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMDEyMTcyJTJDJTIwJTIwMjYwNyUyQyUyMCUyMDIwMjYlMkMlMjAlMjAyODc4JTJDJTIwJTIwMjE2NiUyQyUyMCUyMDEwMTIlMkMlMjAlMjAlMjAxMDIlNUQlNUQlMkMlMjBkdHlwZSUzRGludDMyKSUzRQ==",highlighted:`&lt;tf.Tensor: shape=(<span class="hljs-number">1</span>, <span class="hljs-number">16</span>), dtype=int32, numpy=
array([[  <span class="hljs-number">101</span>,  <span class="hljs-number">1045</span>,  <span class="hljs-number">1005</span>,  <span class="hljs-number">2310</span>,  <span class="hljs-number">2042</span>,  <span class="hljs-number">3403</span>,  <span class="hljs-number">2005</span>,  <span class="hljs-number">1037</span>, <span class="hljs-number">17662</span>,
        <span class="hljs-number">12172</span>,  <span class="hljs-number">2607</span>,  <span class="hljs-number">2026</span>,  <span class="hljs-number">2878</span>,  <span class="hljs-number">2166</span>,  <span class="hljs-number">1012</span>,   <span class="hljs-number">102</span>]], dtype=int32)&gt;`,wrap:!1}}),{c(){d(s.$$.fragment),a=u(),d(l.$$.fragment)},l(t){b(s.$$.fragment,t),a=c(t),b(l.$$.fragment,t)},m(t,y){j(s,t,y),r(t,a,y),j(l,t,y),p=!0},i(t){p||(M(s.$$.fragment,t),M(l.$$.fragment,t),p=!0)},o(t){o(s.$$.fragment,t),o(l.$$.fragment,t),p=!1},d(t){t&&i(a),f(s,t),f(l,t)}}}function Xs(m){let s,a,l,p;return s=new T({props:{code:"dG9rZW5pemVkX2lucHV0cyUyMCUzRCUyMHRva2VuaXplcihzZXF1ZW5jZSUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpJTBBcHJpbnQodG9rZW5pemVkX2lucHV0cyU1QiUyMmlucHV0X2lkcyUyMiU1RCk=",highlighted:`tokenized_inputs = tokenizer(sequence, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-built_in">print</span>(tokenized_inputs[<span class="hljs-string">&quot;input_ids&quot;</span>])`,wrap:!1}}),l=new T({props:{code:"dGVuc29yKCU1QiU1QiUyMCUyMDEwMSUyQyUyMCUyMDEwNDUlMkMlMjAlMjAxMDA1JTJDJTIwJTIwMjMxMCUyQyUyMCUyMDIwNDIlMkMlMjAlMjAzNDAzJTJDJTIwJTIwMjAwNSUyQyUyMCUyMDEwMzclMkMlMjAxNzY2MiUyQyUyMDEyMTcyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwMjYwNyUyQyUyMCUyMDIwMjYlMkMlMjAlMjAyODc4JTJDJTIwJTIwMjE2NiUyQyUyMCUyMDEwMTIlMkMlMjAlMjAlMjAxMDIlNUQlNUQp",highlighted:`tensor([[  <span class="hljs-number">101</span>,  <span class="hljs-number">1045</span>,  <span class="hljs-number">1005</span>,  <span class="hljs-number">2310</span>,  <span class="hljs-number">2042</span>,  <span class="hljs-number">3403</span>,  <span class="hljs-number">2005</span>,  <span class="hljs-number">1037</span>, <span class="hljs-number">17662</span>, <span class="hljs-number">12172</span>,
          <span class="hljs-number">2607</span>,  <span class="hljs-number">2026</span>,  <span class="hljs-number">2878</span>,  <span class="hljs-number">2166</span>,  <span class="hljs-number">1012</span>,   <span class="hljs-number">102</span>]])`,wrap:!1}}),{c(){d(s.$$.fragment),a=u(),d(l.$$.fragment)},l(t){b(s.$$.fragment,t),a=c(t),b(l.$$.fragment,t)},m(t,y){j(s,t,y),r(t,a,y),j(l,t,y),p=!0},i(t){p||(M(s.$$.fragment,t),M(l.$$.fragment,t),p=!0)},o(t){o(s.$$.fragment,t),o(l.$$.fragment,t),p=!1},d(t){t&&i(a),f(s,t),f(l,t)}}}function Bs(m){let s,a;return s=new T({props:{code:"aW1wb3J0JTIwdGVuc29yZmxvdyUyMGFzJTIwdGYlMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b1Rva2VuaXplciUyQyUyMFRGQXV0b01vZGVsRm9yU2VxdWVuY2VDbGFzc2lmaWNhdGlvbiUwQSUwQWNoZWNrcG9pbnQlMjAlM0QlMjAlMjJkaXN0aWxiZXJ0LWJhc2UtdW5jYXNlZC1maW5ldHVuZWQtc3N0LTItZW5nbGlzaCUyMiUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKGNoZWNrcG9pbnQpJTBBbW9kZWwlMjAlM0QlMjBURkF1dG9Nb2RlbEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24uZnJvbV9wcmV0cmFpbmVkKGNoZWNrcG9pbnQpJTBBJTBBc2VxdWVuY2UlMjAlM0QlMjAlMjJJJ3ZlJTIwYmVlbiUyMHdhaXRpbmclMjBmb3IlMjBhJTIwSHVnZ2luZ0ZhY2UlMjBjb3Vyc2UlMjBteSUyMHdob2xlJTIwbGlmZS4lMjIlMEElMEF0b2tlbnMlMjAlM0QlMjB0b2tlbml6ZXIudG9rZW5pemUoc2VxdWVuY2UpJTBBaWRzJTIwJTNEJTIwdG9rZW5pemVyLmNvbnZlcnRfdG9rZW5zX3RvX2lkcyh0b2tlbnMpJTBBJTBBaW5wdXRfaWRzJTIwJTNEJTIwdGYuY29uc3RhbnQoJTVCaWRzJTVEKSUwQXByaW50KCUyMklucHV0JTIwSURzJTNBJTIyJTJDJTIwaW5wdXRfaWRzKSUwQSUwQW91dHB1dCUyMCUzRCUyMG1vZGVsKGlucHV0X2lkcyklMEFwcmludCglMjJMb2dpdHMlM0ElMjIlMkMlMjBvdXRwdXQubG9naXRzKQ==",highlighted:`<span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, TFAutoModelForSequenceClassification

checkpoint = <span class="hljs-string">&quot;distilbert-base-uncased-finetuned-sst-2-english&quot;</span>
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
model = TFAutoModelForSequenceClassification.from_pretrained(checkpoint)

sequence = <span class="hljs-string">&quot;I&#x27;ve been waiting for a HuggingFace course my whole life.&quot;</span>

tokens = tokenizer.tokenize(sequence)
ids = tokenizer.convert_tokens_to_ids(tokens)

input_ids = tf.constant([ids])
<span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;Input IDs:&quot;</span>, input_ids)

output = model(input_ids)
<span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;Logits:&quot;</span>, output.logits)`,wrap:!1}}),{c(){d(s.$$.fragment)},l(l){b(s.$$.fragment,l)},m(l,p){j(s,l,p),a=!0},i(l){a||(M(s.$$.fragment,l),a=!0)},o(l){o(s.$$.fragment,l),a=!1},d(l){f(s,l)}}}function xs(m){let s,a;return s=new T({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b1Rva2VuaXplciUyQyUyMEF1dG9Nb2RlbEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24lMEElMEFjaGVja3BvaW50JTIwJTNEJTIwJTIyZGlzdGlsYmVydC1iYXNlLXVuY2FzZWQtZmluZXR1bmVkLXNzdC0yLWVuZ2xpc2glMjIlMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZChjaGVja3BvaW50KSUwQW1vZGVsJTIwJTNEJTIwQXV0b01vZGVsRm9yU2VxdWVuY2VDbGFzc2lmaWNhdGlvbi5mcm9tX3ByZXRyYWluZWQoY2hlY2twb2ludCklMEElMEFzZXF1ZW5jZSUyMCUzRCUyMCUyMkkndmUlMjBiZWVuJTIwd2FpdGluZyUyMGZvciUyMGElMjBIdWdnaW5nRmFjZSUyMGNvdXJzZSUyMG15JTIwd2hvbGUlMjBsaWZlLiUyMiUwQSUwQXRva2VucyUyMCUzRCUyMHRva2VuaXplci50b2tlbml6ZShzZXF1ZW5jZSklMEFpZHMlMjAlM0QlMjB0b2tlbml6ZXIuY29udmVydF90b2tlbnNfdG9faWRzKHRva2VucyklMEElMEFpbnB1dF9pZHMlMjAlM0QlMjB0b3JjaC50ZW5zb3IoJTVCaWRzJTVEKSUwQXByaW50KCUyMklucHV0JTIwSURzJTNBJTIyJTJDJTIwaW5wdXRfaWRzKSUwQSUwQW91dHB1dCUyMCUzRCUyMG1vZGVsKGlucHV0X2lkcyklMEFwcmludCglMjJMb2dpdHMlM0ElMjIlMkMlMjBvdXRwdXQubG9naXRzKQ==",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, AutoModelForSequenceClassification

checkpoint = <span class="hljs-string">&quot;distilbert-base-uncased-finetuned-sst-2-english&quot;</span>
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
model = AutoModelForSequenceClassification.from_pretrained(checkpoint)

sequence = <span class="hljs-string">&quot;I&#x27;ve been waiting for a HuggingFace course my whole life.&quot;</span>

tokens = tokenizer.tokenize(sequence)
ids = tokenizer.convert_tokens_to_ids(tokens)

input_ids = torch.tensor([ids])
<span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;Input IDs:&quot;</span>, input_ids)

output = model(input_ids)
<span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;Logits:&quot;</span>, output.logits)`,wrap:!1}}),{c(){d(s.$$.fragment)},l(l){b(s.$$.fragment,l)},m(l,p){j(s,l,p),a=!0},i(l){a||(M(s.$$.fragment,l),a=!0)},o(l){o(s.$$.fragment,l),a=!1},d(l){f(s,l)}}}function Fs(m){let s,a;return s=new T({props:{code:"SW5wdXQlMjBJRHMlM0ElMjB0Zi5UZW5zb3IoJTBBJTVCJTVCJTIwMTA0NSUyMCUyMDEwMDUlMjAlMjAyMzEwJTIwJTIwMjA0MiUyMCUyMDM0MDMlMjAlMjAyMDA1JTIwJTIwMTAzNyUyMDE3NjYyJTIwMTIxNzIlMjAlMjAyNjA3JTIwJTIwMjAyNiUyMCUyMDI4NzglMEElMjAlMjAlMjAyMTY2JTIwJTIwMTAxMiU1RCU1RCUyQyUyMHNoYXBlJTNEKDElMkMlMjAxNCklMkMlMjBkdHlwZSUzRGludDMyKSUwQUxvZ2l0cyUzQSUyMHRmLlRlbnNvciglNUIlNUItMi43Mjc2MjA4JTIwJTIwMi44Nzg5Mzc3JTVEJTVEJTJDJTIwc2hhcGUlM0QoMSUyQyUyMDIpJTJDJTIwZHR5cGUlM0RmbG9hdDMyKQ==",highlighted:`Input IDs: tf.Tensor(
[[ <span class="hljs-number">1045</span>  <span class="hljs-number">1005</span>  <span class="hljs-number">2310</span>  <span class="hljs-number">2042</span>  <span class="hljs-number">3403</span>  <span class="hljs-number">2005</span>  <span class="hljs-number">1037</span> <span class="hljs-number">17662</span> <span class="hljs-number">12172</span>  <span class="hljs-number">2607</span>  <span class="hljs-number">2026</span>  <span class="hljs-number">2878</span>
   <span class="hljs-number">2166</span>  <span class="hljs-number">1012</span>]], shape=(<span class="hljs-number">1</span>, <span class="hljs-number">14</span>), dtype=int32)
Logits: tf.Tensor([[-<span class="hljs-number">2.7276208</span>  <span class="hljs-number">2.8789377</span>]], shape=(<span class="hljs-number">1</span>, <span class="hljs-number">2</span>), dtype=float32)`,wrap:!1}}),{c(){d(s.$$.fragment)},l(l){b(s.$$.fragment,l)},m(l,p){j(s,l,p),a=!0},i(l){a||(M(s.$$.fragment,l),a=!0)},o(l){o(s.$$.fragment,l),a=!1},d(l){f(s,l)}}}function Hs(m){let s,a;return s=new T({props:{code:"SW5wdXQlMjBJRHMlM0ElMjAlNUIlNUIlMjAxMDQ1JTJDJTIwJTIwMTAwNSUyQyUyMCUyMDIzMTAlMkMlMjAlMjAyMDQyJTJDJTIwJTIwMzQwMyUyQyUyMCUyMDIwMDUlMkMlMjAlMjAxMDM3JTJDJTIwMTc2NjIlMkMlMjAxMjE3MiUyQyUyMCUyMDI2MDclMkMlMjAyMDI2JTJDJTIwJTIwMjg3OCUyQyUyMCUyMDIxNjYlMkMlMjAlMjAxMDEyJTVEJTVEJTBBTG9naXRzJTNBJTIwJTVCJTVCLTIuNzI3NiUyQyUyMCUyMDIuODc4OSU1RCU1RA==",highlighted:`Input IDs: [[ <span class="hljs-number">1045</span>,  <span class="hljs-number">1005</span>,  <span class="hljs-number">2310</span>,  <span class="hljs-number">2042</span>,  <span class="hljs-number">3403</span>,  <span class="hljs-number">2005</span>,  <span class="hljs-number">1037</span>, <span class="hljs-number">17662</span>, <span class="hljs-number">12172</span>,  <span class="hljs-number">2607</span>, <span class="hljs-number">2026</span>,  <span class="hljs-number">2878</span>,  <span class="hljs-number">2166</span>,  <span class="hljs-number">1012</span>]]
Logits: [[-<span class="hljs-number">2.7276</span>,  <span class="hljs-number">2.8789</span>]]`,wrap:!1}}),{c(){d(s.$$.fragment)},l(l){b(s.$$.fragment,l)},m(l,p){j(s,l,p),a=!0},i(l){a||(M(s.$$.fragment,l),a=!0)},o(l){o(s.$$.fragment,l),a=!1},d(l){f(s,l)}}}function Ss(m){let s,a="✏️ <strong>Încercați!</strong> Convertiți această listă <code>batched_ids</code> într-un tensor și treceți-o prin modelul dumneavoastră. Verificați dacă obțineți aceleași logits ca înainte (dar de două ori)!";return{c(){s=U("p"),s.innerHTML=a},l(l){s=J(l,"P",{"data-svelte-h":!0}),w(s)!=="svelte-3tzcvk"&&(s.innerHTML=a)},m(l,p){r(l,s,p)},p:ks,d(l){l&&i(s)}}}function Ys(m){let s,a,l,p;return s=new T({props:{code:"bW9kZWwlMjAlM0QlMjBURkF1dG9Nb2RlbEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24uZnJvbV9wcmV0cmFpbmVkKGNoZWNrcG9pbnQpJTBBJTBBc2VxdWVuY2UxX2lkcyUyMCUzRCUyMCU1QiU1QjIwMCUyQyUyMDIwMCUyQyUyMDIwMCU1RCU1RCUwQXNlcXVlbmNlMl9pZHMlMjAlM0QlMjAlNUIlNUIyMDAlMkMlMjAyMDAlNUQlNUQlMEFiYXRjaGVkX2lkcyUyMCUzRCUyMCU1QiUwQSUyMCUyMCUyMCUyMCU1QjIwMCUyQyUyMDIwMCUyQyUyMDIwMCU1RCUyQyUwQSUyMCUyMCUyMCUyMCU1QjIwMCUyQyUyMDIwMCUyQyUyMHRva2VuaXplci5wYWRfdG9rZW5faWQlNUQlMkMlMEElNUQlMEElMEFwcmludChtb2RlbCh0Zi5jb25zdGFudChzZXF1ZW5jZTFfaWRzKSkubG9naXRzKSUwQXByaW50KG1vZGVsKHRmLmNvbnN0YW50KHNlcXVlbmNlMl9pZHMpKS5sb2dpdHMpJTBBcHJpbnQobW9kZWwodGYuY29uc3RhbnQoYmF0Y2hlZF9pZHMpKS5sb2dpdHMp",highlighted:`model = TFAutoModelForSequenceClassification.from_pretrained(checkpoint)

sequence1_ids = [[<span class="hljs-number">200</span>, <span class="hljs-number">200</span>, <span class="hljs-number">200</span>]]
sequence2_ids = [[<span class="hljs-number">200</span>, <span class="hljs-number">200</span>]]
batched_ids = [
    [<span class="hljs-number">200</span>, <span class="hljs-number">200</span>, <span class="hljs-number">200</span>],
    [<span class="hljs-number">200</span>, <span class="hljs-number">200</span>, tokenizer.pad_token_id],
]

<span class="hljs-built_in">print</span>(model(tf.constant(sequence1_ids)).logits)
<span class="hljs-built_in">print</span>(model(tf.constant(sequence2_ids)).logits)
<span class="hljs-built_in">print</span>(model(tf.constant(batched_ids)).logits)`,wrap:!1}}),l=new T({props:{code:"dGYuVGVuc29yKCU1QiU1QiUyMDEuNTY5MzY3OCUyMC0xLjM4OTQ1ODElNUQlNUQlMkMlMjBzaGFwZSUzRCgxJTJDJTIwMiklMkMlMjBkdHlwZSUzRGZsb2F0MzIpJTBBdGYuVGVuc29yKCU1QiU1QiUyMDAuNTgwMzAwNSUyMCUyMC0wLjQxMjUyNDI4JTVEJTVEJTJDJTIwc2hhcGUlM0QoMSUyQyUyMDIpJTJDJTIwZHR5cGUlM0RmbG9hdDMyKSUwQXRmLlRlbnNvciglMEElNUIlNUIlMjAxLjU2OTM2ODElMjAtMS4zODk0NTgyJTVEJTBBJTIwJTVCJTIwMS4zMzczNDg2JTIwLTEuMjE2MzE5MyU1RCU1RCUyQyUyMHNoYXBlJTNEKDIlMkMlMjAyKSUyQyUyMGR0eXBlJTNEZmxvYXQzMik=",highlighted:`tf.Tensor([[ <span class="hljs-number">1.5693678</span> -<span class="hljs-number">1.3894581</span>]], shape=(<span class="hljs-number">1</span>, <span class="hljs-number">2</span>), dtype=float32)
tf.Tensor([[ <span class="hljs-number">0.5803005</span>  -<span class="hljs-number">0.41252428</span>]], shape=(<span class="hljs-number">1</span>, <span class="hljs-number">2</span>), dtype=float32)
tf.Tensor(
[[ <span class="hljs-number">1.5693681</span> -<span class="hljs-number">1.3894582</span>]
 [ <span class="hljs-number">1.3373486</span> -<span class="hljs-number">1.2163193</span>]], shape=(<span class="hljs-number">2</span>, <span class="hljs-number">2</span>), dtype=float32)`,wrap:!1}}),{c(){d(s.$$.fragment),a=u(),d(l.$$.fragment)},l(t){b(s.$$.fragment,t),a=c(t),b(l.$$.fragment,t)},m(t,y){j(s,t,y),r(t,a,y),j(l,t,y),p=!0},i(t){p||(M(s.$$.fragment,t),M(l.$$.fragment,t),p=!0)},o(t){o(s.$$.fragment,t),o(l.$$.fragment,t),p=!1},d(t){t&&i(a),f(s,t),f(l,t)}}}function qs(m){let s,a,l,p;return s=new T({props:{code:"bW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JTZXF1ZW5jZUNsYXNzaWZpY2F0aW9uLmZyb21fcHJldHJhaW5lZChjaGVja3BvaW50KSUwQSUwQXNlcXVlbmNlMV9pZHMlMjAlM0QlMjAlNUIlNUIyMDAlMkMlMjAyMDAlMkMlMjAyMDAlNUQlNUQlMEFzZXF1ZW5jZTJfaWRzJTIwJTNEJTIwJTVCJTVCMjAwJTJDJTIwMjAwJTVEJTVEJTBBYmF0Y2hlZF9pZHMlMjAlM0QlMjAlNUIlMEElMjAlMjAlMjAlMjAlNUIyMDAlMkMlMjAyMDAlMkMlMjAyMDAlNUQlMkMlMEElMjAlMjAlMjAlMjAlNUIyMDAlMkMlMjAyMDAlMkMlMjB0b2tlbml6ZXIucGFkX3Rva2VuX2lkJTVEJTJDJTBBJTVEJTBBJTBBcHJpbnQobW9kZWwodG9yY2gudGVuc29yKHNlcXVlbmNlMV9pZHMpKS5sb2dpdHMpJTBBcHJpbnQobW9kZWwodG9yY2gudGVuc29yKHNlcXVlbmNlMl9pZHMpKS5sb2dpdHMpJTBBcHJpbnQobW9kZWwodG9yY2gudGVuc29yKGJhdGNoZWRfaWRzKSkubG9naXRzKQ==",highlighted:`model = AutoModelForSequenceClassification.from_pretrained(checkpoint)

sequence1_ids = [[<span class="hljs-number">200</span>, <span class="hljs-number">200</span>, <span class="hljs-number">200</span>]]
sequence2_ids = [[<span class="hljs-number">200</span>, <span class="hljs-number">200</span>]]
batched_ids = [
    [<span class="hljs-number">200</span>, <span class="hljs-number">200</span>, <span class="hljs-number">200</span>],
    [<span class="hljs-number">200</span>, <span class="hljs-number">200</span>, tokenizer.pad_token_id],
]

<span class="hljs-built_in">print</span>(model(torch.tensor(sequence1_ids)).logits)
<span class="hljs-built_in">print</span>(model(torch.tensor(sequence2_ids)).logits)
<span class="hljs-built_in">print</span>(model(torch.tensor(batched_ids)).logits)`,wrap:!1}}),l=new T({props:{code:"dGVuc29yKCU1QiU1QiUyMDEuNTY5NCUyQyUyMC0xLjM4OTUlNUQlNUQlMkMlMjBncmFkX2ZuJTNEJTNDQWRkbW1CYWNrd2FyZCUzRSklMEF0ZW5zb3IoJTVCJTVCJTIwMC41ODAzJTJDJTIwLTAuNDEyNSU1RCU1RCUyQyUyMGdyYWRfZm4lM0QlM0NBZGRtbUJhY2t3YXJkJTNFKSUwQXRlbnNvciglNUIlNUIlMjAxLjU2OTQlMkMlMjAtMS4zODk1JTVEJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTVCJTIwMS4zMzczJTJDJTIwLTEuMjE2MyU1RCU1RCUyQyUyMGdyYWRfZm4lM0QlM0NBZGRtbUJhY2t3YXJkJTNFKQ==",highlighted:`tensor([[ <span class="hljs-number">1.5694</span>, -<span class="hljs-number">1.3895</span>]], grad_fn=&lt;AddmmBackward&gt;)
tensor([[ <span class="hljs-number">0.5803</span>, -<span class="hljs-number">0.4125</span>]], grad_fn=&lt;AddmmBackward&gt;)
tensor([[ <span class="hljs-number">1.5694</span>, -<span class="hljs-number">1.3895</span>],
        [ <span class="hljs-number">1.3373</span>, -<span class="hljs-number">1.2163</span>]], grad_fn=&lt;AddmmBackward&gt;)`,wrap:!1}}),{c(){d(s.$$.fragment),a=u(),d(l.$$.fragment)},l(t){b(s.$$.fragment,t),a=c(t),b(l.$$.fragment,t)},m(t,y){j(s,t,y),r(t,a,y),j(l,t,y),p=!0},i(t){p||(M(s.$$.fragment,t),M(l.$$.fragment,t),p=!0)},o(t){o(s.$$.fragment,t),o(l.$$.fragment,t),p=!1},d(t){t&&i(a),f(s,t),f(l,t)}}}function Ls(m){let s,a,l,p;return s=new T({props:{code:"YmF0Y2hlZF9pZHMlMjAlM0QlMjAlNUIlMEElMjAlMjAlMjAlMjAlNUIyMDAlMkMlMjAyMDAlMkMlMjAyMDAlNUQlMkMlMEElMjAlMjAlMjAlMjAlNUIyMDAlMkMlMjAyMDAlMkMlMjB0b2tlbml6ZXIucGFkX3Rva2VuX2lkJTVEJTJDJTBBJTVEJTBBJTBBYXR0ZW50aW9uX21hc2slMjAlM0QlMjAlNUIlMEElMjAlMjAlMjAlMjAlNUIxJTJDJTIwMSUyQyUyMDElNUQlMkMlMEElMjAlMjAlMjAlMjAlNUIxJTJDJTIwMSUyQyUyMDAlNUQlMkMlMEElNUQlMEElMEFvdXRwdXRzJTIwJTNEJTIwbW9kZWwodGYuY29uc3RhbnQoYmF0Y2hlZF9pZHMpJTJDJTIwYXR0ZW50aW9uX21hc2slM0R0Zi5jb25zdGFudChhdHRlbnRpb25fbWFzaykpJTBBcHJpbnQob3V0cHV0cy5sb2dpdHMp",highlighted:`batched_ids = [
    [<span class="hljs-number">200</span>, <span class="hljs-number">200</span>, <span class="hljs-number">200</span>],
    [<span class="hljs-number">200</span>, <span class="hljs-number">200</span>, tokenizer.pad_token_id],
]

attention_mask = [
    [<span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>],
    [<span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">0</span>],
]

outputs = model(tf.constant(batched_ids), attention_mask=tf.constant(attention_mask))
<span class="hljs-built_in">print</span>(outputs.logits)`,wrap:!1}}),l=new T({props:{code:"dGYuVGVuc29yKCUwQSU1QiU1QiUyMDEuNTY5MzY4MSUyMCUyMC0xLjM4OTQ1ODIlMjAlNUQlMEElMjAlNUIlMjAwLjU4MDMwMjElMjAlMjAtMC40MTI1MjU4NiU1RCU1RCUyQyUyMHNoYXBlJTNEKDIlMkMlMjAyKSUyQyUyMGR0eXBlJTNEZmxvYXQzMik=",highlighted:`tf.Tensor(
[[ <span class="hljs-number">1.5693681</span>  -<span class="hljs-number">1.3894582</span> ]
 [ <span class="hljs-number">0.5803021</span>  -<span class="hljs-number">0.41252586</span>]], shape=(<span class="hljs-number">2</span>, <span class="hljs-number">2</span>), dtype=float32)`,wrap:!1}}),{c(){d(s.$$.fragment),a=u(),d(l.$$.fragment)},l(t){b(s.$$.fragment,t),a=c(t),b(l.$$.fragment,t)},m(t,y){j(s,t,y),r(t,a,y),j(l,t,y),p=!0},i(t){p||(M(s.$$.fragment,t),M(l.$$.fragment,t),p=!0)},o(t){o(s.$$.fragment,t),o(l.$$.fragment,t),p=!1},d(t){t&&i(a),f(s,t),f(l,t)}}}function Ks(m){let s,a,l,p;return s=new T({props:{code:"YmF0Y2hlZF9pZHMlMjAlM0QlMjAlNUIlMEElMjAlMjAlMjAlMjAlNUIyMDAlMkMlMjAyMDAlMkMlMjAyMDAlNUQlMkMlMEElMjAlMjAlMjAlMjAlNUIyMDAlMkMlMjAyMDAlMkMlMjB0b2tlbml6ZXIucGFkX3Rva2VuX2lkJTVEJTJDJTBBJTVEJTBBJTBBYXR0ZW50aW9uX21hc2slMjAlM0QlMjAlNUIlMEElMjAlMjAlMjAlMjAlNUIxJTJDJTIwMSUyQyUyMDElNUQlMkMlMEElMjAlMjAlMjAlMjAlNUIxJTJDJTIwMSUyQyUyMDAlNUQlMkMlMEElNUQlMEElMEFvdXRwdXRzJTIwJTNEJTIwbW9kZWwodG9yY2gudGVuc29yKGJhdGNoZWRfaWRzKSUyQyUyMGF0dGVudGlvbl9tYXNrJTNEdG9yY2gudGVuc29yKGF0dGVudGlvbl9tYXNrKSklMEFwcmludChvdXRwdXRzLmxvZ2l0cyk=",highlighted:`batched_ids = [
    [<span class="hljs-number">200</span>, <span class="hljs-number">200</span>, <span class="hljs-number">200</span>],
    [<span class="hljs-number">200</span>, <span class="hljs-number">200</span>, tokenizer.pad_token_id],
]

attention_mask = [
    [<span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>],
    [<span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">0</span>],
]

outputs = model(torch.tensor(batched_ids), attention_mask=torch.tensor(attention_mask))
<span class="hljs-built_in">print</span>(outputs.logits)`,wrap:!1}}),l=new T({props:{code:"dGVuc29yKCU1QiU1QiUyMDEuNTY5NCUyQyUyMC0xLjM4OTUlNUQlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlNUIlMjAwLjU4MDMlMkMlMjAtMC40MTI1JTVEJTVEJTJDJTIwZ3JhZF9mbiUzRCUzQ0FkZG1tQmFja3dhcmQlM0Up",highlighted:`tensor([[ <span class="hljs-number">1.5694</span>, -<span class="hljs-number">1.3895</span>],
        [ <span class="hljs-number">0.5803</span>, -<span class="hljs-number">0.4125</span>]], grad_fn=&lt;AddmmBackward&gt;)`,wrap:!1}}),{c(){d(s.$$.fragment),a=u(),d(l.$$.fragment)},l(t){b(s.$$.fragment,t),a=c(t),b(l.$$.fragment,t)},m(t,y){j(s,t,y),r(t,a,y),j(l,t,y),p=!0},i(t){p||(M(s.$$.fragment,t),M(l.$$.fragment,t),p=!0)},o(t){o(s.$$.fragment,t),o(l.$$.fragment,t),p=!1},d(t){t&&i(a),f(s,t),f(l,t)}}}function Ps(m){let s,a="✏️ <strong>Încercați!</strong> Aplicați manual tokenizarea pe cele două propoziții utilizate în secțiunea 2 (“I’ve been waiting for a HuggingFace course my whole life.” și “I hate this so much!”). Treceți-le prin model și verificați dacă obțineți aceeași logiți ca în secțiunea 2. Acum grupați-le împreună folosind token-ul de padding, apoi creați masca de atenție corespunzătoare. Verificați dacă obțineți aceleași rezultate atunci când parcurgeți modelul!";return{c(){s=U("p"),s.innerHTML=a},l(l){s=J(l,"P",{"data-svelte-h":!0}),w(s)!=="svelte-16ntdo2"&&(s.innerHTML=a)},m(l,p){r(l,s,p)},p:ks,d(l){l&&i(s)}}}function Os(m){let s,a,l,p,t,y,B,De,h,k,Ze,_,$,ve,x,vl="În secțiunea anterioară, am explorat cel mai simplu caz de utilizare: realizarea de inferențe pe o singură secvență scurtă. Cu toate acestea, apar deja unele întrebări:",Xe,F,Nl="<li>Cum gestionăm secvențe multiple?</li> <li>Cum gestionăm secvențe multiple <em>de lungimi diferite</em>?</li> <li>Indicii vocabularului sunt singurele intrări care permit unui model să funcționeze bine?</li> <li>Există o secvență prea lungă?</li>",Be,H,Ql="Să vedem ce tipuri de probleme prezintă aceste întrebări și cum le putem rezolva folosind API-ul 🤗 Transformers.",xe,S,Fe,Y,zl="În exercițiul anterior ați văzut cum secvențele sunt transformate în liste de numere. Să convertim această listă de numere într-un tensor și să o transmitem modelului:",He,I,g,Ne,q,Vl="Oh, nu! De ce a eșuat? Am urmat pașii din pipeline-ul din secțiunea 2.",Se,L,El="Problema este că am trimis o singură secvență către model, în timp ce modelele 🤗 Transformers așteaptă în mod implicit mai multe propoziții. Aici am încercat să facem tot ce a făcut tokenizatorul în fundal atunci când l-am aplicat unei <code>secvențe</code>. Dar, dacă vă uitați cu atenție, veți vedea că tokenizatorul nu a convertit doar lista de ID-uri de intrare într-un tensor, ci a adăugat și o dimensiune peste aceasta:",Ye,A,C,Qe,K,Wl="Să încercăm din nou și să adăugăm o nouă dimensiune:",qe,Z,v,ze,P,Gl="Imprimăm ID-urile de intrare, precum și logit-urile rezultate - iată rezultatul:",Le,N,Q,Ve,O,Rl="Batching-ul este acțiunea de a trimite mai multe propoziții prin model, toate odată. Dacă aveți o singură propoziție, puteți crea un lot cu o singură secvență:",Ke,ee,Pe,le,Dl="Acesta este un batch de două secvențe identice!",Oe,G,el,se,Xl="Batching-ul permite modelului să funcționeze atunci când îi furnizați mai multe secvențe. Utilizarea mai multor secvențe este la fel de simplă ca și crearea unui lot cu o singură secvență. Există însă o a doua problemă. Atunci când încercați să combinați două (sau mai multe) propoziții, acestea pot avea lungimi diferite. Dacă ați mai lucrat vreodată cu tensori, știți că aceștia trebuie să aibă o formă dreptunghiulară, deci nu veți putea converti direct lista de ID-uri de intrare într-un tensor. Pentru a rezolva această problemă, de obicei <em>umplem</em> datele de intrare.",ll,te,sl,ne,Bl="Următoarea serie de liste nu poate fi convertită într-un tensor:",tl,ae,nl,ie,xl="Pentru a ocoli acest lucru, vom folosi <em>padding-ul</em> pentru ca tensorii noștri să aibă o formă dreptunghiulară. Padding-ul (umplerea datelor) asigură că toate propozițiile noastre au aceeași lungime prin adăugarea unui cuvânt special numit <em>padding token</em> la propozițiile cu mai puține valori. De exemplu, dacă aveți 10 propoziții cu 10 cuvinte și 1 propoziție cu 20 de cuvinte, padding-ul va asigura că toate propozițiile au 20 de cuvinte. În exemplul nostru, tensorul rezultat arată astfel:",al,re,il,pe,Fl="ID-ul token-ului de padding poate fi găsit în <code>tokenizer.pad_token_id</code>. Să-l folosim și să trimitem cele două propoziții prin model în mod separat și grupate împreună:",rl,z,V,Ee,ue,Hl="Este ceva în neregulă cu logit-urile din predicțiile noastre grupate: al doilea rând ar trebui să fie identic cu logit-urile pentru a doua propoziție, dar avem valori complet diferite!",pl,ce,Sl="Acest lucru se datorează faptului că principala caracteristică a modelelor Transformer sunt straturile de atenție care <em>contextualizează</em> fiecare token. Acestea vor lua în considerare token-urile de umplutură, deoarece se ocupă de toate token-urile unei secvențe. Pentru a obține același rezultat atunci când trecem propoziții individuale de diferite lungimi prin model sau atunci când trecem un batch cu aceleași propoziții și același umplutură aplicată, trebuie să spunem acelor straturi de atenție să ignore token-urile de umplutură. Acest lucru se realizează prin utilizarea unei măști de atenție (attention mask).",ul,oe,cl,Me,Yl="<em>Măștile de atenție</em> sunt tensori cu exact aceeași formă ca tensorul ID-urilor de intrare, completate cu 0 și 1: valorile 1 indică faptul că ar trebui să se acorde atenție token-urilor corespunzătoare, iar valorile 0 indică faptul că nu ar trebui să se acorde atenție token-urilor corespunzătoare (adică acestea ar trebui ignorate de straturile de atenție ale modelului).",ol,me,ql="Să completăm exemplul anterior cu o mască de atenție:",Ml,E,W,We,de,Ll="Acum obținem aceeași logits pentru a doua propoziție din batch.",ml,be,Kl="Observăm cum ultima valoare a celei de-a doua secvențe este un ID de padding, care este o valoare 0 în masca de atenție.",dl,R,bl,je,jl,fe,Pl="Cu modelele Transformer, există o limită a lungimii secvențelor pe care le putem transmite modelelor. Majoritatea modelelor gestionează secvențe de până la 512 sau 1024 de token-uri și se vor bloca atunci când li se cere să proceseze secvențe mai lungi. Există două soluții la această problemă:",fl,ye,Ol="<li>Utilizați un model cu o lungime de secvență acceptată mai mare.</li> <li>Trunchiați secvențele.</li>",yl,Ue,es='Modelele au diferite lungimi de secvență acceptate, iar unele sunt specializate în tratarea secvențelor foarte lungi. <a href="https://huggingface.co/docs/transformers/model_doc/longformer" rel="nofollow">Longformer</a> este un exemplu, iar altul este <a href="https://huggingface.co/docs/transformers/model_doc/led" rel="nofollow">LED</a>. Dacă lucrați la o sarcină care necesită secvențe foarte lungi, vă recomandăm să aruncați o privire la aceste modele.',Ul,Je,ls="În caz contrar, vă recomandăm să vă trunchiați secvențele prin specificarea parametrului <code>max_sequence_length</code>:",Jl,we,wl,Te,Tl,Ge,hl;t=new Ns({props:{fw:m[0]}}),B=new Re({props:{title:"Gestionarea secvențelor multiple",local:"gestionarea-secvențelor-multiple",headingTag:"h1"}});const ss=[Vs,zs],he=[];function ts(e,n){return e[0]==="pt"?0:1}h=ts(m),k=he[h]=ss[h](m);const ns=[Ws,Es],ke=[];function as(e,n){return e[0]==="pt"?0:1}_=as(m),$=ke[_]=ns[_](m),S=new Re({props:{title:"Modelele așteaptă un batch de intrări",local:"modelele-așteaptă-un-batch-de-intrări",headingTag:"h2"}});const is=[Rs,Gs],_e=[];function rs(e,n){return e[0]==="pt"?0:1}I=rs(m),g=_e[I]=is[I](m);const ps=[Xs,Ds],$e=[];function us(e,n){return e[0]==="pt"?0:1}A=us(m),C=$e[A]=ps[A](m);const cs=[xs,Bs],Ie=[];function os(e,n){return e[0]==="pt"?0:1}Z=os(m),v=Ie[Z]=cs[Z](m);const Ms=[Hs,Fs],ge=[];function ms(e,n){return e[0]==="pt"?0:1}N=ms(m),Q=ge[N]=Ms[N](m),ee=new T({props:{code:"YmF0Y2hlZF9pZHMlMjAlM0QlMjAlNUJpZHMlMkMlMjBpZHMlNUQ=",highlighted:'<span class="hljs-attr">batched_ids</span> = [ids, ids]',wrap:!1}}),G=new hs({props:{$$slots:{default:[Ss]},$$scope:{ctx:m}}}),te=new Re({props:{title:"Padding-ul datelor de intrare",local:"padding-ul-datelor-de-intrare",headingTag:"h2"}}),ae=new T({props:{code:"YmF0Y2hlZF9pZHMlMjAlM0QlMjAlNUIlMEElMjAlMjAlMjAlMjAlNUIyMDAlMkMlMjAyMDAlMkMlMjAyMDAlNUQlMkMlMEElMjAlMjAlMjAlMjAlNUIyMDAlMkMlMjAyMDAlNUQlMEElNUQ=",highlighted:`batched_ids = [
    [<span class="hljs-number">200</span>, <span class="hljs-number">200</span>, <span class="hljs-number">200</span>],
    [<span class="hljs-number">200</span>, <span class="hljs-number">200</span>]
]`,wrap:!1}}),re=new T({props:{code:"cGFkZGluZ19pZCUyMCUzRCUyMDEwMCUwQSUwQWJhdGNoZWRfaWRzJTIwJTNEJTIwJTVCJTBBJTIwJTIwJTIwJTIwJTVCMjAwJTJDJTIwMjAwJTJDJTIwMjAwJTVEJTJDJTBBJTIwJTIwJTIwJTIwJTVCMjAwJTJDJTIwMjAwJTJDJTIwcGFkZGluZ19pZCU1RCUyQyUwQSU1RA==",highlighted:`padding_id = <span class="hljs-number">100</span>

batched_ids = [
    [<span class="hljs-number">200</span>, <span class="hljs-number">200</span>, <span class="hljs-number">200</span>],
    [<span class="hljs-number">200</span>, <span class="hljs-number">200</span>, padding_id],
]`,wrap:!1}});const ds=[qs,Ys],Ae=[];function bs(e,n){return e[0]==="pt"?0:1}z=bs(m),V=Ae[z]=ds[z](m),oe=new Re({props:{title:"Attention masks(măști de atenție)",local:"attention-masks",headingTag:"h2"}});const js=[Ks,Ls],Ce=[];function fs(e,n){return e[0]==="pt"?0:1}return E=fs(m),W=Ce[E]=js[E](m),R=new hs({props:{$$slots:{default:[Ps]},$$scope:{ctx:m}}}),je=new Re({props:{title:"Secvențe mai lungi",local:"secvențe-mai-lungi",headingTag:"h2"}}),we=new T({props:{code:"c2VxdWVuY2UlMjAlM0QlMjBzZXF1ZW5jZSU1QiUzQW1heF9zZXF1ZW5jZV9sZW5ndGglNUQ=",highlighted:"sequence = sequence[:max_sequence_length]",wrap:!1}}),Te=new Qs({props:{source:"https://github.com/huggingface/course/blob/main/chapters/rum/chapter2/5.mdx"}}),{c(){s=U("meta"),a=u(),l=U("p"),p=u(),d(t.$$.fragment),y=u(),d(B.$$.fragment),De=u(),k.c(),Ze=u(),$.c(),ve=u(),x=U("p"),x.textContent=vl,Xe=u(),F=U("ul"),F.innerHTML=Nl,Be=u(),H=U("p"),H.textContent=Ql,xe=u(),d(S.$$.fragment),Fe=u(),Y=U("p"),Y.textContent=zl,He=u(),g.c(),Ne=u(),q=U("p"),q.textContent=Vl,Se=u(),L=U("p"),L.innerHTML=El,Ye=u(),C.c(),Qe=u(),K=U("p"),K.textContent=Wl,qe=u(),v.c(),ze=u(),P=U("p"),P.textContent=Gl,Le=u(),Q.c(),Ve=u(),O=U("p"),O.textContent=Rl,Ke=u(),d(ee.$$.fragment),Pe=u(),le=U("p"),le.textContent=Dl,Oe=u(),d(G.$$.fragment),el=u(),se=U("p"),se.innerHTML=Xl,ll=u(),d(te.$$.fragment),sl=u(),ne=U("p"),ne.textContent=Bl,tl=u(),d(ae.$$.fragment),nl=u(),ie=U("p"),ie.innerHTML=xl,al=u(),d(re.$$.fragment),il=u(),pe=U("p"),pe.innerHTML=Fl,rl=u(),V.c(),Ee=u(),ue=U("p"),ue.textContent=Hl,pl=u(),ce=U("p"),ce.innerHTML=Sl,ul=u(),d(oe.$$.fragment),cl=u(),Me=U("p"),Me.innerHTML=Yl,ol=u(),me=U("p"),me.textContent=ql,Ml=u(),W.c(),We=u(),de=U("p"),de.textContent=Ll,ml=u(),be=U("p"),be.textContent=Kl,dl=u(),d(R.$$.fragment),bl=u(),d(je.$$.fragment),jl=u(),fe=U("p"),fe.textContent=Pl,fl=u(),ye=U("ul"),ye.innerHTML=Ol,yl=u(),Ue=U("p"),Ue.innerHTML=es,Ul=u(),Je=U("p"),Je.innerHTML=ls,Jl=u(),d(we.$$.fragment),wl=u(),d(Te.$$.fragment),Tl=u(),Ge=U("p"),this.h()},l(e){const n=Zs("svelte-u9bgzb",document.head);s=J(n,"META",{name:!0,content:!0}),n.forEach(i),a=c(e),l=J(e,"P",{}),ws(l).forEach(i),p=c(e),b(t.$$.fragment,e),y=c(e),b(B.$$.fragment,e),De=c(e),k.l(e),Ze=c(e),$.l(e),ve=c(e),x=J(e,"P",{"data-svelte-h":!0}),w(x)!=="svelte-4ill58"&&(x.textContent=vl),Xe=c(e),F=J(e,"UL",{"data-svelte-h":!0}),w(F)!=="svelte-hvd40"&&(F.innerHTML=Nl),Be=c(e),H=J(e,"P",{"data-svelte-h":!0}),w(H)!=="svelte-v1se4v"&&(H.textContent=Ql),xe=c(e),b(S.$$.fragment,e),Fe=c(e),Y=J(e,"P",{"data-svelte-h":!0}),w(Y)!=="svelte-aln8pl"&&(Y.textContent=zl),He=c(e),g.l(e),Ne=c(e),q=J(e,"P",{"data-svelte-h":!0}),w(q)!=="svelte-12dxwu1"&&(q.textContent=Vl),Se=c(e),L=J(e,"P",{"data-svelte-h":!0}),w(L)!=="svelte-yekvch"&&(L.innerHTML=El),Ye=c(e),C.l(e),Qe=c(e),K=J(e,"P",{"data-svelte-h":!0}),w(K)!=="svelte-wbsm1t"&&(K.textContent=Wl),qe=c(e),v.l(e),ze=c(e),P=J(e,"P",{"data-svelte-h":!0}),w(P)!=="svelte-1xr9u3w"&&(P.textContent=Gl),Le=c(e),Q.l(e),Ve=c(e),O=J(e,"P",{"data-svelte-h":!0}),w(O)!=="svelte-i79i9q"&&(O.textContent=Rl),Ke=c(e),b(ee.$$.fragment,e),Pe=c(e),le=J(e,"P",{"data-svelte-h":!0}),w(le)!=="svelte-psj20t"&&(le.textContent=Dl),Oe=c(e),b(G.$$.fragment,e),el=c(e),se=J(e,"P",{"data-svelte-h":!0}),w(se)!=="svelte-mkjens"&&(se.innerHTML=Xl),ll=c(e),b(te.$$.fragment,e),sl=c(e),ne=J(e,"P",{"data-svelte-h":!0}),w(ne)!=="svelte-nyd9xy"&&(ne.textContent=Bl),tl=c(e),b(ae.$$.fragment,e),nl=c(e),ie=J(e,"P",{"data-svelte-h":!0}),w(ie)!=="svelte-7ltdaf"&&(ie.innerHTML=xl),al=c(e),b(re.$$.fragment,e),il=c(e),pe=J(e,"P",{"data-svelte-h":!0}),w(pe)!=="svelte-qx46ym"&&(pe.innerHTML=Fl),rl=c(e),V.l(e),Ee=c(e),ue=J(e,"P",{"data-svelte-h":!0}),w(ue)!=="svelte-7q00i2"&&(ue.textContent=Hl),pl=c(e),ce=J(e,"P",{"data-svelte-h":!0}),w(ce)!=="svelte-1wm1min"&&(ce.innerHTML=Sl),ul=c(e),b(oe.$$.fragment,e),cl=c(e),Me=J(e,"P",{"data-svelte-h":!0}),w(Me)!=="svelte-1pqiu7n"&&(Me.innerHTML=Yl),ol=c(e),me=J(e,"P",{"data-svelte-h":!0}),w(me)!=="svelte-1cpev44"&&(me.textContent=ql),Ml=c(e),W.l(e),We=c(e),de=J(e,"P",{"data-svelte-h":!0}),w(de)!=="svelte-14al49h"&&(de.textContent=Ll),ml=c(e),be=J(e,"P",{"data-svelte-h":!0}),w(be)!=="svelte-1w97x9s"&&(be.textContent=Kl),dl=c(e),b(R.$$.fragment,e),bl=c(e),b(je.$$.fragment,e),jl=c(e),fe=J(e,"P",{"data-svelte-h":!0}),w(fe)!=="svelte-106z6ta"&&(fe.textContent=Pl),fl=c(e),ye=J(e,"UL",{"data-svelte-h":!0}),w(ye)!=="svelte-kfcj30"&&(ye.innerHTML=Ol),yl=c(e),Ue=J(e,"P",{"data-svelte-h":!0}),w(Ue)!=="svelte-1tld82w"&&(Ue.innerHTML=es),Ul=c(e),Je=J(e,"P",{"data-svelte-h":!0}),w(Je)!=="svelte-1p4ewle"&&(Je.innerHTML=ls),Jl=c(e),b(we.$$.fragment,e),wl=c(e),b(Te.$$.fragment,e),Tl=c(e),Ge=J(e,"P",{}),ws(Ge).forEach(i),this.h()},h(){Ts(s,"name","hf:doc:metadata"),Ts(s,"content",et)},m(e,n){vs(document.head,s),r(e,a,n),r(e,l,n),r(e,p,n),j(t,e,n),r(e,y,n),j(B,e,n),r(e,De,n),he[h].m(e,n),r(e,Ze,n),ke[_].m(e,n),r(e,ve,n),r(e,x,n),r(e,Xe,n),r(e,F,n),r(e,Be,n),r(e,H,n),r(e,xe,n),j(S,e,n),r(e,Fe,n),r(e,Y,n),r(e,He,n),_e[I].m(e,n),r(e,Ne,n),r(e,q,n),r(e,Se,n),r(e,L,n),r(e,Ye,n),$e[A].m(e,n),r(e,Qe,n),r(e,K,n),r(e,qe,n),Ie[Z].m(e,n),r(e,ze,n),r(e,P,n),r(e,Le,n),ge[N].m(e,n),r(e,Ve,n),r(e,O,n),r(e,Ke,n),j(ee,e,n),r(e,Pe,n),r(e,le,n),r(e,Oe,n),j(G,e,n),r(e,el,n),r(e,se,n),r(e,ll,n),j(te,e,n),r(e,sl,n),r(e,ne,n),r(e,tl,n),j(ae,e,n),r(e,nl,n),r(e,ie,n),r(e,al,n),j(re,e,n),r(e,il,n),r(e,pe,n),r(e,rl,n),Ae[z].m(e,n),r(e,Ee,n),r(e,ue,n),r(e,pl,n),r(e,ce,n),r(e,ul,n),j(oe,e,n),r(e,cl,n),r(e,Me,n),r(e,ol,n),r(e,me,n),r(e,Ml,n),Ce[E].m(e,n),r(e,We,n),r(e,de,n),r(e,ml,n),r(e,be,n),r(e,dl,n),j(R,e,n),r(e,bl,n),j(je,e,n),r(e,jl,n),r(e,fe,n),r(e,fl,n),r(e,ye,n),r(e,yl,n),r(e,Ue,n),r(e,Ul,n),r(e,Je,n),r(e,Jl,n),j(we,e,n),r(e,wl,n),j(Te,e,n),r(e,Tl,n),r(e,Ge,n),hl=!0},p(e,[n]){const ys={};n&1&&(ys.fw=e[0]),t.$set(ys);let kl=h;h=ts(e),h!==kl&&(X(),o(he[kl],1,1,()=>{he[kl]=null}),D(),k=he[h],k||(k=he[h]=ss[h](e),k.c()),M(k,1),k.m(Ze.parentNode,Ze));let _l=_;_=as(e),_!==_l&&(X(),o(ke[_l],1,1,()=>{ke[_l]=null}),D(),$=ke[_],$||($=ke[_]=ns[_](e),$.c()),M($,1),$.m(ve.parentNode,ve));let $l=I;I=rs(e),I!==$l&&(X(),o(_e[$l],1,1,()=>{_e[$l]=null}),D(),g=_e[I],g||(g=_e[I]=is[I](e),g.c()),M(g,1),g.m(Ne.parentNode,Ne));let Il=A;A=us(e),A!==Il&&(X(),o($e[Il],1,1,()=>{$e[Il]=null}),D(),C=$e[A],C||(C=$e[A]=ps[A](e),C.c()),M(C,1),C.m(Qe.parentNode,Qe));let gl=Z;Z=os(e),Z!==gl&&(X(),o(Ie[gl],1,1,()=>{Ie[gl]=null}),D(),v=Ie[Z],v||(v=Ie[Z]=cs[Z](e),v.c()),M(v,1),v.m(ze.parentNode,ze));let Al=N;N=ms(e),N!==Al&&(X(),o(ge[Al],1,1,()=>{ge[Al]=null}),D(),Q=ge[N],Q||(Q=ge[N]=Ms[N](e),Q.c()),M(Q,1),Q.m(Ve.parentNode,Ve));const Us={};n&2&&(Us.$$scope={dirty:n,ctx:e}),G.$set(Us);let Cl=z;z=bs(e),z!==Cl&&(X(),o(Ae[Cl],1,1,()=>{Ae[Cl]=null}),D(),V=Ae[z],V||(V=Ae[z]=ds[z](e),V.c()),M(V,1),V.m(Ee.parentNode,Ee));let Zl=E;E=fs(e),E!==Zl&&(X(),o(Ce[Zl],1,1,()=>{Ce[Zl]=null}),D(),W=Ce[E],W||(W=Ce[E]=js[E](e),W.c()),M(W,1),W.m(We.parentNode,We));const Js={};n&2&&(Js.$$scope={dirty:n,ctx:e}),R.$set(Js)},i(e){hl||(M(t.$$.fragment,e),M(B.$$.fragment,e),M(k),M($),M(S.$$.fragment,e),M(g),M(C),M(v),M(Q),M(ee.$$.fragment,e),M(G.$$.fragment,e),M(te.$$.fragment,e),M(ae.$$.fragment,e),M(re.$$.fragment,e),M(V),M(oe.$$.fragment,e),M(W),M(R.$$.fragment,e),M(je.$$.fragment,e),M(we.$$.fragment,e),M(Te.$$.fragment,e),hl=!0)},o(e){o(t.$$.fragment,e),o(B.$$.fragment,e),o(k),o($),o(S.$$.fragment,e),o(g),o(C),o(v),o(Q),o(ee.$$.fragment,e),o(G.$$.fragment,e),o(te.$$.fragment,e),o(ae.$$.fragment,e),o(re.$$.fragment,e),o(V),o(oe.$$.fragment,e),o(W),o(R.$$.fragment,e),o(je.$$.fragment,e),o(we.$$.fragment,e),o(Te.$$.fragment,e),hl=!1},d(e){e&&(i(a),i(l),i(p),i(y),i(De),i(Ze),i(ve),i(x),i(Xe),i(F),i(Be),i(H),i(xe),i(Fe),i(Y),i(He),i(Ne),i(q),i(Se),i(L),i(Ye),i(Qe),i(K),i(qe),i(ze),i(P),i(Le),i(Ve),i(O),i(Ke),i(Pe),i(le),i(Oe),i(el),i(se),i(ll),i(sl),i(ne),i(tl),i(nl),i(ie),i(al),i(il),i(pe),i(rl),i(Ee),i(ue),i(pl),i(ce),i(ul),i(cl),i(Me),i(ol),i(me),i(Ml),i(We),i(de),i(ml),i(be),i(dl),i(bl),i(jl),i(fe),i(fl),i(ye),i(yl),i(Ue),i(Ul),i(Je),i(Jl),i(wl),i(Tl),i(Ge)),i(s),f(t,e),f(B,e),he[h].d(e),ke[_].d(e),f(S,e),_e[I].d(e),$e[A].d(e),Ie[Z].d(e),ge[N].d(e),f(ee,e),f(G,e),f(te,e),f(ae,e),f(re,e),Ae[z].d(e),f(oe,e),Ce[E].d(e),f(R,e),f(je,e),f(we,e),f(Te,e)}}}const et='{"title":"Gestionarea secvențelor multiple","local":"gestionarea-secvențelor-multiple","sections":[{"title":"Modelele așteaptă un batch de intrări","local":"modelele-așteaptă-un-batch-de-intrări","sections":[],"depth":2},{"title":"Padding-ul datelor de intrare","local":"padding-ul-datelor-de-intrare","sections":[],"depth":2},{"title":"Attention masks(măști de atenție)","local":"attention-masks","sections":[],"depth":2},{"title":"Secvențe mai lungi","local":"secvențe-mai-lungi","sections":[],"depth":2}],"depth":1}';function lt(m,s,a){let l="pt";return gs(()=>{const p=new URLSearchParams(window.location.search);a(0,l=p.get("fw")||"pt")}),[l]}class ct extends As{constructor(s){super(),Cs(this,s,lt,Os,Is,{})}}export{ct as component};
