AynEngine Sovereign Qwen3-0.6B Mantiq
AynEngine-Qwen3-0.6B-Mantiq is a specialized sovereign language model grounded in Classical Arabic morphology (Sarf) and Ghazalian deductive logic (Mantiq al-Burhan). Fine-tuned from Qwen/Qwen3-0.6B, this model features an expanded vocabulary of 160,807 tokens, specialized morphological root tokens (<root_XXX>), and a Direct Preference Optimization (DPO) alignment stage that reinforces demonstrative proof (Burhan) while unlearning sophistry and circular fallacies (Safsatah).
Designed specifically for on-device and edge deployment, the standalone model weighs only ~1.15 GB in bfloat16 and quantizes to ~340 MB in 4-bit GGUF, enabling sub-millisecond root extraction and offline inference on mobile devices, embedded routers, and single-board computers.
Key Architectural Features
1. Expanded Morphological Vocabulary (160,807 Tokens)
The standard Qwen3 vocabulary (151,936 tokens) was expanded by +8,871 specialized linguistic and epistemic tokens:
- 9,057 Classical Arabic Roots (
<root_كتب>,<root_علم>,<root_برهن>, etc.) derived from canonical dictionaries (Lisan al-Arab, Kitab al-Ayn). - 48 Sarf Morphological Paradigms (
<wazn_فاعل>,<wazn_مفعول>,<wazn_استفعال>, etc.). - 33 Epistemic Mantiq Markers (
<mantiq_burhan>,<mantiq_safsatah>,<mantiq_dawr_batil>, etc.). - 100% Lossless Roundtrip Decoding: Guarantees zero byte degradation during tokenization and detokenization.
2. Ghazali Mantiq Alignment (Burhan vs Safsatah)
The model was trained through a two-stage cognitive curriculum inspired by Abu Hamid al-Ghazali's Mi'yar al-Ilm (The Standard of Knowledge) and Al-Qistas al-Mustaqim (The Correct Balance):
- Supervised Fine-Tuning (SFT): Grounding the model on valid categorical syllogisms, definitions (Hadd), and sound logical proofs.
- Direct Preference Optimization (DPO): Contrastive preference pairs training the model to assign lower probability to sophisms, equivocation (Ishtirak Lafzi), and circular arguments (Dawr Batil), achieving a 96.08% preference confidence for sound proofs.
3. The 5 Classical Epistemic Pillars
The internal reasoning architecture integrates the 5 Classical Arabic lexicographical disciplines:
- Al-Mufradat (al-Raghib al-Isfahani): Pure ontological domain modeling and teleology (Ghayah).
- Asas al-Balaghah (al-Zamakhshari): Rhetorical clarity, distinguishing literal runtime truth (Haqiqah) from leaky abstractions (Majaz).
- Lisan al-Arab (Ibn Manzur): Exhaustive edge-case taxonomy and complete lifecycle states.
- Kitab al-Ayn (al-Farahidi): Atomic primitive decomposition and state-space safety.
- Al-Kitab (Sibawayh): Strict syntactic governance (Amil/Ma'mul) and AST integrity.
Empirical Benchmark Performance
| Evaluation Domain | Metric | Result |
|---|---|---|
| Sarf Root Extraction | Canonical Root Coverage (Lisan clean) | 84.21% Precision (0.7ms latency) |
| Tokenizer Lossless Integrity | Roundtrip String Equivalence | 100.0% Exact Match |
| Mantiq DPO Preference | Burhan vs Safsatah Discriminative Margin | +3.2168 Margin (96.08% Confidence) |
| Code Syntactic Integrity | Python Abstract Syntax Tree (AST parse) | 100.0% Pass Rate |
| Google MBPP Benchmark | Tuple Intersection Task (#2 Sanitized) | 100.0% Pass@1 (5.81s) |
| CPU Generation Speed | 16 Threads on x86_64 CPU | 10.5 - 11.4 tokens/sec |
| Memory Footprint | Active RAM in bfloat16 | 1.18 GB RAM (quantizable to ~340 MB) |
Quickstart Guide
Installation
pip install transformers torch peft
Basic Inference (Python)
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
model_id = "path/to/aynengine-qwen3-0.6b-mantiq"
# 1. Load Tokenizer & Model
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype=torch.bfloat16,
device_map="auto"
)
# 2. Format Prompt with Mantiq Epistemic Boundaries
prompt = "Analyze the logical proof: All humans are rational beings. Zaid is human. Therefore Zaid is rational."
chat = [
{"role": "system", "content": "You are a Ghazali Mantiq evaluator. Verify if the deduction constitutes Burhan."},
{"role": "user", "content": prompt}
]
inputs = tokenizer.apply_chat_template(chat, return_tensors="pt", add_generation_prompt=True)
outputs = model.generate(inputs, max_new_tokens=150, temperature=0.2)
response = tokenizer.decode(outputs[0][inputs.shape[1]:], skip_special_tokens=True)
print(response)
Morphological Annotation
# The tokenizer automatically parses root boundaries
text = "استكشاف البرهان المنطقي"
# Decomposes into roots: <root_كشف>, <root_برهن>, <root_نطق>
Edge & On-Device Deployment
Due to its compact 609M parameter architecture, this model can be converted to GGUF format for real-time edge execution:
# Convert to GGUF using llama.cpp
python convert_hf_to_gguf.py path/to/aynengine-qwen3-0.6b-mantiq --outtype q4_k_m
# Run on CPU with sub-second latency
./llama-cli -m aynengine-qwen3-0.6b-mantiq.Q4_K_M.gguf -p "مقدمة البرهان:" -n 128 -t 4
- Target Platforms: Android (Termux / Kotlin ONNX), Raspberry Pi 4/5, OpenWrt / Huawei Routers, WyreNet P2P decentralized messaging nodes, and TajweedSST speech engines.
Limitations
- Small Parameter Ceiling: At 590M parameters, the model is not intended to write massive multi-file codebases or replace 70B+ general-purpose models.
- Single-Pass Circular Fallacies: Very subtle tautological sophisms require explicit chain-of-thought prompting (
<think>...</think>) to prevent the model from assuming sound structure.
Citation & License
- License: Apache 2.0
- Base Model:
Qwen/Qwen3-0.6Bby Qwen Team - Epistemic Apparatus: AynEngine AI Coding Edition & Ghazali Mantiq Curriculum
License & Intellectual Property Rights
This model, its architecture (including BPE-Free Farāhīdian/Sībawayhian tokenization, RootAttention, and Ishtiqāq-Attention), and its weights are released under the AynEngine & University of Prishtina Sovereign Academic License.
- Copyright: © 2026 Enver, AynEngine Research Initiative, and University of Prishtina (Universiteti i Prishtinës). All rights reserved.
- Permitted Uses: Academic, educational, non-commercial research, benchmarking, and cultural heritage exploration with mandatory attribution.
- Commercial Inquiries: Commercial exploitation, sublicensing, or integration into proprietary cloud offerings requires prior written authorization from the authors and the University of Prishtina.
- Full License: See
LICENSEin this repository.