Repository navigation
update documentation and skills - #489
Conversation
| let modelContainer = try await EmbedderModelFactory.shared.loadContainer( | ||
| from: #hubDownloader(), | ||
| using: #huggingFaceTokenizerLoader(), | ||
| configuration: EmbedderRegistry.nomic_text_v1_5 |
There was a problem hiding this comment.
Some stragglers using the old API
| let texts = ["First text", "Second text", "Third text"] | ||
|
|
||
| let embeddings = await container.perform { model, tokenizer, pooler in | ||
| let embeddings = await container.perform { context in |
There was a problem hiding this comment.
Update this to the non-deprecated form of the call. Note that all of this will be obsolete with #335
- make sure we are using current best practices e.g. for #huggingFaceTokenizerLoader() - where found, update skills to current API
dd6d6d1 to
1049429
Compare
| let container = try await LLMModelFactory.shared.loadContainer( | ||
| from: HubClient.default, | ||
| using: TokenizersLoader(), // TokenizersLoader() from MLXLMTokenizers (swift-tokenizers-mlx) | ||
| from: #hubDownloader(), |
There was a problem hiding this comment.
I think we need updated imports here (import MLXHuggingFace, import HuggingFace and import Tokenizers)
| let container = try await LLMModelFactory.shared.loadContainer( | ||
| from: HubClient.default, | ||
| using: TokenizersLoader(), | ||
| from: #hubDownloader(), |
There was a problem hiding this comment.
I think we also need updated imports here (import MLXHuggingFace, import HuggingFace and import Tokenizers)
| // etc. | ||
| import MLXLMCommon | ||
| import MLXHuggingFace | ||
| import Tokenizers |
There was a problem hiding this comment.
Needs import HuggingFace
|
|
||
| `#huggingFaceTokenizerLoader()` delegates to `Tokenizers.AutoTokenizer`, which maps the | ||
| `tokenizer_class` from `tokenizer_config.json` onto its own built-in implementations and | ||
| falls back to a BPE tokenizer for unknown classes. If that is not what you want, write |
There was a problem hiding this comment.
Not a huge issue, but this isn't quite true as stated. AutoTokenizer.from(modelFolder:) only falls back to BPE if strict=false, but by default, it's true. In the default case, it doesn't fall back - it throws unsupportedTokenizer. So people should still make their own tokenizer if they care very much about this but it might be more to avoid errors than to avoid fallbacks.
There was a problem hiding this comment.
Do you want to propose a rephrase? Perhaps just noting that you can write a custom TokenizerLoader that does fall back to BPE would be more correct.
| import MLXLLM | ||
| import MLXLMCommon | ||
|
|
||
| import IntegrationPackage |
There was a problem hiding this comment.
Is it desired to remove this? I'm a little confused by this example - with the proposed changes, it now shows a generic HuggingFace macro example (identical to the previous section) rather than an IntegrationPackage-specific example.
There was a problem hiding this comment.
yes, when the 3.x mlx-swift-lm was cut we had an integration package to document. We no longer have that (the author stopped supporting it and retracted it).
@aleroot is working on one that could be documented here when he wants to promote it.
There was a problem hiding this comment.
@davidkoski sure, after the release I will add a PR(probably after #619) with the option for https://github.com/aleroot/swift-tokenizers , on my app is working well already for awhile now. The only thing is that: I do not plan to add any downloader to that library. The library is however fully drop in replacement for the swift-transformers.
| `#huggingFaceTokenizerLoader()` macro provides a concrete loader backed by Swift | ||
| Tokenizers' `AutoTokenizer`: |
There was a problem hiding this comment.
May want to change the "Swift Tokenizers" reference to "Swift Transformers".
There was a problem hiding this comment.
May want to change the "Swift Tokenizers" reference to "Swift Transformers".
| @@ -263,7 +266,7 @@ Users who were passing a custom `HubApi` instance should create a `HubClient` in | |||
There was a problem hiding this comment.
May want to change the "Swift Tokenizers" reference to "Swift Transformers".
Apply the upstream commits ee673d6..55db721 as a 3-way patch. CLAUDE.md is excluded. - c043fb3 pick up mlx-swift 0.32.2 (ml-explore#646) - 0493daf Named image attachments in MLXLMCommon and the Foundation Models adapter (ml-explore#535) - 0dcfe2f Convert the booleans in tool parameter schemas to Swift Bool values (ml-explore#653) - 37dab60 be able to trigger workflows on main. notes about upcoming releases. (ml-explore#647) - 390c5fd require mlx-swift-0.32.3 for SDK issue (ml-explore#657) - 3b339ad adjustments for running tests on NAX/TF32 hardware (ml-explore#649) - ac6f565 update documentation and skills (ml-explore#489) - ce3950e Drop MTP weights from converted Qwen 3.5 VLM checkpoints (ml-explore#642) - 9112fae Synchronize cross-SIMD WHT reads before shared-memory writes (ml-explore#650) - 7e4024e NemotronH: MoE keys are optional, so dense checkpoints load (ml-explore#635) - 1830ae4 Declare the fused GDN projection as compile state so it frees with the model (ml-explore#631) - 6e0a0b2 Synchronize Metal before checking cached buffer memory (ml-explore#667) - 9afc3b5 Recommend upToNextMinor in installation instructions (ml-explore#668) - 55db721 Reduce Qwen3 reranking memory by projecting final tokens only (ml-explore#621) Conflict resolutions: - MLXLanguageModel.swift: keep the drain coordinator and runRespond of stable, and keep historyMessages. Add the upstream attachment label validation before resolveConfiguration. historyMessages now throws, because TranscriptConverter.mlxMessages now throws. - TranscriptConverter.swift: keep the mlxMessages(for:replayReasoning:) and convert(entry:) form of stable. Apply the upstream changes in convert(entry:): it throws, an instructions entry drops its images, and extractImages(from:in:) applies the orientation and rejects content that is not an image. - Chat.swift: keep the doc comments of stable, and add the upstream MessageContentLayout and contentParts(for:layout:). - TurboQuantKernels.swift: keep stable. Stable already fixed the same cross-SIMD WHT race with two barriers per stage. - KVCacheTests.swift: take the upstream file (upstream changed it to a suite). Delete the upstream ArraysCache.advance test, because in this fork advance(_:) also moves offset. Add the fork tests for advance and the trim-then-continue test at file scope. - Qwen35FusedGDNProjectionTests.swift: keep the deletion of the opt-in benchmark (it skips unless an environment variable is set). Add the new upstream memory test. - model-container.md: take upstream (llama3_2_3B_4bit and the macros are the real API). - TranscriptConverterTests.swift: the replayReasoning calls now use try. Tests: MLXGuidedGenerationTests 70, MLXFoundationModelsTests 349, CXGrammarTests 7, MLXHuggingFaceMacrosTests 5 pass. MLXLMTests: 1287 Swift Testing tests pass, and 699 of 700 XCTest tests pass. The failure is the wall-clock limit of EvalTests testVarianceNormalizedKVCache32KIngestAndDecodePeakMetalMemorySmoke (0.29 s, limit 0.25 s) in the full run. The test passes alone two times, and this merge does not change EvalTests.swift. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Proposed changes
Checklist
Put an
xin the boxes that apply.pre-commit run --all-filesto format my code / installed pre-commit prior to committing changes