File size: 3,256 Bytes
af872ae c9bffa5 af872ae c9bffa5 af872ae c9bffa5 af872ae c9bffa5 af872ae c9bffa5 af872ae c9bffa5 af872ae 7629151 c9bffa5 7629151 c9bffa5 7629151 c9bffa5 7629151 af872ae c9bffa5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | ---
license: mit
tags:
- onnx
- smartwatch
- intent-classification
- text-generation
- wearable
library_name: onnxruntime
pipeline_tag: text-generation
---
# Smartwatch LM v0.1
Small GPT-style language model trained for wrist-wearable assistant chat. The model learns conversational replies and emits intent tags such as `<INTENT:GET_STEPS>` that your app can parse and route to device handlers.
## Model details
| Property | Value |
|----------|-------|
| Architecture | 6-layer causal GPT (**~12M params**) |
| Context length | 256 tokens |
| Vocab size | 3524 (BPE) |
| Export version | 0.1 |
## Files in this repo
| File | Purpose |
|------|---------|
| `smartwatch_lm_merged.onnx` | On-device inference (ONNX Runtime, opset 17) |
| `checkpoint.pt` | PyTorch weights for fine-tuning or local chat |
| `tokenizer.json` | BPE tokenizer (Hugging Face Tokenizers format) |
| `tokenizer_config.json` | Tokenizer metadata |
| `config.json` | Model architecture and ONNX I/O names |
| `model.py` | PyTorch model definition + checkpoint loader |
| `chat.py` | Interactive PyTorch chat |
| `reply_utils.py` | Gibberish cleanup, intent parse, slot fill |
| `onnx_sample.py` | ONNX generate + cleanup sample script |
| `config.py` | Generation defaults |
## ONNX inference
**Inputs:** `input_ids` — int64 tensor, shape `[batch, seq]` (max seq = 256)
**Outputs:** `logits` — float tensor, shape `[batch, seq, vocab_size]`
Works with ONNX Runtime (CPU, WASM, WebGPU). The merged ONNX file is a single ~52 MB artifact.
```python
import numpy as np
import onnxruntime as ort
session = ort.InferenceSession("smartwatch_lm_merged.onnx", providers=["CPUExecutionProvider"])
x = np.zeros((1, 8), dtype=np.int64)
logits = session.run(None, {"input_ids": x})[0]
print(logits.shape) # (1, 8, 3524)
```
Quick chat with cleanup:
```bash
pip install numpy onnxruntime tokenizers
python onnx_sample.py "How many steps today?"
```
## PyTorch chat
```bash
pip install torch tokenizers
python chat.py
```
```python
from chat import ChatSession
bot = ChatSession(temperature=0.5, max_new_tokens=40, top_k=40)
print(bot.say("How many steps have I taken today?"))
```
## Prompt format
```
user: How many steps have I taken today?
bot: <INTENT:GET_STEPS> You're at <STEPS_TODAY> of <STEP_GOAL> — keep going!
```
The model predicts the next token. Slot placeholders like `<STEPS_TODAY>` are filled by your runtime with live sensor data.
## Documentation
| Guide | Description |
|-------|-------------|
| [Avoiding gibberish](docs/avoiding-gibberish.md) | Special characters to strip, truncation rules, sample scripts |
| [Intent reference](docs/intent-reference.md) | All 35 intents and slot placeholders |
| [Smartwatch integration](docs/smartwatch-integration.md) | End-to-end device wiring |
## Intended use
On-device smartwatch / wearable assistant demos. Not intended for general-purpose chat or safety-critical applications.
## Limitations
- Trained on synthetic data; behavior on real user phrasing may vary
- Does not output real metric values — only intents and slot tokens
- Small 12M model with limited reasoning capability
|