初始化项目,由ModelHub XC社区提供模型

Model: asjadilahi/danAI-55M-Reasoning
Source: Original Platform
This commit is contained in:
ModelHub XC
2026-10-12 04:31:19 +08:00
commit 0daea0785f
23 changed files with 163254 additions and 0 deletions

45
.gitattributes vendored Normal file
View File

@@ -0,0 +1,45 @@
*.7z filter=lfs diff=lfs merge=lfs -text
*.arrow filter=lfs diff=lfs merge=lfs -text
*.bin filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.ckpt filter=lfs diff=lfs merge=lfs -text
*.ftz filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.h5 filter=lfs diff=lfs merge=lfs -text
*.joblib filter=lfs diff=lfs merge=lfs -text
*.lfs.* filter=lfs diff=lfs merge=lfs -text
*.mlmodel filter=lfs diff=lfs merge=lfs -text
*.model filter=lfs diff=lfs merge=lfs -text
*.msgpack filter=lfs diff=lfs merge=lfs -text
*.npy filter=lfs diff=lfs merge=lfs -text
*.npz filter=lfs diff=lfs merge=lfs -text
*.onnx filter=lfs diff=lfs merge=lfs -text
*.ot filter=lfs diff=lfs merge=lfs -text
*.parquet filter=lfs diff=lfs merge=lfs -text
*.pb filter=lfs diff=lfs merge=lfs -text
*.pickle filter=lfs diff=lfs merge=lfs -text
*.pkl filter=lfs diff=lfs merge=lfs -text
*.pt filter=lfs diff=lfs merge=lfs -text
*.pth filter=lfs diff=lfs merge=lfs -text
*.rar filter=lfs diff=lfs merge=lfs -text
*.safetensors filter=lfs diff=lfs merge=lfs -text
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
*.tar.* filter=lfs diff=lfs merge=lfs -text
*.tar filter=lfs diff=lfs merge=lfs -text
*.tflite filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.wasm filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text
*tfevents* filter=lfs diff=lfs merge=lfs -text
danai.jpeg filter=lfs diff=lfs merge=lfs -text
danAI-55M-Reasoning-BF16.gguf filter=lfs diff=lfs merge=lfs -text
danAI-55M-Reasoning-F16.gguf filter=lfs diff=lfs merge=lfs -text
danAI-55M-Reasoning-Q2_K.gguf filter=lfs diff=lfs merge=lfs -text
danAI-55M-Reasoning-Q3_K_M.gguf filter=lfs diff=lfs merge=lfs -text
danAI-55M-Reasoning-Q4_0.gguf filter=lfs diff=lfs merge=lfs -text
danAI-55M-Reasoning-Q4_K_M.gguf filter=lfs diff=lfs merge=lfs -text
danAI-55M-Reasoning-Q5_K_M.gguf filter=lfs diff=lfs merge=lfs -text
danAI-55M-Reasoning-Q6_K.gguf filter=lfs diff=lfs merge=lfs -text
danAI-55M-Reasoning-Q8_0.gguf filter=lfs diff=lfs merge=lfs -text

21
Modelfile Normal file
View File

@@ -0,0 +1,21 @@
# Official Ollama Modelfile for danAI-55M-Reasoning
FROM ./danAI-55M-Reasoning-Q8_0.gguf
# Model Parameters
PARAMETER temperature 0.2
PARAMETER top_p 0.9
PARAMETER top_k 40
PARAMETER repeat_penalty 1.2
PARAMETER stop "<|endoftext|>"
PARAMETER stop "<eos>"
PARAMETER stop "User:"
# Official System Prompt
SYSTEM """You are danAI, a helpful, precise, and wise AI assistant with native reasoning and agentic tool-calling capabilities. When solving reasoning or math problems, think step-by-step."""
# Template
TEMPLATE """{{ if .System }}System: {{ .System }}
{{ end }}{{ range .Messages }}{{ if eq .Role "user" }}User: {{ .Content }}
Assistant: {{ else if eq .Role "assistant" }}{{ .Content }}<|endoftext|>{{ end }}{{ end }}"""

204
README.md Normal file
View File

