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
| """ | |
| Knowledge Base API | |
| 知識タイル一覧表示と検証マーク機構 | |
| """ | |
| from fastapi import APIRouter, Depends, HTTPException, Query | |
| from fastapi.responses import FileResponse, StreamingResponse | |
| from typing import List, Optional | |
| from datetime import datetime | |
| import os | |
| import json | |
| import io | |
| from sqlalchemy.orm import Session | |
| from backend.app.middleware.auth import get_current_user_optional, get_current_user, User | |
| from backend.app.config import settings | |
| from backend.app.database.session import get_db | |
| from backend.app.services.knowledge_service import KnowledgeService, get_knowledge_service | |
| from backend.app.schemas.knowledge import KnowledgeTile, KnowledgeListResponse, KnowledgeDetailResponse, EditRequest, VerificationMark | |
| router = APIRouter() | |
| async def list_knowledge_tiles( | |
| domain_id: Optional[str] = Query(None, description="ドメインでフィルタ"), | |
| verification_type: Optional[str] = Query(None, description="検証タイプでフィルタ"), | |
| search: Optional[str] = Query(None, description="検索クエリ"), | |
| page: int = Query(1, ge=1, description="ページ番号"), | |
| page_size: int = Query(20, ge=1, le=100, description="ページサイズ"), | |
| db: Session = Depends(get_db), | |
| service: KnowledgeService = Depends(get_knowledge_service) | |
| ): | |
| tiles_orm, total_count = service.list_tiles( | |
| db=db, page=page, page_size=page_size, | |
| domain_id=domain_id, verification_type=verification_type, search=search | |
| ) | |
| tiles_pydantic = [KnowledgeTile.from_orm(t) for t in tiles_orm] | |
| return KnowledgeListResponse( | |
| tiles=tiles_pydantic, | |
| total_count=total_count, | |
| page=page, | |
| page_size=page_size, | |
| has_more=(page * page_size) < total_count | |
| ) | |
| async def get_knowledge_tile( | |
| tile_id: str, | |
| db: Session = Depends(get_db), | |
| service: KnowledgeService = Depends(get_knowledge_service) | |
| ): | |
| tile_orm = service.get_tile(db, tile_id=tile_id) | |
| if not tile_orm: | |
| raise HTTPException(status_code=404, detail="Knowledge tile not found") | |
| tile_pydantic = KnowledgeTile.from_orm(tile_orm) | |
| return KnowledgeDetailResponse( | |
| tile=tile_pydantic, | |
| full_content=tile_orm.content, | |
| # TODO: Implement sources, related_tiles, and edit_history from DB | |
| sources=[], | |
| related_tiles=[], | |
| edit_history=[] | |
| ) | |
| async def update_knowledge_tile( | |
| tile_id: str, | |
| request: EditRequest, | |
| current_user: User = Depends(get_current_user), | |
| db: Session = Depends(get_db), | |
| service: KnowledgeService = Depends(get_knowledge_service) | |
| ): | |
| updated_tile_orm = service.update_tile( | |
| db=db, tile_id=tile_id, content=request.content, user=current_user | |
| ) | |
| if not updated_tile_orm: | |
| raise HTTPException(status_code=404, detail="Knowledge tile not found") | |
| return KnowledgeTile.from_orm(updated_tile_orm) | |
| async def get_coordinates_for_3d_visualization( | |
| domain_id: Optional[str] = Query(None, description="特定ドメインのみ取得"), | |
| db: Session = Depends(get_db), | |
| service: KnowledgeService = Depends(get_knowledge_service) | |
| ): | |
| """ | |
| 3D可視化用の座標データを取得 | |
| 座標を持つタイルのみを返し、必要最小限の情報のみを含める | |
| """ | |
| # Fetch all tiles (large page size to get all) | |
| tiles_orm, _ = service.list_tiles(db=db, page_size=10000, domain_id=domain_id) | |
| # Filter tiles that have coordinates and extract minimal data | |
| coordinates_data = [] | |
| for tile in tiles_orm: | |
| if tile.coordinates: # Only include tiles with coordinates | |
| coordinates_data.append({ | |
| "tile_id": tile.id, | |
| "topic": tile.topic, | |
| "domain_id": tile.domain_id, | |
| "coordinates": tile.coordinates, # [x, y, z, c, g, v] | |
| "confidence_score": tile.confidence_score, | |
| "verification_type": tile.verification_type | |
| }) | |
| return { | |
| "tiles": coordinates_data, | |
| "count": len(coordinates_data), | |
| "domain_id": domain_id or "all" | |
| } | |
| async def export_db_json( | |
| domain_id: Optional[str] = Query(None, description="特定ドメインのみエクスポート"), | |
| db: Session = Depends(get_db), | |
| service: KnowledgeService = Depends(get_knowledge_service) | |
| ): | |
| # Fetch all tiles for export | |
| tiles_orm, _ = service.list_tiles(db=db, page_size=10000, domain_id=domain_id) # A large page size to get all | |
| tiles_pydantic = [KnowledgeTile.from_orm(t).dict() for t in tiles_orm] | |
| export_data = { | |
| "metadata": { | |
| "export_date": datetime.now().isoformat(), | |
| "source": "NullAI Knowledge Base", | |
| "domain_filter": domain_id or "all", | |
| "tile_count": len(tiles_pydantic) | |
| }, | |
| "tiles": tiles_pydantic | |
| } | |
| json_str = json.dumps(export_data, indent=2, ensure_ascii=False, default=str) | |
| return StreamingResponse( | |
| io.BytesIO(json_str.encode('utf-8')), | |
| media_type="application/json", | |
| headers={ | |
| "Content-Disposition": f"attachment; filename=null_ai_knowledge_{datetime.now().strftime('%Y%m%d')}.json" | |
| } | |
| ) | |