Skip to content
Back to search

mlx-swift-lm

LLMs and VLMs with MLX Swift

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today

Check it deeper on your machine

It has changed since its scan on 11 Nov 2026.

As a Claude Code plugin, install it and then ask Claude Code:

/plugin marketplace add keithmackay/mackayi/plugin install scanskillsafety@mackayiDo a deep scan of https://github.com/ml-explore/mlx-swift-lm with scanskillsafety

Or from a terminal, clone it and run it:

git clone https://github.com/keithmackay/scanskillsafety-skill ~/.claude/skills/scanskillsafetynode ~/.claude/skills/scanskillsafety/cli.cjs --deep 'https://github.com/ml-explore/mlx-swift-lm'

It checks the exact commit: every file, its packages against OSV (api.osv.dev), how it compares with this page's scan (findsafeskills.com receives the repository's address), and, if you agree, Claude reading every file with your own Claude subscription. It never runs the code.

Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/ml-explore--mlx-swift-lm/badge.svg)](/listings/ml-explore--mlx-swift-lm)

HTML

<a href="/listings/ml-explore--mlx-swift-lm"><img src="/api/listings/ml-explore--mlx-swift-lm/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

Add the core package to your `Package.swift`:

.package(url: "https://github.com/ml-explore/mlx-swift-lm", .upToNextMinor(from: "3.32.3")),

