Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -14,6 +14,48 @@ library_name: coreml
|
|
| 14 |
pipeline_tag: text-generation
|
| 15 |
---
|
| 16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
# LFM2.5 350M — CoreML build for Apple Neural Engine
|
| 18 |
|
| 19 |
CoreML port of [LiquidAI/LFM2.5-350M](https://huggingface.co/LiquidAI/LFM2.5-350M)
|
|
|
|
| 14 |
pipeline_tag: text-generation
|
| 15 |
---
|
| 16 |
|
| 17 |
+
## Use it from Swift
|
| 18 |
+
|
| 19 |
+
<!-- swift-usage-begin -->
|
| 20 |
+
### Add the package
|
| 21 |
+
|
| 22 |
+
`Package.swift`:
|
| 23 |
+
|
| 24 |
+
```swift
|
| 25 |
+
.package(url: "https://github.com/john-rocky/CoreML-LLM", branch: "main"),
|
| 26 |
+
|
| 27 |
+
// In your target:
|
| 28 |
+
.product(name: "CoreMLLLM", package: "CoreML-LLM"),
|
| 29 |
+
```
|
| 30 |
+
|
| 31 |
+
Platforms: iOS 18+ / macOS 15+.
|
| 32 |
+
|
| 33 |
+
### Download + chat (one call)
|
| 34 |
+
|
| 35 |
+
```swift
|
| 36 |
+
import CoreMLLLM
|
| 37 |
+
|
| 38 |
+
// First call pulls the bundle from this repo to Documents/Models/.
|
| 39 |
+
// Subsequent calls reuse the on-disk copy.
|
| 40 |
+
let llm = try await CoreMLLLM.load(repo: "mlboydaisuke/lfm2.5-350m-coreml")
|
| 41 |
+
|
| 42 |
+
let stream = try await llm.generate(
|
| 43 |
+
[CoreMLLLM.Message(role: .user, content: "Hello!")],
|
| 44 |
+
maxTokens: 256
|
| 45 |
+
)
|
| 46 |
+
for await chunk in stream {
|
| 47 |
+
print(chunk, terminator: "")
|
| 48 |
+
}
|
| 49 |
+
```
|
| 50 |
+
|
| 51 |
+
Multi-turn: keep an `[CoreMLLLM.Message]` array, append the
|
| 52 |
+
user/assistant turns, and pass the whole history to
|
| 53 |
+
`generate(_:)` again. Call `llm.reset()` to start a new
|
| 54 |
+
conversation (clears the KV cache).
|
| 55 |
+
<!-- swift-usage-end -->
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
|
| 59 |
# LFM2.5 350M — CoreML build for Apple Neural Engine
|
| 60 |
|
| 61 |
CoreML port of [LiquidAI/LFM2.5-350M](https://huggingface.co/LiquidAI/LFM2.5-350M)
|