Buckets:

rtrm's picture
download
raw
67.8 kB
<meta charset="utf-8" /><meta name="hf:doc:metadata" content="{&quot;title&quot;:&quot;పైప్‌లైన్ వెనుక&quot;,&quot;local&quot;:&quot;పపలన-వనక&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;టోకనైజర్‌తో ప్రీప్రాసెసింగ్&quot;,&quot;local&quot;:&quot;preprocessing-with-a-tokenizer&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;మోడల్ ద్వారా పంపడం&quot;,&quot;local&quot;:&quot;going-through-the-model&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;హై-డైమెన్షనల్ వెక్టర్?&quot;,&quot;local&quot;:&quot;a-high-dimensional-vector&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;మోడల్ హెడ్‌లు: సంఖ్యలకు అర్థం చెప్పడం&quot;,&quot;local&quot;:&quot;model-heads-making-sense-out-of-numbers&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3}],&quot;depth&quot;:2},{&quot;title&quot;:&quot;అవుట్‌పుట్‌ను పోస్ట్‌ప్రాసెసింగ్ చేయడం&quot;,&quot;local&quot;:&quot;postprocessing-the-output&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2}],&quot;depth&quot;:1}">
<link href="/docs/course/pr_1149/te/_app/immutable/assets/0.e3b0c442.css" rel="modulepreload">
<link rel="modulepreload" href="/docs/course/pr_1149/te/_app/immutable/entry/start.eee4c1e0.js">
<link rel="modulepreload" href="/docs/course/pr_1149/te/_app/immutable/chunks/scheduler.cc52f4b9.js">
<link rel="modulepreload" href="/docs/course/pr_1149/te/_app/immutable/chunks/singletons.69904a63.js">
<link rel="modulepreload" href="/docs/course/pr_1149/te/_app/immutable/chunks/index.5033808a.js">
<link rel="modulepreload" href="/docs/course/pr_1149/te/_app/immutable/chunks/paths.e8418a83.js">
<link rel="modulepreload" href="/docs/course/pr_1149/te/_app/immutable/entry/app.0f38558a.js">
<link rel="modulepreload" href="/docs/course/pr_1149/te/_app/immutable/chunks/preload-helper.ae923e55.js">
<link rel="modulepreload" href="/docs/course/pr_1149/te/_app/immutable/chunks/index.bd400c31.js">
<link rel="modulepreload" href="/docs/course/pr_1149/te/_app/immutable/nodes/0.bd814f6d.js">
<link rel="modulepreload" href="/docs/course/pr_1149/te/_app/immutable/chunks/each.e59479a4.js">
<link rel="modulepreload" href="/docs/course/pr_1149/te/_app/immutable/nodes/15.3b94e53e.js">
<link rel="modulepreload" href="/docs/course/pr_1149/te/_app/immutable/chunks/Tip.272e6bd8.js">
<link rel="modulepreload" href="/docs/course/pr_1149/te/_app/immutable/chunks/MermaidChart.svelte_svelte_type_style_lang.25fe1ea6.js">
<link rel="modulepreload" href="/docs/course/pr_1149/te/_app/immutable/chunks/Youtube.4afc5ee9.js">
<link rel="modulepreload" href="/docs/course/pr_1149/te/_app/immutable/chunks/CodeBlock.1794e33c.js">
<link rel="modulepreload" href="/docs/course/pr_1149/te/_app/immutable/chunks/CourseFloatingBanner.6f780cc4.js">
<link rel="modulepreload" href="/docs/course/pr_1149/te/_app/immutable/chunks/FrameworkSwitchCourse.e8e44fa0.js"><!-- HEAD_svelte-u9bgzb_START --><meta name="hf:doc:metadata" content="{&quot;title&quot;:&quot;పైప్‌లైన్ వెనుక&quot;,&quot;local&quot;:&quot;పపలన-వనక&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;టోకనైజర్‌తో ప్రీప్రాసెసింగ్&quot;,&quot;local&quot;:&quot;preprocessing-with-a-tokenizer&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;మోడల్ ద్వారా పంపడం&quot;,&quot;local&quot;:&quot;going-through-the-model&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;హై-డైమెన్షనల్ వెక్టర్?&quot;,&quot;local&quot;:&quot;a-high-dimensional-vector&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;మోడల్ హెడ్‌లు: సంఖ్యలకు అర్థం చెప్పడం&quot;,&quot;local&quot;:&quot;model-heads-making-sense-out-of-numbers&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3}],&quot;depth&quot;:2},{&quot;title&quot;:&quot;అవుట్‌పుట్‌ను పోస్ట్‌ప్రాసెసింగ్ చేయడం&quot;,&quot;local&quot;:&quot;postprocessing-the-output&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2}],&quot;depth&quot;:1}"><!-- HEAD_svelte-u9bgzb_END --> <p></p> <div class="bg-white leading-none border border-gray-100 rounded-lg flex p-0.5 w-56 text-sm mb-4"><a class="flex justify-center flex-1 py-1.5 px-2.5 focus:outline-none !no-underline rounded-l bg-red-50 dark:bg-transparent text-red-600" href="?fw=pt"><svg class="mr-1.5" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><defs><clipPath id="a"><rect x="3.05" y="0.5" width="25.73" height="31" fill="none"></rect></clipPath></defs><g clip-path="url(#a)"><path d="M24.94,9.51a12.81,12.81,0,0,1,0,18.16,12.68,12.68,0,0,1-18,0,12.81,12.81,0,0,1,0-18.16l9-9V5l-.84.83-6,6a9.58,9.58,0,1,0,13.55,0ZM20.44,9a1.68,1.68,0,1,1,1.67-1.67A1.68,1.68,0,0,1,20.44,9Z" fill="#ee4c2c"></path></g></svg> Pytorch </a><a class="flex justify-center flex-1 py-1.5 px-2.5 focus:outline-none !no-underline rounded-r text-gray-500 filter grayscale" href="?fw=tf"><svg class="mr-1.5" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" focusable="false" role="img" width="0.94em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 274"><path d="M145.726 42.065v42.07l72.861 42.07v-42.07l-72.86-42.07zM0 84.135v42.07l36.43 21.03V105.17L0 84.135zm109.291 21.035l-36.43 21.034v126.2l36.43 21.035v-84.135l36.435 21.035v-42.07l-36.435-21.034V105.17z" fill="#E55B2D"></path><path d="M145.726 42.065L36.43 105.17v42.065l72.861-42.065v42.065l36.435-21.03v-84.14zM255.022 63.1l-36.435 21.035v42.07l36.435-21.035V63.1zm-72.865 84.135l-36.43 21.035v42.07l36.43-21.036v-42.07zm-36.43 63.104l-36.436-21.035v84.135l36.435-21.035V210.34z" fill="#ED8E24"></path><path d="M145.726 0L0 84.135l36.43 21.035l109.296-63.105l72.861 42.07L255.022 63.1L145.726 0zm0 126.204l-36.435 21.03l36.435 21.036l36.43-21.035l-36.43-21.03z" fill="#F8BF3C"></path></svg> TensorFlow </a></div> <div class="items-center shrink-0 min-w-[100px] max-sm:min-w-[50px] justify-end ml-auto flex" style="float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"><div class="inline-flex rounded-md max-sm:rounded-sm"><button class="inline-flex items-center gap-1 max-sm:gap-0.5 h-6 max-sm:h-5 px-2 max-sm:px-1.5 text-[11px] max-sm:text-[9px] font-medium text-gray-800 border border-r-0 rounded-l-md max-sm:rounded-l-sm border-gray-200 bg-white hover:shadow-inner dark:border-gray-850 dark:bg-gray-950 dark:text-gray-200 dark:hover:bg-gray-800" aria-live="polite"><span class="inline-flex items-center justify-center rounded-md p-0.5 max-sm:p-0"><svg class="w-3 h-3 max-sm:w-2.5 max-sm:h-2.5" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg></span> <span>Copy page</span></button> <button class="inline-flex items-center justify-center w-6 max-sm:w-5 h-6 max-sm:h-5 disabled:pointer-events-none text-sm text-gray-500 hover:text-gray-700 dark:hover:text-white rounded-r-md max-sm:rounded-r-sm border border-l transition border-gray-200 bg-white hover:shadow-inner dark:border-gray-850 dark:bg-gray-950 dark:text-gray-200 dark:hover:bg-gray-800" aria-haspopup="menu" aria-expanded="false" aria-label="Open copy menu"><svg class="transition-transform text-gray-400 overflow-visible w-3 h-3 max-sm:w-2.5 max-sm:h-2.5 rotate-0" width="1em" height="1em" viewBox="0 0 12 7" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1 1L6 6L11 1" stroke="currentColor"></path></svg></button></div> </div> <h1 class="relative group"><a id="పపలన-వనక" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#పపలన-వనక"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>పైప్‌లైన్ వెనుక</span></h1> <div class="flex space-x-1 absolute z-10 right-0 top-0" style=""><a href="https://discuss.huggingface.co/t/chapter-2-questions" target="_blank"><img alt="Ask a Question" class="!m-0" src="https://img.shields.io/badge/Ask%20a%20question-ffcb4c.svg?logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgLTEgMTA0IDEwNiI+PGRlZnM+PHN0eWxlPi5jbHMtMXtmaWxsOiMyMzFmMjA7fS5jbHMtMntmaWxsOiNmZmY5YWU7fS5jbHMtM3tmaWxsOiMwMGFlZWY7fS5jbHMtNHtmaWxsOiMwMGE5NGY7fS5jbHMtNXtmaWxsOiNmMTVkMjI7fS5jbHMtNntmaWxsOiNlMzFiMjM7fTwvc3R5bGU+PC9kZWZzPjx0aXRsZT5EaXNjb3Vyc2VfbG9nbzwvdGl0bGU+PGcgaWQ9IkxheWVyXzIiPjxnIGlkPSJMYXllcl8zIj48cGF0aCBjbGFzcz0iY2xzLTEiIGQ9Ik01MS44NywwQzIzLjcxLDAsMCwyMi44MywwLDUxYzAsLjkxLDAsNTIuODEsMCw1Mi44MWw1MS44Ni0uMDVjMjguMTYsMCw1MS0yMy43MSw1MS01MS44N1M4MCwwLDUxLjg3LDBaIi8+PHBhdGggY2xhc3M9ImNscy0yIiBkPSJNNTIuMzcsMTkuNzRBMzEuNjIsMzEuNjIsMCwwLDAsMjQuNTgsNjYuNDFsLTUuNzIsMTguNEwzOS40LDgwLjE3YTMxLjYxLDMxLjYxLDAsMSwwLDEzLTYwLjQzWiIvPjxwYXRoIGNsYXNzPSJjbHMtMyIgZD0iTTc3LjQ1LDMyLjEyYTMxLjYsMzEuNiwwLDAsMS0zOC4wNSw0OEwxOC44Niw4NC44MmwyMC45MS0yLjQ3QTMxLjYsMzEuNiwwLDAsMCw3Ny40NSwzMi4xMloiLz48cGF0aCBjbGFzcz0iY2xzLTQiIGQ9Ik03MS42MywyNi4yOUEzMS42LDMxLjYsMCwwLDEsMzguOCw3OEwxOC44Niw4NC44MiwzOS40LDgwLjE3QTMxLjYsMzEuNiwwLDAsMCw3MS42MywyNi4yOVoiLz48cGF0aCBjbGFzcz0iY2xzLTUiIGQ9Ik0yNi40Nyw2Ny4xMWEzMS42MSwzMS42MSwwLDAsMSw1MS0zNUEzMS42MSwzMS42MSwwLDAsMCwyNC41OCw2Ni40MWwtNS43MiwxOC40WiIvPjxwYXRoIGNsYXNzPSJjbHMtNiIgZD0iTTI0LjU4LDY2LjQxQTMxLjYxLDMxLjYxLDAsMCwxLDcxLjYzLDI2LjI5YTMxLjYxLDMxLjYxLDAsMCwwLTQ5LDM5LjYzbC0zLjc2LDE4LjlaIi8+PC9nPjwvZz48L3N2Zz4="></a> <a href="https://colab.research.google.com/github/huggingface/notebooks/blob/master/course/en/chapter2/section2_pt.ipynb" target="_blank"><img alt="Open In Colab" class="!m-0" src="https://colab.research.google.com/assets/colab-badge.svg"></a> <a href="https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/en/chapter2/section2_pt.ipynb" target="_blank"><img alt="Open In Studio Lab" class="!m-0" src="https://studiolab.sagemaker.aws/studiolab.svg"></a></div> <iframe class="w-full xl:w-4/6 h-80" src="https://www.youtube-nocookie.com/embed/1pedAIvTWXk" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> <p data-svelte-h="svelte-ljmebs">ఇప్పుడు ఒక పూర్తి ఉదాహరణతో ప్రారంభిద్దాం. <a href="/course/chapter1">అధ్యాయం 1</a>లో మనం క్రింది కోడ్‌ను నడిపినప్పుడు వెనుకపట్లో ఏమి జరిగిందో చూద్దాం:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START --><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline
classifier = pipeline(<span class="hljs-string">&quot;sentiment-analysis&quot;</span>)
classifier(
[
<span class="hljs-string">&quot;I&#x27;ve been waiting for a HuggingFace course my whole life.&quot;</span>,
<span class="hljs-string">&quot;I hate this so much!&quot;</span>,
]
)<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-q2v0vz">మరియు మనకు వచ్చిన ఫలితాలు:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START -->[{<span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;POSITIVE&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.9598047137260437</span>},
{<span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;NEGATIVE&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.9994558095932007</span>}]<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-1yh24e1"><a href="/course/chapter1">అధ్యాయం 1</a>లో చూశినట్లుగా, ఈ పైప్‌లైన్ మూడు దశలను కలిపి అమలు చేస్తుంది: ప్రీప్రాసెసింగ్, ఇన్‌పుట్‌లను మోడల్ ద్వారా పంపించడం, మరియు పోస్ట్‌ప్రాసెసింగ్:</p> <div class="flex justify-center" data-svelte-h="svelte-n7y0s7"><img class="block dark:hidden" src="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter2/full_nlp_pipeline.svg" alt="పూర్తి NLP పైప్‌లైన్: పాఠ్యాన్ని టోకనైజ్ చేయడం, IDs‌గా మార్చడం, మరియు ట్రాన్స్‌ఫార్మర్ మోడల్ ద్వారా ఇన్‌ఫరెన్స్ జరపడం."> <img class="hidden dark:block" src="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter2/full_nlp_pipeline-dark.svg" alt="పూర్తి NLP పైప్‌లైన్: పాఠ్యాన్ని టోకనైజ్ చేయడం, IDs‌గా మార్చడం, మరియు ట్రాన్స్‌ఫార్మర్ మోడల్ ద్వారా ఇన్‌ఫరెన్స్ జరపడం."></div> <p data-svelte-h="svelte-olckzj">ఇప్పుడు ఈ దశలన్నింటినీ త్వరగా పరిశీలిద్దాం.</p> <h2 class="relative group"><a id="preprocessing-with-a-tokenizer" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#preprocessing-with-a-tokenizer"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>టోకనైజర్‌తో ప్రీప్రాసెసింగ్</span></h2> <p data-svelte-h="svelte-qgpn32">ఇతర న్యూరల్ నెట్‌వర్క్‌ల మాదిరిగానే, Transformer మోడళ్లు రా టెక్స్ట్‌ను నేరుగా ప్రాసెస్ చేయలేవు. కాబట్టి పైప్‌లైన్‌లో మొదటి దశ పాఠ్యాన్ని మోడల్ అర్థం చేసుకునే సంఖ్యల్లోకి మార్చడం. దీని కోసం మనం <em>టోకనైజర్</em> ఉపయోగిస్తాము. ఇది కింది పనులకు బాధ్యత వహిస్తుంది:</p> <ul data-svelte-h="svelte-radhb5"><li>ఇన్‌పుట్‌ను పదాలు, ఉపపదాలు లేదా చిహ్నాలు (ఉదాహరణకు, punctuation)గా విభజించడం — వీటిని <em>tokens</em> అని పిలుస్తారు</li> <li>ప్రతి టోకెన్‌ను ఒక integer కి మ్యాప్ చేయడం</li> <li>మోడల్‌కు ఉపయోగపడే అదనపు ఇన్‌పుట్‌లను జోడించడం</li></ul> <p data-svelte-h="svelte-rw1xqi">ఈ ప్రీప్రాసెసింగ్ మొత్తం మోడల్‌ను ప్రీట్రెయిన్ చేసినప్పుడు ఎలా జరిగిందో అచ్చుగుద్దినట్లుగా జరగాలి. అందుకే ముందుగా ఆ సమాచారాన్ని <a href="https://huggingface.co/models" rel="nofollow">Model Hub</a> నుండి డౌన్‌లోడ్ చేసుకోవాలి. దీని కోసం మనం <code>AutoTokenizer</code> క్లాస్ మరియు దాని <code>from_pretrained()</code> పద్ధతిని ఉపయోగిస్తాము. మన మోడల్ యొక్క checkpoint పేరును ఉపయోగించి, ఇది మోడల్ tokenizer కు సంబంధించిన డేటాను ఆటోమేటిక్‌గా తెచ్చి cache లో భద్రపరుస్తుంది (దాంతో మీరు క్రింది కోడ్‌ను మొదటిసారి నడిపినప్పుడు మాత్రమే అది డౌన్‌లోడ్ అవుతుంది).</p> <p data-svelte-h="svelte-2489zq"><code>sentiment-analysis</code> పైప్‌లైన్ యొక్క డిఫాల్ట్ checkpoint <code>distilbert-base-uncased-finetuned-sst-2-english</code> (దాని మోడల్ కార్డ్‌ను <a href="https://huggingface.co/distilbert-base-uncased-finetuned-sst-2-english" rel="nofollow">ఇక్కడ</a> చూడవచ్చు). కాబట్టి మనం ఈ క్రింది కోడ్‌ను నడుపుతాము:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START --><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)<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-9p1ape">టోకనైజర్ మనకు లభించిన తర్వాత, మనం వాక్యాలను నేరుగా దానిలోకి పంపవచ్చు, మరియు అది మోడల్‌కు ఇవ్వడానికి సిద్ధమైన dictionary ని తిరిగి ఇస్తుంది! ఇప్పుడు చేయవలసింది ఒక్కటే ఉంది: input IDs లిస్ట్‌ను tensors గా మార్చడం.</p> <p data-svelte-h="svelte-1w81wq7">🤗 Transformers ను ఉపయోగించినప్పుడు ఏ ML framework backend గా వాడబడుతుందో గురించి ఆందోళన చెందాల్సిన అవసరం లేదు; కొన్ని మోడళ్లకు అది PyTorch కావచ్చు లేదా Flax కావచ్చు. అయితే Transformer మోడళ్లు కేవలం <em>tensors</em> నే ఇన్‌పుట్‌గా స్వీకరిస్తాయి. మీరు tensors గురించి తొలిసారి వింటుంటే, వాటిని NumPy arrays మాదిరిగా ఊహించవచ్చు. NumPy array ఒక scalar (0D), ఒక vector (1D), ఒక matrix (2D), లేదా మరింత dimensions కలిగి ఉండవచ్చు. ఇవన్నీ tensors లాగానే పనిచేస్తాయి; ఇతర ML frameworks లోని tensors కూడా ఇలాగే ప్రవర్తిస్తాయి, మరియు సాధారణంగా NumPy arrays ను తయారు చేసినంత సులభంగానే వాటిని సృష్టించవచ్చు.</p> <p data-svelte-h="svelte-1e1w19i">మనకు తిరిగి రావలసిన tensor రకాన్ని (PyTorch లేదా సాధారణ NumPy) నిర్ణయించడానికి <code>return_tensors</code> argument ను ఉపయోగిస్తాము:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START -->raw_inputs = [
<span class="hljs-string">&quot;I&#x27;ve been waiting for a HuggingFace course my whole life.&quot;</span>,
<span class="hljs-string">&quot;I hate this so much!&quot;</span>,
]
inputs = tokenizer(raw_inputs, padding=<span class="hljs-literal">True</span>, truncation=<span class="hljs-literal">True</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-built_in">print</span>(inputs)<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-1clsd8w">padding మరియు truncation గురించి ఇప్పుడే ఆందోళన చెందాల్సిన అవసరం లేదు; వాటిని తరువాత వివరిస్తాము. ఇక్కడ గుర్తుపెట్టుకోవలసిన ముఖ్యమైన విషయమేమిటంటే: మీరు ఒక వాక్యం లేదా వాక్యాల జాబితాను పంపవచ్చు, అలాగే మీరు కావలసిన tensor రకాన్ని సూచించవచ్చు (ఏ రకం సూచించకపోతే, ఫలితంగా lists of lists వస్తాయి).</p> <p data-svelte-h="svelte-1yghzjt">ఇక్కడ PyTorch tensors రూపంలో ఫలితాలు ఎలా ఉంటాయో చూడండి:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START -->{
<span class="hljs-string">&#x27;input_ids&#x27;</span>: 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>],
[ <span class="hljs-number">101</span>, <span class="hljs-number">1045</span>, <span class="hljs-number">5223</span>, <span class="hljs-number">2023</span>, <span class="hljs-number">2061</span>, <span class="hljs-number">2172</span>, <span class="hljs-number">999</span>, <span class="hljs-number">102</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>]
]),
<span class="hljs-string">&#x27;attention_mask&#x27;</span>: tensor([
[<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">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">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">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">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>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>]
])
}<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-1lzkdk9">ఆ అవుట్‌పుట్ dictionary లో రెండు keys ఉంటాయి: <code>input_ids</code> మరియు <code>attention_mask</code>. <code>input_ids</code>లో రెండు పంక్తుల integers ఉంటాయి (ప్రతి వాక్యానికి ఒక్కటి), ఇవి ప్రతి వాక్యంలో ఉన్న tokens కు ప్రత్యేకమైన గుర్తింపులు. <code>attention_mask</code> ఏమిటో ఈ అధ్యాయంలో తరువాత వివరిస్తాము.</p> <h2 class="relative group"><a id="going-through-the-model" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#going-through-the-model"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>మోడల్ ద్వారా పంపడం</span></h2> <p data-svelte-h="svelte-1pmpej1">ప్రీట్రెయిన్ చేసిన మోడల్‌ను కూడా మనం టోకనైజర్ మాదిరిగానే డౌన్‌లోడ్ చేసుకోవచ్చు. 🤗 Transformers లో <code>AutoModel</code> క్లాస్ ఉంది, దీనికి కూడా <code>from_pretrained()</code> పద్ధతి ఉంది:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START --><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModel
checkpoint = <span class="hljs-string">&quot;distilbert-base-uncased-finetuned-sst-2-english&quot;</span>
model = AutoModel.from_pretrained(checkpoint)<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-1aakzfh">ఈ కోడ్ స్నిపెట్‌లో, మనం పైప్‌లైన్‌లో ముందే ఉపయోగించిన అదే checkpoint ను డౌన్‌లోడ్ చేసుకున్నాము (అది ఇప్పటికే cache లో ఉండాలి) మరియు దానితో ఒక model ను సృష్టించుకున్నాము.</p> <p data-svelte-h="svelte-qzybs">ఈ architecture కేవలం base Transformer మాడ్యూల్‌ను మాత్రమే కలిగి ఉంటుంది: కొన్ని ఇన్‌పుట్‌లు ఇచ్చినప్పుడు, ఇది <em>hidden states</em> (లేదా <em>features</em>) అని పిలిచే అవుట్‌పుట్‌లను ఇస్తుంది. ప్రతి మోడల్ ఇన్‌పుట్‌కు, Transformer మోడల్ దాని పై ఉన్న <strong>contextual understanding</strong> ను ప్రతిబింబించే ఒక high-dimensional వెక్టర్ లభిస్తుంది.</p> <p data-svelte-h="svelte-vp1izw">ఇది ఇప్పుడే పూర్తిగా అర్థం కాకపోతే ఆందోళన చెందకండి. దీన్ని తరువాత విపులంగా వివరిస్తాము.</p> <p data-svelte-h="svelte-zes9ui">ఈ hidden states కొన్ని సందర్భాల్లో ఉపయోగకరంగా ఉండవచ్చు, కానీ అవి సాధారణంగా మోడల్‌లోని మరో భాగానికి — <em>head</em> — కు ఇన్‌పుట్ అవుతాయి. <a href="/course/chapter1">అధ్యాయం 1</a>లో చూశినట్లుగా, వేర్వేరు పనులు ఒకే architecture తో చేయవచ్చు, కానీ ప్రతి task కు వేర్వేరు head ఉంటుంది.</p> <h3 class="relative group"><a id="a-high-dimensional-vector" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#a-high-dimensional-vector"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>హై-డైమెన్షనల్ వెక్టర్?</span></h3> <p data-svelte-h="svelte-kl5x32">Transformer module నుంచి వచ్చే వెక్టర్ సాధారణంగా పెద్దదే. దీనికి మూడు పరిమాణాలు ఉంటాయి:</p> <ul data-svelte-h="svelte-1e2m2pb"><li><strong>Batch size</strong> (బ్యాచ్ పరిమాణం): ఒకేసారి ప్రాసెస్ చేసే సీక్వెన్స్‌ల సంఖ్య (మన ఉదాహరణలో 2).</li> <li><strong>Sequence length</strong> (సీక్వెన్స్ పొడవు): ప్రతి సీక్వెన్స్‌కు సంబంధించిన సంఖ్యాత్మక ప్రతినిధి యొక్క పొడవు (మన ఉదాహరణలో 16).</li> <li><strong>Hidden size</strong> (హిడెన్ పరిమాణం): ప్రతి ఇన్‌పుట్ టోకెన్‌కి మోడల్ ఉత్పత్తి చేసే వెక్టర్ యొక్క డైమెన్షన్.</li></ul> <p data-svelte-h="svelte-1o9p0u4">ఈ చివరి విలువ కారణంగా దీనిని “high dimensional” అంటారు. చిన్న మోడళ్లలో hidden size 768గా ఉంటుంది; పెద్ద మోడళ్లలో ఇది 3072 లేదా అంతకంటే ఎక్కువ కావచ్చు.</p> <p data-svelte-h="svelte-1iu2fap">మనము ప్రీప్రాసెస్ చేసిన ఇన్‌పుట్‌లను మోడల్‌లోకి పంపితే ఇది స్పష్టంగా కనిపిస్తుంది:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START -->outputs = model(**inputs)
<span class="hljs-built_in">print</span>(outputs.last_hidden_state.shape)<!-- HTML_TAG_END --></pre></div> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START -->torch.Size([<span class="hljs-number">2</span>, <span class="hljs-number">16</span>, <span class="hljs-number">768</span>])<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-1s6a6yz">🤗 Transformers మోడళ్ల అవుట్‌పుట్‌లు <code>namedtuple</code>s లేదా dictionaries లాగా ప్రవర్తిస్తాయి. మీరు వాటిని attributes ద్వారా (మనము చేసినట్లుగా), లేదా key (<code>outputs[&quot;last_hidden_state&quot;]</code>), లేదా index ద్వారా (<code>outputs[0]</code>) కూడా యాక్సెస్ చేయవచ్చు.</p> <h3 class="relative group"><a id="model-heads-making-sense-out-of-numbers" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#model-heads-making-sense-out-of-numbers"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>మోడల్ హెడ్‌లు: సంఖ్యలకు అర్థం చెప్పడం</span></h3> <p data-svelte-h="svelte-u9xwnq">మోడల్ హెడ్‌లు hidden states అనే హై-డైమెన్షనల్ వెక్టర్లను తీసుకుని వాటిని వేరే డైమెన్షన్‌కి ప్రాజెక్ట్ చేస్తాయి. ఇవి సాధారణంగా ఒకటి లేదా కొన్ని లీనియర్ లేయర్‌లతో రూపొందుతాయి:</p> <div class="flex justify-center" data-svelte-h="svelte-1lopug5"><img class="block dark:hidden" src="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter2/transformer_and_head.svg" alt="Transformer నెట్‌వర్క్ మరియు దాని హెడ్."> <img class="hidden dark:block" src="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter2/transformer_and_head-dark.svg" alt="Transformer నెట్‌వర్క్ మరియు దాని హెడ్."></div> <p data-svelte-h="svelte-12bpjji">Transformer మోడల్ యొక్క అవుట్‌పుట్ నేరుగా మోడల్ హెడ్‌కు పంపబడుతుంది, అక్కడ అది ప్రాసెస్ చేయబడుతుంది.</p> <p data-svelte-h="svelte-1ys46kt">ఈ చిత్రంలో, మోడల్ తన embeddings layer మరియు దాని తర్వాతి లేయర్‌లతో చూపబడింది. Embeddings layer టోకనైజ్ చేసిన ఇన్‌పుట్‌లోని ప్రతి input ID ను, దానికి సరిపడే token ను ప్రతినిధ్యం చేసే ఒక వెక్టర్‌గా మారుస్తుంది. ఆ తర్వాతి లేయర్‌లు attention mechanism ను ఉపయోగించి ఆ వెక్టర్‌లను మార్చి, వాక్యాల యొక్క తుది ప్రతినిధిని తయారు చేస్తాయి.</p> <p data-svelte-h="svelte-f5xg02">🤗 Transformers లో అనేక విభిన్న architectures ఉన్నాయి, ప్రతి ఒక్కటి ఒక నిర్దిష్ట పనిని పరిష్కరించడానికి రూపొంది ఉంటుంది. ఇవి కొన్ని ఉదాహరణలు:</p> <ul data-svelte-h="svelte-8np89w"><li><code>*Model</code> (hidden states ను పొందడానికి)</li> <li><code>*ForCausalLM</code></li> <li><code>*ForMaskedLM</code></li> <li><code>*ForMultipleChoice</code></li> <li><code>*ForQuestionAnswering</code></li> <li><code>*ForSequenceClassification</code></li> <li><code>*ForTokenClassification</code></li> <li>ఇంకా మరెన్నో 🤗</li></ul> <p data-svelte-h="svelte-zz0sp8">మన ఉదాహరణలో, వాక్యాలు positive లేదా negative అని వర్గీకరించడానికి sequence classification head కలిగిన మోడల్ అవసరం. అందువల్ల మనం <code>AutoModel</code> ను కాకుండా <code>AutoModelForSequenceClassification</code> ను ఉపయోగిస్తాము:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START --><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForSequenceClassification
checkpoint = <span class="hljs-string">&quot;distilbert-base-uncased-finetuned-sst-2-english&quot;</span>
model = AutoModelForSequenceClassification.from_pretrained(checkpoint)
outputs = model(**inputs)<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-11alj6v">ఇప్పుడు మనం అవుట్‌పుట్ యొక్క shape ను చూడగా, dimensionality చాలా తక్కువగా ఉంటుంది: మోడల్ హెడ్, ముందుగా చూసిన హై-డైమెన్షనల్ వెక్టర్లను తీసుకుని, ప్రతి లేబుల్‌కి ఒకటి చొప్పున రెండు విలువలను కలిగిన వెక్టర్లను ఉత్పత్తి చేస్తుంది:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START --><span class="hljs-built_in">print</span>(outputs.logits.shape)<!-- HTML_TAG_END --></pre></div> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START -->torch.Size([<span class="hljs-number">2</span>, <span class="hljs-number">2</span>])<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-13fvc58">మనకు రెండు వాక్యాలు మరియు రెండు లేబుల్స్ ఉన్నందున, మోడల్ ఇవ్వబడే ఫలితం 2 x 2 ఆకారంలో ఉంటుంది.</p> <h2 class="relative group"><a id="postprocessing-the-output" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#postprocessing-the-output"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>అవుట్‌పుట్‌ను పోస్ట్‌ప్రాసెసింగ్ చేయడం</span></h2> <p data-svelte-h="svelte-1s1c8j3">మోడల్ నుండి వచ్చే అవుట్‌పుట్ విలువలు స్వతహాగా అర్థమయ్యే విధంగా ఉండకపోవచ్చు. ఒకసారి చూద్దాం:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START --><span class="hljs-built_in">print</span>(outputs.logits)<!-- HTML_TAG_END --></pre></div> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START -->tensor([[-<span class="hljs-number">1.5607</span>, <span class="hljs-number">1.6123</span>],
[ <span class="hljs-number">4.1692</span>, -<span class="hljs-number">3.3464</span>]], grad_fn=&lt;AddmmBackward&gt;)<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-7a6n8x">మన మోడల్ మొదటి వాక్యానికి <code>[-1.5607, 1.6123]</code> ను, రెండవ వాక్యానికి <code>[ 4.1692, -3.3464]</code> ను అంచనా వేసింది. ఇవి probabilities కావు — ఇవి <em>logits</em>, అంటే మోడల్ చివరి లేయర్ ఉత్పత్తి చేసే raw, unnormalized స్కోర్లు. ఇవి probabilities‌ గా మారాలంటే <a href="https://en.wikipedia.org/wiki/Softmax_function" rel="nofollow">SoftMax</a> లేయర్ ద్వారా పంపాలి.<br>
(అన్ని 🤗 Transformers మోడళ్లు logits ను 출력 చేస్తాయి, ఎందుకంటే ట్రైనింగ్‌లో loss function సాధారణంగా SoftMax వంటి చివరి activation ను cross-entropy వంటి loss తో కలిపి ఉపయోగిస్తుంది.)</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START --><span class="hljs-keyword">import</span> torch
predictions = torch.nn.functional.softmax(outputs.logits, dim=-<span class="hljs-number">1</span>)
<span class="hljs-built_in">print</span>(predictions)<!-- HTML_TAG_END --></pre></div> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START -->tensor([[<span class="hljs-number">4.0195e-02</span>, <span class="hljs-number">9.5980e-01</span>],
[<span class="hljs-number">9.9946e-01</span>, <span class="hljs-number">5.4418e-04</span>]], grad_fn=&lt;SoftmaxBackward&gt;)<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-135mkbp">ఇప్పుడు మనకు స్పష్టంగా కనిపిస్తోంది: మొదటి వాక్యానికి మోడల్ <code>[0.0402, 0.9598]</code>, రెండవ వాక్యానికి <code>[0.9995, 0.0005]</code> probabilities ను ఇచ్చింది. ఇవి అర్థమయ్యే probability స్కోర్లు.</p> <p data-svelte-h="svelte-i7xp8g">ప్రతి స్థానానికి సంబంధించిన లేబుళ్లను తెలుసుకోవడానికి, మోడల్ యొక్క config లోని <code>id2label</code> లక్షణాన్ని చూడవచ్చు (దీని గురించి తరువాతి విభాగంలో మరింత తెలుసుకుంటాము):</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START -->model.config.id2label<!-- HTML_TAG_END --></pre></div> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START -->{<span class="hljs-number">0</span>: <span class="hljs-string">&#x27;NEGATIVE&#x27;</span>, <span class="hljs-number">1</span>: <span class="hljs-string">&#x27;POSITIVE&#x27;</span>}<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-1mz9chx">ఇప్పుడు మనం ఈ విధంగా నిర్ణయించవచ్చు:</p> <ul data-svelte-h="svelte-d1vxyc"><li>మొదటి వాక్యం: NEGATIVE: 0.0402, POSITIVE: 0.9598</li> <li>రెండవ వాక్యం: NEGATIVE: 0.9995, POSITIVE: 0.0005</li></ul> <p data-svelte-h="svelte-ambn2t">ఇలా మనం పైప్‌లైన్‌లోని మూడు దశలను విజయవంతంగా పునరుద్ధరించాము: టోకనైజర్‌తో ప్రీప్రాసెసింగ్, మోడల్ ద్వారా పంపించడం, మరియు పోస్ట్‌ప్రాసెసింగ్!<br>
ఇప్పుడు ఈ ప్రతి దశను మరింత లోతుగా పరిశీలిద్దాం.</p> <blockquote class="tip"><p data-svelte-h="svelte-1exdsb4">✏️ <strong>ప్రయత్నించండి!</strong> మీ స్వంత రెండు (లేదా మరిన్ని) వాక్యాలను ఎంచుకుని వాటిని <code>sentiment-analysis</code> పైప్‌లైన్‌లో నడపండి. తరువాత ఇక్కడ చూపిన దశలను ఒక్కొక్కటిగా పునరావృతం చేసి, అదే ఫలితాలు వస్తున్నాయా చూడండి!</p></blockquote> <a class="!text-gray-400 !no-underline text-sm flex items-center not-prose mt-4" href="https://github.com/huggingface/course/blob/main/chapters/te/chapter2/2.mdx" target="_blank"><svg class="mr-1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M31,16l-7,7l-1.41-1.41L28.17,16l-5.58-5.59L24,9l7,7z"></path><path d="M1,16l7-7l1.41,1.41L3.83,16l5.58,5.59L8,23l-7-7z"></path><path d="M12.419,25.484L17.639,6.552l1.932,0.518L14.351,26.002z"></path></svg> <span data-svelte-h="svelte-zjs2n5"><span class="underline">Update</span> on GitHub</span></a> <p></p>
<script>
{
__sveltekit_1e95xo9 = {
assets: "/docs/course/pr_1149/te",
base: "/docs/course/pr_1149/te",
env: {}
};
const element = document.currentScript.parentElement;
const data = [null,null];
Promise.all([
import("/docs/course/pr_1149/te/_app/immutable/entry/start.eee4c1e0.js"),
import("/docs/course/pr_1149/te/_app/immutable/entry/app.0f38558a.js")
]).then(([kit, app]) => {
kit.start(app, element, {
node_ids: [0, 15],
data,
form: null,
error: null
});
});
}
</script>

Xet Storage Details

Size:
67.8 kB
·
Xet hash:
db65f933d9ae551af81113cf71406f8330868eca215bf23d402a374bfcf72c84

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.