How shifulegend/project-zero works
Project Zero is a CPU-only LLM inference engine for BitNet ternary and dense GGUF models. Its primary workflow is to start through the CLI, load model weights and tokenizer, then generate tokens using transformer, sampling, and CPU-optimized math components. The repository also includes an HTTP/UI surface, image input, agent tooling, and retrieval-augmented memory. Edges are limited to relationships shown in the README or SOURCE INDEX; unsampled implementation details are not inferred.
Main entry points: forward.c Transformer Forward · main.c CLI Entry · generate.c Token Generation · parallel_matmul.c Parallel Matmul
Components 20
Runtime and Models
- GGUF Loader
src/core/gguf_loader.c - Model Weights
include/core/weights.h - Tokenizer
src/tokenizer/tokenizer_encode.c - KV Cache
include/core/run_state.h
Inference Compute
- Token Generation
src/transformer/generate.c - Transformer Forward
src/transformer/forward.c - Attention
src/transformer/attention.c - Feed-Forward
src/transformer/ffn.c - Parallel Matmul
src/math/parallel_matmul.c - Token Sampling
src/sampling/top_p.c
Inference Extensions
- Vision Pipeline
src/multimodal/vision_pipeline.c - Memory Retrieval
src/rag/auto_retrieve.c - Vector Database
src/rag/vector_db.c - Agent Loop
src/agent/agent_loop.c
Runtime Foundation
- SIMD Dispatch
src/math/simd_dispatch.c - Thread Pool
src/threading/thread_pool.c
Other components
- User
Connections 22
- User → CLI Entry: runs
README.md - CLI Entry → GGUF Loader: loads model
src/cli/main.c - GGUF Loader → Model Weights: populates
- CLI Entry → Tokenizer: initializes
src/cli/main.c - CLI Entry → Token Generation: starts generation
src/cli/main.c - Token Generation → Transformer Forward: runs forward pass
- Transformer Forward → Attention: uses attention
- Transformer Forward → Feed-Forward: uses feed-forward
- Transformer Forward → Parallel Matmul: uses kernels
- Token Generation → Token Sampling: selects token
- Token Generation → KV Cache: updates cache
- Parallel Matmul → Thread Pool: dispatches work
src/math/parallel_matmul.c - Parallel Matmul → SIMD Dispatch: selects kernels
src/math/parallel_matmul.c - User → HTTP API: sends request
- Web UI → HTTP API: calls API
- HTTP API → Vision Pipeline: accepts image input
- CLI Entry → Vision Pipeline: accepts image input
- Vision Pipeline → Transformer Forward: injects vision context
src/multimodal/vision_pipeline.c - Agent Loop → Transformer Forward: invokes inference
src/agent/agent_loop.c - Agent Loop → Memory Retrieval: uses retrieval
src/agent/agent_loop.c - Memory Retrieval → Vector Database: searches memories
- Memory Retrieval → Tokenizer: encodes context