license: mit
library_name: mlx
tags:
- mlx
- lora
- fine-tuned
- medical
- legal
- programming
- science
- null-ai
- knowledge-graph
- spatial-memory
- expert-verification
- multi-domain
base_model: deepseek-ai/DeepSeek-R1-Distill-Qwen-32B
pipeline_tag: text-generation
NullAI: DeepSeek R1 32B - Revolutionary Multi-Domain Knowledge System
🌟 A paradigm shift in AI knowledge management combining spatial memory, expert verification, and multi-stage reasoning
English
🎯 What is NullAI?
NullAI is not just another fine-tuned language model—it's a comprehensive knowledge orchestration system that revolutionizes how AI stores, retrieves, and verifies information across multiple specialized domains.
Unlike traditional LLMs that treat all knowledge uniformly, NullAI implements:
- 3D Spatial Knowledge Organization (Tree-structured Memory)
- Multi-Stage Verification System (Judge Lobes)
- Expert-Authenticated Information (ORCID Integration)
- Domain-Isolated Databases (Specialized Knowledge Stores)
- Certainty-Scored Reasoning Chains
🏗️ Revolutionary Architecture
1. Knowledge Tile System (Fallen Tree / 倒木システム)
NullAI doesn't store knowledge linearly—it uses a Knowledge Tile System where each piece of information is a structured, self-contained unit:
class KnowledgeTile:
tile_id: str # Unique identifier
domain: str # medical|legal|programming|science|general
content: str # The actual knowledge
coordinates: {
x: float, # Abstraction axis (concrete ← → abstract)
y: float, # Expertise axis (basic ← → advanced)
z: float # Temporality axis (timeless ← → current)
}
certainty_score: float # 0.0 - 1.0 (confidence level)
reasoning_chain: List[Step] # How this knowledge was derived
citations: List[Source] # Evidence and references
orcid_verified: bool # Expert authentication status
expert_id: Optional[str] # ORCID identifier
created_at: datetime
last_verified: datetime
Why "Fallen Tree"? Just as a fallen tree in a forest becomes a foundation for new life, each Knowledge Tile serves as a foundation for building more complex understanding. The interconnected network of tiles forms an ecosystem of verified knowledge.
2. Tree-Structured Spatial Memory (樹木型空間記憶)
Knowledge is organized in a 3-dimensional conceptual space:
Z (Temporality)
↑
| ╱ Universal Facts
| ╱
| ╱______ Latest Research
|╱
O────────→ Y (Expertise)
╱| Basic → Advanced
╱ |
╱ ↓
X (Abstraction)
Concrete → Abstract
How it works:
- Query Processing: When you ask a question, NullAI maps it to coordinates in this 3D space
- Proximity Search: Finds relevant tiles within spatial proximity
- Path Optimization: Traces optimal reasoning paths through the knowledge graph
- Context Assembly: Builds context from spatially-related knowledge tiles
Example:
Query: "Latest treatment for atrial fibrillation"
→ Maps to: X=0.6 (moderately abstract), Y=0.8 (advanced), Z=0.9 (very recent)
→ Retrieves tiles within radius of 0.2 units
→ Finds: direct oral anticoagulants, catheter ablation, left atrial appendage closure
→ Assembles evidence-based response with reasoning chain
3. Multi-Stage Judge System (ジャッジシステム)
Every answer goes through a three-tier verification process:
Alpha Lobe: Logical Consistency Judge
def alpha_lobe_verification(reasoning_chain):
"""
Checks basic logical soundness
- No contradictions in premises
- Valid inference steps
- Proper use of quantifiers
- Absence of logical fallacies
"""
checks = {
"contradictions": detect_contradictions(reasoning_chain),
"inference_validity": validate_inference_steps(reasoning_chain),
"fallacies": detect_logical_fallacies(reasoning_chain)
}
return LogicScore(0.0 - 1.0)
Beta Lobe (Basic): Domain Knowledge Consistency
def beta_basic_verification(answer, domain):
"""
Verifies domain-specific accuracy
- Terminology correctness
- Standard protocol compliance
- Common practice alignment
- Domain axiom consistency
"""
domain_kb = load_domain_knowledge_base(domain)
checks = {
"terminology": verify_technical_terms(answer, domain_kb),
"protocols": check_standard_protocols(answer, domain),
"axioms": validate_domain_axioms(answer, domain_kb)
}
return DomainConsistencyScore(0.0 - 1.0)
Beta Lobe (Advanced): Deep Reasoning Verification
def beta_advanced_verification(answer, meta_knowledge):
"""
Evaluates reasoning depth and quality
- Multi-hop reasoning validity
- Causal chain accuracy
- Edge case consideration
- Alternative perspective analysis
"""
checks = {
"reasoning_depth": analyze_reasoning_depth(answer),
"causal_validity": verify_causal_relationships(answer),
"edge_cases": check_edge_case_coverage(answer),
"alternatives": evaluate_alternative_viewpoints(answer)
}
return ReasoningQualityScore(0.0 - 1.0)
Judge Score Aggregation:
Final Certainty = (
0.3 × Alpha_Score +
0.4 × Beta_Basic_Score +
0.3 × Beta_Advanced_Score
)
4. Database Isolation System (DB分離)
NullAI maintains separate, specialized databases for each domain:
NullAI Database Architecture:
├── medical_knowledge.db
│ ├── clinical_guidelines
│ ├── diagnostic_criteria
│ ├── treatment_protocols
│ └── drug_interactions
├── legal_knowledge.db
│ ├── statutes
│ ├── case_law
│ ├── legal_precedents
│ └── regulatory_frameworks
├── programming_knowledge.db
│ ├── algorithms
│ ├── design_patterns
│ ├── best_practices
│ └── language_specifics
├── science_knowledge.db
│ ├── research_methods
│ ├── statistical_techniques
│ ├── experimental_designs
│ └── peer_reviewed_findings
└── general_knowledge.db
├── common_facts
├── general_reasoning
└── cross_domain_connections
Benefits:
- Prevents Cross-Contamination: Medical knowledge doesn't leak into legal reasoning
- Optimized Indexing: Each DB uses domain-specific indexes
- Granular Access Control: Different verification levels per domain
- Independent Updates: Update medical knowledge without affecting legal DB
5. ORCID Expert Authentication (エキスパート認証)
NullAI integrates with the ORCID (Open Researcher and Contributor ID) system to verify expert-contributed knowledge:
class ExpertVerification:
def verify_knowledge_tile(self, tile, orcid_id):
"""
Authenticates knowledge against expert credentials
"""
expert = orcid_api.get_researcher(orcid_id)
# Verify expert qualifications
credentials = {
"field_match": expert.field in tile.domain,
"publication_count": len(expert.publications),
"h_index": expert.h_index,
"institutional_affiliation": expert.institution,
"peer_review_score": expert.peer_review_score
}
# Calculate expert authority score
authority_score = calculate_authority(credentials)
# Update tile with verification
tile.orcid_verified = True
tile.expert_id = orcid_id
tile.authority_score = authority_score
tile.expert_credentials = credentials
return VerificationResult(tile, authority_score)
Expert Authority Levels:
- 🥇 Gold (0.9-1.0): Published researchers with h-index > 20
- 🥈 Silver (0.7-0.9): Practitioners with 10+ years experience
- 🥉 Bronze (0.5-0.7): Verified professionals in the field
- 📋 Standard (<0.5): General community contributions
🔬 Innovative Features
Hot Cache System
Frequently accessed knowledge tiles are kept in a high-speed cache with priority scoring:
cache_priority = (
access_frequency × 0.4 +
certainty_score × 0.3 +
expert_authority × 0.2 +
recency × 0.1
)
Hallucination Detection
Real-time monitoring for knowledge generation:
def detect_hallucination(generated_text, knowledge_tiles):
checks = {
"fact_grounding": all_facts_traced_to_tiles(generated_text),
"citation_validity": all_citations_verified(generated_text),
"confidence_calibration": confidence_matches_evidence(generated_text)
}
if not all(checks.values()):
flag_for_manual_review()
reduce_certainty_score()
Reasoning Chain Extraction
Every answer includes a traceable reasoning chain:
Question: "What's the first-line treatment for hypertension?"
Reasoning Chain:
1. [medical_tile_4829] Current JNC-8 guidelines (2014, ORCID-verified)
↓
2. [medical_tile_5103] First-line agents: Thiazides, ACE-I, ARBs, CCBs
↓
3. [medical_tile_6284] Patient-specific factors (age, race, comorbidities)
↓
4. [medical_tile_7451] Evidence: Thiazides reduce CV events by 15-20%
↓
5. [synthesis] Recommendation: Thiazide diuretic (e.g., HCTZ 12.5-25mg)
Certainty: 0.92 (Alpha: 0.95, Beta-Basic: 0.94, Beta-Advanced: 0.88)
Expert Authority: 0.91 (Cardiology, h-index: 47)
🚀 This Fine-Tuned Model
Model Specifications:
- Base: DeepSeek-R1-Distill-Qwen-32B (32.7B parameters)
- Quantization: 4-bit MLX (61GB → 17.2GB)
- Method: LoRA fine-tuning (2.1M trainable parameters / 0.006%)
- Training Data: 8,768 examples across 5 domains
- Training Platform: Apple Silicon (MPS) with MLX optimization
Training Results:
- Initial Validation Loss: 3.318
- Final Validation Loss: 0.712
- Improvement: 78.5%
- Training Time: ~60 minutes
- Peak Memory: 19.9GB
📊 Supported Domains
Medical 🏥
- Clinical diagnosis and treatment
- Pharmacology and drug interactions
- Evidence-based medicine guidelines
- Medical research interpretation
Legal ⚖️
- Statutory interpretation
- Case law analysis
- Regulatory compliance
- Legal reasoning and argumentation
Programming 💻
- Code generation and optimization
- Algorithm design and analysis
- Debugging and error resolution
- Software architecture patterns
Science 🔬
- Research methodology
- Statistical analysis
- Experimental design
- Data interpretation and visualization
General 🌍
- Cross-domain reasoning
- General knowledge retrieval
- Conceptual explanations
- Educational content
日本語 (Japanese)
🎯 NullAIとは何か?
NullAIは単なるファインチューニング済み言語モデルではありません。複数の専門領域にわたって情報を保存、検索、検証する方法を革新する、包括的な知識統合システムです。
すべての知識を均一に扱う従来のLLMとは異なり、NullAIは以下を実装しています:
- 3次元空間知識組織化(樹木型記憶)
- 多段階検証システム(ジャッジローブ)
- エキスパート認証情報(ORCID統合)
- ドメイン分離データベース(専門知識ストア)
- 確実性スコア付き推論チェーン
🏗️ 革新的なアーキテクチャ
1. Knowledge Tile System(倒木システム)
NullAIは知識を線形に保存しません。各情報が構造化された自己完結型ユニットであるKnowledge Tileシステムを使用します:
class KnowledgeTile:
tile_id: str # 一意識別子
domain: str # 医学|法律|プログラミング|科学|一般
content: str # 実際の知識内容
coordinates: {
x: float, # 抽象度軸(具体的 ← → 抽象的)
y: float, # 専門性軸(基礎 ← → 高度)
z: float # 時間性軸(普遍的 ← → 最新)
}
certainty_score: float # 0.0 - 1.0(信頼度レベル)
reasoning_chain: List[Step] # この知識がどのように導出されたか
citations: List[Source] # 証拠と参照
orcid_verified: bool # エキスパート認証状態
expert_id: Optional[str] # ORCID識別子
created_at: datetime
last_verified: datetime
なぜ「倒木」なのか? 森の中で倒れた木が新しい生命の基盤となるように、各Knowledge Tileはより複雑な理解を構築するための基盤として機能します。相互接続されたタイルのネットワークが、検証済み知識のエコシステムを形成します。
2. 樹木型空間記憶
知識は3次元概念空間に組織化されます:
Z(時間性)
↑
| ╱ 普遍的事実
| ╱
| ╱______ 最新研究
|╱
O────────→ Y(専門性)
╱| 基礎 → 高度
╱ |
╱ ↓
X(抽象度)
具体的 → 抽象的
動作原理:
- クエリ処理:質問をこの3D空間の座標にマッピング
- 近接検索:空間的に近接するタイルを検索
- 経路最適化:知識グラフを通じて最適な推論経路をトレース
- コンテキスト組み立て:空間的に関連する知識タイルからコンテキストを構築
例:
質問:「心房細動の最新治療法は?」
→ マッピング先:X=0.6(やや抽象的)、Y=0.8(高度)、Z=0.9(非常に最新)
→ 半径0.2ユニット内のタイルを取得
→ 発見:直接経口抗凝固薬、カテーテルアブレーション、左心耳閉鎖術
→ 推論チェーン付きのエビデンスベース回答を組み立て
3. 多段階ジャッジシステム
すべての回答は3段階の検証プロセスを経ます:
Alpha Lobe:論理整合性ジャッジ
def alpha_lobe_verification(reasoning_chain):
"""
基本的な論理的健全性をチェック
- 前提の矛盾なし
- 有効な推論ステップ
- 量化子の適切な使用
- 論理的誤謬の不在
"""
checks = {
"contradictions": detect_contradictions(reasoning_chain),
"inference_validity": validate_inference_steps(reasoning_chain),
"fallacies": detect_logical_fallacies(reasoning_chain)
}
return LogicScore(0.0 - 1.0)
Beta Lobe(Basic):ドメイン知識整合性
def beta_basic_verification(answer, domain):
"""
ドメイン固有の正確性を検証
- 用語の正確性
- 標準プロトコル準拠
- 一般的実践との整合性
- ドメイン公理の整合性
"""
domain_kb = load_domain_knowledge_base(domain)
checks = {
"terminology": verify_technical_terms(answer, domain_kb),
"protocols": check_standard_protocols(answer, domain),
"axioms": validate_domain_axioms(answer, domain_kb)
}
return DomainConsistencyScore(0.0 - 1.0)
Beta Lobe(Advanced):深層推論検証
def beta_advanced_verification(answer, meta_knowledge):
"""
推論の深さと質を評価
- 多段階推論の妥当性
- 因果チェーンの正確性
- エッジケースの考慮
- 代替視点の分析
"""
checks = {
"reasoning_depth": analyze_reasoning_depth(answer),
"causal_validity": verify_causal_relationships(answer),
"edge_cases": check_edge_case_coverage(answer),
"alternatives": evaluate_alternative_viewpoints(answer)
}
return ReasoningQualityScore(0.0 - 1.0)
ジャッジスコア統合:
最終確実性 = (
0.3 × Alpha_Score +
0.4 × Beta_Basic_Score +
0.3 × Beta_Advanced_Score
)
4. データベース分離システム(DB分離)
NullAIは各ドメインごとに分離された専門データベースを維持します:
NullAI データベースアーキテクチャ:
├── medical_knowledge.db
│ ├── 臨床ガイドライン
│ ├── 診断基準
│ ├── 治療プロトコル
│ └── 薬物相互作用
├── legal_knowledge.db
│ ├── 法令
│ ├── 判例法
│ ├── 法的先例
│ └── 規制フレームワーク
├── programming_knowledge.db
│ ├── アルゴリズム
│ ├── 設計パターン
│ ├── ベストプラクティス
│ └── 言語固有知識
├── science_knowledge.db
│ ├── 研究方法
│ ├── 統計技術
│ ├── 実験設計
│ └── 査読済み研究結果
└── general_knowledge.db
├── 一般的事実
├── 一般的推論
└── 横断的ドメイン接続
メリット:
- クロス汚染防止:医学知識が法的推論に混入しない
- 最適化されたインデックス:各DBがドメイン固有のインデックスを使用
- 細粒度アクセス制御:ドメインごとに異なる検証レベル
- 独立した更新:法律DBに影響を与えずに医学知識を更新
5. ORCID エキスパート認証
NullAIはORCID(Open Researcher and Contributor ID)システムと統合し、エキスパートが提供した知識を検証します:
class ExpertVerification:
def verify_knowledge_tile(self, tile, orcid_id):
"""
エキスパート資格に対して知識を認証
"""
expert = orcid_api.get_researcher(orcid_id)
# エキスパート資格を検証
credentials = {
"field_match": expert.field in tile.domain,
"publication_count": len(expert.publications),
"h_index": expert.h_index,
"institutional_affiliation": expert.institution,
"peer_review_score": expert.peer_review_score
}
# エキスパート権威スコアを計算
authority_score = calculate_authority(credentials)
# 検証付きタイルを更新
tile.orcid_verified = True
tile.expert_id = orcid_id
tile.authority_score = authority_score
tile.expert_credentials = credentials
return VerificationResult(tile, authority_score)
エキスパート権威レベル:
- 🥇 ゴールド(0.9-1.0):h-index > 20の研究者
- 🥈 シルバー(0.7-0.9):10年以上の経験を持つ実務家
- 🥉 ブロンズ(0.5-0.7):当該分野の検証済み専門家
- 📋 スタンダード(<0.5):一般コミュニティからの貢献
🔬 革新的機能
ホットキャッシュシステム
頻繁にアクセスされる知識タイルは優先度スコア付きで高速キャッシュに保持:
cache_priority = (
access_frequency × 0.4 +
certainty_score × 0.3 +
expert_authority × 0.2 +
recency × 0.1
)
ハルシネーション検出
知識生成のリアルタイム監視:
def detect_hallucination(generated_text, knowledge_tiles):
checks = {
"fact_grounding": all_facts_traced_to_tiles(generated_text),
"citation_validity": all_citations_verified(generated_text),
"confidence_calibration": confidence_matches_evidence(generated_text)
}
if not all(checks.values()):
flag_for_manual_review()
reduce_certainty_score()
推論チェーン抽出
すべての回答にトレース可能な推論チェーンが含まれます:
質問:「高血圧の第一選択治療は?」
推論チェーン:
1. [medical_tile_4829] 現行JNC-8ガイドライン(2014年、ORCID検証済み)
↓
2. [medical_tile_5103] 第一選択薬:サイアザイド、ACE阻害薬、ARB、CCB
↓
3. [medical_tile_6284] 患者固有因子(年齢、人種、併存疾患)
↓
4. [medical_tile_7451] エビデンス:サイアザイドはCV イベントを15-20%減少
↓
5. [統合] 推奨:サイアザイド系利尿薬(例:HCTZ 12.5-25mg)
確実性:0.92(Alpha:0.95、Beta-Basic:0.94、Beta-Advanced:0.88)
エキスパート権威:0.91(循環器内科、h-index:47)
🚀 このファインチューニング済みモデル
モデル仕様:
- ベース:DeepSeek-R1-Distill-Qwen-32B(327億パラメータ)
- 量子化:4bit MLX(61GB → 17.2GB)
- 手法:LoRAファインチューニング(210万訓練可能パラメータ / 0.006%)
- 訓練データ:5ドメインにわたる8,768例
- 訓練プラットフォーム:Apple Silicon(MPS)、MLX最適化
訓練結果:
- 初期検証ロス:3.318
- 最終検証ロス:0.712
- 改善率:78.5%
- 訓練時間:約60分
- ピークメモリ:19.9GB
📊 対応ドメイン
医学 🏥
- 臨床診断と治療
- 薬理学と薬物相互作用
- エビデンスベース医療ガイドライン
- 医学研究の解釈
法律 ⚖️
- 法令解釈
- 判例分析
- 規制コンプライアンス
- 法的推論と論証
プログラミング 💻
- コード生成と最適化
- アルゴリズム設計と分析
- デバッグとエラー解決
- ソフトウェアアーキテクチャパターン
科学 🔬
- 研究方法論
- 統計分析
- 実験設計
- データ解釈と可視化
一般 🌍
- クロスドメイン推論
- 一般知識検索
- 概念説明
- 教育コンテンツ
使用方法
MLXを使用した推論(推奨 - Apple Silicon)
import mlx.core as mx
from mlx_lm import load, generate
# モデルのロード
model, tokenizer = load("kofdai/nullai-deepseek-r1-32b")
# 推論の実行
prompt = "心房細動の治療選択肢について説明してください。"
response = generate(model, tokenizer, prompt=prompt, max_tokens=500)
print(response)
Transformersを使用した推論
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
# モデルとトークナイザーのロード
model_name = "kofdai/nullai-deepseek-r1-32b"
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
model_name,
torch_dtype=torch.float16,
device_map="auto",
trust_remote_code=True
)
# 推論
prompt = "心房細動の治療選択肢について説明してください。"
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=500, temperature=0.7)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(response)
システム要件
最小要件:
- Python 3.10+
- 20GB以上のRAM
- Apple Silicon(M1/M2/M3)またはNVIDIA GPU
推奨環境:
- Apple Silicon Mac (M1 Pro/Max, M2 Pro/Max, M3以上)
- 32GB以上のユニファイドメモリ
- macOS 13.0以上
インストール
# MLX環境(Apple Silicon推奨)
pip install mlx mlx-lm
# Transformers環境
pip install transformers torch accelerate
English
About NullAI
NullAI is an advanced knowledge-based system that integrates multi-domain knowledge reasoning and verification. It provides highly reliable answers across specialized domains such as medicine, law, programming, and science.
About This Model
This model is based on DeepSeek R1 Distill Qwen 32B and fine-tuned on NullAI's multi-domain knowledge dataset.
Key Features:
- Base Model: DeepSeek-R1-Distill-Qwen-32B
- Parameters: 32.7 billion
- Quantization: 4-bit MLX quantization (61GB → 17.2GB)
- Fine-tuning Method: LoRA (Low-Rank Adaptation)
- Training Data: 8,768 training examples + 975 validation examples
- Optimization: Optimized for Apple Silicon (MPS)
Training Results:
- Initial Validation Loss: 3.318
- Final Validation Loss: 0.712 (78.5% improvement)
- Training Iterations: 1000
- Tokens Trained: 88,720
Supported Domains
- Medical: Clinical knowledge, diagnostic reasoning, treatment guidelines
- Legal: Legal interpretation, case analysis, legal reasoning
- Programming: Code generation, debugging, algorithm design
- Science: Scientific methodology, research design, data analysis
- General: Broad general knowledge questions
Usage
Inference with MLX (Recommended - Apple Silicon)
import mlx.core as mx
from mlx_lm import load, generate
# Load model
model, tokenizer = load("kofdai/nullai-deepseek-r1-32b")
# Run inference
prompt = "Explain treatment options for atrial fibrillation."
response = generate(model, tokenizer, prompt=prompt, max_tokens=500)
print(response)
Inference with Transformers
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
# Load model and tokenizer
model_name = "kofdai/nullai-deepseek-r1-32b"
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
model_name,
torch_dtype=torch.float16,
device_map="auto",
trust_remote_code=True
)
# Inference
prompt = "Explain treatment options for atrial fibrillation."
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=500, temperature=0.7)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(response)
System Requirements
Minimum:
- Python 3.10+
- 20GB+ RAM
- Apple Silicon (M1/M2/M3) or NVIDIA GPU
Recommended:
- Apple Silicon Mac (M1 Pro/Max, M2 Pro/Max, M3 or higher)
- 32GB+ unified memory
- macOS 13.0+
Installation
# MLX environment (recommended for Apple Silicon)
pip install mlx mlx-lm
# Transformers environment
pip install transformers torch accelerate
Training Details
Hardware:
- Platform: Apple Silicon (MPS)
- Memory: ~20GB peak usage
- Training Time: ~60 minutes
Hyperparameters:
- Learning Rate: 1e-5
- Batch Size: 1
- Gradient Accumulation: 16 (effective batch size)
- LoRA Rank: 16
- LoRA Alpha: 32
- Max Sequence Length: 2048
- Optimizer: AdamW
Performance Metrics:
- Training Speed: ~0.35-0.40 iterations/sec
- Tokens/sec: ~30-35
- Validation Frequency: Every 100 iterations
- Checkpoint Saves: Every 250 iterations
License
This model is provided for research and educational purposes. For professional decisions in medicine, law, etc., always consult qualified professionals.
Citation
@misc{nullai-deepseek-r1-32b,
title={NullAI: DeepSeek R1 32B Fine-tuned Model},
author={KofDai},
year={2025},
publisher={HuggingFace},
url={https://huggingface.co/kofdai/nullai-deepseek-r1-32b}
}