Something went wrong. Try again.
Routing embedding stack for Qwen3-Embedding-0.6B on Apple Silicon: orchestrator + MLX + llama.cpp backends
Something went wrong. Try again.
886 B · 29 lines
Swift
at main
123456789101112131415161718192021222324252627282930import Foundationimport MLXEmbedders
/// Top-level service the HTTP handler talks to./// Owns the `ModelRegistry` and hides MLX/ModelContainer details from the router.struct EmbedService: Sendable { let registry: ModelRegistry let maxLen: Int
init(registry: ModelRegistry, maxLen: Int) { self.registry = registry self.maxLen = maxLen }
func embed(texts: [String], kind: InputKind, size: ModelSize) async throws -> [[Float]] { let container = try await registry.container(for: size) let maxLen = self.maxLen return await container.perform { model, tokenizer, pooling in Batching.embed( model: model, tokenizer: tokenizer, pooling: pooling, texts: texts, kind: kind, maxLen: maxLen ) } }}