Skip to content

Enable Gemma 4 unified thinking by default - #32

Merged
atdrendel merged 1 commit into
mainfrom
update-mlx-swift-lm
Jul 7, 2026
Merged

Enable Gemma 4 unified thinking by default#32
atdrendel merged 1 commit into
mainfrom
update-mlx-swift-lm

Conversation

@atdrendel

Copy link
Copy Markdown
Contributor
  • Update mlx-swift-lm to fix tool schemas for Gemma 4

- Update mlx-swift-lm to fix tool schemas for Gemma 4
Copilot AI review requested due to automatic review settings July 7, 2026 21:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates SHLLM’s Gemma 4 integration to align with upstream mlx-swift-lm changes (notably tool schema behavior) and makes Gemma 4 Unified default to “thinking” mode unless explicitly disabled.

Changes:

  • Default enable_thinking to true for LLM.gemma4Unified(...) when the caller does not provide it.
  • Update Gemma 4 model tests to remove manual <|think|> prompt tokens and relax assertions that reasoning must be present.
  • Pin mlx-swift-lm to a specific revision and update Package.resolved accordingly.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
Tests/SHLLMTests/Models/Gemma4-E4BTests.swift Removes `<
Tests/SHLLMTests/Models/Gemma4-E2BTests.swift Same test updates as E4B to match updated Gemma 4 behavior.
Tests/SHLLMTests/Models/Gemma4-12BTests.swift Same test updates for Gemma 4 Unified (12B) tool-call flows.
Sources/SHLLM/LLM.swift Enables “thinking” by default for gemma4Unified via additionalContext mutation.
Package.swift / Package.resolved Pins mlx-swift-lm to a specific commit revision to pick up upstream fixes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Sources/SHLLM/LLM.swift
Comment on lines 696 to 700
/// **gemma-4-12b**
///
/// To enable thinking, set
/// `UserInput(additionalContext: ["enable_thinking": true])`
/// and add `<|think|>` to the **beginning** and **end** of
/// the system prompt. (The documentation says to just add it to
/// the beginning of the system prompt, but testing has shown it
/// to be more reliable when added to the beginning and end of the
/// system prompt.
/// `UserInput(additionalContext: ["enable_thinking": true])`.
///
Comment thread Sources/SHLLM/LLM.swift
Comment on lines 709 to +715
try SHLLM.assertSupportedDevice
var input = input
var additionalContext = input.additionalContext ?? [:]
if additionalContext["enable_thinking"] == nil {
additionalContext["enable_thinking"] = true
}
input.additionalContext = additionalContext
@atdrendel
atdrendel merged commit 320272f into main Jul 7, 2026
2 checks passed
@atdrendel
atdrendel deleted the update-mlx-swift-lm branch July 7, 2026 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants