Text Generation
Transformers
GGUF
English
phi
knowledge-system
reasoning
expert-verification
multi-domain
zero-hallucination
spatial-memory
knowledge-tiles
phi-4
microsoft
knowledge-tiles-iath
conversational
Eval Results (legacy)
Instructions to use kofdai/nullai-knowledge-system with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use kofdai/nullai-knowledge-system with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="kofdai/nullai-knowledge-system") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("kofdai/nullai-knowledge-system") model = AutoModelForCausalLM.from_pretrained("kofdai/nullai-knowledge-system", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use kofdai/nullai-knowledge-system with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf kofdai/nullai-knowledge-system:Q4_K_M # Run inference directly in the terminal: llama cli -hf kofdai/nullai-knowledge-system:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf kofdai/nullai-knowledge-system:Q4_K_M # Run inference directly in the terminal: llama cli -hf kofdai/nullai-knowledge-system:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf kofdai/nullai-knowledge-system:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf kofdai/nullai-knowledge-system:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf kofdai/nullai-knowledge-system:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf kofdai/nullai-knowledge-system:Q4_K_M
Use Docker
docker model run hf.co/kofdai/nullai-knowledge-system:Q4_K_M
- LM Studio
- Jan
- vLLM
How to use kofdai/nullai-knowledge-system with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "kofdai/nullai-knowledge-system" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "kofdai/nullai-knowledge-system", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/kofdai/nullai-knowledge-system:Q4_K_M
- SGLang
How to use kofdai/nullai-knowledge-system with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "kofdai/nullai-knowledge-system" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "kofdai/nullai-knowledge-system", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "kofdai/nullai-knowledge-system" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "kofdai/nullai-knowledge-system", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use kofdai/nullai-knowledge-system with Ollama:
ollama run hf.co/kofdai/nullai-knowledge-system:Q4_K_M
- Unsloth Studio
How to use kofdai/nullai-knowledge-system with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for kofdai/nullai-knowledge-system to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for kofdai/nullai-knowledge-system to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for kofdai/nullai-knowledge-system to start chatting
- Docker Model Runner
How to use kofdai/nullai-knowledge-system with Docker Model Runner:
docker model run hf.co/kofdai/nullai-knowledge-system:Q4_K_M
- Lemonade
How to use kofdai/nullai-knowledge-system with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull kofdai/nullai-knowledge-system:Q4_K_M
Run and chat with the model
lemonade run user.nullai-knowledge-system-Q4_K_M
List all available models
lemonade list
- Atomic Chat
| """ | |
| NullAI システムステータスAPI | |
| システムの状態、モデルの可用性、DB接続状況などを取得する。 | |
| """ | |
| from fastapi import APIRouter | |
| from pydantic import BaseModel | |
| from typing import Dict, Any, List, Optional | |
| import sys | |
| import os | |
| import platform | |
| from datetime import datetime | |
| sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))) | |
| router = APIRouter() | |
| class SystemStatus(BaseModel): | |
| """システムステータスのレスポンスモデル""" | |
| status: str # "healthy", "degraded", "unhealthy" | |
| version: str | |
| timestamp: str | |
| environment: Dict[str, Any] | |
| services: Dict[str, Dict[str, Any]] | |
| models: Dict[str, Any] | |
| def check_gpu_status() -> Dict[str, Any]: | |
| """GPU状況を確認""" | |
| try: | |
| import torch | |
| cuda_available = torch.cuda.is_available() | |
| mps_available = hasattr(torch.backends, "mps") and torch.backends.mps.is_available() | |
| result = { | |
| "cuda_available": cuda_available, | |
| "mps_available": mps_available, | |
| "device": "cuda" if cuda_available else ("mps" if mps_available else "cpu") | |
| } | |
| if cuda_available: | |
| result["cuda_device_count"] = torch.cuda.device_count() | |
| result["cuda_device_name"] = torch.cuda.get_device_name(0) if torch.cuda.device_count() > 0 else None | |
| result["cuda_memory_allocated_gb"] = round(torch.cuda.memory_allocated() / 1024**3, 2) | |
| result["cuda_memory_cached_gb"] = round(torch.cuda.memory_reserved() / 1024**3, 2) | |
| return result | |
| except ImportError: | |
| return {"error": "PyTorch not installed", "cuda_available": False, "mps_available": False, "device": "cpu"} | |
| except Exception as e: | |
| return {"error": str(e), "cuda_available": False, "mps_available": False, "device": "cpu"} | |
| def check_transformers_status() -> Dict[str, Any]: | |
| """HuggingFace Transformersの状況を確認""" | |
| try: | |
| import transformers | |
| return { | |
| "available": True, | |
| "version": transformers.__version__ | |
| } | |
| except ImportError: | |
| return {"available": False, "error": "transformers not installed"} | |
| except Exception as e: | |
| return {"available": False, "error": str(e)} | |
| def check_database_status() -> Dict[str, Any]: | |
| """データベースの状況を確認""" | |
| try: | |
| from backend.app.database.session import SessionLocal | |
| db = SessionLocal() | |
| # 簡単なクエリでDB接続を確認 | |
| db.execute("SELECT 1") | |
| db.close() | |
| return {"available": True, "type": "sqlite"} | |
| except Exception as e: | |
| return {"available": False, "error": str(e)} | |
| def check_model_router_status() -> Dict[str, Any]: | |
| """ModelRouterの状況を確認""" | |
| try: | |
| from null_ai.config import ConfigManager | |
| from null_ai.model_router import ModelRouter | |
| config = ConfigManager() | |
| router = ModelRouter(config) | |
| models = config.list_models() | |
| default_model = config.get_default_model() | |
| return { | |
| "available": True, | |
| "total_models": len(models), | |
| "default_model": default_model.model_id if default_model else None, | |
| "supported_providers": ["huggingface", "huggingface_api", "local", "gguf"], | |
| "models": [ | |
| { | |
| "id": m.model_id, | |
| "name": m.display_name, | |
| "provider": m.provider.value, | |
| "is_default": m.is_default | |
| } | |
| for m in models | |
| ] | |
| } | |
| except Exception as e: | |
| return {"available": False, "error": str(e)} | |
| async def get_system_status(): | |
| """ | |
| システムの全体的なステータスを取得。 | |
| - 環境情報(Python版、OS等) | |
| - GPU状況 | |
| - HuggingFace Transformers状況 | |
| - データベース接続状況 | |
| - モデル設定状況 | |
| """ | |
| # 各サービスの状況を確認 | |
| gpu_status = check_gpu_status() | |
| transformers_status = check_transformers_status() | |
| db_status = check_database_status() | |
| model_status = check_model_router_status() | |
| # 全体的なステータスを判定 | |
| all_healthy = ( | |
| transformers_status.get("available", False) and | |
| db_status.get("available", False) and | |
| model_status.get("available", False) | |
| ) | |
| if all_healthy: | |
| overall_status = "healthy" | |
| elif transformers_status.get("available", False) or model_status.get("available", False): | |
| overall_status = "degraded" | |
| else: | |
| overall_status = "unhealthy" | |
| return SystemStatus( | |
| status=overall_status, | |
| version="1.0.0", | |
| timestamp=datetime.utcnow().isoformat(), | |
| environment={ | |
| "python_version": platform.python_version(), | |
| "platform": platform.platform(), | |
| "system": platform.system(), | |
| "processor": platform.processor() | |
| }, | |
| services={ | |
| "gpu": gpu_status, | |
| "transformers": transformers_status, | |
| "database": db_status | |
| }, | |
| models=model_status | |
| ) | |
| async def health_check(): | |
| """軽量なヘルスチェック""" | |
| return {"status": "ok", "timestamp": datetime.utcnow().isoformat()} | |
| async def get_supported_providers(): | |
| """ | |
| サポートされているLLMプロバイダー情報を取得。 | |
| どのプロバイダーが使用可能か、どれが削除されたかを表示。 | |
| """ | |
| return { | |
| "supported": [ | |
| { | |
| "id": "huggingface", | |
| "name": "HuggingFace Transformers", | |
| "description": "ローカルでモデルをダウンロードして実行。GPU推奨。", | |
| "requires_api_key": False, | |
| "requires_gpu": True | |
| }, | |
| { | |
| "id": "huggingface_api", | |
| "name": "HuggingFace Inference API", | |
| "description": "HuggingFaceのサーバーで推論。無料枠あり。", | |
| "requires_api_key": False, | |
| "requires_gpu": False | |
| }, | |
| { | |
| "id": "local", | |
| "name": "Local Model", | |
| "description": "ローカルにダウンロード済みのモデルを使用。", | |
| "requires_api_key": False, | |
| "requires_gpu": True | |
| }, | |
| { | |
| "id": "gguf", | |
| "name": "GGUF (llama.cpp)", | |
| "description": "量子化モデル。CPU環境でも動作可能。", | |
| "requires_api_key": False, | |
| "requires_gpu": False | |
| } | |
| ], | |
| "unsupported": [ | |
| { | |
| "id": "openai", | |
| "reason": "利用規約上、競合モデル作成への使用が禁止されているため削除されました。" | |
| }, | |
| { | |
| "id": "anthropic", | |
| "reason": "利用規約上、競合モデル作成への使用が禁止されているため削除されました。" | |
| }, | |
| { | |
| "id": "ollama", | |
| "reason": "HuggingFaceでの公開を考慮し、直接Transformersを使用する方式に変更されました。" | |
| } | |
| ] | |
| } | |