From 330c6387962b197c5ca7a8051d4864feaecc0f25 Mon Sep 17 00:00:00 2001 From: Jonas Knobloch Date: Fri, 11 Sep 2026 18:38:02 +0200 Subject: WIP --- tokenizer/bpe/special.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 tokenizer/bpe/special.go (limited to 'tokenizer/bpe/special.go') diff --git a/tokenizer/bpe/special.go b/tokenizer/bpe/special.go new file mode 100644 index 0000000..405199f --- /dev/null +++ b/tokenizer/bpe/special.go @@ -0,0 +1,18 @@ +package bpe + +// Add helper to ensure special token +// wip-special-tokens + +func EnsureSpecialToken(t *Tokenizer, token string) int { + vocab := Vocab(t) + + for i, v := range vocab { + if v == token { + return i + } + } + + AddToken(t, token) + + return len(vocab) - 1 +} -- cgit v1.3.1