import{s as le,o as ee}from"../chunks/scheduler.37c15a92.js";import{S as se,i as te,g as u,s as p,r as i,A as ne,h as m,f as t,c as J,j as Fl,u as T,x as I,k as Hl,y as ae,a as n,v as c,t as o,b as Ll,d as U,w as r,p as Pl}from"../chunks/index.2bf4358c.js";import{C as b}from"../chunks/CodeBlock.4f5fc1ad.js";import{C as Kl}from"../chunks/CourseFloatingBanner.06521e8b.js";import{F as pe}from"../chunks/FrameworkSwitchCourse.8d4d4ab6.js";import{H as Zl}from"../chunks/Heading.8ada512a.js";function Je(w){let a,M;return a=new Kl({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/section6_tf.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/en/chapter2/section6_tf.ipynb"}]}}),{c(){i(a.$$.fragment)},l(s){T(a.$$.fragment,s)},m(s,j){c(a,s,j),M=!0},i(s){M||(U(a.$$.fragment,s),M=!0)},o(s){o(a.$$.fragment,s),M=!1},d(s){r(a,s)}}}function Me(w){let a,M;return a=new Kl({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/section6_pt.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/en/chapter2/section6_pt.ipynb"}]}}),{c(){i(a.$$.fragment)},l(s){T(a.$$.fragment,s)},m(s,j){c(a,s,j),M=!0},i(s){M||(U(a.$$.fragment,s),M=!0)},o(s){o(a.$$.fragment,s),M=!1},d(s){r(a,s)}}}function oe(w){let a,M;return a=new b({props:{code:"aW1wb3J0JTIwdGVuc29yZmxvdyUyMGFzJTIwdGYlMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b1Rva2VuaXplciUyQyUyMFRGQXV0b01vZGVsRm9yU2VxdWVuY2VDbGFzc2lmaWNhdGlvbiUwQSUwQWNoZWNrcG9pbnQlMjAlM0QlMjAlMjJkaXN0aWxiZXJ0LWJhc2UtdW5jYXNlZC1maW5ldHVuZWQtc3N0LTItZW5nbGlzaCUyMiUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKGNoZWNrcG9pbnQpJTBBbW9kZWwlMjAlM0QlMjBURkF1dG9Nb2RlbEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24uZnJvbV9wcmV0cmFpbmVkKGNoZWNrcG9pbnQpJTBBc2VxdWVuY2VzJTIwJTNEJTIwJTVCJTIySSd2ZSUyMGJlZW4lMjB3YWl0aW5nJTIwZm9yJTIwYSUyMEh1Z2dpbmdGYWNlJTIwY291cnNlJTIwbXklMjB3aG9sZSUyMGxpZmUuJTIyJTJDJTIwJTIyU28lMjBoYXZlJTIwSSElMjIlNUQlMEElMEF0b2tlbnMlMjAlM0QlMjB0b2tlbml6ZXIoc2VxdWVuY2VzJTJDJTIwcGFkZGluZyUzRFRydWUlMkMlMjB0cnVuY2F0aW9uJTNEVHJ1ZSUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIydGYlMjIpJTBBb3V0cHV0JTIwJTNEJTIwbW9kZWwoKip0b2tlbnMp",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)
sequences = [<span class="hljs-string">&quot;I&#x27;ve been waiting for a HuggingFace course my whole life.&quot;</span>, <span class="hljs-string">&quot;So have I!&quot;</span>]

tokens = tokenizer(sequences, padding=<span class="hljs-literal">True</span>, truncation=<span class="hljs-literal">True</span>, return_tensors=<span class="hljs-string">&quot;tf&quot;</span>)
output = model(**tokens)`,wrap:!1}}),{c(){i(a.$$.fragment)},l(s){T(a.$$.fragment,s)},m(s,j){c(a,s,j),M=!0},i(s){M||(U(a.$$.fragment,s),M=!0)},o(s){o(a.$$.fragment,s),M=!1},d(s){r(a,s)}}}function Ue(w){let a,M;return a=new b({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b1Rva2VuaXplciUyQyUyMEF1dG9Nb2RlbEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24lMEElMEFjaGVja3BvaW50JTIwJTNEJTIwJTIyZGlzdGlsYmVydC1iYXNlLXVuY2FzZWQtZmluZXR1bmVkLXNzdC0yLWVuZ2xpc2glMjIlMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZChjaGVja3BvaW50KSUwQW1vZGVsJTIwJTNEJTIwQXV0b01vZGVsRm9yU2VxdWVuY2VDbGFzc2lmaWNhdGlvbi5mcm9tX3ByZXRyYWluZWQoY2hlY2twb2ludCklMEFzZXF1ZW5jZXMlMjAlM0QlMjAlNUIlMjJJJ3ZlJTIwYmVlbiUyMHdhaXRpbmclMjBmb3IlMjBhJTIwSHVnZ2luZ0ZhY2UlMjBjb3Vyc2UlMjBteSUyMHdob2xlJTIwbGlmZS4lMjIlMkMlMjAlMjJTbyUyMGhhdmUlMjBJISUyMiU1RCUwQSUwQXRva2VucyUyMCUzRCUyMHRva2VuaXplcihzZXF1ZW5jZXMlMkMlMjBwYWRkaW5nJTNEVHJ1ZSUyQyUyMHRydW5jYXRpb24lM0RUcnVlJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiklMEFvdXRwdXQlMjAlM0QlMjBtb2RlbCgqKnRva2Vucyk=",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)
sequences = [<span class="hljs-string">&quot;I&#x27;ve been waiting for a HuggingFace course my whole life.&quot;</span>, <span class="hljs-string">&quot;So have I!&quot;</span>]

tokens = tokenizer(sequences, padding=<span class="hljs-literal">True</span>, truncation=<span class="hljs-literal">True</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
output = model(**tokens)`,wrap:!1}}),{c(){i(a.$$.fragment)},l(s){T(a.$$.fragment,s)},m(s,j){c(a,s,j),M=!0},i(s){M||(U(a.$$.fragment,s),M=!0)},o(s){o(a.$$.fragment,s),M=!1},d(s){r(a,s)}}}function ie(w){let a,M,s,j,Q,sl,V,tl,y,d,K,g,$l="지난 섹션에서는 대부분의 과정을 하나씩 수행해왔습니다. 토크나이저의 작동 방식을 살펴보고 토큰화, 입력 ID로의 변환, 패딩, 잘라내기 그리고 어텐션 마스크에 대해 알아봤습니다.",nl,E,Wl="하지만 2장에서 보았듯이 우리는 🤗 Transformers API의 고수준 함수로 이 모든 것을 처리할 수 있습니다. 문장을 이용해 <code>tokenizer</code>를 호출하면 모델로 넘겨줄 수 있는 입력을 얻게 됩니다.",al,k,pl,R,Cl="이제 <code>model_inputs</code> 변수는 모델이 잘 동작하기 위해 필요한 모든 것을 가지고 있습니다. DistilBERT는 어텐션 마스크뿐만 아니라 입력 ID도 포함합니다. 추가적인 입력을 받는 다른 모델들도 <code>tokenizer</code> 객체에 의해 생기는 결과물을 가지고 있습니다.",Jl,Z,Ol="아래의 예시를 보면 tokenizer 메서드는 매우 강력합니다. 먼저, 이 메서드는 단일 시퀀스를 토큰화할 수 있습니다.",Ml,$,ol,W,Bl="또한 API의 변경 없이 여러 개의 시퀀스를 한 번에 처리할 수 있습니다.",Ul,C,il,O,Al="원하는대로 패딩을 추가할 수 있습니다.",Tl,B,cl,A,Nl="시퀀스 길이를 잘라낼 수도 있습니다.",rl,N,ul,_,_l="<code>tokenizer</code> 객체를 이용해 결과를 특정 프레임워크의 텐서로 변환할 수 있으며, 이는 모델에 바로 보내질 수 있습니다. 예를 들어 아래 코드 예시에서 토크나이저가 프레임워크에 따라 다른 텐서를 반환하게 했습니다 - <code>&quot;pt&quot;</code>는 PyTorch 텐서를 반환하고 <code>&quot;tf&quot;</code>는 TensorFlow 텐서를 반환하며, <code>&quot;np&quot;</code>는 NumPy 배열을 반환합니다.",ml,z,jl,X,Il,D,zl="토크나이저가 반환한 입력 ID를 자세히 살펴보면 이전에 봤던 결과와 조금 다르다는 것을 알 수 있습니다.",bl,S,wl,v,yl,q,Xl="시작과 끝에 추가된 토큰 ID가 있습니다. 두 시퀀스의 ID가 무엇을 의미하는지 확인하기 위해 디코딩해보겠습니다.",dl,G,hl,x,fl,Y,Dl="토크나이저는 문장이 시작할 떄 <code>[CLS]</code>라는 특별한 토큰을 붙이고, 끝날 때는 <code>[SEP]</code> 토큰을 붙입니다. 이런 특별한 토큰을 사용하는 이유는 모델이 사전학습될 때 이 토큰들을 사용했기 때문에 추론 시 동일한 결과를 얻기 위함입니다. 참고로 몇몇 모델은 특수 토큰을 추가하지 않아도 되고, 어떤 모델은 다른 토큰을 추가하기도 합니다. 또한, 이러한 특수 토큰을 시작 부분이나 끝 부분에만 추가하는 모델도 있습니다. 어떤 경우든 토크나이저는 토크나이저로 어떤 내용이 들어올지 알고 있고 이 내용을 처리해줄 것입니다.",Ql,F,Vl,H,Sl="지금까지 <code>tokenizer</code> 객체가 텍스트에 적용될 때 거치는 개별적인 단계를 모두 살펴보았습니다. 이제 마지막으로 이 객체가 패딩을 이용해 여러 시퀀스를 어떻게 처리하는지, 잘라내기를 통해 매우 긴 문장을 어떻게 처리하는지, 주요 API에 따라 다양한 텐서를 다루는 법을 알아봅시다.",gl,h,f,ll,el,El;Q=new pe({props:{fw:w[0]}}),V=new Zl({props:{title:"한 번에 실행하기",local:"putting-it-all-together",headingTag:"h1"}});const vl=[Me,Je],L=[];function ql(l,e){return l[0]==="pt"?0:1}y=ql(w),d=L[y]=vl[y](w),k=new b({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEFjaGVja3BvaW50JTIwJTNEJTIwJTIyZGlzdGlsYmVydC1iYXNlLXVuY2FzZWQtZmluZXR1bmVkLXNzdC0yLWVuZ2xpc2glMjIlMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZChjaGVja3BvaW50KSUwQSUwQXNlcXVlbmNlJTIwJTNEJTIwJTIySSd2ZSUyMGJlZW4lMjB3YWl0aW5nJTIwZm9yJTIwYSUyMEh1Z2dpbmdGYWNlJTIwY291cnNlJTIwbXklMjB3aG9sZSUyMGxpZmUuJTIyJTBBJTBBbW9kZWxfaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKHNlcXVlbmNlKQ==",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer

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

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

model_inputs = tokenizer(sequence)`,wrap:!1}}),$=new b({props:{code:"c2VxdWVuY2UlMjAlM0QlMjAlMjJJJ3ZlJTIwYmVlbiUyMHdhaXRpbmclMjBmb3IlMjBhJTIwSHVnZ2luZ0ZhY2UlMjBjb3Vyc2UlMjBteSUyMHdob2xlJTIwbGlmZS4lMjIlMEElMEFtb2RlbF9pbnB1dHMlMjAlM0QlMjB0b2tlbml6ZXIoc2VxdWVuY2Up",highlighted:`sequence = <span class="hljs-string">&quot;I&#x27;ve been waiting for a HuggingFace course my whole life.&quot;</span>

model_inputs = tokenizer(sequence)`,wrap:!1}}),C=new b({props:{code:"c2VxdWVuY2VzJTIwJTNEJTIwJTVCJTIySSd2ZSUyMGJlZW4lMjB3YWl0aW5nJTIwZm9yJTIwYSUyMEh1Z2dpbmdGYWNlJTIwY291cnNlJTIwbXklMjB3aG9sZSUyMGxpZmUuJTIyJTJDJTIwJTIyU28lMjBoYXZlJTIwSSElMjIlNUQlMEElMEFtb2RlbF9pbnB1dHMlMjAlM0QlMjB0b2tlbml6ZXIoc2VxdWVuY2VzKQ==",highlighted:`sequences = [<span class="hljs-string">&quot;I&#x27;ve been waiting for a HuggingFace course my whole life.&quot;</span>, <span class="hljs-string">&quot;So have I!&quot;</span>]

model_inputs = tokenizer(sequences)`,wrap:!1}}),B=new b({props:{code:"JTIzJTIwJUVBJUIwJTgwJUVDJTlFJUE1JTIwJUVBJUI4JUI0JTIwJUVDJThCJTlDJUVEJTgwJTgwJUVDJThBJUE0JUVDJTlEJTk4JTIwJUVBJUI4JUI4JUVDJTlEJUI0JUVDJTk3JTkwJTIwJUVCJUE3JTlFJUVBJUIyJThDJTIwJUVEJThDJUE4JUVCJTk0JUE5JUVDJTlEJTg0JTIwJUVDJUI2JTk0JUVBJUIwJTgwJUVEJTk1JUE5JUVCJThCJTg4JUVCJThCJUE0LiUwQW1vZGVsX2lucHV0cyUyMCUzRCUyMHRva2VuaXplcihzZXF1ZW5jZXMlMkMlMjBwYWRkaW5nJTNEJTIybG9uZ2VzdCUyMiklMEElMEElMjMlMjAlRUIlQUElQTglRUIlOEQlQjglRUMlOUQlQjQlMjAlRUMlQTclODAlRUMlOUIlOTAlRUQlOTUlOTglRUIlOEElOTQlMjAlRUMlQjUlOUMlRUIlOEMlODAlMjAlRUMlOEIlOUMlRUQlODAlODAlRUMlOEElQTQlMjAlRUElQjglQjglRUMlOUQlQjQlRUMlOTclOTAlMjAlRUIlQTclOUUlRUElQjIlOEMlMjAlRUQlOEMlQTglRUIlOTQlQTklRUMlOUQlODQlMjAlRUMlQjYlOTQlRUElQjAlODAlRUQlOTUlQTklRUIlOEIlODglRUIlOEIlQTQuJTBBJTIzJTIwKEJFUlQlRUIlODIlOTglMjBEaXN0aWxCRVJUJUVDJTlEJTk4JTIwJUVDJUI1JTlDJUVCJThDJTgwJTIwJUVBJUI4JUI4JUVDJTlEJUI0JUVCJThBJTk0JTIwNTEyKSUwQW1vZGVsX2lucHV0cyUyMCUzRCUyMHRva2VuaXplcihzZXF1ZW5jZXMlMkMlMjBwYWRkaW5nJTNEJTIybWF4X2xlbmd0aCUyMiklMEElMEElMjMlMjAlRUMlQTclODAlRUMlQTAlOTUlRUQlOTUlOUMlMjAlRUElQjglQjglRUMlOUQlQjQlRUMlOTclOTAlMjAlRUIlQTclOUUlRUElQjIlOEMlMjAlRUQlOEMlQTglRUIlOTQlQTklRUMlOUQlODQlMjAlRUMlQjYlOTQlRUElQjAlODAlRUQlOTUlQTklRUIlOEIlODglRUIlOEIlQTQuJTBBbW9kZWxfaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKHNlcXVlbmNlcyUyQyUyMHBhZGRpbmclM0QlMjJtYXhfbGVuZ3RoJTIyJTJDJTIwbWF4X2xlbmd0aCUzRDgp",highlighted:`<span class="hljs-comment"># 가장 긴 시퀀스의 길이에 맞게 패딩을 추가합니다.</span>
model_inputs = tokenizer(sequences, padding=<span class="hljs-string">&quot;longest&quot;</span>)

<span class="hljs-comment"># 모델이 지원하는 최대 시퀀스 길이에 맞게 패딩을 추가합니다.</span>
<span class="hljs-comment"># (BERT나 DistilBERT의 최대 길이는 512)</span>
model_inputs = tokenizer(sequences, padding=<span class="hljs-string">&quot;max_length&quot;</span>)

<span class="hljs-comment"># 지정한 길이에 맞게 패딩을 추가합니다.</span>
model_inputs = tokenizer(sequences, padding=<span class="hljs-string">&quot;max_length&quot;</span>, max_length=<span class="hljs-number">8</span>)`,wrap:!1}}),N=new b({props:{code:"c2VxdWVuY2VzJTIwJTNEJTIwJTVCJTIySSd2ZSUyMGJlZW4lMjB3YWl0aW5nJTIwZm9yJTIwYSUyMEh1Z2dpbmdGYWNlJTIwY291cnNlJTIwbXklMjB3aG9sZSUyMGxpZmUuJTIyJTJDJTIwJTIyU28lMjBoYXZlJTIwSSElMjIlNUQlMEElMEElMjMlMjAlRUIlQUElQTglRUIlOEQlQjglRUMlOUQlQjQlMjAlRUMlQTclODAlRUMlOUIlOTAlRUQlOTUlOTglRUIlOEElOTQlMjAlRUMlQjUlOUMlRUIlOEMlODAlMjAlRUMlOEIlOUMlRUQlODAlODAlRUMlOEElQTQlMjAlRUElQjglQjglRUMlOUQlQjQlRUMlOTclOTAlMjAlRUIlQTclOUUlRUElQjIlOEMlMjAlRUMlOEIlOUMlRUQlODAlODAlRUMlOEElQTQlMjAlRUElQjglQjglRUMlOUQlQjQlRUIlQTUlQkMlMjAlRUMlOUUlOTglRUIlOUQlQkMlRUIlODMlODUlRUIlOEIlODglRUIlOEIlQTQuJTBBJTIzJTIwKEJFUlQlRUIlODIlOTglMjBEaXN0aWxCRVJUJUVDJTlEJTk4JTIwJUVDJUI1JTlDJUVCJThDJTgwJTIwJUVBJUI4JUI4JUVDJTlEJUI0JUVCJThBJTk0JTIwNTEyKSUwQW1vZGVsX2lucHV0cyUyMCUzRCUyMHRva2VuaXplcihzZXF1ZW5jZXMlMkMlMjB0cnVuY2F0aW9uJTNEVHJ1ZSklMEElMEElMjMlMjAlRUMlQTclODAlRUMlQTAlOTUlRUQlOTUlOUMlMjAlRUMlQjUlOUMlRUIlOEMlODAlMjAlRUElQjglQjglRUMlOUQlQjQlRUMlOTclOTAlMjAlRUIlQTclOUUlRUElQjIlOEMlMjAlRUMlOEIlOUMlRUQlODAlODAlRUMlOEElQTQlMjAlRUElQjglQjglRUMlOUQlQjQlRUIlQTUlQkMlMjAlRUMlOUUlOTglRUIlOUQlQkMlRUIlODMlODUlRUIlOEIlODglRUIlOEIlQTQuJTBBbW9kZWxfaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKHNlcXVlbmNlcyUyQyUyMG1heF9sZW5ndGglM0Q4JTJDJTIwdHJ1bmNhdGlvbiUzRFRydWUp",highlighted:`sequences = [<span class="hljs-string">&quot;I&#x27;ve been waiting for a HuggingFace course my whole life.&quot;</span>, <span class="hljs-string">&quot;So have I!&quot;</span>]

<span class="hljs-comment"># 모델이 지원하는 최대 시퀀스 길이에 맞게 시퀀스 길이를 잘라냅니다.</span>
<span class="hljs-comment"># (BERT나 DistilBERT의 최대 길이는 512)</span>
model_inputs = tokenizer(sequences, truncation=<span class="hljs-literal">True</span>)

<span class="hljs-comment"># 지정한 최대 길이에 맞게 시퀀스 길이를 잘라냅니다.</span>
model_inputs = tokenizer(sequences, max_length=<span class="hljs-number">8</span>, truncation=<span class="hljs-literal">True</span>)`,wrap:!1}}),z=new b({props:{code:"c2VxdWVuY2VzJTIwJTNEJTIwJTVCJTIySSd2ZSUyMGJlZW4lMjB3YWl0aW5nJTIwZm9yJTIwYSUyMEh1Z2dpbmdGYWNlJTIwY291cnNlJTIwbXklMjB3aG9sZSUyMGxpZmUuJTIyJTJDJTIwJTIyU28lMjBoYXZlJTIwSSElMjIlNUQlMEElMEElMjMlMjBQeVRvcmNoJTIwJUVEJTg1JTkwJUVDJTg0JTlDJUVCJUE1JUJDJTIwJUVCJUIwJTk4JUVEJTk5JTk4JUVEJTk1JUE5JUVCJThCJTg4JUVCJThCJUE0LiUwQW1vZGVsX2lucHV0cyUyMCUzRCUyMHRva2VuaXplcihzZXF1ZW5jZXMlMkMlMjBwYWRkaW5nJTNEVHJ1ZSUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpJTBBJTBBJTIzJTIwVGVuc29yRmxvdyUyMCVFRCU4NSU5MCVFQyU4NCU5QyVFQiVBNSVCQyUyMCVFQiVCMCU5OCVFRCU5OSU5OCVFRCU5NSVBOSVFQiU4QiU4OCVFQiU4QiVBNC4lMEFtb2RlbF9pbnB1dHMlMjAlM0QlMjB0b2tlbml6ZXIoc2VxdWVuY2VzJTJDJTIwcGFkZGluZyUzRFRydWUlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnRmJTIyKSUwQSUwQSUyMyUyME51bVB5JTIwJUVCJUIwJUIwJUVDJTk3JUI0JUVDJTlEJTg0JTIwJUVCJUIwJTk4JUVEJTk5JTk4JUVEJTk1JUE5JUVCJThCJTg4JUVCJThCJUE0LiUwQW1vZGVsX2lucHV0cyUyMCUzRCUyMHRva2VuaXplcihzZXF1ZW5jZXMlMkMlMjBwYWRkaW5nJTNEVHJ1ZSUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIybnAlMjIp",highlighted:`sequences = [<span class="hljs-string">&quot;I&#x27;ve been waiting for a HuggingFace course my whole life.&quot;</span>, <span class="hljs-string">&quot;So have I!&quot;</span>]

<span class="hljs-comment"># PyTorch 텐서를 반환합니다.</span>
model_inputs = tokenizer(sequences, padding=<span class="hljs-literal">True</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-comment"># TensorFlow 텐서를 반환합니다.</span>
model_inputs = tokenizer(sequences, padding=<span class="hljs-literal">True</span>, return_tensors=<span class="hljs-string">&quot;tf&quot;</span>)

<span class="hljs-comment"># NumPy 배열을 반환합니다.</span>
model_inputs = tokenizer(sequences, padding=<span class="hljs-literal">True</span>, return_tensors=<span class="hljs-string">&quot;np&quot;</span>)`,wrap:!1}}),X=new Zl({props:{title:"특수 토큰",local:"special-tokens",headingTag:"h2"}}),S=new b({props:{code:"c2VxdWVuY2UlMjAlM0QlMjAlMjJJJ3ZlJTIwYmVlbiUyMHdhaXRpbmclMjBmb3IlMjBhJTIwSHVnZ2luZ0ZhY2UlMjBjb3Vyc2UlMjBteSUyMHdob2xlJTIwbGlmZS4lMjIlMEElMEFtb2RlbF9pbnB1dHMlMjAlM0QlMjB0b2tlbml6ZXIoc2VxdWVuY2UpJTBBcHJpbnQobW9kZWxfaW5wdXRzJTVCJTIyaW5wdXRfaWRzJTIyJTVEKSUwQSUwQXRva2VucyUyMCUzRCUyMHRva2VuaXplci50b2tlbml6ZShzZXF1ZW5jZSklMEFpZHMlMjAlM0QlMjB0b2tlbml6ZXIuY29udmVydF90b2tlbnNfdG9faWRzKHRva2VucyklMEFwcmludChpZHMp",highlighted:`sequence = <span class="hljs-string">&quot;I&#x27;ve been waiting for a HuggingFace course my whole life.&quot;</span>

model_inputs = tokenizer(sequence)
<span class="hljs-built_in">print</span>(model_inputs[<span class="hljs-string">&quot;input_ids&quot;</span>])

tokens = tokenizer.tokenize(sequence)
ids = tokenizer.convert_tokens_to_ids(tokens)
<span class="hljs-built_in">print</span>(ids)`,wrap:!1}}),v=new b({props:{code:"JTVCMTAxJTJDJTIwMTA0NSUyQyUyMDEwMDUlMkMlMjAyMzEwJTJDJTIwMjA0MiUyQyUyMDM0MDMlMkMlMjAyMDA1JTJDJTIwMTAzNyUyQyUyMDE3NjYyJTJDJTIwMTIxNzIlMkMlMjAyNjA3JTJDJTIwMjAyNiUyQyUyMDI4NzglMkMlMjAyMTY2JTJDJTIwMTAxMiUyQyUyMDEwMiU1RCUwQSU1QjEwNDUlMkMlMjAxMDA1JTJDJTIwMjMxMCUyQyUyMDIwNDIlMkMlMjAzNDAzJTJDJTIwMjAwNSUyQyUyMDEwMzclMkMlMjAxNzY2MiUyQyUyMDEyMTcyJTJDJTIwMjYwNyUyQyUyMDIwMjYlMkMlMjAyODc4JTJDJTIwMjE2NiUyQyUyMDEwMTIlNUQ=",highlighted:`[<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>]
[<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>]`,wrap:!1}}),G=new b({props:{code:"cHJpbnQodG9rZW5pemVyLmRlY29kZShtb2RlbF9pbnB1dHMlNUIlMjJpbnB1dF9pZHMlMjIlNUQpKSUwQXByaW50KHRva2VuaXplci5kZWNvZGUoaWRzKSk=",highlighted:`<span class="hljs-built_in">print</span>(tokenizer.decode(model_inputs[<span class="hljs-string">&quot;input_ids&quot;</span>]))
<span class="hljs-built_in">print</span>(tokenizer.decode(ids))`,wrap:!1}}),x=new b({props:{code:"JTIyJTVCQ0xTJTVEJTIwaSd2ZSUyMGJlZW4lMjB3YWl0aW5nJTIwZm9yJTIwYSUyMGh1Z2dpbmdmYWNlJTIwY291cnNlJTIwbXklMjB3aG9sZSUyMGxpZmUuJTIwJTVCU0VQJTVEJTIyJTBBJTIyaSd2ZSUyMGJlZW4lMjB3YWl0aW5nJTIwZm9yJTIwYSUyMGh1Z2dpbmdmYWNlJTIwY291cnNlJTIwbXklMjB3aG9sZSUyMGxpZmUuJTIy",highlighted:`<span class="hljs-string">&quot;[CLS] i&#x27;ve been waiting for a huggingface course my whole life. [SEP]&quot;</span>
<span class="hljs-string">&quot;i&#x27;ve been waiting for a huggingface course my whole life.&quot;</span>`,wrap:!1}}),F=new Zl({props:{title:"마무리: 토크나이저에서 모델까지",local:"wrapping-up-from-tokenizer-to-model",headingTag:"h2"}});const Gl=[Ue,oe],P=[];function xl(l,e){return l[0]==="pt"?0:1}return h=xl(w),f=P[h]=Gl[h](w),{c(){a=u("meta"),M=p(),s=u("p"),j=p(),i(Q.$$.fragment),sl=p(),i(V.$$.fragment),tl=p(),d.c(),K=p(),g=u("p"),g.textContent=$l,nl=p(),E=u("p"),E.innerHTML=Wl,al=p(),i(k.$$.fragment),pl=p(),R=u("p"),R.innerHTML=Cl,Jl=p(),Z=u("p"),Z.textContent=Ol,Ml=p(),i($.$$.fragment),ol=p(),W=u("p"),W.textContent=Bl,Ul=p(),i(C.$$.fragment),il=p(),O=u("p"),O.textContent=Al,Tl=p(),i(B.$$.fragment),cl=p(),A=u("p"),A.textContent=Nl,rl=p(),i(N.$$.fragment),ul=p(),_=u("p"),_.innerHTML=_l,ml=p(),i(z.$$.fragment),jl=p(),i(X.$$.fragment),Il=p(),D=u("p"),D.textContent=zl,bl=p(),i(S.$$.fragment),wl=p(),i(v.$$.fragment),yl=p(),q=u("p"),q.textContent=Xl,dl=p(),i(G.$$.fragment),hl=p(),i(x.$$.fragment),fl=p(),Y=u("p"),Y.innerHTML=Dl,Ql=p(),i(F.$$.fragment),Vl=p(),H=u("p"),H.innerHTML=Sl,gl=p(),f.c(),ll=p(),el=u("p"),this.h()},l(l){const e=ne("svelte-u9bgzb",document.head);a=m(e,"META",{name:!0,content:!0}),e.forEach(t),M=J(l),s=m(l,"P",{}),Fl(s).forEach(t),j=J(l),T(Q.$$.fragment,l),sl=J(l),T(V.$$.fragment,l),tl=J(l),d.l(l),K=J(l),g=m(l,"P",{"data-svelte-h":!0}),I(g)!=="svelte-2hwo3u"&&(g.textContent=$l),nl=J(l),E=m(l,"P",{"data-svelte-h":!0}),I(E)!=="svelte-tb9qid"&&(E.innerHTML=Wl),al=J(l),T(k.$$.fragment,l),pl=J(l),R=m(l,"P",{"data-svelte-h":!0}),I(R)!=="svelte-11so93b"&&(R.innerHTML=Cl),Jl=J(l),Z=m(l,"P",{"data-svelte-h":!0}),I(Z)!=="svelte-bvmnox"&&(Z.textContent=Ol),Ml=J(l),T($.$$.fragment,l),ol=J(l),W=m(l,"P",{"data-svelte-h":!0}),I(W)!=="svelte-1y7spzk"&&(W.textContent=Bl),Ul=J(l),T(C.$$.fragment,l),il=J(l),O=m(l,"P",{"data-svelte-h":!0}),I(O)!=="svelte-1j2pysy"&&(O.textContent=Al),Tl=J(l),T(B.$$.fragment,l),cl=J(l),A=m(l,"P",{"data-svelte-h":!0}),I(A)!=="svelte-168onl5"&&(A.textContent=Nl),rl=J(l),T(N.$$.fragment,l),ul=J(l),_=m(l,"P",{"data-svelte-h":!0}),I(_)!=="svelte-xpsxoa"&&(_.innerHTML=_l),ml=J(l),T(z.$$.fragment,l),jl=J(l),T(X.$$.fragment,l),Il=J(l),D=m(l,"P",{"data-svelte-h":!0}),I(D)!=="svelte-5tlyj5"&&(D.textContent=zl),bl=J(l),T(S.$$.fragment,l),wl=J(l),T(v.$$.fragment,l),yl=J(l),q=m(l,"P",{"data-svelte-h":!0}),I(q)!=="svelte-pt8kc1"&&(q.textContent=Xl),dl=J(l),T(G.$$.fragment,l),hl=J(l),T(x.$$.fragment,l),fl=J(l),Y=m(l,"P",{"data-svelte-h":!0}),I(Y)!=="svelte-1798v56"&&(Y.innerHTML=Dl),Ql=J(l),T(F.$$.fragment,l),Vl=J(l),H=m(l,"P",{"data-svelte-h":!0}),I(H)!=="svelte-1cd4adl"&&(H.innerHTML=Sl),gl=J(l),f.l(l),ll=J(l),el=m(l,"P",{}),Fl(el).forEach(t),this.h()},h(){Hl(a,"name","hf:doc:metadata"),Hl(a,"content",Te)},m(l,e){ae(document.head,a),n(l,M,e),n(l,s,e),n(l,j,e),c(Q,l,e),n(l,sl,e),c(V,l,e),n(l,tl,e),L[y].m(l,e),n(l,K,e),n(l,g,e),n(l,nl,e),n(l,E,e),n(l,al,e),c(k,l,e),n(l,pl,e),n(l,R,e),n(l,Jl,e),n(l,Z,e),n(l,Ml,e),c($,l,e),n(l,ol,e),n(l,W,e),n(l,Ul,e),c(C,l,e),n(l,il,e),n(l,O,e),n(l,Tl,e),c(B,l,e),n(l,cl,e),n(l,A,e),n(l,rl,e),c(N,l,e),n(l,ul,e),n(l,_,e),n(l,ml,e),c(z,l,e),n(l,jl,e),c(X,l,e),n(l,Il,e),n(l,D,e),n(l,bl,e),c(S,l,e),n(l,wl,e),c(v,l,e),n(l,yl,e),n(l,q,e),n(l,dl,e),c(G,l,e),n(l,hl,e),c(x,l,e),n(l,fl,e),n(l,Y,e),n(l,Ql,e),c(F,l,e),n(l,Vl,e),n(l,H,e),n(l,gl,e),P[h].m(l,e),n(l,ll,e),n(l,el,e),El=!0},p(l,[e]){const Yl={};e&1&&(Yl.fw=l[0]),Q.$set(Yl);let kl=y;y=ql(l),y!==kl&&(Pl(),o(L[kl],1,1,()=>{L[kl]=null}),Ll(),d=L[y],d||(d=L[y]=vl[y](l),d.c()),U(d,1),d.m(K.parentNode,K));let Rl=h;h=xl(l),h!==Rl&&(Pl(),o(P[Rl],1,1,()=>{P[Rl]=null}),Ll(),f=P[h],f||(f=P[h]=Gl[h](l),f.c()),U(f,1),f.m(ll.parentNode,ll))},i(l){El||(U(Q.$$.fragment,l),U(V.$$.fragment,l),U(d),U(k.$$.fragment,l),U($.$$.fragment,l),U(C.$$.fragment,l),U(B.$$.fragment,l),U(N.$$.fragment,l),U(z.$$.fragment,l),U(X.$$.fragment,l),U(S.$$.fragment,l),U(v.$$.fragment,l),U(G.$$.fragment,l),U(x.$$.fragment,l),U(F.$$.fragment,l),U(f),El=!0)},o(l){o(Q.$$.fragment,l),o(V.$$.fragment,l),o(d),o(k.$$.fragment,l),o($.$$.fragment,l),o(C.$$.fragment,l),o(B.$$.fragment,l),o(N.$$.fragment,l),o(z.$$.fragment,l),o(X.$$.fragment,l),o(S.$$.fragment,l),o(v.$$.fragment,l),o(G.$$.fragment,l),o(x.$$.fragment,l),o(F.$$.fragment,l),o(f),El=!1},d(l){l&&(t(M),t(s),t(j),t(sl),t(tl),t(K),t(g),t(nl),t(E),t(al),t(pl),t(R),t(Jl),t(Z),t(Ml),t(ol),t(W),t(Ul),t(il),t(O),t(Tl),t(cl),t(A),t(rl),t(ul),t(_),t(ml),t(jl),t(Il),t(D),t(bl),t(wl),t(yl),t(q),t(dl),t(hl),t(fl),t(Y),t(Ql),t(Vl),t(H),t(gl),t(ll),t(el)),t(a),r(Q,l),r(V,l),L[y].d(l),r(k,l),r($,l),r(C,l),r(B,l),r(N,l),r(z,l),r(X,l),r(S,l),r(v,l),r(G,l),r(x,l),r(F,l),P[h].d(l)}}}const Te='{"title":"한 번에 실행하기","local":"putting-it-all-together","sections":[{"title":"특수 토큰","local":"special-tokens","sections":[],"depth":2},{"title":"마무리: 토크나이저에서 모델까지","local":"wrapping-up-from-tokenizer-to-model","sections":[],"depth":2}],"depth":1}';function ce(w,a,M){let s="pt";return ee(()=>{const j=new URLSearchParams(window.location.search);M(0,s=j.get("fw")||"pt")}),[s]}class we extends se{constructor(a){super(),te(this,a,ce,ie,le,{})}}export{we as component};
