Buckets:

rtrm's picture
download
raw
75.8 kB
<meta charset="utf-8" /><meta name="hf:doc:metadata" content="{&quot;title&quot;:&quot;Chat Templates များ&quot;,&quot;local&quot;:&quot;chat-templates-မ&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;နိဒါန်း&quot;,&quot;local&quot;:&quot;နဒန&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Model အမျိုးအစားများနှင့် Templates များ&quot;,&quot;local&quot;:&quot;model-အမအစမနင-templates-မ&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;Base Models နှင့် Instruct Models များ ကွာခြားချက်&quot;,&quot;local&quot;:&quot;base-models-နင-instruct-models-မ-ကခခက&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;အသုံးများသော Template Formats များ&quot;,&quot;local&quot;:&quot;အသမသ-template-formats-မ&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;အဆင့်မြင့် Features များ&quot;,&quot;local&quot;:&quot;အဆငမင-features-မ&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3}],&quot;depth&quot;:2},{&quot;title&quot;:&quot;အကောင်းဆုံး ကျင့်စဉ်များ&quot;,&quot;local&quot;:&quot;အကငဆ-ကငစဉမ&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;အထွေထွေ လမ်းညွှန်ချက်များ&quot;,&quot;local&quot;:&quot;အထထ-လမညနခကမ&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3}],&quot;depth&quot;:2},{&quot;title&quot;:&quot;လက်တွေ့လေ့ကျင့်ခန်း&quot;,&quot;local&quot;:&quot;လကတလကငခန&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;နောက်ထပ် အရင်းအမြစ်များ&quot;,&quot;local&quot;:&quot;နကထပ-အရငအမစမ&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;ဝေါဟာရ ရှင်းလင်းချက် (Glossary)&quot;,&quot;local&quot;:&quot;ဝဟရ-ရငလငခက-glossary&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2}],&quot;depth&quot;: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/22.518ee1b5.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/CodeBlock.abb4f40e.js">
<link rel="modulepreload" href="/docs/course/pr_1095/my/_app/immutable/chunks/CourseFloatingBanner.c1c08878.js"><!-- HEAD_svelte-u9bgzb_START --><meta name="hf:doc:metadata" content="{&quot;title&quot;:&quot;Chat Templates များ&quot;,&quot;local&quot;:&quot;chat-templates-မ&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;နိဒါန်း&quot;,&quot;local&quot;:&quot;နဒန&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Model အမျိုးအစားများနှင့် Templates များ&quot;,&quot;local&quot;:&quot;model-အမအစမနင-templates-မ&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;Base Models နှင့် Instruct Models များ ကွာခြားချက်&quot;,&quot;local&quot;:&quot;base-models-နင-instruct-models-မ-ကခခက&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;အသုံးများသော Template Formats များ&quot;,&quot;local&quot;:&quot;အသမသ-template-formats-မ&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;အဆင့်မြင့် Features များ&quot;,&quot;local&quot;:&quot;အဆငမင-features-မ&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3}],&quot;depth&quot;:2},{&quot;title&quot;:&quot;အကောင်းဆုံး ကျင့်စဉ်များ&quot;,&quot;local&quot;:&quot;အကငဆ-ကငစဉမ&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;အထွေထွေ လမ်းညွှန်ချက်များ&quot;,&quot;local&quot;:&quot;အထထ-လမညနခကမ&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3}],&quot;depth&quot;:2},{&quot;title&quot;:&quot;လက်တွေ့လေ့ကျင့်ခန်း&quot;,&quot;local&quot;:&quot;လကတလကငခန&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;နောက်ထပ် အရင်းအမြစ်များ&quot;,&quot;local&quot;:&quot;နကထပ-အရငအမစမ&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;ဝေါဟာရ ရှင်းလင်းချက် (Glossary)&quot;,&quot;local&quot;:&quot;ဝဟရ-ရငလငခက-glossary&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2}],&quot;depth&quot;:1}"><!-- HEAD_svelte-u9bgzb_END --> <p></p> <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/main/course/en/chapter11/section2.ipynb" target="_blank"><img alt="Open In Colab" class="!m-0" src="https://colab.research.google.com/assets/colab-badge.svg"></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="chat-templates-မ" 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="#chat-templates-မ"><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>Chat Templates များ</span></h1> <h2 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></h2> <p data-svelte-h="svelte-pnoms0">Chat templates တွေဟာ ဘာသာစကားမော်ဒယ်တွေနဲ့ အသုံးပြုသူတွေကြား အပြန်အလှန်ဆက်သွယ်မှုတွေကို ဖွဲ့စည်းရာမှာ မရှိမဖြစ်လိုအပ်ပါတယ်။ သင်ဟာ ရိုးရှင်းတဲ့ chatbot တစ်ခုတည်ဆောက်သည်ဖြစ်စေ၊ ရှုပ်ထွေးတဲ့ AI agent တစ်ခုတည်ဆောက်သည်ဖြစ်စေ၊ သင်၏ စကားပြောဆိုမှုများကို မှန်ကန်စွာ ပုံစံချနည်းကို နားလည်ထားခြင်းက သင့် model ကနေ အကောင်းဆုံးရလဒ်တွေရရှိဖို့ အရေးကြီးပါတယ်။ ဒီလမ်းညွှန်ချက်မှာ၊ chat templates တွေက ဘာတွေလဲ၊ ဘာကြောင့် အရေးကြီးတာလဲ၊ ပြီးတော့ ဘယ်လို ထိထိရောက်ရောက် အသုံးပြုရမလဲဆိုတာကို ကျွန်တော်တို့ လေ့လာသွားမှာပါ။</p> <blockquote class="tip" data-svelte-h="svelte-1gj6stc"><p>Chat templates တွေက အောက်ပါတို့အတွက် မရှိမဖြစ်လိုအပ်ပါတယ်။</p> <ul><li>တသမတ်တည်းဖြစ်သော စကားပြောဆိုမှုဖွဲ့စည်းပုံကို ထိန်းသိမ်းရန်။</li> <li>အခန်းကဏ္ဍများကို မှန်ကန်စွာ ဖော်ထုတ်နိုင်ရန်။</li> <li>အလှည့်ကျ စကားပြောဆိုမှုများတစ်လျှောက် context ကို စီမံခန့်ခွဲရန်။</li> <li>tool use ကဲ့သို့သော အဆင့်မြင့် features များကို ပံ့ပိုးရန်။</li></ul></blockquote> <h2 class="relative group"><a id="model-အမအစမနင-templates-မ" 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-အမအစမနင-templates-မ"><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 အမျိုးအစားများနှင့် Templates များ</span></h2> <h3 class="relative group"><a id="base-models-နင-instruct-models-မ-ကခခက" 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="#base-models-နင-instruct-models-မ-ကခခက"><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>Base Models နှင့် Instruct Models များ ကွာခြားချက်</span></h3> <p data-svelte-h="svelte-cfop09">Base model တစ်ခုကို နောက်ဆက်တွဲ token ကို ခန့်မှန်းဖို့အတွက် ကုန်ကြမ်းစာသားဒေတာ (raw text data) တွေပေါ်မှာ လေ့ကျင့်ထားပါတယ်။ instruct model တစ်ခုကတော့ ညွှန်ကြားချက်တွေကို လိုက်နာပြီး စကားပြောဆိုမှုတွေမှာ ပါဝင်ဖို့အတွက် သီးခြား fine-tune လုပ်ထားတာ ဖြစ်ပါတယ်။ ဥပမာအားဖြင့်၊ <a href="https://huggingface.co/HuggingFaceTB/SmolLM2-135M" rel="nofollow"><code>SmolLM2-135M</code></a> ဟာ base model တစ်ခုဖြစ်ပြီး၊ <a href="https://huggingface.co/HuggingFaceTB/SmolLM2-135M-Instruct" rel="nofollow"><code>SmolLM2-135M-Instruct</code></a> ကတော့ ၎င်း၏ instruction-tuned variant ဖြစ်ပါတယ်။</p> <p data-svelte-h="svelte-rawwpg">Instruction tuned models တွေဟာ သီးခြားစကားပြောဆိုမှုဖွဲ့စည်းပုံကို လိုက်နာဖို့ လေ့ကျင့်ထားတာကြောင့် chatbot applications တွေအတွက် ပိုမိုသင့်လျော်ပါတယ်။ ဒါ့အပြင် instruct models တွေဟာ tool use၊ multimodal inputs နဲ့ function calling အပါအဝင် ရှုပ်ထွေးတဲ့ အပြန်အလှန်ဆက်သွယ်မှုတွေကို ကိုင်တွယ်နိုင်ပါတယ်။</p> <p data-svelte-h="svelte-1cqbffk">base model တစ်ခုကို instruct model တစ်ခုလို အလုပ်လုပ်စေဖို့၊ ကျွန်တော်တို့ရဲ့ prompts တွေကို model က နားလည်နိုင်တဲ့ တသမတ်တည်း ပုံစံချဖို့ လိုအပ်ပါတယ်။ ဒီနေရာမှာ chat templates တွေက ပါဝင်လာပါတယ်။ ChatML ဟာ ရှင်းလင်းတဲ့ အခန်းကဏ္ဍညွှန်းကိန်းတွေ (system, user, assistant) နဲ့ စကားပြောဆိုမှုတွေကို ဖွဲ့စည်းထားတဲ့ template format တစ်မျိုး ဖြစ်ပါတယ်။ <a href="https://huggingface.co/HuggingFaceTB/SmolLM2-135M-Instruct/blob/e2c3f7557efbdec707ae3a336371d169783f1da1/tokenizer_config.json#L146" rel="nofollow">ChatML အကြောင်း လမ်းညွှန်</a> ကို ကြည့်ပါ။</p> <blockquote class="warning" data-svelte-h="svelte-1vdrt9k"><p>instruct model တစ်ခုကို အသုံးပြုတဲ့အခါ၊ သင်မှန်ကန်တဲ့ chat template format ကို အသုံးပြုနေကြောင်း အမြဲတမ်း စစ်ဆေးပါ။ မှားယွင်းတဲ့ template ကို အသုံးပြုခြင်းက model စွမ်းဆောင်ရည် ညံ့ဖျင်းခြင်း ဒါမှမဟုတ် မမျှော်လင့်ထားတဲ့ အပြုအမူတွေ ဖြစ်ပေါ်စေနိုင်ပါတယ်။ ဒါကို သေချာစေဖို့ အလွယ်ကူဆုံးနည်းလမ်းကတော့ Hub ပေါ်ရှိ model tokenizer configuration ကို စစ်ဆေးဖို့ပါပဲ။ ဥပမာ၊ <code>SmolLM2-135M-Instruct</code> model က <a href="https://huggingface.co/HuggingFaceTB/SmolLM2-135M-Instruct/blob/e2c3f7557efbdec707ae3a336371d169783f1da1/tokenizer_config.json#L146">ဒီ configuration</a> ကို အသုံးပြုပါတယ်။</p></blockquote> <h3 class="relative group"><a id="အသမသ-template-formats-မ" 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="#အသမသ-template-formats-မ"><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>အသုံးများသော Template Formats များ</span></h3> <p data-svelte-h="svelte-l89b9z">တိကျတဲ့ implementation တွေထဲ မဝင်ခင်၊ မတူညီတဲ့ models တွေက ၎င်းတို့ရဲ့ စကားပြောဆိုမှုတွေကို ဘယ်လိုပုံစံချထားတာကို မျှော်လင့်သလဲဆိုတာ နားလည်ဖို့ အရေးကြီးပါတယ်။ ရိုးရှင်းတဲ့ ဥပမာစကားပြောဆိုမှုတစ်ခုကို အသုံးပြုပြီး အသုံးများတဲ့ template formats အချို့ကို လေ့လာကြည့်ရအောင်။</p> <p data-svelte-h="svelte-ism2fr">ဥပမာအားလုံးအတွက် အောက်ပါ စကားပြောဆိုမှုဖွဲ့စည်းပုံကို ကျွန်တော်တို့ အသုံးပြုပါမယ်။</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 -->messages = [
{<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;system&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;You are a helpful assistant.&quot;</span>},
{<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;Hello!&quot;</span>},
{<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;assistant&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;Hi! How can I help you today?&quot;</span>},
{<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;What&#x27;s the weather?&quot;</span>},
]<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-cbltos">ဒါက SmolLM2 နဲ့ Qwen 2 လို models တွေမှာ အသုံးပြုတဲ့ ChatML template ဖြစ်ပါတယ်။</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 -->&lt;|im_start|&gt;system
You are a helpful assistant.&lt;|im_end|&gt;
&lt;|im_start|&gt;user
Hello!&lt;|im_end|&gt;
&lt;|im_start|&gt;assistant
Hi! How can I <span class="hljs-built_in">help</span> you today?&lt;|im_end|&gt;
&lt;|im_start|&gt;user
What<span class="hljs-string">&#x27;s the weather?&lt;|im_start|&gt;assistant</span><!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-1y8l0po">ဒါက <code>mistral</code> template format ကို အသုံးပြုထားတာ ဖြစ်ပါတယ်-</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 -->&lt;s&gt;[INST] You are a helpful assistant. [/INST]
Hi! How can I <span class="hljs-built_in">help</span> you today?&lt;/s&gt;
[INST] Hello! [/INST]<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-1yjyd8v">ဒီ formats တွေကြားက အဓိက ကွာခြားချက်တွေကတော့…
၁။ <strong>System Message Handling</strong>:</p> <ul data-svelte-h="svelte-1et00il"><li>Llama 2 က system messages တွေကို <code>&lt;&lt;SYS&gt;&gt;</code> tags တွေနဲ့ ဝန်းရံထားပါတယ်။</li> <li>Llama 3 က <code>&lt;|system|&gt;</code> tags တွေကို <code>&lt;/s&gt;</code> endings နဲ့ အသုံးပြုပါတယ်။</li> <li>Mistral က system message ကို ပထမဆုံး instruction ထဲမှာ ထည့်သွင်းထားပါတယ်။</li> <li>Qwen က ရှင်းလင်းတဲ့ <code>system</code> role ကို <code>&lt;|im_start|&gt;</code> tags တွေနဲ့ အသုံးပြုပါတယ်။</li> <li>ChatGPT က <code>SYSTEM:</code> prefix ကို အသုံးပြုပါတယ်။</li></ul> <p data-svelte-h="svelte-uoquvj">၂။ <strong>Message Boundaries</strong>:</p> <ul data-svelte-h="svelte-cye6r9"><li>Llama 2 က <code>[INST]</code> နဲ့ <code>[/INST]</code> tags တွေကို အသုံးပြုပါတယ်။</li> <li>Llama 3 က role-specific tags တွေ (<code>&lt;|system|&gt;</code>, <code>&lt;|user|&gt;</code>, <code>&lt;|assistant|&gt;</code>) ကို <code>&lt;/s&gt;</code> endings နဲ့ အသုံးပြုပါတယ်။</li> <li>Mistral က <code>[INST]</code> နဲ့ <code>[/INST]</code> ကို <code>&lt;s&gt;</code> နဲ့ <code>&lt;/s&gt;</code> နဲ့ အသုံးပြုပါတယ်။</li> <li>Qwen က role-specific start/end tokens တွေကို အသုံးပြုပါတယ်။</li></ul> <p data-svelte-h="svelte-1db3vz0">၃။ <strong>Special Tokens</strong>:</p> <ul data-svelte-h="svelte-139vu9p"><li>Llama 2 က စကားပြောဆိုမှု boundaries တွေအတွက် <code>&lt;s&gt;</code> နဲ့ <code>&lt;/s&gt;</code> ကို အသုံးပြုပါတယ်။</li> <li>Llama 3 က message တစ်ခုစီရဲ့ အဆုံးသတ်ဖို့ <code>&lt;/s&gt;</code> ကို အသုံးပြုပါတယ်။</li> <li>Mistral က turn boundaries တွေအတွက် <code>&lt;s&gt;</code> နဲ့ <code>&lt;/s&gt;</code> ကို အသုံးပြုပါတယ်။</li> <li>Qwen က role-specific start/end tokens တွေကို အသုံးပြုပါတယ်။</li></ul> <p data-svelte-h="svelte-1oaix4u">ဒီကွာခြားချက်တွေကို နားလည်ထားခြင်းက models အမျိုးမျိုးနဲ့ အလုပ်လုပ်ဖို့ အဓိကသော့ချက် ဖြစ်ပါတယ်။ transformers library က ဒီပြောင်းလဲမှုတွေကို အလိုအလျောက် ကိုင်တွယ်ဖြေရှင်းရာမှာ ဘယ်လိုကူညီပေးလဲဆိုတာ ကြည့်ရအောင်။</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
<span class="hljs-comment"># ဒါတွေက မတူညီတဲ့ templates တွေကို အလိုအလျောက် အသုံးပြုပါလိမ့်မယ်</span>
mistral_tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;mistralai/Mistral-7B-Instruct-v0.1&quot;</span>)
qwen_tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;Qwen/Qwen-7B-Chat&quot;</span>)
smol_tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;HuggingFaceTB/SmolLM2-135M-Instruct&quot;</span>)
messages = [
{<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;system&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;You are a helpful assistant.&quot;</span>},
{<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;Hello!&quot;</span>},
]
<span class="hljs-comment"># တစ်ခုစီက ၎င်းရဲ့ model template အတိုင်း ပုံစံချပါလိမ့်မယ်</span>
mistral_chat = mistral_tokenizer.apply_chat_template(messages, tokenize=<span class="hljs-literal">False</span>)
qwen_chat = qwen_tokenizer.apply_chat_template(messages, tokenize=<span class="hljs-literal">False</span>)
smol_chat = smol_tokenizer.apply_chat_template(messages, tokenize=<span class="hljs-literal">False</span>)<!-- HTML_TAG_END --></pre></div> <details><summary data-svelte-h="svelte-kt6ja1">Template ဥပမာများကို ကြည့်ရန် နှိပ်ပါ</summary> <p data-svelte-h="svelte-1v39gvb">Qwen 2 နှင့် SmolLM2 ChatML template:</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 -->&lt;|im_start|&gt;system
You are a helpful assistant.&lt;|im_end|&gt;
&lt;|im_start|&gt;user
Hello!&lt;|im_end|&gt;
&lt;|im_start|&gt;assistant
Hi! How can I <span class="hljs-built_in">help</span> you today?&lt;|im_end|&gt;
&lt;|im_start|&gt;user
What<span class="hljs-string">&#x27;s the weather?&lt;|im_start|&gt;assistant</span><!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-c25hqw">Mistral template:</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 -->&lt;s&gt;[INST] You are a helpful assistant. [/INST]
Hi! How can I <span class="hljs-built_in">help</span> you today?&lt;/s&gt;
[INST] Hello! [/INST]<!-- HTML_TAG_END --></pre></div></details> <h3 class="relative group"><a id="အဆငမင-features-မ" 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="#အဆငမင-features-မ"><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>အဆင့်မြင့် Features များ</span></h3> <p data-svelte-h="svelte-1rl7d0u">Chat templates တွေဟာ စကားပြောဆိုမှု အပြန်အလှန်ဆက်သွယ်မှုတွေထက် ပိုမိုရှုပ်ထွေးတဲ့ အခြေအနေတွေကိုလည်း ကိုင်တွယ်နိုင်ပါတယ်။ ဒါတွေမှာ…</p> <p data-svelte-h="svelte-284piz">၁။ <strong>Tool Use</strong>: Models တွေက ပြင်ပ tools တွေ ဒါမှမဟုတ် APIs တွေနဲ့ အပြန်အလှန်ဆက်သွယ်ဖို့ လိုအပ်တဲ့အခါ။
၂။ <strong>Multimodal Inputs</strong>: ပုံရိပ်တွေ၊ အသံတွေ ဒါမှမဟုတ် အခြား media အမျိုးအစားတွေကို ကိုင်တွယ်ဖို့။
၃။ <strong>Function Calling</strong>: ဖွဲ့စည်းပုံရှိတဲ့ function execution အတွက်။
၄။ <strong>Multi-turn Context</strong>: စကားပြောဆိုမှု မှတ်တမ်းကို ထိန်းသိမ်းဖို့။</p> <blockquote class="tip" data-svelte-h="svelte-1pms3z5"><p>အဆင့်မြင့် features တွေကို implement လုပ်တဲ့အခါ…</p> <ul><li>သင့်သီးခြား model နဲ့ သေချာစွာ စမ်းသပ်ပါ။ Vision နဲ့ tool use template တွေက အထူးသဖြင့် ကွဲပြားပါတယ်။</li> <li>feature တစ်ခုစီနဲ့ model တစ်ခုစီကြား token အသုံးပြုမှုကို သေချာစောင့်ကြည့်ပါ။</li> <li>feature တစ်ခုစီအတွက် မျှော်မှန်းထားတဲ့ format ကို မှတ်တမ်းတင်ပါ။</li></ul></blockquote> <p data-svelte-h="svelte-ofxqw">multimodal စကားပြောဆိုမှုတွေအတွက်၊ chat templates တွေက image references ဒါမှမဟုတ် base64-encoded images တွေကို ထည့်သွင်းနိုင်ပါတယ်။</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 -->messages = [
{
<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;system&quot;</span>,
<span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;You are a helpful vision assistant that can analyze images.&quot;</span>,
},
{
<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>,
<span class="hljs-string">&quot;content&quot;</span>: [
{<span class="hljs-string">&quot;type&quot;</span>: <span class="hljs-string">&quot;text&quot;</span>, <span class="hljs-string">&quot;text&quot;</span>: <span class="hljs-string">&quot;What&#x27;s in this image?&quot;</span>},
{<span class="hljs-string">&quot;type&quot;</span>: <span class="hljs-string">&quot;image&quot;</span>, <span class="hljs-string">&quot;image_url&quot;</span>: <span class="hljs-string">&quot;https://example.com/image.jpg&quot;</span>},
],
},
]<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-1th9st8">ဒါက tool use ပါတဲ့ chat template ဥပမာတစ်ခုပါ။</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 -->messages = [
{
<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;system&quot;</span>,
<span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;You are an AI assistant that can use tools. Available tools: calculator, weather_api&quot;</span>,
},
{<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;What&#x27;s 123 * 456 and is it raining in Paris?&quot;</span>},
{
<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;assistant&quot;</span>,
<span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;Let me help you with that.&quot;</span>,
<span class="hljs-string">&quot;tool_calls&quot;</span>: [
{
<span class="hljs-string">&quot;tool&quot;</span>: <span class="hljs-string">&quot;calculator&quot;</span>,
<span class="hljs-string">&quot;parameters&quot;</span>: {<span class="hljs-string">&quot;operation&quot;</span>: <span class="hljs-string">&quot;multiply&quot;</span>, <span class="hljs-string">&quot;x&quot;</span>: <span class="hljs-number">123</span>, <span class="hljs-string">&quot;y&quot;</span>: <span class="hljs-number">456</span>},
},
{<span class="hljs-string">&quot;tool&quot;</span>: <span class="hljs-string">&quot;weather_api&quot;</span>, <span class="hljs-string">&quot;parameters&quot;</span>: {<span class="hljs-string">&quot;city&quot;</span>: <span class="hljs-string">&quot;Paris&quot;</span>, <span class="hljs-string">&quot;country&quot;</span>: <span class="hljs-string">&quot;France&quot;</span>}},
],
},
{<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;tool&quot;</span>, <span class="hljs-string">&quot;tool_name&quot;</span>: <span class="hljs-string">&quot;calculator&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;56088&quot;</span>},
{
<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;tool&quot;</span>,
<span class="hljs-string">&quot;tool_name&quot;</span>: <span class="hljs-string">&quot;weather_api&quot;</span>,
<span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;{&#x27;condition&#x27;: &#x27;rain&#x27;, &#x27;temperature&#x27;: 15}&quot;</span>,
},
]<!-- HTML_TAG_END --></pre></div> <h2 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></h2> <h3 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></h3> <p data-svelte-h="svelte-oxy87h">Chat templates တွေနဲ့ အလုပ်လုပ်တဲ့အခါ၊ အောက်ပါ အဓိကကျင့်စဉ်တွေကို လိုက်နာပါ။</p> <p data-svelte-h="svelte-1tq14je">၁။ <strong>တသမတ်တည်း Formatting</strong>: သင့် application တစ်လျှောက်လုံး တူညီတဲ့ template format ကို အမြဲတမ်း အသုံးပြုပါ။
၂။ <strong>ရှင်းလင်းသော အခန်းကဏ္ဍ သတ်မှတ်ခြင်း</strong>: message တစ်ခုစီအတွက် roles (system, user, assistant, tool) တွေကို ရှင်းလင်းစွာ သတ်မှတ်ပါ။
၃။ <strong>Context Management</strong>: စကားပြောဆိုမှု မှတ်တမ်းကို ထိန်းသိမ်းတဲ့အခါ token ကန့်သတ်ချက်တွေကို သတိထားပါ။
၄။ <strong>Error Handling</strong>: tool calls နဲ့ multimodal inputs တွေအတွက် မှန်ကန်တဲ့ error handling ကို ထည့်သွင်းပါ။
၅။ <strong>Validation</strong>: model ကို မပို့မီ message structure ကို စစ်ဆေးပါ။</p> <blockquote class="warning" data-svelte-h="svelte-1adzn6u"><p>ရှောင်ရှားရမည့် အဖြစ်များသော အမှားများ…</p> <ul><li>တူညီတဲ့ application ထဲမှာ မတူညီတဲ့ template formats တွေကို ရောနှောအသုံးပြုခြင်း။</li> <li>ရှည်လျားတဲ့ စကားပြောဆိုမှု မှတ်တမ်းတွေနဲ့ token ကန့်သတ်ချက်တွေကို ကျော်လွန်ခြင်း။</li> <li>messages တွေမှာ special characters တွေကို မှန်ကန်စွာ escaping မလုပ်ခြင်း။</li> <li>input message structure ကို စစ်ဆေးဖို့ မေ့လျော့ခြင်း။</li> <li>model-specific template လိုအပ်ချက်တွေကို လျစ်လျူရှုခြင်း။</li></ul></blockquote> <h2 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></h2> <p data-svelte-h="svelte-1jbczh6">လက်တွေ့ကမ္ဘာ ဥပမာတစ်ခုနဲ့ chat templates တွေကို implement လုပ်တာကို လေ့ကျင့်ကြရအောင်။</p> <blockquote class="tip"><p data-svelte-h="svelte-2yo2pm"><code>HuggingFaceTB/smoltalk</code> dataset ကို chatml format သို့ ပြောင်းလဲဖို့ အောက်ပါအဆင့်တွေကို လိုက်နာပါ-</p> <p data-svelte-h="svelte-4ak7zz">၁။ dataset ကို 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> datasets <span class="hljs-keyword">import</span> load_dataset
dataset = load_dataset(<span class="hljs-string">&quot;HuggingFaceTB/smoltalk&quot;</span>)<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-112q6be">၂။ processing 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">def</span> <span class="hljs-title function_">convert_to_chatml</span>(<span class="hljs-params">example</span>):
<span class="hljs-keyword">return</span> {
<span class="hljs-string">&quot;messages&quot;</span>: [
{<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: example[<span class="hljs-string">&quot;input&quot;</span>]},
{<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;assistant&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: example[<span class="hljs-string">&quot;output&quot;</span>]},
]
}<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-1uu03aw">၃။ သင်ရွေးချယ်ထားသော model ၏ tokenizer ကို အသုံးပြု၍ chat template ကို apply လုပ်ပါ။</p> <p data-svelte-h="svelte-zxceib">သင်၏ output format သည် သင်၏ target model ၏ လိုအပ်ချက်များနှင့် ကိုက်ညီကြောင်း သေချာစေရန် မမေ့ပါနှင့်!</p></blockquote> <h2 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></h2> <ul data-svelte-h="svelte-kyf9sf"><li><a href="https://huggingface.co/docs/transformers/main/en/chat_templating" rel="nofollow">Hugging Face Chat Templating Guide</a></li> <li><a href="https://huggingface.co/docs/transformers" rel="nofollow">Transformers Documentation</a></li> <li><a href="https://github.com/chujiezheng/chat_templates" rel="nofollow">Chat Templates Examples Repository</a></li></ul> <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-1lwvnjy"><li><strong>Chat Templates</strong>: ဘာသာစကားမော်ဒယ်တွေနဲ့ အသုံးပြုသူတွေကြား အပြန်အလှန်ဆက်သွယ်မှုတွေကို စနစ်တကျ ပြုလုပ်ပေးသည့် ဖွဲ့စည်းပုံများ။ ၎င်းတို့သည် တသမတ်တည်းဖြစ်ပြီး အခြေအနေနှင့်ကိုက်ညီသော တုံ့ပြန်မှုများကို သေချာစေသည်။</li> <li><strong>Language Models</strong>: လူသားဘာသာစကား၏ ဖြန့်ဝေမှုကို နားလည်ရန် လေ့ကျင့်ထားသော AI မော်ဒယ်တစ်ခု။ ၎င်းသည် စာသားထုတ်လုပ်ခြင်း၊ ဘာသာပြန်ခြင်း စသည့်လုပ်ငန်းများတွင် အသုံးပြုနိုင်သည်။</li> <li><strong>AI Agent</strong>: လူသားနှင့် ဆက်သွယ်နိုင်ပြီး သတ်မှတ်ထားသော လုပ်ငန်းဆောင်တာများကို လုပ်ဆောင်နိုင်သည့် Artificial Intelligence (AI) စနစ်။</li> <li><strong>Chatbot</strong>: လူသားတို့၏ စကားပြောဆိုမှုများကို တုပရန် ဒီဇိုင်းထုတ်ထားသော ကွန်ပျူတာပရိုဂရမ်။</li> <li><strong>Consistent Conversation Structure</strong>: စကားပြောဆိုမှု၏ ပုံစံသည် အမြဲတမ်း တူညီနေခြင်း။</li> <li><strong>Role Identification</strong>: စကားပြောဆိုမှုအတွင်း ပါဝင်သူများ (ဥပမာ- system, user, assistant) ၏ အခန်းကဏ္ဍများကို ရှင်းလင်းစွာ ဖော်ထုတ်ခြင်း။</li> <li><strong>Context Management</strong>: စကားပြောဆိုမှု မှတ်တမ်းကို ထိန်းသိမ်းပြီး အတိတ်က စကားပြောဆိုမှုများကို model က မှတ်မိနိုင်စေရန် စီမံခန့်ခွဲခြင်း။</li> <li><strong>Tool Use</strong>: AI model တစ်ခုက ပြင်ပကိရိယာများ (ဥပမာ- calculator, weather API) ကို ခေါ်ဆိုပြီး အသုံးပြုနိုင်ခြင်း။</li> <li><strong>Base Model</strong>: ကုန်ကြမ်းစာသားဒေတာ (raw text data) ပေါ်တွင် နောက်ဆက်တွဲ token ကို ခန့်မှန်းဖို့ လေ့ကျင့်ထားသော ဘာသာစကားမော်ဒယ်။ ၎င်းသည် သီးခြားညွှန်ကြားချက်များကို လိုက်နာရန် fine-tune လုပ်ထားခြင်း မရှိသေးပေ။</li> <li><strong>Instruct Model</strong>: ညွှန်ကြားချက်များကို လိုက်နာပြီး စကားပြောဆိုမှုများတွင် ပါဝင်ရန်အတွက် သီးခြား fine-tune လုပ်ထားသော ဘာသာစကားမော်ဒယ်။</li> <li><strong>Raw Text Data</strong>: မည်သည့် preprocessing မျှ မလုပ်ဆောင်ရသေးသော စာသားဒေတာ။</li> <li><strong>Predict the Next Token</strong>: model တစ်ခုက လက်ရှိ sequence ကို အခြေခံပြီး နောက်ဆက်တွဲဖြစ်လာမည့် စကားလုံး သို့မဟုတ် token ကို ခန့်မှန်းခြင်း။</li> <li><strong>Fine-tuned</strong>: ကြိုတင်လေ့ကျင့်ထားပြီးသား (pre-trained) မော်ဒယ်တစ်ခုကို သီးခြားလုပ်ငန်းတစ်ခု (specific task) အတွက် အနည်းငယ်သော ဒေတာနဲ့ ထပ်မံလေ့ကျင့်ပေးခြင်းကို ဆိုလိုပါတယ်။</li> <li><strong><code>SmolLM2-135M</code></strong>: Hugging Face မှ ထုတ်လုပ်ထားသော base language model တစ်မျိုး။</li> <li><strong><code>SmolLM2-135M-Instruct</code></strong>: <code>SmolLM2-135M</code> ၏ instruction-tuned version။</li> <li><strong>Instruction-tuned Variant</strong>: Base model တစ်ခုကို ညွှန်ကြားချက်များကို လိုက်နာရန်အတွက် ထပ်မံ fine-tune လုပ်ထားသော version။</li> <li><strong>Chatbot Applications</strong>: Chatbot များအတွက် ဒီဇိုင်းထုတ်ထားသော ဆော့ဖ်ဝဲလ်များ။</li> <li><strong>Multimodal Inputs</strong>: ပုံရိပ်များ၊ အသံများ သို့မဟုတ် အခြား media အမျိုးအစားများကဲ့သို့ မတူညီသော input အမျိုးအစားများ။</li> <li><strong>Function Calling</strong>: LLM က သီးခြား function တစ်ခုကို ခေါ်ဆိုပြီး လုပ်ဆောင်စေနိုင်ခြင်း။</li> <li><strong>Prompts</strong>: AI model သို့ ပေးပို့သော ညွှန်ကြားချက်များ သို့မဟုတ် မေးခွန်းများ။</li> <li><strong>ChatML</strong>: စကားပြောဆိုမှုများကို ရှင်းလင်းသော အခန်းကဏ္ဍညွှန်းကိန်းများ (system, user, assistant) ဖြင့် ဖွဲ့စည်းထားသော template format တစ်မျိုး။</li> <li><strong>Role Indicators</strong>: စကားပြောဆိုမှုအတွင်း ပါဝင်သူများ၏ အခန်းကဏ္ဍကို ဖော်ပြသော အမှတ်အသားများ။</li> <li><strong>Tokenizer Configuration</strong>: tokenizer ၏ ဖွဲ့စည်းပုံနှင့် လုပ်ဆောင်ပုံကို သတ်မှတ်ထားသော အချက်အလက်များ။</li> <li><strong>Hub</strong>: Hugging Face Hub ကို ရည်ညွှန်းပြီး AI မော်ဒယ်များ ရှာဖွေ၊ မျှဝေ၊ အသုံးပြုနိုင်သော ဗဟို platform။</li> <li><strong>Llama 2 / Llama 3</strong>: Meta AI မှ ထုတ်လုပ်သော Large Language Models များ။</li> <li><strong>Mistral</strong>: Mistral AI မှ ထုတ်လုပ်သော Large Language Model။</li> <li><strong>Qwen 2</strong>: Alibaba Cloud မှ ထုတ်လုပ်သော Large Language Model။</li> <li><strong>ChatGPT</strong>: OpenAI မှ ဖန်တီးထားသော လူသားနှင့်ဆင်တူသော စာသားများကို ဖန်တီးနိုင်သည့် conversational AI မော်ဒယ်။</li> <li><strong><code>system</code> role</strong>: AI model ၏ အခြေခံညွှန်ကြားချက်များ သို့မဟုတ် အခန်းကဏ္ဍကို သတ်မှတ်သော message role။</li> <li><strong><code>user</code> role</strong>: အသုံးပြုသူမှ ပေးပို့သော message role။</li> <li><strong><code>assistant</code> role</strong>: AI model မှ ပြန်လည်တုံ့ပြန်သော message role။</li> <li><strong><code>[INST]</code> / <code>[/INST]</code> tags</strong>: Llama 2 နှင့် Mistral templates များတွင် ညွှန်ကြားချက်များကို ဝန်းရံရန် အသုံးပြုသော tags များ။</li> <li><strong><code>&lt;|im_start|&gt;</code> / <code>&lt;|im_end|&gt;</code> tags</strong>: ChatML template တွင် message boundaries များကို ဖော်ပြသော tokens များ။</li> <li><strong><code>&lt;s&gt;</code> / <code>&lt;/s&gt;</code> tokens</strong>: Llama 2 နှင့် Mistral templates များတွင် စကားပြောဆိုမှု သို့မဟုတ် turn boundaries များကို ဖော်ပြသော special tokens များ။</li> <li><strong><code>AutoTokenizer</code></strong>: Hugging Face Transformers library မှာ ပါဝင်တဲ့ class တစ်ခုဖြစ်ပြီး မော်ဒယ်အမည်ကို အသုံးပြုပြီး သက်ဆိုင်ရာ tokenizer ကို အလိုအလျောက် load လုပ်ပေးသည်။</li> <li><strong><code>apply_chat_template()</code> Method</strong>: tokenizer ၏ method တစ်ခုဖြစ်ပြီး <code>messages</code> list ကို model အတွက် သင့်လျော်သော chat template format သို့ ပြောင်းလဲပေးသည်။</li> <li><strong><code>tokenize=False</code></strong>: <code>apply_chat_template()</code> method တွင် output ကို tokens များအဖြစ် ပြောင်းလဲခြင်းမရှိဘဲ formatted string အဖြစ်သာ ပြန်ပေးရန် သတ်မှတ်သည်။</li> <li><strong>External Tools/APIs</strong>: AI model နှင့် ဆက်သွယ်နိုင်သော ပြင်ပဆော့ဖ်ဝဲလ်များ သို့မဟုတ် ဝန်ဆောင်မှုများ။</li> <li><strong>Base64-encoded Images</strong>: ပုံရိပ်များကို စာသားအခြေခံ format သို့ ပြောင်းလဲခြင်း။</li> <li><strong><code>image_url</code></strong>: ပုံရိပ်တစ်ခု၏ URL (web address)။</li> <li><strong><code>tool_calls</code></strong>: AI model က ပြင်ပ tool တစ်ခုကို ခေါ်ဆိုရန် စီစဉ်ထားသော အချက်အလက်များ။</li> <li><strong><code>tool_name</code></strong>: ခေါ်ဆိုမည့် tool ၏ အမည်။</li> <li><strong><code>parameters</code></strong>: tool function သို့ ပေးပို့မည့် arguments များ။</li> <li><strong><code>content</code></strong>: message ၏ အကြောင်းအရာ။</li> <li><strong>Consistent Formatting</strong>: သင့် application တစ်လျှောက်လုံး တူညီတဲ့ template format ကို အမြဲတမ်း အသုံးပြုခြင်း။</li> <li><strong>Clear Role Definition</strong>: message တစ်ခုစီအတွက် roles (system, user, assistant, tool) တွေကို ရှင်းလင်းစွာ သတ်မှတ်ခြင်း။</li> <li><strong>Context Management</strong>: စကားပြောဆိုမှု မှတ်တမ်းကို ထိန်းသိမ်းပြီး model က အတိတ်က စကားပြောဆိုမှုများကို မှတ်မိနိုင်စေရန် စီမံခန့်ခွဲခြင်း။</li> <li><strong>Token Limits</strong>: model တစ်ခုက တစ်ကြိမ်တည်း လုပ်ဆောင်နိုင်သော tokens များ၏ အများဆုံးအရေအတွက်။</li> <li><strong>Error Handling</strong>: ပရိုဂရမ်တစ်ခုတွင် အမှားများဖြစ်ပေါ်လာသည့်အခါ ၎င်းတို့ကို ထိရောက်စွာ ကိုင်တွယ်ဖြေရှင်းရန် ဒီဇိုင်းထုတ်ထားသော code အပိုင်း။</li> <li><strong>Validation</strong>: input data သို့မဟုတ် message structure သည် သတ်မှတ်ထားသော စည်းမျဉ်းများနှင့် ကိုက်ညီခြင်းရှိမရှိ စစ်ဆေးခြင်း။</li> <li><strong>Escaping Special Characters</strong>: စာသားအတွင်းရှိ အထူး characters များကို ၎င်းတို့၏ စာသားတန်ဖိုးအဖြစ် အဓိပ္ပာယ်ဖွင့်ဆိုနိုင်ရန် ပြောင်းလဲခြင်း။</li> <li><strong>Model-specific Template Requirements</strong>: သီးခြား model တစ်ခုအတွက် လိုအပ်သော chat template ၏ ပုံစံများ။</li> <li><strong><code>HuggingFaceTB/smoltalk</code> Dataset</strong>: Hugging Face မှ စမ်းသပ်မှုများအတွက် ထုတ်လုပ်ထားသော dataset တစ်မျိုး။</li> <li><strong><code>load_dataset()</code></strong>: Hugging Face Datasets library မှ dataset များကို download လုပ်ပြီး cache လုပ်ရန် အသုံးပြုသော function။</li> <li><strong><code>convert_to_chatml()</code></strong>: dataset ကို ChatML format သို့ ပြောင်းလဲရန်အတွက် processing function။</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/chapter11/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, 22],
data,
form: null,
error: null
});
});
}
</script>

Xet Storage Details

Size:
75.8 kB
·
Xet hash:
342c3e65709f172736bc7f1bf50caca48e54e7afd548ceada6db70e2ab2eff6b

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