@trazum/core 1.8.0 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAI1C,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAQpG,OAAO,EACL,MAAM,EACN,aAAa,EACb,gBAAgB,EAChB,qBAAqB,EACrB,aAAa,EACb,iBAAiB,EACjB,QAAQ,EACR,UAAU,EACV,gBAAgB,EAChB,cAAc,EACd,SAAS,EACT,gBAAgB,EAChB,cAAc,GACf,MAAM,cAAc,CAAC;AAItB,uEAAuE;AACvE,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpD,8EAA8E;AAC9E,+EAA+E;AAC/E,6EAA6E;AAC7E,UAAU;AACV,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAErF,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAGrE,OAAO,EAC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@
1
+ /**
2
+ * Which language a prompt is written in, to the extent it can be told cheaply.
3
+ *
4
+ * **Why the estimator needs this at all.** Measured against the counting
5
+ * endpoint, `estimateTokens` is accurate on English (+1.0%) and badly low on every
6
+ * other Latin language: German -37.3%, Spanish -22.9%, French -15.1%. Characters
7
+ * per token says why — English 3.44, French 2.66, Spanish 2.53, German 2.02 —
8
+ * while the estimator applied one divisor to all of them. Non-English text is
9
+ * thinner in the merge table, so the same number of characters costs more tokens.
10
+ *
11
+ * **Accents are not the signal.** That was the first hypothesis and it was tested
12
+ * and killed: a Spanish sample with zero accented characters comes out at -22.9%,
13
+ * against -22.1% for accented Spanish. Diacritics correlate with non-English text
14
+ * in a corpus and not in a prompt, and weighting them moved the figure by three
15
+ * points. What separates these languages is which words they are made of.
16
+ *
17
+ * So this counts function words — the shortest, commonest, most language-specific
18
+ * tokens there are. `the of and to` against `der die und ist` against
19
+ * `que de la en`.
20
+ *
21
+ * **It answers `null` when unsure, and that is the important part.** A prompt is
22
+ * not an essay: it can be three lines, or English instructions wrapped around a
23
+ * Spanish example, or a JSON schema with no prose at all. Guessing on those would
24
+ * apply a language's divisor to text that is not in that language, which is how a
25
+ * fix for one case becomes a regression for four. `null` means "use the default",
26
+ * and the default is the English-calibrated behaviour this has always had.
27
+ */
28
+ /** Languages this can name. Exported so callers can key a table off it. */
29
+ export declare const DETECTABLE_LANGUAGES: readonly string[];
30
+ /**
31
+ * The language of `text`, or `null` when no answer is safe.
32
+ *
33
+ * Case-insensitive, whole words only, and it stops reading after a bounded
34
+ * prefix: a prompt can be a megabyte, the answer does not get better after a few
35
+ * thousand words, and this runs inside `estimateTokens` on every call.
36
+ */
37
+ export declare function detectTextLanguage(text: string): string | null;
38
+ //# sourceMappingURL=language.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"language.d.ts","sourceRoot":"","sources":["../src/language.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AA+BH,2EAA2E;AAC3E,eAAO,MAAM,oBAAoB,EAAE,SAAS,MAAM,EAAgC,CAAC;AAgBnF;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CA8B9D"}
@@ -0,0 +1,109 @@
1
+ /**
2
+ * Which language a prompt is written in, to the extent it can be told cheaply.
3
+ *
4
+ * **Why the estimator needs this at all.** Measured against the counting
5
+ * endpoint, `estimateTokens` is accurate on English (+1.0%) and badly low on every
6
+ * other Latin language: German -37.3%, Spanish -22.9%, French -15.1%. Characters
7
+ * per token says why — English 3.44, French 2.66, Spanish 2.53, German 2.02 —
8
+ * while the estimator applied one divisor to all of them. Non-English text is
9
+ * thinner in the merge table, so the same number of characters costs more tokens.
10
+ *
11
+ * **Accents are not the signal.** That was the first hypothesis and it was tested
12
+ * and killed: a Spanish sample with zero accented characters comes out at -22.9%,
13
+ * against -22.1% for accented Spanish. Diacritics correlate with non-English text
14
+ * in a corpus and not in a prompt, and weighting them moved the figure by three
15
+ * points. What separates these languages is which words they are made of.
16
+ *
17
+ * So this counts function words — the shortest, commonest, most language-specific
18
+ * tokens there are. `the of and to` against `der die und ist` against
19
+ * `que de la en`.
20
+ *
21
+ * **It answers `null` when unsure, and that is the important part.** A prompt is
22
+ * not an essay: it can be three lines, or English instructions wrapped around a
23
+ * Spanish example, or a JSON schema with no prose at all. Guessing on those would
24
+ * apply a language's divisor to text that is not in that language, which is how a
25
+ * fix for one case becomes a regression for four. `null` means "use the default",
26
+ * and the default is the English-calibrated behaviour this has always had.
27
+ */
28
+ /**
29
+ * Function words per language, lower-cased, matched whole.
30
+ *
31
+ * Chosen for frequency and for *not overlapping*, which matters more: `de` is
32
+ * frequent in Spanish, French and Portuguese, so it earns nothing and is a
33
+ * liability. Each list is words that are common in its own language and rare in
34
+ * the others, which is what lets a small count decide.
35
+ *
36
+ * `en` is included even though it is the default, because the margin rule needs to
37
+ * know when English *won*: a Spanish prompt quoting an English sentence should not
38
+ * become Spanish on two hits.
39
+ */
40
+ const FUNCTION_WORDS = {
41
+ en: ['the', 'and', 'of', 'to', 'is', 'that', 'with', 'for', 'you', 'this', 'are', 'not'],
42
+ es: ['que', 'los', 'las', 'del', 'una', 'para', 'con', 'como', 'pero', 'sus', 'este', 'siempre'],
43
+ fr: ['les', 'des', 'une', 'dans', 'pour', 'avec', 'vous', 'est', 'sur', 'aux', 'cette', 'toujours'],
44
+ de: ['der', 'die', 'das', 'und', 'nicht', 'sie', 'ist', 'mit', 'auf', 'einen', 'einer', 'immer'],
45
+ pt: ['que', 'dos', 'das', 'uma', 'para', 'com', 'como', 'não', 'seu', 'este', 'pelo', 'sempre'],
46
+ /**
47
+ * Rebuilt once, because half of it was Spanish. `per con del una sempre` are as
48
+ * common in Spanish as in Italian, so they earned nothing and cost the margin
49
+ * rule its answer: an Italian code-review prompt scored a tie and came back
50
+ * `null`, fell through to the English divisor, and measured -21.9%. These are
51
+ * words Italian has and Spanish does not.
52
+ */
53
+ it: ['il', 'della', 'nella', 'nel', 'che', 'quando', 'senza', 'gli', 'delle', 'degli', 'più', 'anche'],
54
+ nl: ['het', 'een', 'van', 'niet', 'zijn', 'met', 'voor', 'dat', 'aan', 'deze', 'wordt', 'altijd'],
55
+ };
56
+ /** Languages this can name. Exported so callers can key a table off it. */
57
+ export const DETECTABLE_LANGUAGES = Object.keys(FUNCTION_WORDS);
58
+ /**
59
+ * How many hits the winner needs, absolutely and relative to the runner-up.
60
+ *
61
+ * Both bars exist for the same reason and neither is enough alone. The absolute
62
+ * one stops a three-line prompt being classified on a single word. The ratio stops
63
+ * a document that is genuinely mixed — English instructions around a Spanish
64
+ * example — from being called whichever language happened to appear once more.
65
+ *
66
+ * Deliberately cautious in the direction of `null`. A wrong language costs
67
+ * accuracy on text that was fine before; `null` costs only the improvement.
68
+ */
69
+ const MIN_HITS = 4;
70
+ const MIN_RATIO = 1.6;
71
+ /**
72
+ * The language of `text`, or `null` when no answer is safe.
73
+ *
74
+ * Case-insensitive, whole words only, and it stops reading after a bounded
75
+ * prefix: a prompt can be a megabyte, the answer does not get better after a few
76
+ * thousand words, and this runs inside `estimateTokens` on every call.
77
+ */
78
+ export function detectTextLanguage(text) {
79
+ if (!text)
80
+ return null;
81
+ // Bounded so this stays cheap on a large prompt. Function words are frequent
82
+ // enough that a prefix this size decides anything a whole document would.
83
+ const sample = text.length > 20_000 ? text.slice(0, 20_000) : text;
84
+ const words = sample.toLowerCase().match(/[\p{L}]+/gu);
85
+ if (!words || words.length < MIN_HITS * 2)
86
+ return null;
87
+ const seen = new Set(words);
88
+ const scores = [];
89
+ for (const [language, list] of Object.entries(FUNCTION_WORDS)) {
90
+ let hits = 0;
91
+ // Distinct words rather than occurrences: a prompt that repeats "the" forty
92
+ // times is not more English than one that uses forty different English words,
93
+ // and counting occurrences lets one hammered word decide.
94
+ for (const word of list)
95
+ if (seen.has(word))
96
+ hits++;
97
+ scores.push([language, hits]);
98
+ }
99
+ scores.sort((a, b) => b[1] - a[1]);
100
+ const [best, bestHits] = scores[0];
101
+ const runnerUp = scores[1]?.[1] ?? 0;
102
+ if (bestHits < MIN_HITS)
103
+ return null;
104
+ // A runner-up of zero is a clear win; guard the division rather than special-case.
105
+ if (runnerUp > 0 && bestHits / runnerUp < MIN_RATIO)
106
+ return null;
107
+ return best;
108
+ }
109
+ //# sourceMappingURL=language.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"language.js","sourceRoot":"","sources":["../src/language.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH;;;;;;;;;;;GAWG;AACH,MAAM,cAAc,GAAgD;IAClE,EAAE,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC;IACxF,EAAE,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK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,GAAG,QAAQ;QAAE,OAAO,IAAI,CAAC;IACrC,mFAAmF;IACnF,IAAI,QAAQ,GAAG,CAAC,IAAI,QAAQ,GAAG,QAAQ,GAAG,SAAS;QAAE,OAAO,IAAI,CAAC;IAEjE,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * This is NOT a real tokenizer: it is a heuristic calibrated per character
5
5
  * class. It is built to keep the typical error on ordinary text