Then chose an [integration package for downloaders and tokenizers](https://swiftpackageindex.com/ml-explore/mlx-swift-lm/main/documentation/mlxlmcommon/using#Integration-Packages).

> [!NOTE] > If the documentation link shows a 404, view the > [source](https://github.com/ml-explore/mlx-swift-lm/blob/main/Libraries/MLXLMCommon/Documentation.docc/using.md).

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 155 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. # MLX Swift LM
  2. MLX Swift LM is a Swift package to build tools and applications with large language models (LLMs) and vision language models (VLMs) in [MLX Swift](https://github.com/ml-explore/mlx-swift).
  3. > [!IMPORTANT]
  4. > The `main` branch is a _new_ major version number: 3.x. In order
  5. > to decouple from tokenizer and downloader packages some breaking
  6. > changes were introduced. See [upgrading documentation](https://swiftpackageindex.com/ml-explore/mlx-swift-lm/main/documentation/mlxlmcommon/upgrade) for detailed instructions on upgrading.
  7. > [!IMPORTANT]
  8. > We use `swift-format` to keep the code formatting consistent. CI has this pinned to `603.0.0` right now.
  9. [View Current Release Planning](https://github.com/ml-explore/mlx-swift-lm/issues?q=is%3Aissue+is%3Aopen+label%3Arelease-planning) and read about [Contributing](#contributing).
  10. Some key features include:
  11. - Model loading with integrations for a variety of tokenizer and model downloading packages.
  12. - Low-rank (LoRA) and full model fine-tuning with support for quantized models.
  13. - Many model architectures for both LLMs and VLMs.
  14. For some example applications and tools that use MLX Swift LM, check out [MLX Swift Examples](https://github.com/ml-explore/mlx-swift-examples).
  15. ## Documentation
  16. Developers can use these examples in their own programs -- just import the swift package!
  17. - [Porting and implementing models](https://swiftpackageindex.com/ml-explore/mlx-swift-lm/main/documentation/mlxlmcommon/porting)
  18. - [Techniques for developing in mlx-swift-lm](https://swiftpackageindex.com/ml-explore/mlx-swift-lm/main/documentation/mlxlmcommon/developing)
  19. - [MLXLLMCommon](https://swiftpackageindex.com/ml-explore/mlx-swift-lm/main/documentation/mlxlmcommon): Common API for LLM and VLM
  20. - [MLXLLM](https://swiftpackageindex.com/ml-explore/mlx-swift-lm/main/documentation/mlxllm): Large language model example implementations
  21. - [MLXVLM](https://swiftpackageindex.com/ml-explore/mlx-swift-lm/main/documentation/mlxvlm): Vision language model example implementations
  22. - [MLXEmbedders](https://swiftpackageindex.com/ml-explore/mlx-swift-lm/main/documentation/mlxembedders): Popular encoders and embedding models example implementations
  23. - [MLXGuidedGeneration](Libraries/MLXGuidedGeneration/README.md): Grammar-constrained generation (JSON Schema or EBNF) for any MLX model.
  24. - [MLXFoundationModels](Libraries/MLXFoundationModels/README.md): Bridge MLX models into Apple's `FoundationModels.LanguageModel` for use with `LanguageModelSession`. (Requires the macOS/iOS/visionOS 27.0 SDK.)
  25. - [MLXScriptedLM](https://swiftpackageindex.com/ml-explore/mlx-swift-lm/main/documentation/mlxscriptedlm): Scripted tokenizers and language models -- good for tests or stubbing out behavior without weights
  26. ## Usage
  27. This package integrates with a variety of tokenizer and downloader packages through protocol conformance. Users can pick from three ways to integrate with these packages, which offer different tradeoffs between freedom and convenience.
  28. See documentation on [how to integrate mlx-swift-lm and downloaders/tokenizers](https://swiftpackageindex.com/ml-explore/mlx-swift-lm/main/documentation/mlxlmcommon/using).
  29. > [!NOTE]
  30. > If the documentation link shows a 404, view the
  31. > [source](https://github.com/ml-explore/mlx-swift-lm/blob/main/Libraries/MLXLMCommon/Documentation.docc/using.md).
  32. ## Installation
  33. Add the core package to your `Package.swift`:
  34. ```swift
  35. .package(url: "https://github.com/ml-explore/mlx-swift-lm", .upToNextMinor(from: "3.32.3")),
  36. ```
  37. Then chose an [integration package for downloaders and tokenizers](https://swiftpackageindex.com/ml-explore/mlx-swift-lm/main/documentation/mlxlmcommon/using#Integration-Packages).
  38. > [!NOTE]
  39. > If the documentation link shows a 404, view the
  40. > [source](https://github.com/ml-explore/mlx-swift-lm/blob/main/Libraries/MLXLMCommon/Documentation.docc/using.md).
  41. ## Quick Start
  42. See also [MLXLMCommon](Libraries/MLXLMCommon). The simplest way to get started is using the `MLXHuggingFace` macros, which provide a default Hugging Face downloader and tokenizer integration.
  43. ## Package.swift
  44. ```swift
  45. dependencies: [
  46. .package(url: "https://github.com/ml-explore/mlx-swift-lm", .upToNextMinor(from: "3.32.3")),
  47. .package(url: "https://github.com/huggingface/swift-huggingface", from: "0.9.0"),
  48. .package(url: "https://github.com/huggingface/swift-transformers", from: "1.3.0"),
  49. ],
  50. targets: [
  51. .target(
  52. name: "YourTargetName",
  53. dependencies: [
  54. .product(name: "MLXLLM", package: "mlx-swift-lm"),
  55. .product(name: "MLXLMCommon", package: "mlx-swift-lm"),
  56. .product(name: "MLXHuggingFace", package: "mlx-swift-lm"),
  57. .product(name: "HuggingFace", package: "swift-huggingface"),
  58. .product(name: "Tokenizers", package: "swift-transformers"),
  59. ]),
  60. ]
  61. ```
  62. ## Usage
  63. ```swift
  64. import MLXLLM
  65. import MLXLMCommon
  66. import MLXHuggingFace
  67. import HuggingFace
  68. import Tokenizers
  69. let model = try await #huggingFaceLoadModelContainer(
  70. configuration: LLMRegistry.gemma3_1B_qat_4bit
  71. )
  72. let session = ChatSession(model)
  73. print(try await session.respond(to: "What are two things to see in San Francisco?"))
  74. print(try await session.respond(to: "How about a great place to eat?"))
  75. ```
  76. For alternative integration approaches (custom downloaders, alternative tokenizer packages, local-only weights), see the [using documentation](Libraries/MLXLMCommon/Documentation.docc/using.md).
  77. ## `FoundationModels` integration
  78. `MLXFoundationModels` is a bridge between MLX models and Apple's `FoundationModels` framework: build an `MLXLanguageModel`, pass it to `LanguageModelSession`, and generate through the standard `FoundationModels` API. Requires the macOS/iOS/visionOS 27.0 SDK.
  79. ```swift
  80. import Foundation
  81. import FoundationModels
  82. import HuggingFace
  83. import MLXFoundationModels
  84. import MLXHuggingFace
  85. import MLXLLM
  86. import MLXLMCommon
  87. import Tokenizers
  88. @available(iOS 26.0, macOS 26.0, visionOS 26.0, *)
  89. @Generable
  90. struct Recommendation {
  91. let attraction: String
  92. let neighborhood: String
  93. let tip: String
  94. }
  95. if #available(iOS 27.0, macOS 27.0, visionOS 27.0, *) {
  96. let model = #huggingFaceLanguageModel(
  97. configuration: LLMRegistry.gemma3_1B_qat_4bit,
  98. capabilities: [.guidedGeneration])
  99. let session = LanguageModelSession(model: model)
  100. let recommendation = try await session.respond(
  101. to: "Recommend one thing to do in Chicago.",
  102. generating: Recommendation.self)
  103. print(recommendation.content)
  104. // Recommendation(
  105. // attraction: "Art Institute of Chicago",
  106. // neighborhood: "Loop",
  107. // tip: "Admire Seurat's Sunday on La Grande Jatte up close.")
  108. }
  109. ```
  110. Here, we combine `MLXFoundationModels` with [`MLXGuidedGeneration`](Libraries/MLXGuidedGeneration/README.md) by requesting a `@Generable` type: the response is grammar-constrained to that type's schema. `MLXGuidedGeneration` is a standalone primitive that constrains any MLX model's output to a schema.
  111. Other capabilities include `.vision`, `.toolCalling`, and `.reasoning`. See [Libraries/MLXFoundationModels](Libraries/MLXFoundationModels/README.md) for the full capability set, custom weights and loaders, and more information about using MLXFoundationModels.
  112. ## Contributing
  113. See [CONTRIBUTING.md](CONTRIBUTING.md) for how to build, test, and submit changes.
  114. Smaller, focused PRs are easier and quicker to review. Sometimes larger PRs can't be helped. If you want to discuss, feel free to open an issue or ask questions in a PR. If responses are slow, feel free to @ `davidkoski` - there is a lot of activity and it probably just got past me. I will do my best to respond!

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.