mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #6161] [Feature]: Improve token estimation and token count display for CJK text #3433
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#3433
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @minikkeuen on GitHub (Sep 13, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/6161
Originally assigned to: @SpicyMarinara on GitHub.
What problem does this solve?
Marinara uses lightweight character-based token estimation in several places.
The existing heuristic works reasonably well as a rough estimate for English text, but can significantly underestimate Korean, Japanese, and Chinese text because CJK text has different tokenization characteristics.
Token count displays are also inconsistent across prompt and context inputs. Some fields show character counts, some show estimated token counts, and some relevant prompt fields show no count at all.
This makes it harder to estimate prompt and context size consistently, especially when working with CJK-heavy text.
Proposed solution
Improve the existing lightweight token estimator while keeping it simple and model-agnostic:
Also use the shared token estimator more consistently across relevant prompt and context input fields:
The estimates are intentionally approximate and are not intended to reproduce any specific model's tokenizer.
Alternatives considered
Additional context
The implementation is split into two commits: one for the lightweight CJK-aware estimator and one for the prompt/context token count UI changes.
Template check
@SpicyMarinara commented on GitHub (Sep 13, 2026):
Maintainer follow-up: Codex is applying and validating the review fixes in the existing PR #6164 on behalf of @SpicyMarinara, preserving the contributor’s implementation and commits. This continues the existing PR; no duplicate implementation branch or PR is being opened.
@SpicyMarinara commented on GitHub (Sep 13, 2026):
Addressed by PR #6164, merged into staging at
67e5a486. The contributor’s CJK estimator and counter changes are preserved with the review fixes. All required checks, 266 Node regressions, the full browser matrix, and CodeRabbit completed successfully.