6
- * (English/Spanish, markdown, code) inside ±15%, which is plenty for comparing
6
+ * (English/Spanish, markdown, code) inside ±10%, which is plenty for comparing
7
7
  * two versions of the same prompt — but do NOT bill anyone from it.
8
8
  *
9
9
  * **That band is a design target that has not been measured.** It is printed on
@@ -20,6 +20,46 @@
20
20
  * For exact numbers use `countTokensAnthropic` (the official token-counting
21
21
  * endpoint, which is free) or pass your own `TokenCounter`.
22
22
  */
23
+ /**
24
+ * The error band this estimator is published under, as a percentage.
25
+ *
26
+ * **Measured, not chosen, and it has moved three times.** It was `15` for eight
27
+ * releases as a design target nobody had checked; the first measurement found two
28
+ * of eight samples outside it and it went to `25`; fixing the digit divisor and
29
+ * calibrating per language brought it back to `15`. This is the fourth value and
30
+ * the first one that is comfortably above what the corpus actually shows.
31
+ *
32
+ * ```
33
+ * worst measured error 6.4% (code-heavy, which nothing is fitted to)
34
+ * published band 10%
35
+ * ```
36
+ *
37
+ * **The margin is deliberate and it is not slack.** 6.4 rounded up is 7, and
38
+ * publishing 7 would be a tighter claim than twenty-one samples across six text
39
+ * types can support: the corpus has no Korean, no Arabic, no Cyrillic prose, no
40
+ * mixed-script document, and a seventh text type could easily land at eight. A
41
+ * band that becomes false the first time somebody measures something new is the
42
+ * exact fault this whole exercise was fixing. Overstating the uncertainty is the
43
+ * safe direction for a tool that reports money.
44
+ *
45
+ * What earned the drop from 15 was **splitting kana from han**. Every CJK
46
+ * character was charged one token, which put Japanese at +11.2% — the worst error
47
+ * anywhere in the corpus — while Chinese sat at −3.2% under the same rule. Kana
48
+ * measure 0.75 tokens per character and han 1.05, and that pair takes the two
49
+ * samples to −1.5% and +1.3%. See `KANA_TOKENS_PER_CHAR`.
50
+ *
51
+ * **Which samples the band rests on matters more than the number.** Eight of the
52
+ * twenty-one had a constant fitted to them — seven Latin divisors and the digit
53
+ * divisor — so their residuals are optimistic by construction. The two worst
54
+ * errors in the corpus, `code-heavy` at 6.4% and `punctuation-heavy` at 5.7%, are
55
+ * fitted to nothing at all, and they are what sets this figure.
56
+ *
57
+ * Exported so every report, README and tool description reads the same number. It
58
+ * was a literal in twenty-four files before this, with the only machine-readable
59
+ * copy in a test, and `token-band.test.js` now fails any file that states a
60
+ * different one.
61
+ */
62
+ export declare const ESTIMATE_ERROR_BAND_PCT = 10;
23
63
  /**
24
64
  * Estimates how many tokens `text` occupies.
25
65
  *
@@ -1 +1 @@
1
- {"version":3,"file":"tokenizer.d.ts","sourceRoot":"","sources":["../src/tokenizer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAeH;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAwFnD;AAED,sDAAsD;AACtD,MAAM,MAAM,iBAAiB,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;AAElE,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,+DAA+D;IAC/D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;IACzB,gFAAgF;IAChF,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,uBAAuB,GAAG,iBAAiB,CA6BxF"}
1
+ {"version":3,"file":"tokenizer.d.ts","sourceRoot":"","sources":["../src/tokenizer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAKH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAmG1C;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAuHnD;AAED,sDAAsD;AACtD,MAAM,MAAM,iBAAiB,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;AAElE,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,+DAA+D;IAC/D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;IACzB,gFAAgF;IAChF,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,uBAAuB,GAAG,iBAAiB,CA6BxF"}
package/dist/tokenizer.js CHANGED
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * This is NOT a real tokenizer: it is a heuristic calibrated per character
5
5
  * class. It is built to keep the typical error on ordinary text
6
- * (English/Spanish, markdown, code) inside ±15%, which is plenty for comparing
6
+ * (English/Spanish, markdown, code) inside ±10%, which is plenty for comparing
7
7
  * two versions of the same prompt — but do NOT bill anyone from it.
8
8
  *
9
9
  * **That band is a design target that has not been measured.** It is printed on
@@ -20,10 +20,133 @@
20
20
  * For exact numbers use `countTokensAnthropic` (the official token-counting
21
21
  * endpoint, which is free) or pass your own `TokenCounter`.
22
22
  */
