Buckets:
| <meta charset="utf-8" /><meta name="hf:doc:metadata" content="{"title":"Error တစ်ခုရတဲ့အခါ ဘာလုပ်ရမလဲ။","local":"what-to-do-when-you-get-an-error","sections":[{"title":"🤗 Transformers ရဲ့ pipeline ကို Debug လုပ်ခြင်း","local":"debugging-the-pipeline-from-transformers","sections":[],"depth":2},{"title":"သင့် Model ၏ Forward Pass ကို Debug လုပ်ခြင်း","local":"debugging-the-forward-pass-of-your-model","sections":[],"depth":2},{"title":"ဝေါဟာရ ရှင်းလင်းချက် (Glossary)","local":"ဝဟရ-ရငလငခက-glossary","sections":[],"depth":2}],"depth":1}"> | |
| <link href="/docs/course/pr_1095/my/_app/immutable/assets/0.e3b0c442.css" rel="modulepreload"> | |
| <link rel="modulepreload" href="/docs/course/pr_1095/my/_app/immutable/entry/start.8e25cab6.js"> | |
| <link rel="modulepreload" href="/docs/course/pr_1095/my/_app/immutable/chunks/scheduler.893fe8c9.js"> | |
| <link rel="modulepreload" href="/docs/course/pr_1095/my/_app/immutable/chunks/singletons.ba455c5c.js"> | |
| <link rel="modulepreload" href="/docs/course/pr_1095/my/_app/immutable/chunks/index.bce52c8a.js"> | |
| <link rel="modulepreload" href="/docs/course/pr_1095/my/_app/immutable/chunks/paths.9a7be869.js"> | |
| <link rel="modulepreload" href="/docs/course/pr_1095/my/_app/immutable/entry/app.b12ce275.js"> | |
| <link rel="modulepreload" href="/docs/course/pr_1095/my/_app/immutable/chunks/preload-helper.b5ee8f74.js"> | |
| <link rel="modulepreload" href="/docs/course/pr_1095/my/_app/immutable/chunks/index.b1df2166.js"> | |
| <link rel="modulepreload" href="/docs/course/pr_1095/my/_app/immutable/nodes/0.77c840e7.js"> | |
| <link rel="modulepreload" href="/docs/course/pr_1095/my/_app/immutable/chunks/each.e59479a4.js"> | |
| <link rel="modulepreload" href="/docs/course/pr_1095/my/_app/immutable/nodes/87.cacb6412.js"> | |
| <link rel="modulepreload" href="/docs/course/pr_1095/my/_app/immutable/chunks/MermaidChart.svelte_svelte_type_style_lang.e6d31e72.js"> | |
| <link rel="modulepreload" href="/docs/course/pr_1095/my/_app/immutable/chunks/Youtube.ec5d7916.js"> | |
| <link rel="modulepreload" href="/docs/course/pr_1095/my/_app/immutable/chunks/CodeBlock.abb4f40e.js"> | |
| <link rel="modulepreload" href="/docs/course/pr_1095/my/_app/immutable/chunks/CourseFloatingBanner.c1c08878.js"> | |
| <link rel="modulepreload" href="/docs/course/pr_1095/my/_app/immutable/chunks/FrameworkSwitchCourse.4480e339.js"><!-- HEAD_svelte-u9bgzb_START --><meta name="hf:doc:metadata" content="{"title":"Error တစ်ခုရတဲ့အခါ ဘာလုပ်ရမလဲ။","local":"what-to-do-when-you-get-an-error","sections":[{"title":"🤗 Transformers ရဲ့ pipeline ကို Debug လုပ်ခြင်း","local":"debugging-the-pipeline-from-transformers","sections":[],"depth":2},{"title":"သင့် Model ၏ Forward Pass ကို Debug လုပ်ခြင်း","local":"debugging-the-forward-pass-of-your-model","sections":[],"depth":2},{"title":"ဝေါဟာရ ရှင်းလင်းချက် (Glossary)","local":"ဝဟရ-ရငလငခက-glossary","sections":[],"depth":2}],"depth":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="what-to-do-when-you-get-an-error" 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="#what-to-do-when-you-get-an-error"><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>Error တစ်ခုရတဲ့အခါ ဘာလုပ်ရမလဲ။</span></h1> <div class="flex space-x-1 absolute z-10 right-0 top-0" style=""><a href="https://discuss.huggingface.co/t/chapter-8-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/chapter8/section2.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/chapter8/section2.ipynb" target="_blank"><img alt="Open In Studio Lab" class="!m-0" src="https://studiolab.sagemaker.aws/studiolab.svg"></a></div> <p data-svelte-h="svelte-1t2rxvn">ဒီအပိုင်းမှာ သင် အသစ် tune လုပ်ထားတဲ့ Transformer model ကနေ predictions တွေ ထုတ်လုပ်ဖို့ ကြိုးစားတဲ့အခါ ဖြစ်ပေါ်နိုင်တဲ့ အဖြစ်များတဲ့ errors အချို့ကို ကြည့်ရပါမယ်။ ဒါက <a href="/course/chapter8/section4">အပိုင်း ၄</a> အတွက် သင့်ကို ပြင်ဆင်ပေးပါလိမ့်မယ်။ အဲဒီမှာ ကျွန်တော်တို့ training phase ကို ဘယ်လို debug လုပ်ရမလဲဆိုတာ လေ့လာသွားမှာပါ။</p> <iframe class="w-full xl:w-4/6 h-80" src="https://www.youtube-nocookie.com/embed/DQ-CpJn6Rc4" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> <p data-svelte-h="svelte-14ig579">ဒီအပိုင်းအတွက် <a href="https://huggingface.co/lewtun/distilbert-base-uncased-finetuned-squad-d5716d28" rel="nofollow">template model repository</a> တစ်ခုကို ကျွန်တော်တို့ ပြင်ဆင်ထားပါတယ်။ ဒီအခန်းမှာ code ကို run ချင်တယ်ဆိုရင် ပထမဆုံး model ကို သင်ရဲ့ account ပေါ်က <a href="https://huggingface.co" rel="nofollow">Hugging Face Hub</a> သို့ copy လုပ်ဖို့ လိုအပ်ပါလိမ့်မယ်။ ဒါကိုလုပ်ဖို့၊ Jupyter notebook မှာ အောက်ပါတို့ကို run ခြင်းဖြင့် အရင်ဆုံး log in ဝင်ပါ။</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> huggingface_hub <span class="hljs-keyword">import</span> notebook_login | |
| notebook_login()<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-1miijx6">သို့မဟုတ် သင်အကြိုက်ဆုံး terminal မှာ အောက်ပါတို့ကို run ပါ။</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 -->huggingface-cli login<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-148qdc7">ဒါက သင့် username နဲ့ password ကို ထည့်သွင်းဖို့ တောင်းဆိုပါလိမ့်မယ်၊ ပြီးတော့ token တစ်ခုကို <em>~/.cache/huggingface/</em> အောက်မှာ သိမ်းဆည်းပါလိမ့်မယ်။ log in ဝင်ပြီးတာနဲ့၊ အောက်ပါ function နဲ့ template repository ကို copy လုပ်နိုင်ပါတယ်။</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> distutils.dir_util <span class="hljs-keyword">import</span> copy_tree | |
| <span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> Repository, snapshot_download, create_repo, get_full_repo_name | |
| <span class="hljs-keyword">def</span> <span class="hljs-title function_">copy_repository_template</span>(): | |
| <span class="hljs-comment"># repo ကို clone လုပ်ပြီး local path ကို ထုတ်ယူပါ</span> | |
| template_repo_id = <span class="hljs-string">"lewtun/distilbert-base-uncased-finetuned-squad-d5716d28"</span> | |
| commit_hash = <span class="hljs-string">"be3eaffc28669d7932492681cd5f3e8905e358b4"</span> | |
| template_repo_dir = snapshot_download(template_repo_id, revision=commit_hash) | |
| <span class="hljs-comment"># Hub ပေါ်မှာ empty repo တစ်ခု ဖန်တီးပါ</span> | |
| model_name = template_repo_id.split(<span class="hljs-string">"/"</span>)[<span class="hljs-number">1</span>] | |
| create_repo(model_name, exist_ok=<span class="hljs-literal">True</span>) | |
| <span class="hljs-comment"># empty repo ကို clone လုပ်ပါ</span> | |
| new_repo_id = get_full_repo_name(model_name) | |
| new_repo_dir = model_name | |
| repo = Repository(local_dir=new_repo_dir, clone_from=new_repo_id) | |
| <span class="hljs-comment"># ဖိုင်တွေကို copy လုပ်ပါ</span> | |
| copy_tree(template_repo_dir, new_repo_dir) | |
| <span class="hljs-comment"># Hub သို့ push လုပ်ပါ</span> | |
| repo.push_to_hub()<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-1m0w5da">အခု <code>copy_repository_template()</code> ကို ခေါ်လိုက်တဲ့အခါ၊ ဒါက template repository ရဲ့ copy တစ်ခုကို သင့် account အောက်မှာ ဖန်တီးပါလိမ့်မယ်။</p> <h2 class="relative group"><a id="debugging-the-pipeline-from-transformers" 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="#debugging-the-pipeline-from-transformers"><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>🤗 Transformers ရဲ့ pipeline ကို Debug လုပ်ခြင်း</span></h2> <p data-svelte-h="svelte-i5l3yn">Transformer models တွေကို debug လုပ်တဲ့ အံ့ဖွယ်ကောင်းတဲ့ ကမ္ဘာဆီ ကျွန်တော်တို့ရဲ့ ခရီးကို စတင်ဖို့အတွက်၊ အောက်ပါအခြေအနေကို စဉ်းစားကြည့်ပါ- သင်ဟာ e-commerce website တစ်ခုက customers တွေကို consumer products တွေအကြောင်း အဖြေရှာဖို့ ကူညီဖို့အတွက် question answering project တစ်ခုမှာ လုပ်ဖော်ကိုင်ဖက်တစ်ဦးနဲ့ အလုပ်လုပ်နေပါတယ်။ သင့်လုပ်ဖော်ကိုင်ဖက်က သင့်ဆီကို အောက်ပါစာတစ်စောင် ပို့လိုက်ပါတယ်။</p> <blockquote data-svelte-h="svelte-1n5rjch"><p>G’day! ကျွန်တော် Hugging Face course ရဲ့ <a href="/course/chapter7/7">Chapter 7</a> မှာပါတဲ့ နည်းလမ်းတွေကို အသုံးပြုပြီး experiment တစ်ခု run ခဲ့တာ SQuAD ပေါ်မှာ ရလဒ်ကောင်းတွေ ရခဲ့တယ်။ ကျွန်တော်တို့ ဒီ model ကို ကျွန်တော်တို့ project အတွက် starting point အဖြစ် အသုံးပြုနိုင်မယ်လို့ ထင်တယ်။ Hub ပေါ်က model ID က “lewtun/distillbert-base-uncased-finetuned-squad-d5716d28” ပါ။ စိတ်ကြိုက် စမ်းသပ်ကြည့်ပါ။ :)</p></blockquote> <p data-svelte-h="svelte-i8x7xk">ပြီးတော့ သင်ပထမဆုံး တွေးမိတာက 🤗 Transformers က <code>pipeline</code> ကို အသုံးပြုပြီး model ကို load လုပ်ဖို့ပါပဲ။</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 | |
| model_checkpoint = get_full_repo_name(<span class="hljs-string">"distillbert-base-uncased-finetuned-squad-d5716d28"</span>) | |
| reader = pipeline(<span class="hljs-string">"question-answering"</span>, model=model_checkpoint)<!-- 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-string">""" | |
| OSError: Can't load config for 'lewtun/distillbert-base-uncased-finetuned-squad-d5716d28'. Make sure that: | |
| - 'lewtun/distillbert-base-uncased-finetuned-squad-d5716d28' is a correct model identifier listed on 'https://huggingface.co/models' | |
| - or 'lewtun/distillbert-base-uncased-finetuned-squad-d5716d28' is the correct path to a directory containing a config.json file | |
| """</span><!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-11kw6b1">ဟာ မဟုတ်သေးဘူး၊ တစ်ခုခု မှားနေပုံရတယ်။ သင် programming နဲ့ အခုမှ စတင်သူဆိုရင် ဒီလို errors တွေက ပထမတော့ နားမလည်နိုင်ပုံရနိုင်ပါတယ် (<code>OSError</code> ဆိုတာ ဘာလဲ?! )။ ဒီမှာ ပြသထားတဲ့ error က Python traceback (aka stack trace) လို့ခေါ်တဲ့ အများကြီး ပိုကြီးတဲ့ error report ရဲ့ နောက်ဆုံးအပိုင်းပဲ ရှိပါသေးတယ်။ ဥပမာ၊ ဒီ code ကို Google Colab မှာ run နေတယ်ဆိုရင်၊ အောက်ပါ screenshot လိုမျိုး တစ်ခုခုကို သင်တွေ့ရပါလိမ့်မယ်။</p> <div class="flex justify-center" data-svelte-h="svelte-1196hzp"><img src="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter8/traceback.png" alt="A Python traceback." width="100%"></div> <p data-svelte-h="svelte-1bvkwfu">ဒီ reports တွေထဲမှာ အချက်အလက်များစွာ ပါဝင်တာကြောင့်၊ အဓိက အစိတ်အပိုင်းတွေကို အတူတူ လေ့လာကြည့်ရအောင်။ ပထမဆုံး သတိပြုရမယ့်အချက်က tracebacks တွေကို <em>အောက်ကနေ အပေါ်သို့</em> ဖတ်ရတာပါပဲ။ English စာသားကို အပေါ်ကနေ အောက်ကို ဖတ်လေ့ရှိတဲ့ သင်အတွက် ဒါက ထူးဆန်းနိုင်ပါတယ်၊ ဒါပေမယ့် ဒါက model နဲ့ tokenizer ကို download လုပ်တဲ့အခါ <code>pipeline</code> က လုပ်ဆောင်တဲ့ function calls တွေရဲ့ sequence ကို traceback က ပြသနေတာကို ထင်ဟပ်ပါတယ်။ (<code>pipeline</code> က ဘယ်လိုအလုပ်လုပ်တယ်ဆိုတာ အသေးစိတ်သိရှိဖို့ <a href="/course/chapter2">Chapter 2</a> ကို ကြည့်ပါ)။</p> <blockquote class="tip" data-svelte-h="svelte-bdyeg"><p>🚨 Google Colab က traceback မှာ “6 frames” ကို ဝန်းရံထားတဲ့ အပြာရောင် box ကို တွေ့လား? ဒါက Colab ရဲ့ special feature တစ်ခုဖြစ်ပြီး traceback ကို “frames” တွေအဖြစ် ဖိသိပ်ထားပါတယ်။ error ရဲ့ source ကို မရှာတွေ့ဘူးဆိုရင်၊ အဲဒီ မြှားနှစ်စင်းကို နှိပ်ပြီး traceback အပြည့်အစုံကို ချဲ့ကြည့်ဖို့ သေချာပါစေ။</p></blockquote> <p data-svelte-h="svelte-1461amc">ဒါက traceback ရဲ့ နောက်ဆုံးလိုင်းက နောက်ဆုံး error message ကို ဖော်ပြပြီး raise လုပ်ခဲ့တဲ့ exception ရဲ့ နာမည်ကို ပေးတယ်လို့ ဆိုလိုပါတယ်။ ဒီကိစ္စမှာ exception အမျိုးအစားက <code>OSError</code> ဖြစ်ပြီး၊ ဒါက system နဲ့ ဆက်စပ်တဲ့ error တစ်ခုကို ဖော်ပြပါတယ်။ အတူပါလာတဲ့ error message ကို ဖတ်ကြည့်မယ်ဆိုရင်၊ model ရဲ့ <em>config.json</em> file မှာ ပြဿနာတစ်ခုခု ရှိပုံရတယ်ဆိုတာ မြင်ရပြီး၊ ဒါကို ဖြေရှင်းဖို့ အကြံပြုချက်နှစ်ခု ပေးထားပါတယ်။</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">""" | |
| Make sure that: | |
| - 'lewtun/distillbert-base-uncased-finetuned-squad-d5716d28' is a correct model identifier listed on 'https://huggingface.co/models' | |
| - or 'lewtun/distillbert-base-uncased-finetuned-squad-d5716d28' is the correct path to a directory containing a config.json file | |
| """</span><!-- HTML_TAG_END --></pre></div> <blockquote class="tip" data-svelte-h="svelte-gbefww"><p>💡 နားလည်ရခက်တဲ့ error message တစ်ခု ကြုံတွေ့ရရင်၊ message ကို Google ဒါမှမဟုတ် <a href="https://stackoverflow.com/" rel="nofollow">Stack Overflow</a> ရဲ့ search bar ထဲကို copy လုပ်ပြီး paste လုပ်လိုက်ပါ (တကယ်ပါပဲ!)။ သင်ဟာ error ကို ပထမဆုံး ကြုံတွေ့ရသူ မဟုတ်နိုင်တာကြောင့်၊ community ထဲက တခြားသူတွေ တင်ထားတဲ့ ဖြေရှင်းနည်းတွေကို ရှာဖွေဖို့ ဒါက ကောင်းမွန်တဲ့ နည်းလမ်းတစ်ခုပါပဲ။ ဥပမာ၊ Stack Overflow ပေါ်မှာ <code>OSError: Can't load config for</code> ကို ရှာဖွေကြည့်မယ်ဆိုရင် ပြဿနာကို ဖြေရှင်းဖို့ starting point အဖြစ် အသုံးပြုနိုင်တဲ့ <a href="https://stackoverflow.com/search?q=OSError%3A+Can%27t+load+config+for+" rel="nofollow">hits</a> အချို့ကို ပေးပါလိမ့်မယ်။</p></blockquote> <p data-svelte-h="svelte-z1be2q">ပထမဆုံး အကြံပြုချက်က model ID မှန်ကန်ခြင်းရှိမရှိ စစ်ဆေးခိုင်းတာကြောင့်၊ ပထမဆုံး လုပ်ရမယ့်အလုပ်က identifier ကို copy လုပ်ပြီး Hub ရဲ့ search bar ထဲကို paste လုပ်ဖို့ပါပဲ။</p> <div class="flex justify-center" data-svelte-h="svelte-6ebc1j"><img src="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter8/wrong-model-id.png" alt="The wrong model name." width="100%"></div> <p data-svelte-h="svelte-1xgwmvo">အင်း၊ ကျွန်တော်တို့ လုပ်ဖော်ကိုင်ဖက်ရဲ့ model က Hub မှာ မရှိပုံရတယ်… ဟာ၊ ဒါပေမယ့် model ရဲ့ နာမည်မှာ typo တစ်ခုရှိနေတယ်။ DistilBERT မှာ “l” တစ်လုံးပဲ ပါတာကြောင့်၊ ဒါကို ပြင်ပြီး “lewtun/distilbert-base-uncased-finetuned-squad-d5716d28” ကို အစားရှာကြည့်ရအောင်။</p> <div class="flex justify-center" data-svelte-h="svelte-1b95mxr"><img src="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter8/true-model-id.png" alt="The right model name." width="100%"></div> <p data-svelte-h="svelte-izr02d">ကောင်းပြီ၊ ဒါက hit တစ်ခုရခဲ့တယ်။ အခုမှန်ကန်တဲ့ model ID နဲ့ model ကို ထပ်မံ download လုပ်ကြည့်ရအောင်…</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_checkpoint = get_full_repo_name(<span class="hljs-string">"distilbert-base-uncased-finetuned-squad-d5716d28"</span>) | |
| reader = pipeline(<span class="hljs-string">"question-answering"</span>, model=model_checkpoint)<!-- 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-string">""" | |
| OSError: Can't load config for 'lewtun/distilbert-base-uncased-finetuned-squad-d5716d28'. Make sure that: | |
| - 'lewtun/distilbert-base-uncased-finetuned-squad-d5716d28' is a correct model identifier listed on 'https://huggingface.co/models' | |
| - or 'lewtun/distilbert-base-uncased-finetuned-squad-d5716d28' is the correct path to a directory containing a config.json file | |
| """</span><!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-nqu67u">ဟာ၊ ထပ်ပြီး ဖျက်ဆီးခံရပြန်ပြီ — machine learning engineer တစ်ယောက်ရဲ့ နေ့စဉ်ဘဝကို ကြိုဆိုပါတယ်။ model ID ကို ကျွန်တော်တို့ ပြင်ဆင်ပြီးသွားပြီဖြစ်တဲ့အတွက်၊ ပြဿနာက repository ထဲမှာ ရှိနေရပါမယ်။ 🤗 Hub ပေါ်က repository တစ်ခုရဲ့ အကြောင်းအရာတွေကို မြန်မြန်ဆန်ဆန် ဝင်ရောက်ကြည့်ရှုဖို့ နည်းလမ်းတစ်ခုက <code>huggingface_hub</code> library ရဲ့ <code>list_repo_files()</code> function ကို အသုံးပြုခြင်းပါပဲ။</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> huggingface_hub <span class="hljs-keyword">import</span> list_repo_files | |
| list_repo_files(repo_id=model_checkpoint)<!-- 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-string">'.gitattributes'</span>, <span class="hljs-string">'README.md'</span>, <span class="hljs-string">'pytorch_model.bin'</span>, <span class="hljs-string">'special_tokens_map.json'</span>, <span class="hljs-string">'tokenizer_config.json'</span>, <span class="hljs-string">'training_args.bin'</span>, <span class="hljs-string">'vocab.txt'</span>]<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-1vfz8rs">စိတ်ဝင်စားစရာကောင်းတယ် — repository ထဲမှာ <em>config.json</em> file မရှိပုံရဘူး။ ကျွန်တော်တို့ရဲ့ <code>pipeline</code> က model ကို load မလုပ်နိုင်တာ အံ့သြစရာမရှိပါဘူး၊ ကျွန်တော်တို့ လုပ်ဖော်ကိုင်ဖက်က fine-tune လုပ်ပြီးနောက် ဒီ file ကို Hub သို့ push လုပ်ဖို့ မေ့သွားတာ ဖြစ်ရပါမယ်။ ဒီကိစ္စမှာ၊ ပြဿနာက ဖြေရှင်းရတာ ရိုးရှင်းပုံရပါတယ်- သူတို့ကို file ထည့်ဖို့ တောင်းဆိုနိုင်ပါတယ်၊ ဒါမှမဟုတ် model ID ကနေ pretrained model က <a href="https://huggingface.co/distilbert-base-uncased" rel="nofollow"><code>distilbert-base-uncased</code></a> ဖြစ်တယ်ဆိုတာ မြင်ရတာကြောင့်၊ ဒီ model အတွက် config ကို download လုပ်ပြီး ကျွန်တော်တို့ repo ကို push လုပ်ခြင်းဖြင့် ပြဿနာဖြေရှင်းနိုင်မလားဆိုတာ ကြည့်နိုင်ပါတယ်။ အဲဒါကို စမ်းကြည့်ရအောင်။ <a href="/course/chapter2">Chapter 2</a> မှာ ကျွန်တော်တို့ သင်ယူခဲ့တဲ့ နည်းလမ်းတွေကို အသုံးပြုပြီး၊ model ရဲ့ configuration ကို <code>AutoConfig</code> class နဲ့ download လုပ်နိုင်ပါတယ်။</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> AutoConfig | |
| pretrained_checkpoint = <span class="hljs-string">"distilbert-base-uncased"</span> | |
| config = AutoConfig.from_pretrained(pretrained_checkpoint)<!-- HTML_TAG_END --></pre></div> <blockquote class="warning" data-svelte-h="svelte-hfx7yk"><p>🚨 ကျွန်တော်တို့ ဒီနေရာမှာ အသုံးပြုနေတဲ့ နည်းလမ်းက အမြဲတမ်း မှန်ကန်တာ မဟုတ်ပါဘူး၊ ဘာလို့လဲဆိုတော့ ကျွန်တော်တို့ လုပ်ဖော်ကိုင်ဖက်က model ကို fine-tuning မလုပ်ခင် <code>distilbert-base-uncased</code> ရဲ့ configuration ကို ပြောင်းလဲထားနိုင်လို့ပါပဲ။ တကယ့်ဘဝမှာတော့ ကျွန်တော်တို့ အရင်ဆုံး သူတို့နဲ့ စစ်ဆေးချင်ပါလိမ့်မယ်၊ ဒါပေမယ့် ဒီအပိုင်းရဲ့ ရည်ရွယ်ချက်အတွက်တော့ သူတို့က default configuration ကို အသုံးပြုခဲ့တယ်လို့ ယူဆပါမယ်။</p></blockquote> <p data-svelte-h="svelte-1hdxrye">ပြီးရင် ဒါကို configuration ရဲ့ <code>push_to_hub()</code> function နဲ့ ကျွန်တော်တို့ရဲ့ model repository ကို push လုပ်နိုင်ပါတယ်။</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 -->config.push_to_hub(model_checkpoint, commit_message=<span class="hljs-string">"Add config.json"</span>)<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-1bzlx5x">အခု <code>main</code> branch ပေါ်က နောက်ဆုံး commit ကနေ model ကို load လုပ်ခြင်းဖြင့် ဒါက အလုပ်ဖြစ်လားဆိုတာ စစ်ဆေးနိုင်ပါပြီ-</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 -->reader = pipeline(<span class="hljs-string">"question-answering"</span>, model=model_checkpoint, revision=<span class="hljs-string">"main"</span>) | |
| context = <span class="hljs-string">r""" | |
| Extractive Question Answering is the task of extracting an answer from a text | |
| given a question. An example of a question answering dataset is the SQuAD | |
| dataset, which is entirely based on that task. If you would like to fine-tune a | |
| model on a SQuAD task, you may leverage the | |
| examples/pytorch/question-answering/run_squad.py script. | |
| 🤗 Transformers is interoperable with the PyTorch, TensorFlow, and JAX | |
| frameworks, so you can use your favourite tools for a wide variety of tasks! | |
| """</span> | |
| question = <span class="hljs-string">"What is extractive question answering?"</span> | |
| reader(question=question, context=context)<!-- 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-string">'score'</span>: <span class="hljs-number">0.38669535517692566</span>, | |
| <span class="hljs-string">'start'</span>: <span class="hljs-number">34</span>, | |
| <span class="hljs-string">'end'</span>: <span class="hljs-number">95</span>, | |
| <span class="hljs-string">'answer'</span>: <span class="hljs-string">'the task of extracting an answer from a text given a question'</span>}<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-5k2cep">ဝိုး၊ အလုပ်ဖြစ်သွားပြီ! သင် ခုလေးတင် သင်ယူခဲ့တာတွေကို ပြန်လည်အကျဉ်းချုပ်ကြည့်ရအောင်…</p> <ul data-svelte-h="svelte-1l4fpt8"><li>Python မှာ errors တွေကို <em>tracebacks</em> လို့သိကြပြီး အောက်ကနေ အပေါ်သို့ ဖတ်ရပါတယ်။ error message ရဲ့ နောက်ဆုံးလိုင်းက ပြဿနာရဲ့ source ကို ရှာဖွေဖို့ လိုအပ်တဲ့ အချက်အလက်တွေကို အများအားဖြင့် ပါဝင်ပါတယ်။</li> <li>နောက်ဆုံးလိုင်းမှာ လုံလောက်တဲ့ အချက်အလက်တွေ မပါဝင်ဘူးဆိုရင်၊ traceback ကို အပေါ်ကိုတက်ပြီး error ဘယ်နေရာမှာ ဖြစ်ခဲ့လဲဆိုတာ source code ထဲမှာ ဖော်ထုတ်နိုင်မလားဆိုတာ ကြည့်ပါ။</li> <li>error messages တွေထဲက တစ်ခုမှ သင့်ကို ပြဿနာ debug လုပ်ဖို့ မကူညီနိုင်ဘူးဆိုရင်၊ အလားတူပြဿနာအတွက် online မှာ ဖြေရှင်းနည်း ရှာဖွေကြည့်ပါ။</li> <li><code>huggingface_hub</code> library က Hub ပေါ်က repositories တွေနဲ့ အပြန်အလှန်တုံ့ပြန်ဖို့နဲ့ debug လုပ်ဖို့ အသုံးပြုနိုင်တဲ့ ကိရိယာအစုံအလင်ကို ပံ့ပိုးပေးပါတယ်။</li></ul> <p data-svelte-h="svelte-19ku3f6">အခု pipeline ကို ဘယ်လို debug လုပ်ရမလဲဆိုတာ သင်သိပြီဆိုတော့၊ model ရဲ့ forward pass မှာ ပိုမိုခက်ခဲတဲ့ ဥပမာတစ်ခုကို ကြည့်ရအောင်။</p> <h2 class="relative group"><a id="debugging-the-forward-pass-of-your-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="#debugging-the-forward-pass-of-your-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>သင့် Model ၏ Forward Pass ကို Debug လုပ်ခြင်း</span></h2> <p data-svelte-h="svelte-kc3kde"><code>pipeline</code> က predictions တွေကို မြန်မြန်ဆန်ဆန် ထုတ်လုပ်ဖို့ လိုအပ်တဲ့ applications အများစုအတွက် ကောင်းမွန်ပေမယ့်၊ တခါတလေ model ရဲ့ logits တွေကို ဝင်ရောက်ကြည့်ရှုဖို့ လိုအပ်ပါလိမ့်မယ် (ဥပမာ- သင်အသုံးပြုချင်တဲ့ custom post-processing အချို့ရှိရင်)။ ဒီကိစ္စမှာ ဘာတွေမှားနိုင်သလဲဆိုတာ ကြည့်ဖို့၊ ကျွန်တော်တို့ရဲ့ <code>pipeline</code> ကနေ model နဲ့ tokenizer ကို အရင်ဆုံး ယူလိုက်ရအောင်။</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 -->tokenizer = reader.tokenizer | |
| model = reader.model<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-9o70rb">နောက်ထပ် မေးခွန်းတစ်ခု လိုအပ်တာကြောင့်၊ ကျွန်တော်တို့ အကြိုက်ဆုံး frameworks တွေကို ထောက်ပံ့ပေးထားခြင်းရှိမရှိ ကြည့်ရအောင်။</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 -->question = <span class="hljs-string">"Which frameworks can I use?"</span><!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-p0rxnd"><a href="/course/chapter7">Chapter 7</a> မှာ ကျွန်တော်တို့ တွေ့ခဲ့ရတဲ့အတိုင်း၊ ကျွန်တော်တို့ လုပ်ဆောင်ရမယ့် ပုံမှန်အဆင့်တွေက inputs တွေကို tokenize လုပ်တာ၊ start နဲ့ end tokens တွေရဲ့ logits တွေကို ထုတ်ယူတာ၊ ပြီးတော့ answer span ကို decode လုပ်တာတွေပါပဲ-</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 | |
| inputs = tokenizer(question, context, add_special_tokens=<span class="hljs-literal">True</span>) | |
| input_ids = inputs[<span class="hljs-string">"input_ids"</span>][<span class="hljs-number">0</span>] | |
| outputs = model(**inputs) | |
| answer_start_scores = outputs.start_logits | |
| answer_end_scores = outputs.end_logits | |
| <span class="hljs-comment"># score ရဲ့ argmax နဲ့ answer ရဲ့ အဖြစ်နိုင်ဆုံး အစကို ရယူပါ</span> | |
| answer_start = torch.argmax(answer_start_scores) | |
| <span class="hljs-comment"># score ရဲ့ argmax နဲ့ answer ရဲ့ အဖြစ်နိုင်ဆုံး အဆုံးကို ရယူပါ</span> | |
| answer_end = torch.argmax(answer_end_scores) + <span class="hljs-number">1</span> | |
| answer = tokenizer.convert_tokens_to_string( | |
| tokenizer.convert_ids_to_tokens(input_ids[answer_start:answer_end]) | |
| ) | |
| <span class="hljs-built_in">print</span>(<span class="hljs-string">f"Question: <span class="hljs-subst">{question}</span>"</span>) | |
| <span class="hljs-built_in">print</span>(<span class="hljs-string">f"Answer: <span class="hljs-subst">{answer}</span>"</span>)<!-- 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-string">""" | |
| --------------------------------------------------------------------------- | |
| AttributeError Traceback (most recent call last) | |
| /var/folders/28/k4cy5q7s2hs92xq7_h89_vgm0000gn/T/ipykernel_75743/2725838073.py in <module> | |
| 1 inputs = tokenizer(question, text, add_special_tokens=True) | |
| 2 input_ids = inputs["input_ids"] | |
| ----> 3 outputs = model(**inputs) | |
| 4 answer_start_scores = outputs.start_logits | |
| 5 answer_end_scores = outputs.end_logits | |
| ~/miniconda3/envs/huggingface/lib/python3.8/site-packages/torch/nn/modules/module.py in _call_impl(self, *input, **kwargs) | |
| 1049 if not (self._backward_hooks or self._forward_hooks or self._forward_pre_hooks or _global_backward_hooks | |
| 1050 or _global_forward_hooks or _global_forward_pre_hooks): | |
| -> 1051 return forward_call(*input, **kwargs) | |
| 1052 # Do not call functions when jit is used | |
| 1053 full_backward_hooks, non_full_backward_hooks = [], [] | |
| ~/miniconda3/envs/huggingface/lib/python3.8/site-packages/transformers/models/distilbert/modeling_distilbert.py in forward(self, input_ids, attention_mask, head_mask, inputs_embeds, start_positions, end_positions, output_attentions, output_hidden_states, return_dict) | |
| 723 return_dict = return_dict if return_dict is not None else self.config.use_return_dict | |
| 724 | |
| --> 725 distilbert_output = self.distilbert( | |
| 725 distilbert_output = self.distilbert( | |
| 726 input_ids=input_ids, | |
| 727 attention_mask=attention_mask, | |
| ~/miniconda3/envs/huggingface/lib/python3.8/site-packages/torch/nn/modules/module.py in _call_impl(self, *input, **kwargs) | |
| 1049 if not (self._backward_hooks or self._forward_hooks or self._forward_pre_hooks or _global_backward_hooks | |
| 1050 or _global_forward_hooks or _global_forward_pre_hooks): | |
| -> 1051 return forward_call(*input, **kwargs) | |
| 1052 # Do not call functions when jit is used | |
| 1053 full_backward_hooks, non_full_backward_hooks = [], [] | |
| ~/miniconda3/envs/huggingface/lib/python3.8/site-packages/transformers/models/distilbert/modeling_distilbert.py in forward(self, input_ids, attention_mask, head_mask, inputs_embeds, output_attentions, output_hidden_states, return_dict) | |
| 471 raise ValueError("You cannot specify both input_ids and inputs_embeds at the same time") | |
| 472 elif input_ids is not None: | |
| --> 473 input_shape = input_ids.size() | |
| 474 elif inputs_embeds is not None: | |
| 475 input_shape = inputs_embeds.size()[:-1] | |
| AttributeError: 'list' object has no attribute 'size' | |
| """</span><!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-13aa4kv">ဟာ၊ ကျွန်တော်တို့ code ထဲမှာ bug တစ်ခုရှိပုံရတယ်။ ဒါပေမယ့် ကျွန်တော်တို့ debug လုပ်ရတာ မကြောက်ပါဘူး။ Python debugger ကို notebook မှာ အသုံးပြုနိုင်ပါတယ်။</p> <iframe class="w-full xl:w-4/6 h-80" src="https://www.youtube-nocookie.com/embed/rSPyvPw0p9k" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> <p data-svelte-h="svelte-1dhys0v">ဒါမှမဟုတ် terminal မှာ-</p> <iframe class="w-full xl:w-4/6 h-80" src="https://www.youtube-nocookie.com/embed/5PkZ4rbHL6c" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> <p data-svelte-h="svelte-15fazy4">ဒီနေရာမှာ error message က <code>'list' object has no attribute 'size'</code> လို့ ပြောထားတာကို မြင်ရပြီး၊ <code>model(**inputs)</code> မှာ ပြဿနာဖြစ်ပွားခဲ့တဲ့ လိုင်းကို <code>--></code> မြှားက ညွှန်ပြနေတာကို မြင်ရပါတယ်။ ဒါကို Python debugger ကို အသုံးပြုပြီး interactive mode နဲ့ debug လုပ်နိုင်ပါတယ်၊ ဒါပေမယ့် အခုတော့ ကျွန်တော်တို့ <code>inputs</code> ရဲ့ slice တစ်ခုကို ရိုးရှင်းစွာ print ထုတ်ပြီး ဘာတွေရှိသလဲဆိုတာ ကြည့်ရအောင်။</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 -->inputs[<span class="hljs-string">"input_ids"</span>][:<span class="hljs-number">5</span>]<!-- 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">101</span>, <span class="hljs-number">2029</span>, <span class="hljs-number">7705</span>, <span class="hljs-number">2015</span>, <span class="hljs-number">2064</span>]<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-12uahxw">ဒါက သာမန် Python <code>list</code> တစ်ခုလိုတော့ မြင်ရပါတယ်၊ ဒါပေမယ့် type ကို ထပ်စစ်ကြည့်ရအောင်။</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">type</span>(inputs[<span class="hljs-string">"input_ids"</span>])<!-- 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-built_in">list</span><!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-gnjxjj">ဟုတ်တယ်၊ ဒါက Python <code>list</code> တစ်ခု သေချာပါတယ်။ ဒါဆို ဘာမှားခဲ့တာလဲ။ <a href="/course/chapter2">Chapter 2</a> ကနေ မှတ်မိပါသေးလား၊ 🤗 Transformers မှာရှိတဲ့ <code>AutoModelForXxx</code> classes တွေက <em>tensors</em> (PyTorch ဒါမှမဟုတ် TensorFlow မှာ) ပေါ်မှာ အလုပ်လုပ်ပြီး၊ common operation တစ်ခုကတော့ PyTorch မှာဆိုရင် <code>Tensor.size()</code> ကို အသုံးပြုပြီး tensor ရဲ့ dimensions တွေကို ထုတ်ယူတာပါပဲ။ traceback ကို ထပ်ကြည့်ရအောင်၊ ဘယ်လိုင်းက exception ကို ဖြစ်စေခဲ့သလဲဆိုတာ ကြည့်ဖို့…</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-regexp">/miniconda3/</span>envs<span class="hljs-regexp">/huggingface/</span>lib<span class="hljs-regexp">/python3.8/</span>site-packages<span class="hljs-regexp">/transformers/m</span>odels<span class="hljs-regexp">/distilbert/m</span>odeling_distilbert.py in forward(self, input_ids, attention_mask, head_mask, inputs_embeds, output_attentions, output_hidden_states, return_dict) | |
| <span class="hljs-number">471</span> raise ValueError(<span class="hljs-string">"You cannot specify both input_ids and inputs_embeds at the same time"</span>) | |
| <span class="hljs-number">472</span> elif input_ids is not None: | |
| --> <span class="hljs-number">473</span> input_shape = input_ids.<span class="hljs-keyword">size</span>() | |
| <span class="hljs-number">474</span> elif inputs_embeds is not None: | |
| <span class="hljs-number">475</span> input_shape = inputs_embeds.<span class="hljs-keyword">size</span>()[:-<span class="hljs-number">1</span>] | |
| AttributeError: <span class="hljs-string">'list'</span> object has no attribute <span class="hljs-string">'size'</span><!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-nufco6">ကျွန်တော်တို့ code က <code>input_ids.size()</code> ကို ခေါ်ဖို့ ကြိုးစားခဲ့ပုံရပါတယ်။ ဒါပေမယ့် ဒါက <code>list</code> (container တစ်ခုသာ ဖြစ်တဲ့) Python <code>list</code> အတွက် အလုပ်လုပ်မှာ မဟုတ်ပါဘူး။ ဒီပြဿနာကို ဘယ်လိုဖြေရှင်းမလဲ။ Stack Overflow ပေါ်မှာ error message ကို ရှာကြည့်လိုက်တော့ သက်ဆိုင်ရာ <a href="https://stackoverflow.com/search?q=AttributeError%3A+%27list%27+object+has+no+attribute+%27size%27&s=c15ec54c-63cb-481d-a749-408920073e8f" rel="nofollow">hits</a> အတော်များများ တွေ့ရပါတယ်။ ပထမဆုံးတစ်ခုကို နှိပ်လိုက်တဲ့အခါ ကျွန်တော်တို့ရဲ့ မေးခွန်းနဲ့ ဆင်တူတဲ့ မေးခွန်းတစ်ခုကို ပြသပြီး၊ အဖြေကို အောက်ပါ screenshot မှာ တွေ့ရပါလိမ့်မယ်။</p> <div class="flex justify-center" data-svelte-h="svelte-1i8wi5i"><img src="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter8/stack-overflow.png" alt="An answer from Stack Overflow." width="100%"></div> <p data-svelte-h="svelte-1i1spi5">အဖြေက tokenizer မှာ <code>return_tensors='pt'</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 -->inputs = tokenizer(question, context, add_special_tokens=<span class="hljs-literal">True</span>, return_tensors=<span class="hljs-string">"pt"</span>) | |
| input_ids = inputs[<span class="hljs-string">"input_ids"</span>][<span class="hljs-number">0</span>] | |
| outputs = model(**inputs) | |
| answer_start_scores = outputs.start_logits | |
| answer_end_scores = outputs.end_logits | |
| <span class="hljs-comment"># score ရဲ့ argmax နဲ့ answer ရဲ့ အဖြစ်နိုင်ဆုံး အစကို ရယူပါ</span> | |
| answer_start = torch.argmax(answer_start_scores) | |
| <span class="hljs-comment"># score ရဲ့ argmax နဲ့ answer ရဲ့ အဖြစ်နိုင်ဆုံး အဆုံးကို ရယူပါ</span> | |
| answer_end = torch.argmax(answer_end_scores) + <span class="hljs-number">1</span> | |
| answer = tokenizer.convert_tokens_to_string( | |
| tokenizer.convert_ids_to_tokens(input_ids[answer_start:answer_end]) | |
| ) | |
| <span class="hljs-built_in">print</span>(<span class="hljs-string">f"Question: <span class="hljs-subst">{question}</span>"</span>) | |
| <span class="hljs-built_in">print</span>(<span class="hljs-string">f"Answer: <span class="hljs-subst">{answer}</span>"</span>)<!-- 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-string">""" | |
| Question: Which frameworks can I use? | |
| Answer: pytorch, tensorflow, and jax | |
| """</span><!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-165u1ut">ကောင်းပြီ၊ အလုပ်ဖြစ်သွားပြီ! ဒါဟာ Stack Overflow က ဘယ်လောက်အသုံးဝင်တယ်ဆိုတာကို ပြသတဲ့ ဥပမာကောင်းတစ်ခုပါပဲ- အလားတူပြဿနာတစ်ခုကို ဖော်ထုတ်ခြင်းဖြင့်၊ community ထဲက တခြားသူတွေရဲ့ အတွေ့အကြုံကနေ ကျွန်တော်တို့ အကျိုးကျေးဇူး ရရှိခဲ့ပါတယ်။ ဒါပေမယ့် ဒီလို ရှာဖွေမှုမျိုးက အမြဲတမ်း သက်ဆိုင်ရာအဖြေကို ပေးမှာ မဟုတ်ပါဘူး၊ ဒါဆို ဒီလိုကိစ္စတွေမှာ သင်ဘာလုပ်နိုင်မလဲ။ ကံကောင်းစွာနဲ့ပဲ၊ <a href="https://discuss.huggingface.co/" rel="nofollow">Hugging Face forums</a> မှာ ကြိုဆိုသော developers community တစ်ခု ရှိပြီး သင့်ကို ကူညီနိုင်ပါတယ်။ နောက်အပိုင်းမှာ၊ အဖြေရနိုင်ခြေရှိတဲ့ ကောင်းမွန်တဲ့ forum မေးခွန်းတွေကို ဘယ်လိုဖန်တီးရမလဲဆိုတာ ကြည့်ရပါမယ်။</p> <h2 class="relative group"><a id="ဝဟရ-ရငလငခက-glossary" 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="#ဝဟရ-ရငလငခက-glossary"><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>ဝေါဟာရ ရှင်းလင်းချက် (Glossary)</span></h2> <ul data-svelte-h="svelte-1evsxuk"><li><strong>Error</strong>: ပရိုဂရမ်တစ်ခု အလုပ်လုပ်နေစဉ် ဖြစ်ပေါ်လာသော ပြဿနာတစ်ခုကြောင့် ၎င်းသည် ပုံမှန်အတိုင်း ဆက်လက်လုပ်ဆောင်နိုင်ခြင်းမရှိခြင်း။</li> <li><strong>Predictions</strong>: Machine Learning မော်ဒယ်တစ်ခုက input data ကို အခြေခံပြီး ခန့်မှန်းထုတ်ပေးသော ရလဒ်များ။</li> <li><strong>Transformer Model</strong>: Natural Language Processing (NLP) မှာ အောင်မြင်မှုများစွာရရှိခဲ့တဲ့ deep learning architecture တစ်မျိုးပါ။</li> <li><strong>Debug</strong>: ကွန်ပျူတာပရိုဂရမ်တစ်ခုရှိ အမှားများ (bugs) ကို ရှာဖွေ၊ ဖော်ထုတ်ပြီး ပြင်ဆင်ခြင်း။</li> <li><strong>Training Phase</strong>: Machine Learning မော်ဒယ်တစ်ခုကို ဒေတာများဖြင့် လေ့ကျင့်ပေးသည့် အချိန်အပိုင်းအခြား။</li> <li><strong>Template Model Repository</strong>: နမူနာအဖြစ် အသုံးပြုရန် ပြင်ဆင်ထားသော model repository။</li> <li><strong>Hugging Face Hub</strong>: AI မော်ဒယ်တွေ၊ datasets တွေနဲ့ demo တွေကို အခြားသူတွေနဲ့ မျှဝေဖို့၊ ရှာဖွေဖို့နဲ့ ပြန်လည်အသုံးပြုဖို့အတွက် အွန်လိုင်း platform တစ်ခု ဖြစ်ပါတယ်။</li> <li><strong>Jupyter Notebook</strong>: code, text, images, နှင့် mathematical equations တို့ကို ပေါင်းစပ်နိုင်သော interactive computing environment။</li> <li><strong><code>notebook_login()</code> Function</strong>: Jupyter/Colab Notebooks များတွင် Hugging Face Hub သို့ login ဝင်ရန် အသုံးပြုသော function။</li> <li><strong>Terminal</strong>: command-line interface မှတစ်ဆင့် ကွန်ပျူတာကို ထိန်းချုပ်ရန် အသုံးပြုသော interface။</li> <li><strong><code>huggingface-cli login</code></strong>: Hugging Face CLI (Command Line Interface) မှ Hugging Face Hub သို့ login ဝင်ရန် အသုံးပြုသော command။</li> <li><strong>Token</strong>: Hugging Face Hub တွင် အကောင့် authentication အတွက် အသုံးပြုသော ထူးခြားသည့် ကုဒ်။</li> <li><strong><code>~/.cache/huggingface/</code></strong>: Hugging Face libraries များက cache ဖိုင်များကို သိမ်းဆည်းသော default directory။</li> <li><strong><code>distutils.dir_util.copy_tree</code></strong>: Python ရဲ့ <code>distutils</code> library ကနေ directory tree တစ်ခုလုံးကို copy လုပ်ဖို့အတွက် utility function။</li> <li><strong><code>huggingface_hub</code> Library</strong>: Hugging Face Hub နှင့် အပြန်အလှန်ဆက်သွယ်ရန် အသုံးပြုသော Python library။</li> <li><strong><code>Repository</code> Class</strong>: <code>huggingface_hub</code> library မှ Git repository များကို ကိုင်တွယ်ရန်အတွက် class။</li> <li><strong><code>snapshot_download()</code> Function</strong>: Hugging Face Hub မှ repository တစ်ခု၏ snapshot ကို download လုပ်ရန် function။</li> <li><strong><code>create_repo()</code> Function</strong>: Hugging Face Hub ပေါ်တွင် repository အသစ်တစ်ခု ဖန်တီးရန် function။</li> <li><strong><code>get_full_repo_name()</code> Function</strong>: Hugging Face Hub ပေါ်ရှိ repository ၏ full name (username/repo_name) ကို ရယူရန် function။</li> <li><strong><code>local_dir</code></strong>: Repository ကို clone လုပ်မည့် local directory။</li> <li><strong><code>clone_from</code></strong>: Repository ကို clone လုပ်မည့် remote URL သို့မဟုတ် ID။</li> <li><strong><code>push_to_hub()</code> Method</strong>: Hugging Face Transformers library မှ model, tokenizer, သို့မဟုတ် configuration များကို Hugging Face Hub သို့ upload လုပ်ရန် အသုံးပြုသော method။</li> <li><strong>Pipeline from 🤗 Transformers</strong>: Hugging Face Transformers library မှ model များကို သီးခြားလုပ်ငန်းများအတွက် အသုံးပြုရလွယ်ကူစေရန် အဆင့်မြင့် abstraction။</li> <li><strong>Question Answering Project</strong>: မေးခွန်းတစ်ခုကို ဖြေကြားရန် AI model များကို အသုံးပြုသည့် project။</li> <li><strong>E-commerce Website</strong>: အင်တာနက်မှတစ်ဆင့် ကုန်ပစ္စည်းများ သို့မဟုတ် ဝန်ဆောင်မှုများကို ဝယ်ယူရောင်းချနိုင်သော website။</li> <li><strong>Consumer Products</strong>: ပုံမှန်စားသုံးသူများ အသုံးပြုသော ကုန်ပစ္စည်းများ။</li> <li><strong>SQuAD (Stanford Question Answering Dataset)</strong>: မေးခွန်းဖြေဆိုခြင်းအတွက် အသုံးပြုသော လူကြိုက်များသည့် dataset။</li> <li><strong>Model ID</strong>: Hugging Face Hub ပေါ်ရှိ model တစ်ခု၏ ထူးခြားသော ဖော်ထုတ်ကိန်း (identifier)။</li> <li><strong><code>OSError</code></strong>: Python တွင် operating system-related error များကို ညွှန်ပြသော exception အမျိုးအစား။</li> <li><strong><code>config.json</code> File</strong>: Transformer model ၏ configuration (ဥပမာ- hidden size, number of layers) ကို သိမ်းဆည်းထားသော JSON file။</li> <li><strong>Python Traceback (Stack Trace)</strong>: Python ပရိုဂရမ်တစ်ခုတွင် error ဖြစ်ပွားခဲ့သည့်အခါ function calls ၏ sequence ကို ပြသသော error report။</li> <li><strong>Exception</strong>: Python ပရိုဂရမ်တစ်ခု၏ ပုံမှန်စီးဆင်းမှုကို ပြတ်တောက်စေသော error တစ်မျိုး။</li> <li><strong>Stack Overflow</strong>: programmer များအတွက် မေးခွန်းများမေးရန်နှင့် အဖြေများရှာဖွေရန် လူကြိုက်များသော Q&A website။</li> <li><strong>Typo</strong>: စာလုံးပေါင်းမှားယွင်းမှု။</li> <li><strong>DistilBERT</strong>: BERT model ၏ ပေါ့ပါးသော version။</li> <li><strong><code>.gitattributes</code></strong>: Git repository အတွင်းရှိ files များကို မည်သို့ ကိုင်တွယ်ရမည်ကို သတ်မှတ်ရန် အသုံးပြုသော Git configuration file။</li> <li><strong><code>README.md</code></strong>: Markdown format ဖြင့် ရေးသားထားသော project ၏ အဓိက မှတ်တမ်းဖိုင်။</li> <li><strong><code>pytorch_model.bin</code></strong>: PyTorch framework ဖြင့် trained လုပ်ထားသော model ၏ weights များကို သိမ်းဆည်းထားသော binary file။</li> <li><strong><code>special_tokens_map.json</code></strong>: tokenizer ၏ special tokens များနှင့် ၎င်းတို့၏ mappings များကို သိမ်းဆည်းထားသော JSON file။</li> <li><strong><code>tokenizer_config.json</code></strong>: tokenizer ၏ configuration ကို သိမ်းဆည်းထားသော JSON file။</li> <li><strong><code>training_args.bin</code></strong>: training arguments များကို သိမ်းဆည်းထားသော binary file။</li> <li><strong><code>vocab.txt</code></strong>: tokenizer ၏ vocabulary ကို သိမ်းဆည်းထားသော text file။</li> <li><strong><code>AutoConfig</code> Class</strong>: Hugging Face Transformers library မှာ ပါဝင်တဲ့ class တစ်ခုဖြစ်ပြီး မော်ဒယ်အမည်ကို အသုံးပြုပြီး သက်ဆိုင်ရာ configuration ကို အလိုအလျောက် load လုပ်ပေးသည်။</li> <li><strong><code>from_pretrained()</code> Method</strong>: Hugging Face Transformers library မှ model, tokenizer, သို့မဟုတ် configuration ကို pretrained version မှ load လုပ်ရန် အသုံးပြုသော method။</li> <li><strong>Default Configuration</strong>: model သို့မဟုတ် library တစ်ခု၏ မူရင်း (standard) configuration။</li> <li><strong><code>commit_message</code></strong>: Git repository သို့ ပြောင်းလဲမှုများကို push လုပ်သောအခါ ထည့်သွင်းသော message။</li> <li><strong><code>main</code> Branch</strong>: Git repository ၏ ပင်မ development branch။</li> <li><strong><code>revision</code> Argument</strong>: <code>pipeline()</code> function တွင် model ၏ သတ်မှတ်ထားသော revision (branch name, commit hash သို့မဟုတ် tag) မှ load လုပ်ရန်။</li> <li><strong>Extractive Question Answering</strong>: ပေးထားသော စာသားတစ်ခုမှ မေးခွန်း၏ အဖြေကို တိုက်ရိုက်ထုတ်ယူခြင်း။</li> <li><strong>Interoperable</strong>: မတူညီသော စနစ်များ သို့မဟုတ် applications များကြား အတူတကွ အလုပ်လုပ်နိုင်ခြင်း။</li> <li><strong>PyTorch</strong>: Facebook (ယခု Meta) က ဖန်တီးထားတဲ့ open-source machine learning library တစ်ခုဖြစ်ပြီး deep learning မော်ဒယ်တွေ တည်ဆောက်ဖို့အတွက် အသုံးပြုပါတယ်။</li> <li><strong>TensorFlow</strong>: Google က ဖန်တီးထားတဲ့ open-source machine learning library တစ်ခုဖြစ်ပြီး deep learning မော်ဒယ်တွေ တည်ဆောက်ဖို့အတွက် အသုံးပြုပါတယ်။</li> <li><strong>JAX</strong>: Google မှ ထုတ်လုပ်ထားသော high-performance numerical computing library တစ်ခုဖြစ်ပြီး Python မှာ automatic differentiation ကို ထောက်ပံ့ပေးသည်။</li> <li><strong>Tracebacks</strong>: Python မှာ error ဖြစ်တဲ့အခါ function call sequence ကိုပြတဲ့ error report။</li> <li><strong>Source Code</strong>: ပရိုဂရမ်တစ်ခု၏ မူရင်း code။</li> <li><strong>Forward Pass</strong>: Neural network တစ်ခုသို့ input data ကို ပေးပို့ပြီး output ကို တွက်ချက်ခြင်း။</li> <li><strong>Logits</strong>: Neural network ၏ နောက်ဆုံး output layer မှ ထုတ်ပေးသော raw, unnormalized scores များ။</li> <li><strong>Custom Post-processing</strong>: model ၏ output များကို ပိုမိုအသုံးဝင်သော ပုံစံသို့ ပြောင်းလဲရန်အတွက် သီးခြားပြင်ဆင်ထားသော လုပ်ငန်းစဉ်။</li> <li><strong>Tokenizer</strong>: စာသား (သို့မဟုတ် အခြားဒေတာ) ကို AI မော်ဒယ်များ စီမံဆောင်ရွက်နိုင်ရန် tokens တွေအဖြစ် ပိုင်းခြားပေးသည့် ကိရိယာ သို့မဟုတ် လုပ်ငန်းစဉ်။</li> <li><strong><code>torch</code> Library</strong>: PyTorch framework အတွက် Python library။</li> <li><strong><code>add_special_tokens=True</code></strong>: tokenizer ကို input sequence ထဲသို့ special tokens (ဥပမာ- <code>[CLS]</code>, <code>[SEP]</code>) ထည့်သွင်းရန် ညွှန်ကြားခြင်း။</li> <li><strong><code>input_ids</code></strong>: Tokenizer မှ ထုတ်ပေးသော tokens တစ်ခုစီ၏ ထူးခြားသော ဂဏန်းဆိုင်ရာ ID များ။</li> <li><strong><code>outputs.start_logits</code></strong>: Question Answering model မှ အဖြေစတင်မည့် token အတွက် ထုတ်ပေးသော logits များ။</li> <li><strong><code>outputs.end_logits</code></strong>: Question Answering model မှ အဖြေပြီးဆုံးမည့် token အတွက် ထုတ်ပေးသော logits များ။</li> <li><strong><code>torch.argmax()</code></strong>: PyTorch tensor တစ်ခု၏ အမြင့်ဆုံးတန်ဖိုးရှိသော index ကို ရယူသော function။</li> <li><strong><code>tokenizer.convert_tokens_to_string()</code></strong>: tokens စာရင်းကို string တစ်ခုအဖြစ် ပြန်ပြောင်းပေးသော tokenizer method။</li> <li><strong><code>tokenizer.convert_ids_to_tokens()</code></strong>: ID စာရင်းကို tokens စာရင်းအဖြစ် ပြန်ပြောင်းပေးသော tokenizer method။</li> <li><strong>AttributeError</strong>: Python တွင် object တစ်ခု၌ မရှိသော attribute ကို ဝင်ရောက်ကြည့်ရှုရန် ကြိုးစားသောအခါ ဖြစ်ပေါ်လာသော exception။</li> <li><strong>Python Debugger</strong>: Python code များကို step-by-step စစ်ဆေးပြီး debug လုပ်ရန် ကိရိယာ။</li> <li><strong>Slice</strong>: list သို့မဟုတ် array ၏ အစိတ်အပိုင်းတစ်ခု။</li> <li><strong><code>Tensor.size()</code> Method</strong>: PyTorch tensor တစ်ခု၏ dimensions များကို ပြန်ပေးသော method။</li> <li><strong><code>return_tensors='pt'</code></strong>: tokenizer ကို output များကို PyTorch tensors အဖြစ် ပြန်ပေးရန် ညွှန်ကြားခြင်း။</li> <li><strong>Community of Developers</strong>: ဆော့ဖ်ဝဲလ်ဖန်တီးသူများ၏ အဖွဲ့အစည်း။</li></ul> <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/my/chapter8/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_5q47hu = { | |
| assets: "/docs/course/pr_1095/my", | |
| base: "/docs/course/pr_1095/my", | |
| env: {} | |
| }; | |
| const element = document.currentScript.parentElement; | |
| const data = [null,null]; | |
| Promise.all([ | |
| import("/docs/course/pr_1095/my/_app/immutable/entry/start.8e25cab6.js"), | |
| import("/docs/course/pr_1095/my/_app/immutable/entry/app.b12ce275.js") | |
| ]).then(([kit, app]) => { | |
| kit.start(app, element, { | |
| node_ids: [0, 87], | |
| data, | |
| form: null, | |
| error: null | |
| }); | |
| }); | |
| } | |
| </script> | |
Xet Storage Details
- Size:
- 104 kB
- Xet hash:
- 3423a0cc74e16079f92ac77da317e6c08ec8efec705acf47cca16c52613c2eec
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.