Instructions to use litert-community/OLMo-2-1B-Instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- LiteRT-LM
How to use litert-community/OLMo-2-1B-Instruct with LiteRT-LM:
# LiteRT-LM runs on various platforms (Android, iOS, Windows, Linux, macOS, IoT, Web/WASM) # and supports many APIs (C++, Python, Kotlin, Swift, JavaScript, Flutter). # For platform-specific integration guides, please refer to the official developer website: # https://ai.google.dev/edge/litert-lm # To try LiteRT-LM, the easiest way is to use our CLI tool. # 1. Install the LiteRT-LM CLI tool: pip install -U litert-lm # 2. Download and run this model locally: # See: https://ai.google.dev/edge/litert-lm/cli litert-lm run \ --from-huggingface-repo=litert-community/OLMo-2-1B-Instruct \ --prompt="Write me a poem"
- LiteRT
How to use litert-community/OLMo-2-1B-Instruct with LiteRT:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
Upload folder using huggingface_hub
Browse files- .gitattributes +2 -0
- OLMo-2-1B-Instruct_q4_block32_ekv4096.litertlm +3 -0
- README.md +97 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
model.litertlm filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
OLMo-2-1B-Instruct_q4_block32_ekv4096.litertlm filter=lfs diff=lfs merge=lfs -text
|
OLMo-2-1B-Instruct_q4_block32_ekv4096.litertlm
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:669484d528d9b981ddf5057126f3b0e629e2fe793310f95959f8463eb538b811
|
| 3 |
+
size 931241056
|
README.md
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
base_model: allenai/OLMo-2-0425-1B-Instruct
|
| 4 |
+
tags:
|
| 5 |
+
- litert
|
| 6 |
+
- litert-lm
|
| 7 |
+
- litertlm
|
| 8 |
+
- on-device
|
| 9 |
+
- edge
|
| 10 |
+
- olmo2
|
| 11 |
+
pipeline_tag: text-generation
|
| 12 |
+
library_name: litert-lm
|
| 13 |
+
---
|
| 14 |
+
|
| 15 |
+
# OLMo-2-1B-Instruct — LiteRT-LM (blockwise int4)
|
| 16 |
+
|
| 17 |
+
[allenai/OLMo-2-0425-1B-Instruct](https://huggingface.co/allenai/OLMo-2-0425-1B-Instruct)
|
| 18 |
+
converted to the **LiteRT-LM** (`.litertlm`) format for on-device inference with
|
| 19 |
+
Google's [LiteRT-LM](https://github.com/google-ai-edge/litert-lm) runtime (the
|
| 20 |
+
engine behind the official `litert-community/*` models).
|
| 21 |
+
|
| 22 |
+
OLMo-2 is AllenAI's **fully-open** model family (Apache-2.0; open weights, data,
|
| 23 |
+
and training code). This 1B variant is small enough to run on a phone — verified on
|
| 24 |
+
iPhone 17 Pro. Converted with the **official** upstream `litert-torch` — no fork.
|
| 25 |
+
|
| 26 |
+
| | |
|
| 27 |
+
|---|---|
|
| 28 |
+
| **File** | `OLMo-2-1B-Instruct_q4_block32_ekv4096.litertlm` (~0.93 GB) |
|
| 29 |
+
| **Quantization** | int4 weights — **blockwise (block 32) + OCTAV** optimal-clipping, symmetric; embedding INT8 |
|
| 30 |
+
| **Compute** | integer |
|
| 31 |
+
| **Context (KV cache)** | 4096 |
|
| 32 |
+
| **Base model** | allenai/OLMo-2-0425-1B-Instruct |
|
| 33 |
+
| **Decode speed** | ~24 tok/s (iPhone 17 Pro; loads 5.2 s, ~1.2 GB footprint) · ~138 tok/s (Mac M-series, Metal GPU) |
|
| 34 |
+
|
| 35 |
+
## Usage
|
| 36 |
+
|
| 37 |
+
Run with the LiteRT-LM runtime:
|
| 38 |
+
|
| 39 |
+
```bash
|
| 40 |
+
litert_lm_main \
|
| 41 |
+
--model_path OLMo-2-1B-Instruct_q4_block32_ekv4096.litertlm \
|
| 42 |
+
--backend gpu \
|
| 43 |
+
--input_prompt "Explain on-device AI in one sentence."
|
| 44 |
+
```
|
| 45 |
+
|
| 46 |
+
The `.litertlm` bundle carries the tokenizer and the prompt template (OLMo-2's
|
| 47 |
+
native Tülu format — `<|user|>` / `<|assistant|>`, stop token `<|endoftext|>`),
|
| 48 |
+
so no separate tokenizer files are needed.
|
| 49 |
+
|
| 50 |
+
## Run on Android
|
| 51 |
+
|
| 52 |
+
The easiest way to try this model on a phone is the official
|
| 53 |
+
**[Google AI Edge Gallery](https://github.com/google-ai-edge/gallery)** app:
|
| 54 |
+
|
| 55 |
+
1. Install a **recent** Gallery (package `com.google.ai.edge.gallery`, APK from the repo's
|
| 56 |
+
[releases](https://github.com/google-ai-edge/gallery/releases) — 1.0.15+ supports `.litertlm`).
|
| 57 |
+
2. Download `OLMo-2-1B-Instruct_q4_block32_ekv4096.litertlm` and push it to the device:
|
| 58 |
+
```bash
|
| 59 |
+
adb push OLMo-2-1B-Instruct_q4_block32_ekv4096.litertlm /sdcard/Download/
|
| 60 |
+
```
|
| 61 |
+
3. In the app, tap **+** (bottom-right), pick the file, and choose CPU or GPU. At
|
| 62 |
+
~0.93 GB this 1B fits comfortably on an 8 GB phone.
|
| 63 |
+
4. Chat — the bundle already carries the tokenizer and OLMo-2 prompt template.
|
| 64 |
+
|
| 65 |
+
See the Gallery
|
| 66 |
+
[Importing Local Models](https://github.com/google-ai-edge/gallery/wiki/6.-Importing-Local-Models-(optional))
|
| 67 |
+
guide for details. To embed it in **your own** Android app, use the LiteRT-LM Kotlin API
|
| 68 |
+
(`com.google.ai.edge.litertlm:litertlm-android`).
|
| 69 |
+
|
| 70 |
+
## Quality — GSM8K
|
| 71 |
+
|
| 72 |
+
Measured on GSM8K (n=100, greedy, 0-shot chain-of-thought, identical prompt and
|
| 73 |
+
answer-extraction for every row).
|
| 74 |
+
|
| 75 |
+
| Configuration | GSM8K |
|
| 76 |
+
|---|---|
|
| 77 |
+
| bf16 (reference) | 72.0% |
|
| 78 |
+
| **This model — LiteRT int4 (BOCTAV4)** | **63.0%** |
|
| 79 |
+
|
| 80 |
+
63 % is a strong, coherent, non-degenerate score for a 1B (the `\boxed{}`-style answers
|
| 81 |
+
terminate cleanly at `<|endoftext|>`). At 1B, 4-bit quantization costs ~9 pt vs bf16 —
|
| 82 |
+
a small model has less redundancy to absorb int4 rounding than a 3B+ (where the same
|
| 83 |
+
recipe is at parity). An int8 build recovers only ~2 pt (65 %) for +60 % size, so int4
|
| 84 |
+
is shipped as the best size/quality trade-off for on-device.
|
| 85 |
+
|
| 86 |
+
## Conversion
|
| 87 |
+
|
| 88 |
+
Converted with the **official** upstream [`litert-torch`](https://github.com/google-ai-edge/litert)
|
| 89 |
+
`export_hf` (clean `git worktree` at `upstream/main`, dev-fork patches excluded).
|
| 90 |
+
`Olmo2ForCausalLM` rides the stock converter with no custom code: QK-norm and OLMo-2's
|
| 91 |
+
reordered post-norm lower to generic ops. The int4 recipe is **blockwise (block 32) +
|
| 92 |
+
OCTAV** with the embedding at INT8.
|
| 93 |
+
|
| 94 |
+
## License
|
| 95 |
+
|
| 96 |
+
Apache-2.0, inherited from the base model
|
| 97 |
+
[allenai/OLMo-2-0425-1B-Instruct](https://huggingface.co/allenai/OLMo-2-0425-1B-Instruct).
|