23
+ import { detectTextLanguage } from './language.js';
23
24
  import { SAFE_FETCH_INIT, checkedEndpoint } from './net.js';
25
+ /**
26
+ * The error band this estimator is published under, as a percentage.
27
+ *
28
+ * **Measured, not chosen, and it has moved three times.** It was `15` for eight
29
+ * releases as a design target nobody had checked; the first measurement found two
30
+ * of eight samples outside it and it went to `25`; fixing the digit divisor and
31
+ * calibrating per language brought it back to `15`. This is the fourth value and
32
+ * the first one that is comfortably above what the corpus actually shows.
33
+ *
34
+ * ```
35
+ * worst measured error 6.4% (code-heavy, which nothing is fitted to)
36
+ * published band 10%
37
+ * ```
38
+ *
39
+ * **The margin is deliberate and it is not slack.** 6.4 rounded up is 7, and
40
+ * publishing 7 would be a tighter claim than twenty-one samples across six text
41
+ * types can support: the corpus has no Korean, no Arabic, no Cyrillic prose, no
42
+ * mixed-script document, and a seventh text type could easily land at eight. A
43
+ * band that becomes false the first time somebody measures something new is the
44
+ * exact fault this whole exercise was fixing. Overstating the uncertainty is the
45
+ * safe direction for a tool that reports money.
46
+ *
47
+ * What earned the drop from 15 was **splitting kana from han**. Every CJK
48
+ * character was charged one token, which put Japanese at +11.2% — the worst error
49
+ * anywhere in the corpus — while Chinese sat at −3.2% under the same rule. Kana
50
+ * measure 0.75 tokens per character and han 1.05, and that pair takes the two
51
+ * samples to −1.5% and +1.3%. See `KANA_TOKENS_PER_CHAR`.
52
+ *
53
+ * **Which samples the band rests on matters more than the number.** Eight of the
54
+ * twenty-one had a constant fitted to them — seven Latin divisors and the digit
55
+ * divisor — so their residuals are optimistic by construction. The two worst
56
+ * errors in the corpus, `code-heavy` at 6.4% and `punctuation-heavy` at 5.7%, are
57
+ * fitted to nothing at all, and they are what sets this figure.
58
+ *
59
+ * Exported so every report, README and tool description reads the same number. It
60
+ * was a literal in twenty-four files before this, with the only machine-readable
61
+ * copy in a test, and `token-band.test.js` now fails any file that states a
62
+ * different one.
63
+ */
64
+ export const ESTIMATE_ERROR_BAND_PCT = 10;
24
65
  const CJK = /[぀-ヿ㐀-䶿一-鿿가-힯]/;
66
+ /**
67
+ * Kana, separated from the rest of CJK because they do not cost the same.
68
+ *
69
+ * **This was the largest error left in the corpus.** Every CJK character was
70
+ * charged one token, and measured against the counting endpoint that put Japanese
71
+ * at **+11.2%** — the worst figure anywhere in twenty-one samples — while Chinese
72
+ * came out at −3.2% under the identical rule. One constant cannot be right for
73
+ * both, and the reason is visible in the samples: the Japanese one is 58% kana and
74
+ * the Chinese one is 0%.
75
+ *
76
+ * Kana are a small syllabary that appears in every sentence, so the merge table
77
+ * covers runs of them and several characters share a token. Han are tens of
78
+ * thousands of rare characters; a merge table cannot cover them and they cost
79
+ * about one each, sometimes more.
80
+ *
81
+ * The signal needs no detector. A character is kana or it is not, and the two
82
+ * samples separate perfectly — 58.3% against 0.00% — so this is a property of the
83
+ * character rather than a guess about the document. That is the difference between
84
+ * this and `language.ts`, which has to decide and is allowed to refuse.
85
+ */
86
+ const KANA = /[぀-ヿ]/;
25
87
  const LETTER = /[A-Za-zÀ-ɏͰ-ϿЀ-ӿ]/;
