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)# pip install -U transformers accelerate # 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=256) 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
Build from source code
git clone https://github.com/ggml-org/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-app # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama serve -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
- Llama new
- 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 Desktop
- 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
Download hallucination_detector.py from kofdai/nullai-knowledge-system: direct link, hf CLI and curl.
- Browser
- Download file 4.15 kB
-
https://huggingface.co/kofdai/nullai-knowledge-system/resolve/main/hallucination_detector.py
- Command line
-
hf download hf://kofdai/nullai-knowledge-system/hallucination_detector.py
-
curl -L -o hallucination_detector.py https://huggingface.co/kofdai/nullai-knowledge-system/resolve/main/hallucination_detector.py
4.15 kB
| import numpy as np | |
| def _classify_risk_level(score: float) -> str: | |
| """リスクスコアをカテゴリに分類する。""" | |
| if score < 0.1: return "very_low" | |
| if score < 0.3: return "low" | |
| if score < 0.6: return "moderate" | |
| if score < 0.8: return "high" | |
| return "very_high" | |
| def calculate_hallucination_risk_score(alpha_response: dict, validation_result: dict) -> dict: | |
| """ | |
| α-Lobeの回答とβ-Lobeの検証結果から、ハルシネーションのリスクを計算します。 | |
| Args: | |
| alpha_response (dict): α-Lobeからの構造化レスポンス。 | |
| validation_result (dict): β-Lobeによる検証結果。 | |
| Returns: | |
| dict: ハルシネーションリスクスコアと関連情報。 | |
| """ | |
| risk_score = 0.0 | |
| # --- 検証結果に基づくリスク加算 --- | |
| anchor_passed = validation_result["checks"]["anchor_facts"]["passed"] | |
| logic_passed = validation_result["checks"].get("logic", {"passed": True})["passed"] | |
| context_passed = validation_result["checks"].get("context", {"passed": True})["passed"] | |
| # Anchor事実との矛盾は最大のリスク | |
| risk_score += (1 - (1 if anchor_passed else 0)) * 0.5 | |
| # 論理矛盾も高いリスク | |
| risk_score += (1 - (1 if logic_passed else 0)) * 0.3 | |
| # 医学的文脈の矛盾 | |
| risk_score += (1 - (1 if context_passed else 0)) * 0.2 | |
| # --- 回答内容に基づくリスク加算 --- | |
| # α-Lobe自体の自信度が低い場合 | |
| alpha_confidence = alpha_response.get("confidence", 0.7) | |
| if alpha_confidence < 0.5: | |
| risk_score += 0.1 | |
| # 不確実性に関する言及がない場合、過信しているリスク | |
| uncertainties = alpha_response.get("uncertainties", []) | |
| if not uncertainties: | |
| risk_score += 0.05 | |
| # 引用元が全くない場合 | |
| sources_cited = alpha_response.get("sources_cited", []) | |
| if not sources_cited: | |
| risk_score += 0.1 | |
| final_risk_score = min(1.0, risk_score) | |
| return { | |
| "hallucination_risk_score": final_risk_score, | |
| "risk_level": _classify_risk_level(final_risk_score), | |
| "action_required": final_risk_score >= 0.3 | |
| } | |
| if __name__ == '__main__': | |
| # --- ダミーデータによる使用例 --- | |
| # ケース1: 安全な回答 | |
| safe_alpha_res = { | |
| "confidence": 0.9, "uncertainties": [], "sources_cited": ["JCS 2023 Guideline"] | |
| } | |
| safe_validation_res = { | |
| "checks": {"anchor_facts": {"passed": True}, "logic": {"passed": True}, "context": {"passed": True}} | |
| } | |
| risk_1 = calculate_hallucination_risk_score(safe_alpha_res, safe_validation_res) | |
| print(f"--- Case 1: Safe Response ---") | |
| print(f" Risk Score: {risk_1['hallucination_risk_score']:.2f} ({risk_1['risk_level']})") | |
| print(f" Action Required: {risk_1['action_required']}") | |
| # ケース2: リスクのある回答 (事実誤認、引用なし) | |
| risky_alpha_res = { | |
| "confidence": 0.95, "uncertainties": [], "sources_cited": [] | |
| } | |
| risky_validation_res = { | |
| "checks": {"anchor_facts": {"passed": False}, "logic": {"passed": True}, "context": {"passed": True}} | |
| } | |
| risk_2 = calculate_hallucination_risk_score(risky_alpha_res, risky_validation_res) | |
| print(f"\n--- Case 2: Risky Response ---") | |
| print(f" Risk Score: {risk_2['hallucination_risk_score']:.2f} ({risk_2['risk_level']})") | |
| print(f" Action Required: {risk_2['action_required']}") | |
| # ケース3: リスク中程度の回答 (論理エラー、自信度低い) | |
| medium_alpha_res = { | |
| "confidence": 0.4, "uncertainties": ["かもしれない"], "sources_cited": ["Some Journal"] | |
| } | |
| medium_validation_res = { | |
| "checks": {"anchor_facts": {"passed": True}, "logic": {"passed": False}, "context": {"passed": True}} | |
| } | |
| risk_3 = calculate_hallucination_risk_score(medium_alpha_res, medium_validation_res) | |
| print(f"\n--- Case 3: Medium Risk Response ---") | |
| print(f" Risk Score: {risk_3['hallucination_risk_score']:.2f} ({risk_3['risk_level']})") | |
| print(f" Action Required: {risk_3['action_required']}") | |