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
84b84ce2
Unverified
Commit
84b84ce2
authored
Sep 09, 2024
by
Patrick Devine
Committed by
GitHub
Sep 09, 2024
Browse files
catch when model vocab size is set correctly (#6714)
parent
bb6a086d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
3 deletions
+7
-3
convert/convert.go
convert/convert.go
+7
-3
No files found.
convert/convert.go
View file @
84b84ce2
...
@@ -208,14 +208,18 @@ func ConvertModel(fsys fs.FS, ws io.WriteSeeker) error {
...
@@ -208,14 +208,18 @@ func ConvertModel(fsys fs.FS, ws io.WriteSeeker) error {
return
err
return
err
}
}
if
vocabSize
:=
int
(
p
.
VocabSize
);
vocabSize
>
len
(
t
.
Vocabulary
.
Tokens
)
{
vocabSize
:=
int
(
p
.
VocabSize
)
slog
.
Warn
(
"vocabulary is smaller than expected, padding with dummy tokens"
,
"expect"
,
p
.
VocabSize
,
"actual"
,
len
(
t
.
Vocabulary
.
Tokens
))
switch
{
case
vocabSize
>
len
(
t
.
Vocabulary
.
Tokens
)
:
slog
.
Warn
(
"vocabulary is smaller than expected, padding with dummy tokens"
,
"expect"
,
vocabSize
,
"actual"
,
len
(
t
.
Vocabulary
.
Tokens
))
for
i
:=
range
vocabSize
-
len
(
t
.
Vocabulary
.
Tokens
)
{
for
i
:=
range
vocabSize
-
len
(
t
.
Vocabulary
.
Tokens
)
{
t
.
Vocabulary
.
Tokens
=
append
(
t
.
Vocabulary
.
Tokens
,
fmt
.
Sprintf
(
"[PAD%d]"
,
i
))
t
.
Vocabulary
.
Tokens
=
append
(
t
.
Vocabulary
.
Tokens
,
fmt
.
Sprintf
(
"[PAD%d]"
,
i
))
t
.
Vocabulary
.
Scores
=
append
(
t
.
Vocabulary
.
Scores
,
-
1
)
t
.
Vocabulary
.
Scores
=
append
(
t
.
Vocabulary
.
Scores
,
-
1
)
t
.
Vocabulary
.
Types
=
append
(
t
.
Vocabulary
.
Types
,
tokenTypeUserDefined
)
t
.
Vocabulary
.
Types
=
append
(
t
.
Vocabulary
.
Types
,
tokenTypeUserDefined
)
}
}
}
else
{
case
vocabSize
<
len
(
t
.
Vocabulary
.
Tokens
)
:
return
fmt
.
Errorf
(
"vocabulary is larger than expected '%d' instead of '%d'"
,
len
(
t
.
Vocabulary
.
Tokens
),
vocabSize
)
default
:
slog
.
Debug
(
"vocabulary"
,
"size"
,
len
(
t
.
Vocabulary
.
Tokens
))
slog
.
Debug
(
"vocabulary"
,
"size"
,
len
(
t
.
Vocabulary
.
Tokens
))
}
}
...
...
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