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
20e35938
Commit
20e35938
authored
Mar 11, 2025
by
jmorganca
Committed by
Michael Yang
Mar 11, 2025
Browse files
model: validate left and right pairs before merging them
parent
63a39406
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
0 deletions
+4
-0
model/process_text_spm.go
model/process_text_spm.go
+4
-0
No files found.
model/process_text_spm.go
View file @
20e35938
...
@@ -169,6 +169,10 @@ func (spm SentencePieceModel) Encode(s string, addSpecial bool) ([]int32, error)
...
@@ -169,6 +169,10 @@ func (spm SentencePieceModel) Encode(s string, addSpecial bool) ([]int32, error)
continue
continue
}
}
if
id
:=
spm
.
vocab
.
Encode
(
string
(
left
.
runes
)
+
string
(
right
.
runes
));
id
<
0
{
continue
}
merges
[
pair
.
a
]
.
runes
=
append
(
left
.
runes
,
right
.
runes
...
)
merges
[
pair
.
a
]
.
runes
=
append
(
left
.
runes
,
right
.
runes
...
)
merges
[
pair
.
b
]
.
runes
=
nil
merges
[
pair
.
b
]
.
runes
=
nil
merges
[
pair
.
a
]
.
n
=
right
.
n
merges
[
pair
.
a
]
.
n
=
right
.
n
...
...
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