mirror of
https://github.com/ollama/ollama.git
synced 2026-03-11 17:34:04 -05:00
This change adds a new x/tokenizer package which includes: * New BPE and SentencePiece tokenizers * Removing the dependency on the imagegen tokenizers * Fixes to multibyte decoding in the pipeline * Various correctness and benchmark tests Not included in this PR is the WordPiece tokenizer for BERT models which will be added when we add embedding models. The imagegen tokenizers will also be removed in a follow-up PR.
27 lines
468 B
Go
27 lines
468 B
Go
//go:build mlx
|
|
|
|
package tokenizer
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestLoadFromBytesRejectsWordPiece(t *testing.T) {
|
|
data := []byte(`{
|
|
"model": {
|
|
"type": "WordPiece",
|
|
"vocab": {"[UNK]": 0, "hello": 1}
|
|
},
|
|
"added_tokens": []
|
|
}`)
|
|
|
|
_, err := LoadFromBytes(data)
|
|
if err == nil {
|
|
t.Fatal("expected WordPiece load to fail")
|
|
}
|
|
if !strings.Contains(err.Error(), "unsupported tokenizer type: WordPiece") {
|
|
t.Fatalf("unexpected error: %v", err)
|
|
}
|
|
}
|