This repository has been archived on 2026-11-24. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Deadcode 1e968f6e1d radiance 1.7.0
- every model serves without a GPU: libavx covers every op, so `--kernels libavx` alone serves
  every shipped container
- Qwen3-ASR (zivius): speech to text on /v1/audio/transcriptions and live over /v1/realtime
- /v1/messages works with Claude Code as it ships (gearwave00001)
- a long agent conversation keeps its cached history when the client rewrites its last turn
  (manueloverride)
- a stream's first event goes out with the first token, so llama-benchy measures prefill right
- opt-in --prefill-interleave (Smellyyyy, baKon) and --prefill-span (keptn42)
- four-rank TP releases the link early; four-rank selftests and docs/TP4.md (goodman-b)
- NVFP4 and FP8 compressed-tensors imports (devmilan); tools/rad-export for finetunes and LoRA
  adapters (baKon)
- many fixes, among them lost tokens on stop strings under concurrency, keep-alive, MiniCPM5 tool
  arguments and the CPU's vision and audio encoders
- plugin ABI 17 and changed op schemas: out-of-tree plugins must be rebuilt
2026-10-16 18:25:18 +02:00

48 lines
2.5 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/* tokref.h -- an independent reference encoder for checking core/text's.
*
* `encode` runs the declared chain the way llama.cpp does: its structural splitters for the
* patterns it recognises, std::regex over a category-collapsed copy of the text for the rest, and
* a string-keyed bigram queue for the merge. It shares no code with core/text/tokenizer_regex.cpp
* or tokenizer_bpe.cpp; tokenizer_test and rad-tokcheck compare the two id for id.
*
* Known differences from HuggingFace tokenizers, which core/text follows. These are the only
* places the two encoders may disagree, and the comparing tests name each case:
* - `(?i:'s|'t|'re|'ve|'m|'ll|'d)` is rewritten to `'[sS]|...` before matching, which drops
* Oniguruma's case orbit of 's': U+017F LATIN SMALL LETTER LONG S. "'ſ" is a contraction to
* HuggingFace and not here.
* - llama.cpp's category tables are Unicode 15.1; the Oniguruma in tokenizers is 16.0. The 5185
* codepoints assigned in 16.0 (Garay, Todhri, Tulu-Tigalari, ..., new CJK strokes and Latin
* letters) are unassigned here and categorised there.
* - `\p{Han}+` is llama.cpp's name for its Kimi-K2 splitter, which does not implement K2's
* upper/lower-case letter classes and uses its own Han ranges.
* - `\d{1,3}(?=(?:\d{3})*\b)` is split by llama.cpp's AFMoE digit rule, which also splits digit
* runs followed by letters; the pattern does not.
* - Split behaviours other than Isolated are applied as Isolated. (Punctuation and Digits
* apply theirs: they are written here from HuggingFace's character predicates, over the
* category and \s tables of core/text/tokenizer_ucd.h, rather than as patterns.)
* - A regex Replace normaliser runs std::regex (ECMAScript, bytes) and expands `$` in its
* replacement; HuggingFace inserts the replacement verbatim.
*/
#pragma once
#include "text/tokenizer.h"
#include <string>
#include <string_view>
#include <vector>
namespace rad {
namespace tokref {
/* Same contract as Tokenizer::encode. */
int encode(const Vocab& v, std::string_view text, std::vector<int32_t>& out,
bool add_special, bool parse_special);
/* One word through one Split pattern, Isolated, as the reference splits it. */
std::vector<std::string> split(const std::string& pattern, const std::string& word);
/* True when llama.cpp has a hand-written splitter for `pattern` (after the (?i) rewrite). */
bool structural(const std::string& pattern);
} /* namespace tokref */
} /* namespace rad */