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
| import json | |
| import hashlib | |
| from knowledge_tile_generator import create_knowledge_tile | |
| from reasoning_chain_extractor import extract_reasoning_chain | |
| from coordinate_mapper import map_reasoning_to_medical_space | |
| from iath_encoder import IathEncoder | |
| from iath_decoder import IathDecoder | |
| def generate_sample_tile() -> dict: | |
| """ | |
| 検証用のサンプルKnowledge Tileを生成します。 | |
| """ | |
| dummy_response = { | |
| 'thinking': 'まず、心筋梗塞の定義から始めます。これは心筋への血流が途絶えることで心筋が壊死する状態です。次に、診断のゴールドスタンダードであるトロポニン測定について考慮します。これは~という理由で重要です。さらに心電図の変化も重要な所見です。ST上昇が見られる場合、急性期と判断されます。', | |
| 'response': '急性心筋梗塞は、迅速な診断と治療が求められる救急疾患です。診断は主に、臨床症状(胸痛など)、心電図変化(ST上昇など)、心筋逸脱酵素(特にトロポニン)の上昇を三本柱として行われます。アルゴリズムとしては、まず疑いがあれば直ちに12誘導心電図を記録し、バイタルサインを確認します。ST上昇があれば、緊急カテーテル治療の適応を考慮します。<参考資料> 日本循環器学会ガイドライン2023', | |
| } | |
| topic = "心筋梗塞の急性期診断" | |
| reasoning = extract_reasoning_chain(dummy_response) | |
| coordinates = map_reasoning_to_medical_space(reasoning) | |
| knowledge_tile = create_knowledge_tile(dummy_response, coordinates, topic) | |
| return knowledge_tile | |
| def verify_lossless_compression(original_tile: dict) -> dict: | |
| """ | |
| 指定されたKnowledge Tileの可逆圧縮を検証します。 | |
| エンコード -> デコードを実行し、結果がオリジナルと一致するか確認します。 | |
| """ | |
| encoder = IathEncoder() | |
| decoder = IathDecoder() | |
| # ステップ1: エンコード | |
| try: | |
| compressed_data = encoder.encode_tile(original_tile) | |
| original_size = len(json.dumps(original_tile, ensure_ascii=False).encode('utf-8')) | |
| except Exception as e: | |
| return {"status": f"✗ エンコード失敗: {e}", "is_lossless": False} | |
| # ステップ2: デコード | |
| try: | |
| decompressed_tile = decoder.decode_tile(compressed_data) | |
| except Exception as e: | |
| return {"status": f"✗ デコード失敗: {e}", "is_lossless": False} | |
| # ステップ3: ハッシュを比較して可逆性を検証 | |
| # NOTE: デコード処理では一部のフィールド(source, historyなど)が復元されないため、 | |
| # それらのフィールドを比較対象から除外した上でハッシュを計算します。 | |
| def get_comparable_hash(tile_data: dict) -> str: | |
| # 比較対象のキーを限定 | |
| keys_to_compare = ["metadata", "content", "coordinates", "verification"] | |
| comparable_data = {key: tile_data.get(key) for key in keys_to_compare} | |
| # 安定したハッシュ生成のため、キーでソートしてJSON化 | |
| serialized = json.dumps(comparable_data, sort_keys=True, ensure_ascii=False) | |
| return hashlib.sha256(serialized.encode('utf-8')).hexdigest() | |
| original_hash = get_comparable_hash(original_tile) | |
| decompressed_hash = get_comparable_hash(decompressed_tile) | |
| is_lossless = original_hash == decompressed_hash | |
| status = "✓ 完全な可逆圧縮" if is_lossless else "✗ 情報損失あり" | |
| report = { | |
| "is_lossless": is_lossless, | |
| "status": status, | |
| "original_hash": original_hash, | |
| "decompressed_hash": decompressed_hash, | |
| "original_size": original_size, | |
| "compressed_size": len(compressed_data), | |
| "compression_ratio": f"{(len(compressed_data) / original_size):.2%}" if original_size > 0 else "N/A", | |
| } | |
| return report | |
| if __name__ == "__main__": | |
| print("--- 可逆圧縮検証開始 ---") | |
| # 1. サンプルタイルを生成 | |
| print("1. サンプルKnowledge Tileを生成中...") | |
| sample_tile = generate_sample_tile() | |
| # 2. 可逆圧縮を検証 | |
| print("2. エンコード -> デコードを実行し、可逆性を検証中...") | |
| verification_report = verify_lossless_compression(sample_tile) | |
| # 3. 結果を表示 | |
| print("\n--- 可逆圧縮検証結果 ---") | |
| print(f"ステータス: {verification_report['status']}") | |
| print(f" 可逆性: {verification_report['is_lossless']}") | |
| print(f" 元データのハッシュ: {verification_report['original_hash']}") | |
| print(f" 復元データのハッシュ: {verification_report['decompressed_hash']}") | |
| print(f" 元の推定サイズ: {verification_report['original_size']} bytes") | |
| print(f" 圧縮後のサイズ: {verification_report['compressed_size']} bytes") | |
| print(f" 圧縮率: {verification_report['compression_ratio']}") | |
| if not verification_report['is_lossless']: | |
| print("\n[!] ハッシュが一致しませんでした。エンコーダーとデコーダーの実装を確認してください。") | |