Browse Source

add trailing \n\n after <end_of_image> to match reference implementation

jmorganca 1 month ago
parent
commit
11bfa62796
1 changed files with 4 additions and 2 deletions
  1. 4 2
      model/models/gemma3/model.go

+ 4 - 2
model/models/gemma3/model.go

@@ -133,8 +133,10 @@ func (m *Model) PostTokenize(ctx ml.Context, inputs []input.Input) ([]input.Inpu
 				result = append(result, input.Input{Multimodal: imageToken, MultimodalHash: fnvHash.Sum64()})
 				result = append(result, input.Input{Multimodal: imageToken, MultimodalHash: fnvHash.Sum64()})
 			}
 			}
 
 
-			// <end_of_image>
-			result = append(result, input.Input{Token: 256000})
+			result = append(result,
+				input.Input{Token: 256000}, // <end_of_image>
+				input.Input{Token: 108},    // "\n\n"
+			)
 		}
 		}
 	}
 	}