File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -574,7 +574,8 @@ public final class LLMModelFactory: ModelFactory {
574574
575575 // Build a ModelConfiguration with loaded EOS token IDs and tool call format
576576 var mutableConfiguration = configuration
577- mutableConfiguration. eosTokenIds = eosTokenIds. union ( configuration. eosTokenIds)
577+ eosTokenIds. formUnion ( configuration. eosTokenIds)
578+ mutableConfiguration. eosTokenIds = eosTokenIds
578579 if mutableConfiguration. toolCallFormat == nil {
579580 mutableConfiguration. toolCallFormat = ToolCallFormat . infer (
580581 from: baseConfig. modelType, configData: configData)
Original file line number Diff line number Diff line change @@ -101,7 +101,12 @@ public struct ModelConfiguration: Sendable {
101101 /// Additional tokens to use for end of string (specified as strings, converted to IDs at runtime)
102102 public var extraEOSTokens : Set < String >
103103
104- /// EOS token IDs loaded from config.json/generation_config.json
104+ /// EOS token IDs used during generation.
105+ ///
106+ /// At load time this set is populated by merging:
107+ /// - IDs from the model's `config.json` / `generation_config.json` (loaded at runtime)
108+ /// - Any additional IDs provided by the registry / caller at registration time
109+ /// (e.g. `eosTokenIds: [0]` in ``LLMRegistry`` for Gemma-4 pad-token workaround)
105110 public var eosTokenIds : Set < Int > = [ ]
106111
107112 /// Tool call format for this model (nil = default JSON format)
Original file line number Diff line number Diff line change @@ -361,7 +361,8 @@ public final class VLMModelFactory: ModelFactory {
361361 }
362362
363363 var mutableConfiguration = configuration
364- mutableConfiguration. eosTokenIds = eosTokenIds. union ( configuration. eosTokenIds)
364+ eosTokenIds. formUnion ( configuration. eosTokenIds)
365+ mutableConfiguration. eosTokenIds = eosTokenIds
365366
366367 // Auto-detect tool call format from model type if not explicitly set
367368 if mutableConfiguration. toolCallFormat == nil {
You can’t perform that action at this time.
0 commit comments