<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sandesh Dhungana</title>
    <description>The latest articles on DEV Community by Sandesh Dhungana (@sandesh32).</description>
    <link>https://dev.to/sandesh32</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F752187%2F189b4542-bf5a-4741-a216-7f35d7f880e5.jpeg</url>
      <title>DEV Community: Sandesh Dhungana</title>
      <link>https://dev.to/sandesh32</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sandesh32"/>
    <language>en</language>
    <item>
      <title>Be a Responsible Prompter: How Clear, Concise Prompts Save Compute, Time, and Energy</title>
      <dc:creator>Sandesh Dhungana</dc:creator>
      <pubDate>Mon, 23 Nov 2026 17:06:13 +0000</pubDate>
      <link>https://dev.to/sandesh32/be-a-responsible-prompter-how-clear-concise-prompts-save-compute-time-and-energy-4ld6</link>
      <guid>https://dev.to/sandesh32/be-a-responsible-prompter-how-clear-concise-prompts-save-compute-time-and-energy-4ld6</guid>
      <description>&lt;h2&gt;
  
  
  Why Prompt Clarity Matters
&lt;/h2&gt;

&lt;p&gt;When you ask an AI model to generate text, the model explores a large space of possible completions. Every extra token you add to a prompt expands that space, and the model must perform more matrix multiplications to evaluate each candidate. Those extra operations translate directly into higher electricity consumption on the data center hardware. In practice, a prompt that is five words longer can increase the total token count of a request by 10‑15 % and the corresponding compute cost by a similar margin. Reducing unnecessary words therefore saves both time for the user and energy for the provider.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Write Concise Prompts
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;State the goal first&lt;/strong&gt; – Begin with the verb that describes what you need (e.g., "Summarize," "Translate," "Generate a list").&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Include only essential context&lt;/strong&gt; – Provide the minimum amount of background that the model cannot infer. If the model already knows the language, omit "in English" unless you are switching languages.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use explicit constraints&lt;/strong&gt; – If you need a specific format, mention it in a short clause (e.g., "as a JSON object" or "in three bullet points").&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Avoid filler adjectives&lt;/strong&gt; – Words like "very," "extremely," or "nice" rarely change the output but increase token count.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Leverage system messages&lt;/strong&gt; – When using an API that supports system prompts, move static instructions there so they are not repeated with every user query.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Example: Summarizing an Article
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Inefficient prompt&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Please read the following article about climate policy that was published last week on the website of the International Climate Initiative, and then give me a short summary of the main points, focusing especially on the new legislation that was mentioned, and try to keep the summary under 200 words.&lt;/p&gt;

&lt;p&gt;Token count for the prompt: 44 tokens (approx). The model must parse the request, identify the article, and figure out the desired length.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Optimized prompt&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Summarize the article below in under 200 words, focusing on the new climate legislation.&lt;br&gt;
[article text]&lt;/p&gt;

&lt;p&gt;Token count for the prompt: 22 tokens (approx). The same request is delivered in half the tokens. In a batch of 100 similar requests, the token savings would be roughly 2,200 tokens, which translates to measurable compute reduction on the server side.&lt;/p&gt;

&lt;h2&gt;
  
  
  Measuring the Impact
&lt;/h2&gt;

&lt;p&gt;Most AI providers expose token usage in their API responses. By comparing the &lt;code&gt;prompt_tokens&lt;/code&gt; field before and after optimization, you can see the exact reduction. For a single request, cutting 20 tokens can lower the cost by about $0.0002 (depending on pricing). Multiply that across thousands of daily queries, and the financial savings become non‑trivial. More importantly, the energy saved per token is roughly proportional to the number of matrix operations, so a 30 % reduction in token count can shave a similar percentage off the CPU/GPU cycles used.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tips for Ongoing Improvement
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Audit your prompts regularly&lt;/strong&gt; – Keep a log of the most frequent queries and look for repetitive filler.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use token‑counting tools&lt;/strong&gt; – Simple scripts can count tokens before sending a request; flag prompts that exceed a target length.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Iterate with A/B testing&lt;/strong&gt; – Send the original and the shortened prompt to the model and compare output quality. If the concise version meets the requirement, adopt it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Document prompt patterns&lt;/strong&gt; – Create a shared library of short, well‑tested prompts for common tasks. Teams can copy these instead of writing new, longer versions each time.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Educate collaborators&lt;/strong&gt; – When onboarding new users, demonstrate the cost impact of verbose prompts with concrete numbers from your own logs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By treating prompt design as a part of responsible AI usage, you reduce compute waste, lower operational costs, and contribute to a smaller carbon footprint for the whole ecosystem. Clear, concise prompts are a simple habit that yields immediate benefits for both developers and the environment.&lt;/p&gt;

</description>
      <category>prompting</category>
      <category>efficiency</category>
      <category>ai</category>
      <category>sustainability</category>
    </item>
    <item>
      <title>Do typos make AI work harder? Tokenization and misspelled prompts</title>
      <dc:creator>Sandesh Dhungana</dc:creator>
      <pubDate>Mon, 23 Nov 2026 15:06:38 +0000</pubDate>
      <link>https://dev.to/sandesh32/do-typos-make-ai-work-harder-tokenization-and-misspelled-prompts-2dpk</link>
      <guid>https://dev.to/sandesh32/do-typos-make-ai-work-harder-tokenization-and-misspelled-prompts-2dpk</guid>
      <description>&lt;h2&gt;
  
  
  Tokenization basics
&lt;/h2&gt;