26
88
  const DIGIT = /[0-9]/;
89
+ /**
90
+ * Characters per token, per language.
91
+ *
92
+ * Measured, one entry at a time, against `test/fixtures/token-ground-truth.json`.
93
+ * English keeps 4 because it measures +1.0% there; the others are lower because
94
+ * they are thinner in the merge table and cost more tokens for the same text.
95
+ *
96
+ * **Every one of these now has a held-out test.** Each language was calibrated on
97
+ * support prompts and then measured again on a code-review prompt — a different
98
+ * register, different vocabulary, different length — and the divisors held:
99
+ * English +1.0% then +0.4%, German -9.2% then -8.5%, French -1.2% then -5.8%,
100
+ * Spanish -6.2% then -9.7% under the previous values. That is the evidence that
101
+ * these fit a language rather than a template, and it is why the band can rest on
102
+ * them now.
103
+ *
104
+ * `en` stays at a round 4 rather than the 4.05 the search prefers: a hundredth of
105
+ * a divisor is precision the twenty-one samples cannot support, and it changes no
106
+ * estimate.
107
+ *
108
+ * A language absent from this table falls through to `DEFAULT_DIVISOR`, which is
109
+ * the English number and the behaviour this estimator has always had. Adding a
110
+ * language means measuring it, not guessing it.
111
+ */
112
+ const DIVISOR_BY_LANGUAGE = {
113
+ en: 4,
114
+ es: 2.8,
115
+ fr: 3.05,
116
+ de: 2.25,
117
+ it: 2.8,
118
+ pt: 3.05,
119
+ nl: 2.65,
120
+ };
121
+ /**
122
+ * Tokens per character for the two halves of CJK, measured.
123
+ *
124
+ * `0.75` and `1.05` come from a search over the two CJK samples in
125
+ * `test/fixtures/token-ground-truth.json`, and they take that pair from
126
+ * +11.2% / −3.2% to −1.5% / +1.3%.
127
+ *
128
+ * **Two samples fitted two constants, so those residuals are in-sample and
129
+ * optimistic by construction** — the same caveat the Latin divisors carry, stated
130
+ * for the same reason. What makes them worth having anyway is the size of the
131
+ * error they replace and the fact that they move in opposite directions: a single
132
+ * constant could not have been within four points of both, whatever it was set to.
133
+ * The honest test is a third CJK sample, and the corpus grows one at a time.
134
+ *
135
+ * Hangul keeps the old cost of 1, because nothing here measures Korean. Guessing
136
+ * it from Japanese would be inventing a figure — the two scripts have nothing in
137
+ * common that would make one predict the other.
138
+ */
139
+ const KANA_TOKENS_PER_CHAR = 0.75;
140
+ const HAN_TOKENS_PER_CHAR = 1.05;
141
+ /**
142
+ * What a prompt gets when the language could not be told.
143
+ *
144
+ * The English value on purpose. An unknown-language prompt is most often English
145
+ * or code, and lowering this would inflate every estimate that the detector
146
+ * declined to classify — a change that helps nothing measured and hurts the two
147
+ * samples the estimator gets right.
148
+ */
149
+ const DEFAULT_DIVISOR = 4;
27
150
  /** Effective word length: non-ASCII characters split into more tokens. */