@@ -0,0 +1,204 @@
---
language:
- en
license: apache-2.0
tags:
- danai
- small-language-model
- slm
- edge-ai
- agentic
- tool-calling
- reasoning
- cot
- mobile
- gguf
- quantization
- ollama
- llama-cpp
- 4bit
- 8bit
- 2bit
pipeline_tag: text-generation
inference: false
---
<div align="center">
<img src="danai.jpeg" alt="danAI Logo" width="500" style="border-radius: 12px; box-shadow: 0 4px 20px rgba(0,0,0,0.15);"/>
# 🧠 danAI-55M-Reasoning
**An Ultra-Lightweight 54.5M Agentic & Reasoning Language Model for Edge Devices, Mobile Intelligence, and Microcontrollers**
*Created by **Asjad Ilahi** ([@asjadilahi](https://huggingface.co/asjadilahi))*
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![Parameters](https://img.shields.io/badge/Parameters-54.5M-green.svg)]()
[![RAM Footprint](https://img.shields.io/badge/RAM_Footprint-13MB_to_104MB-orange.svg)]()
[![Quantizations](https://img.shields.io/badge/Formats-GGUF_|_Safetensors_|_Ollama-blueviolet.svg)]()
[![Throughput](https://img.shields.io/badge/Speed->300_tok/s_(Metal/CPU)-purple.svg)]()
</div>
---
### 🌟 About danAI (*دانا - Wise / Intelligent*)
**danAI-55M-Reasoning** is an ultra-compact **54.5 Million parameter Small Language Model (SLM)** designed from the ground up to bring high-grade reasoning, instruction following, and autonomous agentic capabilities to low-power edge hardware, mobile processors, and IoT devices in an ultra-low **13 MB to 104 MB memory footprint**.
Named after the Urdu word ***Dānā (دانا)*** meaning *wise* or *intelligent*, **danAI** proves that extreme efficiency and agentic intelligence can coexist without requiring multi-gigabyte models.
---
## ⚡ Quantized Models & Formats (16-bit, 8-bit, 4-bit, 2-bit)
All official quantizations and weights are hosted directly in this repository:
| Bit Width | Format | Target File | File Size | Memory Footprint | Recommended Use Case / Target Hardware |
| :---: | :---: | :---: | :---: | :---: | :---: |
| **16-bit** | PyTorch Safetensors | [`model.safetensors`](./model.safetensors) | 104 MB | 104 MB | Standard PyTorch / Hugging Face BF16 inference |
| **16-bit** | PyTorch Safetensors | [`model.fp16.safetensors`](./model.fp16.safetensors) | 104 MB | 104 MB | Standard Half-Precision CUDA GPUs |
| **16-bit** | Master FP32 | [`model.fp32.safetensors`](./model.fp32.safetensors) | 208 MB | 208 MB | Research, analysis & master precision benchmarking |
| **16-bit** | GGUF F16 | [`danAI-55M-Reasoning-F16.gguf`](./danAI-55M-Reasoning-F16.gguf) | 137 MB | 137 MB | llama.cpp / Ollama unquantized reference baseline |
| **16-bit** | GGUF BF16 | [`danAI-55M-Reasoning-BF16.gguf`](./danAI-55M-Reasoning-BF16.gguf) | 137 MB | 137 MB | Apple Silicon Metal & modern CPU engines |
| **8-bit** | GGUF Q8_0 | [`danAI-55M-Reasoning-Q8_0.gguf`](./danAI-55M-Reasoning-Q8_0.gguf) | 73.5 MB | **~74 MB** | **⭐ Recommended for Ollama / llama.cpp (Near 0% quality loss)** |
| **8-bit** | PyTorch INT8 | [`danAI-55M-Reasoning-INT8.safetensors`](./danAI-55M-Reasoning-INT8.safetensors) | 52.2 MB | **~52 MB** | High-speed PyTorch 8-bit symmetric weight inference |
| **6-bit** | GGUF Q6_K | [`danAI-55M-Reasoning-Q6_K.gguf`](./danAI-55M-Reasoning-Q6_K.gguf) | 57.1 MB | ~57 MB | High-precision K-quant balance |
| **5-bit** | GGUF Q5_K_M | [`danAI-55M-Reasoning-Q5_K_M.gguf`](./danAI-55M-Reasoning-Q5_K_M.gguf) | 50.9 MB | ~51 MB | Compact balanced K-quant |
| **4-bit** | GGUF Q4_K_M | [`danAI-55M-Reasoning-Q4_K_M.gguf`](./danAI-55M-Reasoning-Q4_K_M.gguf) | 45.0 MB | **~45 MB** | **⭐ Optimal Edge Balance: Mobile chips, Raspberry Pi, Edge AI** |
| **4-bit** | GGUF Q4_0 | [`danAI-55M-Reasoning-Q4_0.gguf`](./danAI-55M-Reasoning-Q4_0.gguf) | 43.7 MB | ~44 MB | Universal 4-bit block quant for embedded platforms |
| **4-bit** | PyTorch INT4 | [`danAI-55M-Reasoning-INT4.safetensors`](./danAI-55M-Reasoning-INT4.safetensors) | 26.4 MB | **~26 MB** | Ultra-compact 4-bit packed weights for PyTorch on-device |
| **3-bit** | GGUF Q3_K_M | [`danAI-55M-Reasoning-Q3_K_M.gguf`](./danAI-55M-Reasoning-Q3_K_M.gguf) | 38.6 MB | ~39 MB | Sub-40MB K-quant compression |
| **2-bit** | GGUF Q2_K | [`danAI-55M-Reasoning-Q2_K.gguf`](./danAI-55M-Reasoning-Q2_K.gguf) | 32.8 MB | **~33 MB** | 2-bit K-quant for microcontrollers & extreme RAM limits |
| **2-bit** | PyTorch INT2 | [`danAI-55M-Reasoning-INT2.safetensors`](./danAI-55M-Reasoning-INT2.safetensors) | 13.4 MB | **~13 MB** | Ultra-low 2-bit packed representation (4 weights/byte) |
---
## 🚀 Quickstart & Inference
### 1. Ollama (1-Command Local Run)
```bash
# Download GGUF and Modelfile
huggingface-cli download asjadilahi/danAI-55M-Reasoning danAI-55M-Reasoning-Q8_0.gguf Modelfile --local-dir .
# Create and run with Ollama
ollama create danai -f Modelfile
ollama run danai "What is 5 + 7?"
```
### 2. llama.cpp / llama-cli
```bash
# Download any GGUF quant (e.g. Q8_0 or Q4_K_M)
huggingface-cli download asjadilahi/danAI-55M-Reasoning danAI-55M-Reasoning-Q8_0.gguf --local-dir .
# Run with llama-cli (>300 tokens/sec on Apple Silicon / CPU)
llama-cli -m danAI-55M-Reasoning-Q8_0.gguf -p "System: You are danAI, a helpful AI assistant.\n\nUser: Solve 25 * 4.\n\nAssistant: <think>" -n 128
```
### 3. Interactive Python Chat with Live Tool Calling
```bash
# Clone repository
git clone https://github.com/Asjad-Ilahi/danAI-55M.git
cd danAI-55M
pip install torch safetensors huggingface-hub tokenizers
# Run interactive assistant (automatically pulls weights from Hugging Face)
python scripts/chat.py
```
### 4. Standalone Quantized PyTorch Runner (INT8, INT4, INT2, BF16)
```python
import torch
from tokenizers import Tokenizer
from safetensors.torch import load_file
from scripts.quantized_chat import load_quantized_model
# Load 8-bit, 4-bit, or 2-bit quantized safetensors
model, mode = load_quantized_model("hf_export/danAI-55M-Reasoning-INT8.safetensors")
tokenizer = Tokenizer.from_file("tokenizer/tokenizer.json")
prompt = "System: You are danAI, a helpful AI assistant.\n\nUser: What is 2 + 2?\n\nAssistant: <think>"
input_ids = torch.tensor([tokenizer.encode(prompt).ids], dtype=torch.long)
with torch.no_grad():
for _ in range(30):
logits = model(input_ids)[0]
next_token = torch.argmax(logits[0, -1, :]).item()
input_ids = torch.cat([input_ids, torch.tensor([[next_token]])], dim=1)
if next_token in [0, tokenizer.token_to_id("<|endoftext|>")]:
break
print(tokenizer.decode(input_ids[0].tolist()))
```
---
## 💎 Core Strengths
1. **⚡ Ultra-Low 13 MB to 104 MB RAM Footprint**:
* Runs smoothly on mobile chips, Apple Silicon, Raspberry Pi, and microcontrollers.
2. **🛠️ Native Agentic Tool Calling (100% Invocation Rate)**:
* Automatically emits structured `<tool_call>` JSON blocks to offload exact multi-digit math to a `calculator` tool (`123433 * 564332 = 69657191756`) and live real-time queries to `search_web`.
3. **💭 Chain-of-Thought (`<think>`) Step-by-Step Reasoning**:
* Decomposes multi-step arithmetic, logic, and planning inside `<think>` tokens before emitting the final answer.
4. **🥇 #1 in Direct Sub-100M Science Benchmarks**:
* Decisively outperforms **Pythia-70M** across ARC-Easy (39.2% vs 37.4%), ARC-Challenge (25.2% vs 18.1%), and MMLU (27.4% vs 25.1%) while being **22% smaller**.
5. **🏆 Outperforms OpenAI GPT-2 Small (124M)**:
* Beats GPT-2 on ARC-Easy (39.2% vs 35.8%), ARC-Challenge (25.2% vs 21.4%), and MMLU (27.4% vs 26.2%) at **less than half the memory**.
---
## 🏆 Full-Dataset Benchmark Leaderboard
Evaluated across **100% of all official test and validation samples** (>20,000+ test questions) against all major sub-150M open models:
| Model | Active Params | Training Scale | GSM8K (Direct) | Agentic Tools | ARC-Challenge *(Hard Science)* | ARC-Easy *(2,376 q)* | ARC (Avg) | MMLU *(1,520 q)* | RAM Footprint | PIQA *(1,838 q)* |
| :--- | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| **danAI-55M-Reasoning** | **54.5M** | **~3B tokens** | **3.0%** | **100.0% (Native)** | **25.2%** | **39.2%** | **32.2%** | **27.4%** | **13MB – 104 MB** | **56.1%** |
| **Pythia-70M** *(EleutherAI)* | 70M | 300B tokens | 0.0% | 0.0% | 18.1% | 37.4% | 27.8% | 25.1% | 140 MB | 59.5% |
| **GPT-2 Small** *(OpenAI)* | 124M | 40B tokens | 0.0% | 0.0% | 21.4% | 35.8% | 28.6% | 26.2% | 248 MB | 63.3% |
| **MobileLLM-125M** *(Meta AI)* | 125M | 1,000B tokens | 0.5% | 0.0% | 27.7% | 45.5% | 36.6% | - | 250 MB | 64.6% |
| **SmolLM-135M** *(Hugging Face)* | 135M | 600B tokens | 1.0% | 0.0% | - | - | 42.4% | 30.2% | 270 MB | 68.4% |
| **SmolLM2-135M** *(Hugging Face)* | 135M | 2,000B tokens | 1.4% | 0.0% | - | - | 43.9% | 31.5% | 270 MB | 68.4% |
---
## 📐 Architecture Specifications
* **Model Name**: `danAI-55M-Reasoning`
* **Total Parameters**: 54,525,952 (54.5M)
* **Layers**: 12 Transformer Blocks
* **Hidden Dimension**: 512
* **Attention Heads**: 8 Query Heads
* **KV Heads**: 4 Key/Value Heads (Grouped Query Attention - GQA)
* **Head Dimension**: 64
* **Intermediate Dimension**: 1376 (SwiGLU MLP)
* **Vocab Size**: 32,768 (Byte-Pair Encoding, Tied Embeddings)
* **Positional Embeddings**: RoPE (Rotary Position Embeddings, Base theta=10000.0, NTK Extension factor=2.0)
* **Max Context Length**: 2048 tokens
* **Memory Footprint**: 13 MB (INT2) / 26 MB (INT4) / 45 MB (Q4_K_M) / 74 MB (Q8_0) / 104 MB (FP16/BF16)
---
## 🔗 Official Links & Resources
* **GitHub Repository**: [https://github.com/Asjad-Ilahi/danAI-55M](https://github.com/Asjad-Ilahi/danAI-55M)
* **Hugging Face Hub**: [https://huggingface.co/asjadilahi/danAI-55M-Reasoning](https://huggingface.co/asjadilahi/danAI-55M-Reasoning)
---
## 📜 Citation & License
```bibtex
@misc{ilahi2026danai55m,
author = {Asjad Ilahi},
title = {danAI-55M-Reasoning: Ultra-Lightweight Agentic and Reasoning Language Model},
year = {2026},
publisher = {Hugging Face},
howpublished = {\url{https://huggingface.co/asjadilahi/danAI-55M-Reasoning}}
}
```
* **License**: Apache 2.0 (Open-source, commercial use permitted)
* **Author**: Asjad Ilahi ([@asjadilahi](https://huggingface.co/asjadilahi))

27
config.json Normal file
View File

@@ -0,0 +1,27 @@
{
"architectures": [
"CausalLM"
],
"model_type": "danai",
"vocab_size": 32768,
"hidden_size": 512,
"intermediate_size": 1376,
"num_hidden_layers": 12,
"num_attention_heads": 8,
"num_key_value_heads": 4,
"head_dim": 64,
"hidden_act": "silu",
"max_position_embeddings": 2048,
"initializer_range": 0.02,
"rms_norm_eps": 1e-05,
"use_cache": true,
"tie_word_embeddings": true,
"rope_theta": 10000.0,
"rope_scaling": null,
"torch_dtype": "bfloat16",
"transformers_version": "5.15.0",
"total_parameters": 54525952,
"model_name": "danAI-55M-Reasoning",
"author": "Asjad Ilahi (asjadilahi)",
"license": "apache-2.0"
}

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:2e9158767448cec0ac7fb765c6d4c1efa05441314acbe5443c314fbf1e0f38f0
size 143947520

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:d070e0e15e78bd63b7e84f2b44a695685ea1a3b3e35f392c35ce49105b78b9eb
size 143947456

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:d08b8142890efd4d2bc30c28ade2c692dc7c81104d804e56b11d86636c10e958
size 14062424

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:c961ef8a9c50a91f600f2772093041affdb687dfe4ea19a97be73164b3b31498
size 27694000

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:fdbfd3b5959163a48cbc83ad54c356fd65d52f86355895c2866ec409ba78c2a0
size 54759448

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:8482a6b13d98140d80acdbbb85d5ac5891064d4279fabccee1cb92edf6c49ffb
size 34432768

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:e31fce3da40ad1f50e78de2610bfa61adb92f6c1e0814073deab6c51fefbc03d
size 40445696

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:e1b1cdae0153c653fbf4be7f798df10ea321d7cf50572c0289521f33922ce092
size 45774592

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:6425721f60ff2c24200bb3d46d790446fc00c015dca7ad56425483e5f0b586d8
size 47193856

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:bc927ec9c3c68ed19e7214ad72e7b93db2639fde2a6779bcb8a69d4966f5344e
size 53321472

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:fffb32ba8d6c3bfb7cf61dedd651cbc9f19d364578b131b7946dd3dfbc16d47f
size 59832064

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:2142e3709582ef41727a2fa6083dbb8bd2a7f0d965df6ded2c707d78bdf87a5c
size 77100800

3
danai.jpeg Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:61ddfa12195d716bf7a4484cebc3472a835195a9356c707a57d6d41cb1ce3b13
size 2293998

3
model.fp16.safetensors Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:c02670891f6458ec0b26b097168f1493127094d613aa23403cae4fe7c326b76f
size 109088600

3
model.fp32.safetensors Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:8208476b278089e7c13bca6f680f17daa02e6a164cab8c5e6be46ecf703b78fd
size 218166192

3
model.safetensors Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:a5259394882f9d2a03c3a19efd9e1ff588340140e1463433092b4b7f3289b9f4
size 109088704

14
special_tokens_map.json Normal file
View File

@@ -0,0 +1,14 @@
{
"bos_token": "<|endoftext|>",
"eos_token": "<|endoftext|>",
"unk_token": "<unk>",
"pad_token": "<pad>",
"additional_special_tokens": [
"<think>",
"</think>",
"<tool_call>",
"</tool_call>",
"<tool_response>",
"</tool_response>"
]
}

162883
tokenizer.json Normal file

File diff suppressed because it is too large Load Diff

12
tokenizer_config.json Normal file
View File

@@ -0,0 +1,12 @@
{
"add_bos_token": false,
"add_eos_token": false,
"bos_token": "<|endoftext|>",
"eos_token": "<|endoftext|>",
"unk_token": "<unk>",
"pad_token": "<pad>",
"clean_up_tokenization_spaces": false,
"model_max_length": 2048,
"tokenizer_class": "PreTrainedTokenizerFast",
"chat_template": "{% if messages[0]['role'] == 'system' %}{% set system_message = messages[0]['content'] %}{% set loop_messages = messages[1:] %}{% else %}{% set system_message = '' %}{% set loop_messages = messages %}{% endif %}{% if system_message %}System: {{ system_message }}\n\n{% endif %}{% for message in loop_messages %}{% if message['role'] == 'user' %}User: {{ message['content'] }}\n\nAssistant: {% elif message['role'] == 'assistant' %}{{ message['content'] }}<|endoftext|>{% endif %}{% endfor %}"
}