{"id":30,"date":"2026-04-08T14:57:02","date_gmt":"2026-04-08T13:57:02","guid":{"rendered":"https:\/\/shopping-news.site\/?p=30"},"modified":"2026-04-08T15:16:11","modified_gmt":"2026-04-08T14:16:11","slug":"chat-templates-can-improve-lm-inferencing","status":"publish","type":"post","link":"https:\/\/shopping-news.site\/?p=30","title":{"rendered":"Chat Templates can improve LM inferencing."},"content":{"rendered":"<div class=\"anp-pro-entry\">\n<p class=\"anp-pro-lead\">The topic <strong>Chat Templates can improve LM inferencing.<\/strong> is currently the subject of lively discussion \u2014 readers and analysts are keeping a close eye on developments.<\/p>\n<p class=\"anp-pro-p\">This is taking place in a dynamic environment: companies\u2019 decisions and competitors\u2019 reactions can quickly change the picture.<\/p>\n<p class=\"anp-pro-p\">We load the SmolLM3 tokenizer and see its tokenizer.chat_template.  When the user asks \u201cHow far is the sun?\u201d, the template produces a single prompt like:<\/p>\n<p class=\"anp-pro-p\">The model then fills in the assistant\u2019s reply. for example, the output might be: \u201cThe sun is about 93 million miles away.\u201d<\/p>\n<p class=\"anp-pro-p\">Imagine you have a talking robot and you want it to know who\u2019s talking and what to say. A chat template is like a script or recipe that tells the robot how to set up each conversation.<\/p>\n<p class=\"anp-pro-p\">Every time someone asks something, the computer fills in the blanks, and the puppet (the AI) knows exactly when to speak.<\/p>\n<p class=\"anp-pro-p\">This way, the conversation always follows the same \u201crecipe\u201d or \u201cscript,\u201d so the AI doesn\u2019t get confused about what to do. This helps even small models (like SmolLM3) understand the pattern of a conversation.<\/p>\n<p class=\"anp-pro-p\">In other words, a chat template defines the format of the prompt. for example, a template might say:<\/p>\n<figure class=\"anp-pro-inline-figure\" style=\"margin:1.75em auto;text-align:center;max-width:100%;\"><img class=\"anp-pro-inline-img\" src=\"http:\/\/shopping-news.site\/wp-content\/uploads\/2026\/04\/https3A2F2Fdev-to-uploads.s3.amazonaws.com2Fuploads2Farticles2Frgdp9vfksu2yrrpsfrt2.webp\" alt=\"\" style=\"display:block;margin:0 auto;max-width:100%;width:auto;height:auto;object-fit:contain;object-position:center;\" loading=\"lazy\" decoding=\"async\"><\/figure>\n<p class=\"anp-pro-p\">Here, {{system_message}} is a placeholder for any initial instruction, {{user_message}} is where the user\u2019s input goes, and {{assistant_message}} is where the model should reply. The tokenizer takes this template and the conversation data, fills in the placeholders, and then tokenizes the resulting string. Hugging Face\u2019s Transformers library handles this automatically, so developers don\u2019t have to manually concatenate strings or add special tokens.<\/p>\n<p class=\"anp-pro-p\">Placeholders: These are like blanks in the script. Common placeholders are {{user}}, {{assistant}}, and sometimes {{system}} or others. When you run a conversation, the actual text from the user or previous assistant message is plugged into these placeholders. for example, if {{user}} was \u201cWhat is 2+2?\u201d, the template might produce something like \u201cUser: What is 2+2?\u201d in the final prompt.<\/p>\n<p class=\"anp-pro-p\">Roles: Templates usually distinguish who is speaking. The most common roles are:<\/p>\n<p class=\"anp-pro-p\">Some templates might also include Function\/Tool messages (for advanced uses), but basic chat templates focus on system\/user\/assistant.<\/p>\n<p class=\"anp-pro-p\">`, if needed) and converts it to IDs. for example, if the system message is \u201cSolve math problems,\u201d and the user asks \u201c2+2?\u201d, the filled prompt might be:<\/p>\n<p class=\"anp-pro-p\">These features can improve accuracy and safety because the model sees prompts exactly as the trainers intended. As Hugging Face puts it, chat templates are the foundation of instruction tuning, giving a stable format.<\/p>\n<figure class=\"anp-pro-inline-figure\" style=\"margin:1.75em auto;text-align:center;max-width:100%;\"><img class=\"anp-pro-inline-img\" src=\"http:\/\/shopping-news.site\/wp-content\/uploads\/2026\/04\/https3A2F2Fdev-to-uploads.s3.amazonaws.com2Fuploads2Farticles2Fn7oswxidnxnx8eud3dlq.webp\" alt=\"\" style=\"display:block;margin:0 auto;max-width:100%;width:auto;height:auto;object-fit:contain;object-position:center;\" loading=\"lazy\" decoding=\"async\"><\/figure>\n<p class=\"anp-pro-p\">In summary, chat templates greatly simplify formatting, but you must still handle safety (e.g. sanitize inputs), manage long conversations, and ensure the template itself is correct for your use case.<\/p>\n<p class=\"anp-pro-p\">Templates let you quickly answer FAQs or store snippets for re-use.<\/p>\n<p class=\"anp-pro-p\">Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment&#8217;s permalink.<\/p>\n<p class=\"anp-pro-p\">For further actions, you may consider blocking this person and\/or reporting abuse<\/p>\n<p class=\"anp-pro-p\">Thank you to our Diamond Sponsors for supporting the DEV Community<\/p>\n<p class=\"anp-pro-p\">Google AI is the official AI Model and Platform Partner of DEV<\/p>\n<p class=\"anp-pro-p\">DEV Community \u2014 A space to discuss and keep up software development and manage your software career<\/p>\n<p class=\"anp-pro-p\">Built on Forem \u2014 the open source software that powers DEV and other inclusive communities.<\/p>\n<p class=\"anp-pro-p\">We&#8217;re a place where coders share, stay up-to-date and grow their careers.<\/p>\n<aside class=\"anp-pro-aside\" aria-label=\"context\">\n<p class=\"anp-pro-kicker\">Why it matters<\/p>\n<p class=\"anp-pro-p\">News like this often changes audience expectations and competitors\u2019 plans.<\/p>\n<p class=\"anp-pro-p\">When one player makes a move, others usually react \u2014 it is worth reading the event in context.<\/p>\n<\/aside>\n<aside class=\"anp-pro-aside\" aria-label=\"outlook\">\n<p class=\"anp-pro-kicker\">What to look out for next<\/p>\n<p class=\"anp-pro-p\">The full picture will become clear in time, but the headline already shows the dynamics of the industry.<\/p>\n<p class=\"anp-pro-p\">Further statements and user reactions will add to the story.<\/p>\n<\/aside>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>The topic Chat Templates can improve LM inferencing. is currently the subject of lively discussion \u2014 readers and<\/p>\n","protected":false},"author":1,"featured_media":31,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[31,28,17,30,29,27],"class_list":["post-30","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tech","tag-assistant","tag-chat","tag-systems","tag-template","tag-templates","tag-user"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Chat Templates can improve LM inferencing. - shopping-news.site<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/shopping-news.site\/?p=30\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Chat Templates can improve LM inferencing. - shopping-news.site\" \/>\n<meta property=\"og:description\" content=\"The topic Chat Templates can improve LM inferencing. is currently the subject of lively discussion \u2014 readers and\" \/>\n<meta property=\"og:url\" content=\"https:\/\/shopping-news.site\/?p=30\" \/>\n<meta property=\"og:site_name\" content=\"shopping-news.site\" \/>\n<meta property=\"article:published_time\" content=\"2026-04-08T13:57:02+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-04-08T14:16:11+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/shopping-news.site\/wp-content\/uploads\/2026\/04\/https3A2F2Fdev-to-uploads.s3.amazonaws.com2Fuploads2Farticles2Fvoygz6vb3gjmmbulye2b.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1167\" \/>\n\t<meta property=\"og:image:height\" content=\"610\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"shopping_new\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"shopping_new\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/shopping-news.site\\\/?p=30#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/shopping-news.site\\\/?p=30\"},\"author\":{\"name\":\"shopping_new\",\"@id\":\"https:\\\/\\\/shopping-news.site\\\/#\\\/schema\\\/person\\\/ac3b8aa0836b6d8581914b83b9929238\"},\"headline\":\"Chat Templates can improve LM inferencing.\",\"datePublished\":\"2026-04-08T13:57:02+00:00\",\"dateModified\":\"2026-04-08T14:16:11+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/shopping-news.site\\\/?p=30\"},\"wordCount\":639,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/shopping-news.site\\\/?p=30#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/shopping-news.site\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/https3A2F2Fdev-to-uploads.s3.amazonaws.com2Fuploads2Farticles2Fvoygz6vb3gjmmbulye2b.webp\",\"keywords\":[\"Assistant\",\"Chat\",\"Systems\",\"Template\",\"Templates\",\"User\"],\"articleSection\":[\"Tech\"],\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/shopping-news.site\\\/?p=30#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/shopping-news.site\\\/?p=30\",\"url\":\"https:\\\/\\\/shopping-news.site\\\/?p=30\",\"name\":\"Chat Templates can improve LM inferencing. - shopping-news.site\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/shopping-news.site\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/shopping-news.site\\\/?p=30#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/shopping-news.site\\\/?p=30#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/shopping-news.site\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/https3A2F2Fdev-to-uploads.s3.amazonaws.com2Fuploads2Farticles2Fvoygz6vb3gjmmbulye2b.webp\",\"datePublished\":\"2026-04-08T13:57:02+00:00\",\"dateModified\":\"2026-04-08T14:16:11+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/shopping-news.site\\\/#\\\/schema\\\/person\\\/ac3b8aa0836b6d8581914b83b9929238\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/shopping-news.site\\\/?p=30#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/shopping-news.site\\\/?p=30\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/shopping-news.site\\\/?p=30#primaryimage\",\"url\":\"https:\\\/\\\/shopping-news.site\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/https3A2F2Fdev-to-uploads.s3.amazonaws.com2Fuploads2Farticles2Fvoygz6vb3gjmmbulye2b.webp\",\"contentUrl\":\"https:\\\/\\\/shopping-news.site\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/https3A2F2Fdev-to-uploads.s3.amazonaws.com2Fuploads2Farticles2Fvoygz6vb3gjmmbulye2b.webp\",\"width\":1167,\"height\":610},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/shopping-news.site\\\/?p=30#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/shopping-news.site\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Chat Templates can improve LM inferencing.\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/shopping-news.site\\\/#website\",\"url\":\"https:\\\/\\\/shopping-news.site\\\/\",\"name\":\"shopping-news.site\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/shopping-news.site\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-GB\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/shopping-news.site\\\/#\\\/schema\\\/person\\\/ac3b8aa0836b6d8581914b83b9929238\",\"name\":\"shopping_new\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/38f7f0fbea410988ca8e02b5e12e387a1eb5f906c6bf65421604bafacf913268?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/38f7f0fbea410988ca8e02b5e12e387a1eb5f906c6bf65421604bafacf913268?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/38f7f0fbea410988ca8e02b5e12e387a1eb5f906c6bf65421604bafacf913268?s=96&d=mm&r=g\",\"caption\":\"shopping_new\"},\"sameAs\":[\"http:\\\/\\\/shopping-news.site\"],\"url\":\"https:\\\/\\\/shopping-news.site\\\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Chat Templates can improve LM inferencing. - shopping-news.site","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/shopping-news.site\/?p=30","og_locale":"en_GB","og_type":"article","og_title":"Chat Templates can improve LM inferencing. - shopping-news.site","og_description":"The topic Chat Templates can improve LM inferencing. is currently the subject of lively discussion \u2014 readers and","og_url":"https:\/\/shopping-news.site\/?p=30","og_site_name":"shopping-news.site","article_published_time":"2026-04-08T13:57:02+00:00","article_modified_time":"2026-04-08T14:16:11+00:00","og_image":[{"width":1167,"height":610,"url":"http:\/\/shopping-news.site\/wp-content\/uploads\/2026\/04\/https3A2F2Fdev-to-uploads.s3.amazonaws.com2Fuploads2Farticles2Fvoygz6vb3gjmmbulye2b.webp","type":"image\/webp"}],"author":"shopping_new","twitter_card":"summary_large_image","twitter_misc":{"Written by":"shopping_new","Estimated reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/shopping-news.site\/?p=30#article","isPartOf":{"@id":"https:\/\/shopping-news.site\/?p=30"},"author":{"name":"shopping_new","@id":"https:\/\/shopping-news.site\/#\/schema\/person\/ac3b8aa0836b6d8581914b83b9929238"},"headline":"Chat Templates can improve LM inferencing.","datePublished":"2026-04-08T13:57:02+00:00","dateModified":"2026-04-08T14:16:11+00:00","mainEntityOfPage":{"@id":"https:\/\/shopping-news.site\/?p=30"},"wordCount":639,"commentCount":0,"image":{"@id":"https:\/\/shopping-news.site\/?p=30#primaryimage"},"thumbnailUrl":"https:\/\/shopping-news.site\/wp-content\/uploads\/2026\/04\/https3A2F2Fdev-to-uploads.s3.amazonaws.com2Fuploads2Farticles2Fvoygz6vb3gjmmbulye2b.webp","keywords":["Assistant","Chat","Systems","Template","Templates","User"],"articleSection":["Tech"],"inLanguage":"en-GB","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/shopping-news.site\/?p=30#respond"]}]},{"@type":"WebPage","@id":"https:\/\/shopping-news.site\/?p=30","url":"https:\/\/shopping-news.site\/?p=30","name":"Chat Templates can improve LM inferencing. - shopping-news.site","isPartOf":{"@id":"https:\/\/shopping-news.site\/#website"},"primaryImageOfPage":{"@id":"https:\/\/shopping-news.site\/?p=30#primaryimage"},"image":{"@id":"https:\/\/shopping-news.site\/?p=30#primaryimage"},"thumbnailUrl":"https:\/\/shopping-news.site\/wp-content\/uploads\/2026\/04\/https3A2F2Fdev-to-uploads.s3.amazonaws.com2Fuploads2Farticles2Fvoygz6vb3gjmmbulye2b.webp","datePublished":"2026-04-08T13:57:02+00:00","dateModified":"2026-04-08T14:16:11+00:00","author":{"@id":"https:\/\/shopping-news.site\/#\/schema\/person\/ac3b8aa0836b6d8581914b83b9929238"},"breadcrumb":{"@id":"https:\/\/shopping-news.site\/?p=30#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/shopping-news.site\/?p=30"]}]},{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/shopping-news.site\/?p=30#primaryimage","url":"https:\/\/shopping-news.site\/wp-content\/uploads\/2026\/04\/https3A2F2Fdev-to-uploads.s3.amazonaws.com2Fuploads2Farticles2Fvoygz6vb3gjmmbulye2b.webp","contentUrl":"https:\/\/shopping-news.site\/wp-content\/uploads\/2026\/04\/https3A2F2Fdev-to-uploads.s3.amazonaws.com2Fuploads2Farticles2Fvoygz6vb3gjmmbulye2b.webp","width":1167,"height":610},{"@type":"BreadcrumbList","@id":"https:\/\/shopping-news.site\/?p=30#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/shopping-news.site\/"},{"@type":"ListItem","position":2,"name":"Chat Templates can improve LM inferencing."}]},{"@type":"WebSite","@id":"https:\/\/shopping-news.site\/#website","url":"https:\/\/shopping-news.site\/","name":"shopping-news.site","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/shopping-news.site\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-GB"},{"@type":"Person","@id":"https:\/\/shopping-news.site\/#\/schema\/person\/ac3b8aa0836b6d8581914b83b9929238","name":"shopping_new","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/secure.gravatar.com\/avatar\/38f7f0fbea410988ca8e02b5e12e387a1eb5f906c6bf65421604bafacf913268?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/38f7f0fbea410988ca8e02b5e12e387a1eb5f906c6bf65421604bafacf913268?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/38f7f0fbea410988ca8e02b5e12e387a1eb5f906c6bf65421604bafacf913268?s=96&d=mm&r=g","caption":"shopping_new"},"sameAs":["http:\/\/shopping-news.site"],"url":"https:\/\/shopping-news.site\/?author=1"}]}},"_links":{"self":[{"href":"https:\/\/shopping-news.site\/index.php?rest_route=\/wp\/v2\/posts\/30","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/shopping-news.site\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/shopping-news.site\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/shopping-news.site\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/shopping-news.site\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=30"}],"version-history":[{"count":1,"href":"https:\/\/shopping-news.site\/index.php?rest_route=\/wp\/v2\/posts\/30\/revisions"}],"predecessor-version":[{"id":37,"href":"https:\/\/shopping-news.site\/index.php?rest_route=\/wp\/v2\/posts\/30\/revisions\/37"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/shopping-news.site\/index.php?rest_route=\/wp\/v2\/media\/31"}],"wp:attachment":[{"href":"https:\/\/shopping-news.site\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=30"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/shopping-news.site\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=30"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/shopping-news.site\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=30"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}