madewithlaya

Catalog / Tools & apps

0061GitHub

LayaKit: a Swift package that runs one Laya decision per call on Core ML

SwiftPM package ported from laya-coreml. Point it at the aac6fef Core ML bundles (general or ANE) and call predict with choice, score or noul; no Python at runtime.

Open source ↗ github.comcostfree, localtime-
tahby/LayaKitREADME ↗
# LayaKit

A Swift package that runs one Laya typed decision per call on-device via Core ML — no Python at runtime. Ported from [`mizorewww/laya-coreml`](https://github.com/mizorewww/laya-coreml).

## Requirements

- macOS 15+
- Apple silicon
- Xcode 26+

## Install

Add LayaKit as a SwiftPM dependency:

```swift
.package(url: "https://github.com/<org>/LayaKit", from: "1.0.0")
```

```swift
.target(
    name: "YourTarget",
    dependencies: [.product(name: "LayaKit", package: "LayaKit")]
)
```

## Download bundles

```
pip install -U huggingface_hub
hf download aac6fef/laya-multilingual-coreml --local-dir models/general
hf download aac6fef/laya-multilingual-coreml-ane --local-dir models/ane
```

## Usage

```swift
let agent = try await LayaAgent(bundle: URL(fileURLWithPath: "models/ane"))
let answer = try agent.predict(state: "I was billed twice. Refund the duplicate.",
                               question: .choice(instructions: "Who should handle this?",
                                                 options: ["billing", "technical", "sales"]))
```

## Question types

| Case | Parameters | Description |
| --- | --- | --- |
| `.choice` | `instructions: String`, `options: [String]`, `descriptions: [String: String]?` | Pick one label out of a set of options, optionally with a description per option. |
| `.score` | `instructions: String`, `levels: [String]` | Rate along an ordered scale; each level is described by a string. |
| `.noul` | `instructions: String`, `falseText: String?`, `trueText: String?` | A yes/no judgment, optionally with custom text for the false/true cases. |

## CLI usage

`laya-cli` runs a single question against a bundle and prints the answer as JSON.

```
laya-cli --bundle <path> --state <text> --question <path-to-json> [--bench N]
```

- `--bun

Also filed under Tools & apps

  1. 0005

    laya-mlx plays Snake at 60 decisions per second

    介绍比Jev快50倍,在你设备上跑的laya-mlx! 只在你的设备上占用最高1G内存 Laya是一个开源的类似于Jev的,基于文本输出概率的分类系统 我将其移植到MLX,并且做了一些性能优化! 视频中就是这个模型在我的本地M3Max上玩贪吃蛇 这个模型能够以每秒决策60次的速度玩贪吃蛇! https://t.co/31KGUiNunb

    @mizorewww · Tools & apps · free, local · 60 decisions/s

  2. 0112

    Laya on Axera AX650 and AX8850 edge NPUs, under 70 ms

    AXERA-TECH's conversion of all three Laya checkpoints for its edge AI chips, reported at latency under 70 ms per decision on AX650/AX8850.

    AXERA-TECH · Tools & apps · free, on-device · < 70 ms on AX650 / AX8850

  3. 0099

    laya-mcp (PerryLink): a warm sidecar that fixes Laya's silent truncation and constant noul

    MCP server plus HTTP sidecar: token-budget preflight that reports what would be cut, a persisted calibration store, structured errors, and a noul fix (P(true) 0.5 → 1.0).

    @PerryLink · Tools & apps · free, local

  4. 0097

    Gomoku against Laya-MLX: you play black, the model picks white's move from six candidates

    Local 15x15 Gomoku on Apple Silicon. Rules in Python, board in the browser, every AI move one real Laya choice over up to six candidates, probabilities shown. No Gomoku training.

    smile-magic · Tools & apps · free, local