mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #1005] CRLF line-break tokens (\r\n, ids 317/845/8301) get far too little probability; everything else matches llama.cpp #441
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#441
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 @brenoperucchi on GitHub (Oct 5, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/1005
#803 was closed after its author traced the perplexity gap to CRLF line endings in the test text. The bug they found along the way has no issue of its own, so here it is, with a reproduction on a native GSQ-RCO pack.
On the same text, the same context and the same positions, Strata gives Windows line-break tokens a much higher NLL than the plain
\ntokens they replace. All other tokens score the same.Setup
--short-read 8192 --prompt-cache 0 --adapt-swaps 0, scored withSTRATA_LOGPOS(column 3)docs/*.mdandtools/*.py, 8 chunks of 2048 tokens, second half of each chunk scored (8,184 positions). The CRLF copy is the same text with every\nreplaced by\r\n, so the two token sequences differ only in the line-break ids.Result
Mean NLL per line-break token, same positions:
\n(198), 239 times\r\n(317)\n\n(271), 64 times\r\n\r\n(845)\n\n\n(1358), 2 times\r\n\r\n\r\n(8301)Perplexity goes from 6.807 (LF) to 7.292 (CRLF), and all of the increase sits on those three tokens. This matches what the #803 author reported on IQ3_S (mean NLL about 3.25 on the CRLF tokens against 0.39 for
\n), and they saw it on 0.1.32 and 0.1.39, with three different packs and with--pcie-frac 0and1.0.For reference, on the LF text Strata matches llama.cpp b11053 on the same GGUF: 6.807 vs 6.823 at 2K, 6.000 vs 5.987 at 8K (4 chunks of 8192), and 1.380 vs 1.380 on a Portuguese text. So the problem is specific to these ids.
Why it matters
On Windows, CRLF reaches the model easily: files read from disk, tool output, text written in text mode. Short exact answers still came out right in #803, but the model reads every Windows line break as surprising, and any perplexity measured on such text looks worse than it is. We haven't measured what it does to long outputs.
Workaround
Normalizing
\r\nto\nbefore tokenizing avoids it (the #803 author does it inChatTemplate.render(), and we added it to our client). That changes what the model sees and leaves the cause in place.Question
Is there anything in how these ids reach the model (the token embedding, the PLE n-gram lookup or its hashing) that treats them differently from llama.cpp? The #803 author checked the PLE hashing against llama.cpp's code and didn't find a difference. I can build from source on this machine and run any diagnostic build or dump you suggest.
@ysj1977007282-cmd commented on GitHub (Oct 6, 2026):
会考虑适配闪电其它更高精度的gguf模型吗?
@Niko1221 commented on GitHub (Oct 7, 2026):
First test, no engine change: score the same CRLF text with llama.cpp on the same GGUF. If llama.cpp is equally high, the model scores CRLF tokens low and we add a docs note. If not, we look at the tokenizer pre-split and the PLE hashing for ids 317, 845 and 8301. Please post the llama.cpp numbers if you can run it.
@brenoperucchi commented on GitHub (Oct 7, 2026):
llama.cpp b11053 on the same GGUF gives the CRLF text a perplexity as high as Strata does, so the model itself scores CRLF low.
Same text as in the description (the repo's
docs/*.mdandtools/*.py, 8 chunks of 2048 tokens,llama-perplexitywith the production offload settings):Both go up about 7% and agree within the error bar. Strata's gap sits on the three line-break tokens (317, 845, 8301), as shown in the description; I did not get per-token numbers out of
llama-perplexity.A note on the method: on Windows
llama-perplexityreads--filein text mode and turns\r\ninto\nbefore tokenizing: a file with real\r\nscored 6.823, the same as the LF copy. A copy with\r\r\nreaches the tokenizer as\r\nand gives the 7.279 above.llama-tokenize, which reads the bytes as they are, gives ids 198 and 271 for the LF copy and 317 and 845 for the CRLF copy, the same ids Strata uses.So the docs note you suggested fits: CRLF text raises perplexity on this model in both engines, and normalizing
\r\nto\nbefore tokenizing avoids it.@Niko1221 commented on GitHub (Oct 13, 2026):
Thanks for the report. To keep the tracker current we are closing issues older than three days: 0.1.44 is out with a long list of fixes, and many older reports are covered by it or by 0.1.43.1.
If this still happens on 0.1.44, please leave a comment here with your engine log (and the version line it prints), and we will reopen it. A new issue that links this one works too.