Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ollama
Commits
463a6caa
"src/vscode:/vscode.git/clone" did not exist on "8bf80fc8d8aade3bd3fca5054d05b65488fbbf8f"
Commit
463a6caa
authored
Aug 19, 2025
by
Devon Rifkin
Browse files
model: add bpe roundtripping tests
parent
fc5fb09f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
0 deletions
+30
-0
model/bytepairencoding_test.go
model/bytepairencoding_test.go
+30
-0
No files found.
model/bytepairencoding_test.go
View file @
463a6caa
...
...
@@ -207,6 +207,36 @@ func TestLlama(t *testing.T) {
}
}
})
t
.
Run
(
"roundtriping 0x00-0xFF"
,
func
(
t
*
testing
.
T
)
{
t
.
Parallel
()
for
b
:=
0x00
;
b
<=
0xFF
;
b
++
{
input
:=
string
(
rune
(
b
))
ids
,
err
:=
tokenizer
.
Encode
(
input
,
false
)
if
err
!=
nil
{
t
.
Errorf
(
"failed to encode rune 0x%02X: %v"
,
b
,
err
)
continue
}
decoded
,
err
:=
tokenizer
.
Decode
(
ids
)
if
err
!=
nil
{
t
.
Errorf
(
"failed to decode rune 0x%02X: %v"
,
b
,
err
)
continue
}
if
b
==
0x00
{
if
len
(
decoded
)
!=
0
{
t
.
Errorf
(
"Decode(Encode(0x00)) should be empty, got %v"
,
ids
)
}
continue
}
if
decoded
!=
input
{
t
.
Errorf
(
"rune 0x%02X failed roundtrip: got %q, want %q"
,
b
,
decoded
,
input
)
}
}
})
}
func
BenchmarkBytePairEncoding
(
b
*
testing
.
B
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment