Skip to content
DenseChip
Learn
PracticeCode labInterview

DenseChip

Navigate

Menu

LearnPracticeCode labInterview

Tools

All toolsSV editorCode repoResume
DenseChip

Practice, courses, and chip-design tools in one focused workspace.

LearnPracticeCode labInterviewToolsLearning paths

© 2026 DenseChip

AboutContactPrivacyTerms
Skip to lesson

Course contents

  • Getting Started with AI for VLSI Engineers5
  • Just Enough AI: Models and Context15
    • What a Language Model Does
    • Tokens and Tokenization
      • Tokens, Words and Characters
      • Subword Tokens and Byte-Pair Encoding
      • Why Some Text Costs More Tokens
      • Approximate Rules of Thumb
      • Estimating Tokens Before Sending
    • Context Window and Attention for Users
  • Prompting13
  • Trust and Verification14
  • Using AI for Engineering Work17
  • Engineering Walkthroughs7
  • Practical Foundations for AI Workflows4
  • Engineering Data5
  • Retrieval-Augmented Generation6
  • Agents and Tool Use18
  • Agent Design8
  • MCP and Skills6
  • Multi-Agent Design6
  • Practical Capstone6
  • Tokens, Cost and Latency12
  • Agentic Workflows for Chip Teams18
  • Interview and Judgment10
  • AI Skills: Full Course Index
  • Working with AI Glossary
  • Working with AI Cheatsheet
Loading lesson

‹Tokens and Tokenization
  1. Topics
  2. AI Skills for VLSI Engineers
  3. Just Enough AI: Models and Context
  4. Tokens and Tokenization
  5. Why Some Text Costs More Tokens

Just Enough AI · Beginner to Intermediate

Why Some Text Costs More Tokens

Why code, identifiers, numbers and non-English text use more tokens than prose.

On this page

    Prose gets long pieces

    Common prose words are often single pieces in many splitters. Their groups occurred enough in training to earn long entries.

    That is approximate and tokenizer-dependent. Rates vary by model, so measure them on the actual splitter.

    Code and identifiers

    Code mixes words with symbols, case changes and underscores. Each boundary is a likely cut, so identifiers split into several pieces.

    A Verilog name such as wdata_q_3 has three cut points before the digit. Dots, brackets and widths add further pieces around it.

    Shape

    Why it splits

    Approximate effect

    `snake_case` names

    Underscores mark boundaries

    About one piece per segment, approximately.

    `camelCase` names

    Case changes mark boundaries

    About one piece per hump, approximately.

    Dotted and indexed access

    Each symbol becomes its own piece

    One or more extra pieces per symbol.

    Operators and whitespace runs

    Dense symbols rarely form long groups

    Short pieces throughout.

    Numbers and other scripts

    Digit strings split into short pieces, and hex such as 8'hff splits at the quote and case steps. Long numbers therefore cost more pieces than a prose word of equal length.

    Non-Latin scripts average fewer characters per token with common splitters, approximately. This too varies by model, so measure it on representative samples.

    plaintext
    1
    2
    3
    4
    5
    44 characters of prose at about 4 chars per token (stated approximate rate)
    tokens = 44 / 4 = 11
    44 characters of dense code at about 2.5 chars per token (stated approximate rate)
    tokens = 44 / 2.5 = 17.6, about 17 to 18 pieces
    ratio = 17.6 / 11 = 1.6, so the code uses about three-fifths more pieces

    A fake splitting demo

    The program below uses a FAKE scripted splitter, not any real tokenizer. It cuts on every non-alphanumeric character to show boundaries, and says so.

    example.py
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    import sys
    
    PROSE = "the cat sat on the mat"
    CODE = "wdata_3<=8'hff;"
    
    def fake_split(s):
        parts = []
        cur = ""
        for ch in s:
            if ch.isalnum():
                cur += ch
            else:
                if cur:
                    parts.append(cur)
                    cur = ""
                if ch.strip():
                    parts.append(ch)
        if cur:
            parts.append(cur)
        return parts
    
    bad = 0
    for s in [PROSE, CODE, "clk"]:
        parts = fake_split(s)
        if any(p == "" for p in parts):
            bad += 1
        if "".join(parts) != s.replace(" ", ""):
            bad += 1
    if len(fake_split(CODE)) <= len(fake_split(PROSE)):
        bad += 1
    if fake_split("clk") != ["clk"]:
        bad += 1
    if bad != 0:
        print("FAIL: " + str(bad) + " checks wrong")
        sys.exit(1)
    print("PASS: prose " + str(len(fake_split(PROSE))) + " parts code " + str(len(fake_split(CODE))) + " parts")

    Common mistakes

    Common pitfall

    Prose rates do not transfer to RTL or logs. Budgeting a Verilog file at prose density undercounts pieces, sometimes badly.

    Interview

    Likely probes: name three cut points in one identifier.

    • Underscores, case steps and trailing digits each invite a cut.

    • Quotes in hex literals and brackets around ranges add pieces.

    • Other scripts and digits run shorter than prose, approximately.

    Check yourself wdata_q_3 is 9 characters. Why is a 2-piece guess optimistic?

    Two underscores plus a digit boundary invite cuts, so about one piece per segment is likelier. Exact splits still vary by model.

    Check yourself What does the FAKE splitter prove, and what does it not prove?

    It proves boundaries multiply pieces on code-like shapes. It proves nothing about any real splitter, whose table and rates vary by model.

    Related topics

    • Subword tokens and byte-pair encoding

    • Approximate rules of thumb

    Previous

    13 / 173

    Next: Approximate Rules of Thumb

    Up next

    Up nextApproximate Rules of Thumb

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • Tokens, Words and Characters
    • Estimating Tokens Before Sending