&lt;p&gt;Modern large‑language models never see raw characters. Before any inference step the input string is broken down into &lt;strong&gt;tokens&lt;/strong&gt;, the atomic units the model was trained on. For OpenAI's GPT‑4 family the tokenizer is a byte‑pair‑encoding (BPE) that tries to reuse common sub‑word patterns. A token can be a whole word ("computer"), a common prefix or suffix ("ing"), or even a single byte if the sequence is rare. The model’s attention mechanism works over these token IDs, so the number of tokens directly determines the amount of computation required for a forward pass.&lt;/p&gt;

&lt;h2&gt;
  
  
  How misspellings affect the token stream
&lt;/h2&gt;

&lt;p&gt;When a word appears exactly as it did during training, the tokenizer usually maps it to a single token. Misspellings, however, break that pattern. The BPE algorithm then falls back to smaller pieces that &lt;em&gt;do&lt;/em&gt; exist in its vocabulary. The result is a longer token sequence for the same semantic content, which means the model has to process more positions.&lt;/p&gt;

&lt;p&gt;Consider the sentence:&lt;/p&gt;

&lt;p&gt;The quick brown fox jumps over the lazy dog.&lt;/p&gt;

&lt;p&gt;In the GPT‑4 tokenizer this string is tokenized as 10 tokens – one for each word plus the period. Now replace two words with common typos:&lt;/p&gt;

&lt;p&gt;The quik brown fox jumps ovr the lazy dog.&lt;/p&gt;

&lt;p&gt;Running the same tokenizer yields 12 tokens. "quick" becomes the two‑token pair "qui" + "k", and "over" becomes "ov" + "er". The rest of the sentence stays unchanged. Those extra two tokens are not just a bookkeeping quirk; they increase the length of the attention matrix from 10×10 to 12×12, adding roughly 24 % more pairwise attention operations for this tiny example.&lt;/p&gt;

&lt;h2&gt;
  
  
  Concrete example with GPT‑4
&lt;/h2&gt;

&lt;p&gt;Below is a short Python snippet that demonstrates the token count difference using the &lt;code&gt;tiktoken&lt;/code&gt; library:&lt;/p&gt;

&lt;p&gt;python&lt;br&gt;
import tiktoken&lt;br&gt;
enc = tiktoken.encoding_for_model("gpt-4")&lt;br&gt;
clean = "The quick brown fox jumps over the lazy dog."&lt;br&gt;
typo  = "The quik brown fox jumps ovr the lazy dog."&lt;br&gt;
print(len(enc.encode(clean)), "tokens")   # → 10&lt;br&gt;
print(len(enc.encode(typo)), "tokens")    # → 12&lt;/p&gt;

&lt;p&gt;The model does not "work harder" in the sense of performing extra reasoning; it simply performs more low‑level matrix multiplications because the input is longer. In practice this translates to higher latency and higher token‑based pricing for API calls.&lt;/p&gt;

&lt;h2&gt;
  
  
  Strategies to mitigate token overhead
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Pre‑processing spell‑check&lt;/strong&gt; – Running a lightweight spell‑checker (e.g., &lt;code&gt;symspellpy&lt;/code&gt; or &lt;code&gt;hunspell&lt;/code&gt;) on user‑generated prompts can collapse misspelled words back into their canonical forms before they hit the tokenizer. The overhead of a quick dictionary lookup is negligible compared to the extra attention work caused by longer token streams.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Prompt templating&lt;/strong&gt; – If you embed user input inside a fixed template, keep the template short and place the variable portion at the end. This way any extra tokens caused by typos are confined to a single contiguous block, reducing the overall attention cost compared to scattering typos throughout a long narrative.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Chunked inference&lt;/strong&gt; – For very long inputs, split the text into chunks that respect sentence boundaries. If a chunk contains many misspellings, you can run a separate clean‑up pass on that chunk only, saving work on the rest of the document.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Model‑level tricks&lt;/strong&gt; – Some newer models expose a "token‑budget" flag that stops processing once a certain token count is reached. By monitoring the token count after tokenization you can reject or ask the user to re‑phrase overly noisy prompts before they consume compute.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  When typos actually help
&lt;/h2&gt;

&lt;p&gt;In a few niche scenarios a typo can &lt;em&gt;reduce&lt;/em&gt; token count. Rare proper nouns or technical jargon that the tokenizer does not know may be split into many sub‑tokens, while a shortened misspelled version could be a single token. For example, the brand name "Xiaomi" is tokenized as two tokens ("Xiao" + "mi"), whereas the misspelled "Xiaomi" with a missing "i" ("Xiaomi") might be a single token if it appears in the vocabulary. However, this is accidental and not reliable; relying on misspellings to save tokens quickly backfires when the model misinterprets the intent.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bottom line
&lt;/h2&gt;

&lt;p&gt;Typos do not make an LLM think harder, but they make it &lt;strong&gt;compute harder&lt;/strong&gt;. Each additional token expands the attention matrix and adds a proportional amount of floating‑point work. The impact is most noticeable in latency‑sensitive applications or when operating under strict token budgets. A simple pre‑processing step that corrects common misspellings can shave a few tokens off every request, yielding measurable cost and speed improvements without altering the semantic content of the prompt.&lt;/p&gt;

&lt;p&gt;Developers building user‑facing AI products should therefore treat spelling normalization as a performance optimisation rather than a purely cosmetic nicety. The extra few milliseconds saved per request add up, and the reduced token usage directly lowers API costs. In short: &lt;strong&gt;yes, typos make AI work harder, but the fix is straightforward and inexpensive&lt;/strong&gt;.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>nlp</category>
      <category>tokenization</category>
      <category>typos</category>
    </item>
  </channel>
</rss>
