termux-bitnet
Production 1.58-bit (i2_s) BitNet On-Device Inference SDK & Dual Engine for Android Termux & ARM64.
1. Overview & Architecture
termux-bitnet is an optimized on-device inference engine and dual SDK (Python & Node.js) engineered for running 1.58-bit quantized Large Language Models (BitNet b1.58) natively on Android Termux, ARM64 mobile processors, and edge devices.
The underlying computation engine executes 1.58-bit ternary quantized weights {-1, 0, +1} directly via hand-vectorized ARM64 NEON SIMD and DotProd vector instructions (vdotq_s32), replacing floating-point matrix multiplications with integer additions and subtractions under a sub-350MB RAM footprint.
[Python Application / CLI] [Node.js / TypeScript App]
│ │
▼ (BitNetEngine / ctypes) ▼ (BitNetEngine / FFI)
[termux-bitnet Python SDK] [termux-bitnet npm Thin Gateway]
│ │
└──────────────────┬──────────────────┘
│
▼ (Strict C ABI: libtermux_bitnet.so)
[Native C++17 BitNet Core Engine]
│
▼
[ARM64 NEON + DotProd (vdotq_s32) Vector Kernels]
2. Verified BitNet GGUF Model Registry
termux-bitnet provides deterministic model downloading and caching from verified Hugging Face repositories with HTTP Range resume capability:
| Model Alias | Hugging Face Repository & File | Parameters | Quantization | File Size | Target Device |
|---|---|---|---|---|---|
bitnet-2b |
microsoft/bitnet-b1.58-2B-4T-gguf |
2.4B | i2_s |
1.13 GB | Flagship Phones (Galaxy S20+, S24, S25, Pixel) |
bitnet-large |
RichardErkhov/1bitLLM_-_bitnet_b1_58-large-gguf |
0.7B | Q4_0 |
404 MB | Entry-level / Low-RAM ARM64 Devices |
bitnet-3b |
Green-Sky/bitnet_b1_58-3B-GGUF |
3.3B | q1_3 |
730 MB | High-Capacity Mobile Workstations |
bitnet-3b-q4 |
RichardErkhov/1bitLLM_-_bitnet_b1_58-3B-gguf |
3.3B | Q4_0 |
1.83 GB | High-Precision Quantized Model |
3. Installation
3.1 Python SDK & CLI (PyPI)
# In Android Termux or ARM64 Linux
pip install termux-bitnet
3.2 Node.js SDK & CLI (npm)
# Global installation (Independent CLI namespace: termux-bitnet-js)
npm install -g termux-bitnet
3.3 Zero-Drift Source Installation
git clone https://github.com/uno-km/termux-bitnet.git
cd termux-bitnet
chmod +x install.sh
./install.sh
4. CLI Usage
4.1 Python CLI (termux-bitnet)
# 1. Hardware Diagnostic (ARM NEON & DotProd SIMD Verification)
termux-bitnet info
# 2. List Available Verified Models
termux-bitnet models
# 3. Download Model with Range Resume Support
termux-bitnet download bitnet-2b
# 4. Run On-Device Inference
termux-bitnet run -m ~/.cache/termux-bitnet/models/bitnet-2b-ggml-model-i2_s.gguf \
-p "Explain quantum computing in one sentence." \
-t 4 -c 2048 -n 64 --temp 0.7 --top-p 0.95
4.2 Node.js CLI (termux-bitnet-js)
# 1. Hardware Diagnostic
termux-bitnet-js info
# 2. Model Registry List
termux-bitnet-js models
# 3. Run Inference via Node.js Gateway
termux-bitnet-js run -m ~/.cache/termux-bitnet/models/bitnet-2b-ggml-model-i2_s.gguf \
-p "Explain quantum computing in one sentence." -t 4 -n 64
5. Programmatic API
5.1 Python SDK
from termux_bitnet import BitNetEngine, BitNetConfig
# 1. Configure Engine Parameters
config = BitNetConfig(
model_path="models/bitnet-2b.gguf",
n_threads=4,
temperature=0.7,
top_p=0.95,
top_k=40,
min_p=0.05,
repeat_penalty=1.15,
)
# 2. Stream Generation with Context Manager
with BitNetEngine(config) as engine:
print("[Prompt]: Write a Python palindrome check function")
print("[Response]: ", end="", flush=True)
for token in engine.generate_stream("Write a Python palindrome check function:"):
print(token, end="", flush=True)
print()
5.2 Node.js & TypeScript SDK
const { createEngine } = require('termux-bitnet');
async function main() {
const engine = createEngine({
modelPath: 'models/bitnet-2b.gguf',
threads: 4,
temperature: 0.7,
topP: 0.95,
});
console.log('[Prompt]: Explain quantum computing in one sentence');
console.log('[Response]: ');
await engine.generateStream(
'Explain quantum computing in one sentence',
64,
(token) => {
process.stdout.write(token);
}
);
console.log('\n');
}
main();
6. Configuration Parameter Matrix (BitNetConfig)
| CLI Flag | Python (BitNetConfig) |
Node.js (BitNetOptions) |
Default | Description |
|---|---|---|---|---|
-m, --model |
model_path |
modelPath |
"" |
Path to GGUF model binary |
-p, --prompt |
prompt |
prompt |
"" |
Input prompt text |
-t, --threads |
n_threads |
threads |
cores |
Number of CPU worker threads |
-c, --ctx-size |
n_ctx |
contextSize |
2048 |
KV Cache context window size |
-b, --batch-size |
n_batch |
batchSize |
512 |
Prompt evaluation batch size |
-n, --n-predict |
n_predict |
maxTokens |
128 |
Maximum tokens to generate |
--temp |
temperature |
temperature |
0.7 |
Softmax temperature (0.0 = Greedy) |
--top-p |
top_p |
topP |
0.95 |
Nucleus Top-P sampling cutoff |
--top-k |
top_k |
topK |
40 |
Top-K sampling cutoff |
--min-p |
min_p |
minP |
0.05 |
Min-P relative probability cutoff |
--repeat-penalty |
repeat_penalty |
repeatPenalty |
1.15 |
Repetition penalty coefficient |
-s, --seed |
seed |
seed |
0 |
Random seed (0 = non-deterministic) |
--system-prompt |
system_prompt |
systemPrompt |
"" |
System prompt prefix |
-r, --stop |
stop_tokens |
stopTokens |
"" |
Stop sequence tokens |
7. Official Documentation & Specifications
- Official Documentation Site: https://uno-km.github.io/termux-bitnet/
- AI Agent Context Feed: llms.txt
- Full Technical Specification: llms-full.txt
8. License & Foundation
Released under the Apache License 2.0.
Engineered under the AMEVA Open-Source Foundation (AOSF) & uno-km ecosystem.
Metadata
Release files for termux-bitnet 1.0.14
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| termux_bitnet-1.0.14.tar.gz | 37.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| termux_bitnet-1.0.14-cp312-cp312-win_amd64.whl | CPython 3.12 | CPython 3.12 | Windows x86-64 | Details |
Total release size: 59.2 kB
Release files / termux_bitnet-1.0.14.tar.gz
| Download URL | termux_bitnet-1.0.14.tar.gz |
|---|---|
| Size | 37.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0279036e11ea6a86e7b9e78a64438ea15e76f04296a69ada2551717e3635cf8d
|
|
BLAKE2b-256 checksum How to use checksums |
700adc8e013c11de79c3eabd8080697eeef632ccbbd395c0c92a49e1998e8d94
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.0
|
Release files / termux_bitnet-1.0.14-cp312-cp312-win_amd64.whl
| Download URL | termux_bitnet-1.0.14-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 21.8 kB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
bdb3dccee68c1c2c76f4979f2316f5986d2d55b182ada4979f52dd2a03832f66
|
|
BLAKE2b-256 checksum How to use checksums |
df9ebb900ab1a90d14abbe453ab7ee936402d0d7c91591e65ca74e408d7d8071
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.0
|