28
151
  function effectiveLength(word) {
29
152
  let len = 0;
@@ -46,7 +169,16 @@ function effectiveLength(word) {
46
169
  export function estimateTokens(text) {
47
170
  if (!text)
48
171
  return 0;
172
+ // Detected once for the whole text, not per word. A prompt is one document; a
173
+ // per-word guess would be noise, and this runs on every call.
174
+ const language = detectTextLanguage(text);
175
+ const divisor = (language === null ? undefined : DIVISOR_BY_LANGUAGE[language]) ?? DEFAULT_DIVISOR;
49
176
  let total = 0;
177
+ /**
178
+ * CJK is summed separately because it is the one class counted in fractions of
179
+ * a token. Everything else is whole tokens by the character class it belongs to.
180
+ */
181
+ let cjkTokens = 0;
50
182
  let i = 0;
51
183
  const chars = Array.from(text);
52
184
  while (i < chars.length) {
@@ -65,12 +197,19 @@ export function estimateTokens(text) {
65
197
  continue;
66
198
  }
67
199
  if (CJK.test(ch)) {
68
- let n = 0;
200
+ /**
201
+ * Accumulated as a fraction and rounded once, at the end.
202
+ *
203
+ * Rounding up per run was the first attempt and it was wrong by five
204
+ * points. Ordinary Japanese alternates kana and han inside every sentence,
205
+ * so the runs are short and there are many of them — and a `Math.ceil` per
206
+ * run charges most of a token for each boundary. That is an artefact of
207
+ * where the loop happens to break, not of what the text costs.
208
+ */
69
209
  while (i < chars.length && CJK.test(chars[i])) {
70
- n++;
210
+ cjkTokens += KANA.test(chars[i]) ? KANA_TOKENS_PER_CHAR : HAN_TOKENS_PER_CHAR;
71
211
  i++;
72
212
  }
73
- total += n;
74
213
  continue;
75
214
  }
76
215
  if (LETTER.test(ch)) {
@@ -79,7 +218,7 @@ export function estimateTokens(text) {
79
218
  word += chars[i];
80
219
  i++;
81
220
  }
82
- total += Math.max(1, Math.ceil(effectiveLength(word) / 4));
221
+ total += Math.max(1, Math.ceil(effectiveLength(word) / divisor));
83
222
  continue;
84
223
  }
85
224
  if (DIGIT.test(ch)) {
@@ -88,7 +227,20 @@ export function estimateTokens(text) {
88
227
  n++;
89
228
  i++;
90
229
  }
91
- total += Math.ceil(n / 3);
230
+ /**
231
+ * 1.5 digits per token, not 3.
232
+ *
233
+ * The 3 was a guess and it was the single worst constant in this file:
234
+ * measured against the counting endpoint, the numeric-heavy sample came out
235
+ * **30.6% under** — by far the largest error in the corpus. Claude's
236
+ * tokenizer splits long digit runs far more finely than prose, because a
237
+ * merge table cannot cover every number.
238
+ *
239
+ * Corrected in isolation, which is why it can be trusted: changing only
240
+ * this takes that sample from -30.6% to -5.0% and moves nothing else more
241
+ * than four points. See `test/fixtures/token-ground-truth.json`.
242
+ */
243
+ total += Math.ceil(n / 1.5);
92
244
  continue;
93
245
  }
94
246
  // Outside the BMP (emoji, unusual symbols): usually 2+ tokens.
@@ -120,7 +272,8 @@ export function estimateTokens(text) {
120
272
  total += Math.ceil(n / 2);
121
273
  }
122
274
  }
123
- return total;
275
+ // Rounded once, over the whole document, rather than per run — see the CJK branch.
276
+ return total + Math.ceil(cjkTokens);
124
277
  }
125
278
  /**
126
279
  * Exact counter using the official `/v1/messages/count_tokens` endpoint.
@@ -1 +1 @@
1
- {"version":3,"file":"tokenizer.js","sourceRoot":"","sources":["../src/tokenizer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE5D,MAAM,GAAG,GAAG,gBAAgB,CAAC;AAC7B,MAAM,MAAM,GAAG,mBAAmB,CAAC;AACnC,MAAM,KAAK,GAAG,OAAO,CAAC;AAEtB,0EAA0E;AAC1E,SAAS,eAAe,CAAC,IAAY;IACnC,IAAI,GAAG,GAAG,CAAC,CAAC;IACZ,KAAK,MAAM,EAAE,IAAI,IAAI;QAAE,GAAG,IAAI,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7D,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,IAAI,CAAC,IAAI;QAAE,OAAO,CAAC,CAAC;IAEpB,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAE/B,OAAO,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;QACxB,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC,CAAE,CAAC;QAErB,IAAI,EAAE,KAAK,GAAG,IAAI,EAAE,KAAK,IAAI,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC;YAC7C,CAAC,EAAE,CAAC;YACJ,SAAS;QACX,CAAC;QAED,IAAI,E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wBAAwB,EAAE,CAAC,CAAC;IAE7F,OAAO,KAAK,EAAE,IAAY,EAAmB,EAAE;QAC7C,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;YAAE,OAAO,CAAC,CAAC;QAC3B,MAAM,GAAG,GAAG,MAAM,SAAS,CAAC,GAAG,QAAQ,2BAA2B,EAAE;YAClE,GAAG,eAAe;YAClB,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;gBAClC,WAAW,EAAE,MAAM;gBACnB,mBAAmB,EAAE,YAAY;aAClC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;SAC7E,CAAC,CAAC;QACH,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,wBAAwB,GAAG,CAAC,MAAM,MAAM,MAAM,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAC9E,CAAC;QACD,MAAM,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAA6B,CAAC;QAC5D,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC,CAAC;AACJ,CAAC"}
package/dist/types.d.ts CHANGED
@@ -39,7 +39,7 @@ export interface RuleResult {
39
39
  /** Severity of an advisory: the higher it is, the more money is usually at stake. */
40
40
  export type AdvisorySeverity = 'info' | 'opportunity' | 'warning';
41
41
  /** Every advisory the core can emit. */
42
- export type AdvisoryId = 'context-overflow' | 'prompt-caching' | 'prompt-caching-not-worth-it' | 'below-cache-minimum' | 'cache-prefix-reorder' | 'batch-api' | 'model-downgrade' | 'output-dominated' | 'promo-pricing' | 'contradictory-instructions' | 'redundant-examples' | 'restated-output-format' | 'movable-output-schema';
42
+ export type AdvisoryId = 'context-overflow' | 'context-near-limit' | 'prompt-caching' | 'prompt-caching-not-worth-it' | 'below-cache-minimum' | 'cache-prefix-reorder' | 'batch-api' | 'model-downgrade' | 'output-dominated' | 'promo-pricing' | 'contradictory-instructions' | 'redundant-examples' | 'restated-output-format' | 'movable-output-schema';
43
43
  /** A recommendation that does NOT modify the prompt, only informs. */
44
44
  export interface Advisory {
45
45
  id: AdvisoryId;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,oCAAoC;AAEpC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD,gEAAgE;AAChE,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,YAAY,CAAC;AAE9C;;;;;;GAMG;AACH,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,SAAS,CAAC;IACjB,wEAAwE;IACxE,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CACrD;AAED,4EAA4E;AAC5E,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,SAAS,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,0DAA0D;IAC1D,WAAW,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,OAAO,EAAE,UAAU,EAAE,CAAC;CACvB;AAED,qFAAqF;AACrF,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,aAAa,GAAG,SAAS,CAAC;AAElE,wCAAwC;AACxC,MAAM,MAAM,UAAU,GAClB,kBAAkB,GAClB,g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