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
fb569880
Commit
fb569880
authored
Feb 01, 2024
by
Michael Yang
Browse files
account for image projection in token count
parent
d046bee7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
0 deletions
+4
-0
server/routes.go
server/routes.go
+4
-0
No files found.
server/routes.go
View file @
fb569880
...
@@ -1273,6 +1273,10 @@ func trimmedPrompt(ctx context.Context, chat *ChatHistory, model *Model) (string
...
@@ -1273,6 +1273,10 @@ func trimmedPrompt(ctx context.Context, chat *ChatHistory, model *Model) (string
promptsToAdd
=
append
(
promptsToAdd
,
promptInfo
{
vars
:
chat
.
Prompts
[
i
],
tokenLen
:
len
(
encodedTokens
)})
promptsToAdd
=
append
(
promptsToAdd
,
promptInfo
{
vars
:
chat
.
Prompts
[
i
],
tokenLen
:
len
(
encodedTokens
)})
images
=
append
(
images
,
chat
.
Prompts
[
i
]
.
Images
...
)
images
=
append
(
images
,
chat
.
Prompts
[
i
]
.
Images
...
)
// clip has a projection dimension of 768
// TODO: use kv['clip.vision.projection_dim'] from projection instead
totalTokenLength
+=
768
*
len
(
chat
.
Prompts
[
i
]
.
Images
)
}
}
// ensure the system prompt is included, if not already
// ensure the system prompt is included, if not already
...
...
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