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
65b0f329
Commit
65b0f329
authored
Mar 11, 2025
by
jmorganca
Committed by
Michael Yang
Mar 11, 2025
Browse files
Revert "Allow models to force a new batch"
This reverts commit c7eae586b899083acebcd9b3847b89ea78c2850c.
parent
06007c0a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
10 deletions
+14
-10
model/input/input.go
model/input/input.go
+0
-6
model/models/gemma3/model.go
model/models/gemma3/model.go
+2
-2
runner/ollamarunner/runner.go
runner/ollamarunner/runner.go
+1
-1
server/prompt.go
server/prompt.go
+11
-1
No files found.
model/input/input.go
View file @
65b0f329
...
...
@@ -15,12 +15,6 @@ type Input struct {
// stored in Multimodal, used for caching and comparing
// equality.
MultimodalHash
uint64
// BatchBreak forces a new batch to be started with this
// input. For example, this can be used to align images
// with batches. Note that batches may be divided in additional
// locations as well.
BatchBreak
bool
}
// MultimodalIndex is a multimodal element (such as an image)
...
...
model/models/gemma3/model.go
View file @
65b0f329
...
...
@@ -112,8 +112,8 @@ func (m *Model) PostTokenize(ctx ml.Context, inputs []input.Input) ([]input.Inpu
result
=
append
(
result
,
inp
)
}
else
{
imageInputs
:=
[]
input
.
Input
{
{
Token
:
108
},
// "\n\n"
{
Token
:
255999
,
BatchBreak
:
true
},
// "<start_of_image>""
{
Token
:
108
},
// "\n\n"
{
Token
:
255999
},
// "<start_of_image>""
}
result
=
append
(
result
,
imageInputs
...
)
...
...
runner/ollamarunner/runner.go
View file @
65b0f329
...
...
@@ -363,7 +363,7 @@ func (s *Server) processBatch() error {
}
}
if
j
>=
s
.
batchSize
||
(
inp
.
BatchBreak
&&
len
(
seq
.
pendingInputs
)
!=
0
)
{
if
j
>=
s
.
batchSize
{
break
}
...
...
server/prompt.go
View file @
65b0f329
...
...
@@ -26,6 +26,7 @@ func chatPrompt(ctx context.Context, m *Model, tokenize tokenizeFunc, opts *api.
var
system
[]
api
.
Message
isMllama
:=
checkMllamaModelFamily
(
m
)
isGemma3
:=
checkGemma3ModelFamily
(
m
)
var
imageNumTokens
int
// TODO: Ideally we would compute this from the projector metadata but some pieces are implementation dependent
...
...
@@ -40,7 +41,7 @@ func chatPrompt(ctx context.Context, m *Model, tokenize tokenizeFunc, opts *api.
n
:=
len
(
msgs
)
-
1
// in reverse, find all messages that fit into context window
for
i
:=
n
;
i
>=
0
;
i
--
{
if
isMllama
&&
len
(
msgs
[
i
]
.
Images
)
>
1
{
if
(
isMllama
||
isGemma3
)
&&
len
(
msgs
[
i
]
.
Images
)
>
1
{
return
""
,
nil
,
errTooManyImages
}
...
...
@@ -157,3 +158,12 @@ func checkMllamaModelFamily(m *Model) bool {
}
return
false
}
func
checkGemma3ModelFamily
(
m
*
Model
)
bool
{
for
_
,
arch
:=
range
m
.
Config
.
ModelFamilies
{
if
arch
==
"gemma3"
{
return
true
}
}
return
false
}
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