A Hugging Face compatible causal language model with an optional shared-weight swarm runtime for routing, skills, goals, scaffolding, tool planning, agentic sessions, and local app integrations.
Start here for coherent Ollama-style use: if Hugging Face shows a llama_cpp snippet for phillswarm-4b-ollama-f16.gguf, treat that as a raw GGUF preview only. For the full PhillSwarm system, run launch_ollama_bridge.py and use phillswarm-4b:full. The bridge preserves the custom HF model code, swarm controller, verified skills, goals, tools, and vision-sidecar path behind Ollama-compatible APIs.
starts the PhillSwarm full-runtime bridge if it is not already running
waits until the bridge is ready
runs ollama list to confirm the direct Ollama CLI sees the full model
on macOS/Linux, adds OLLAMA_HOST to .zshrc or .bashrc when it can detect the active shell
After setup, open a new terminal and use normal Ollama commands:
bash
1ollama list
2ollama run phillswarm-4b:full
Model name:
phillswarm-4b:full
What This Is
Phill Swarm-MoE is a sparse Mixture-of-Experts causal language model packaged as a normal Hugging Face checkpoint. It can be loaded as a standard AutoModelForCausalLM model, or used through the optional PhillSwarmController runtime for agentic features.
The checkpoint in this folder is the grown 4B final package:
Parameters: 4,144,993,832.
Architecture: Swarm-MoE decoder-only causal LM.
Layers: 40 unique routed layers.
Hidden size: 1024.
Experts: 16 routed experts with top-2 routing plus shared expert path.
Attention: grouped-query attention with Q/K RMSNorm, optional V norm gate, RoPE, KV cache.
Tokenizer: Qwen tokenizer copied into the final package.
Precision target: bf16.
Context configured: 4096 positions.
Plain truth: the normal model API remains standard. Swarm mode, goals, app streaming, tools, scaffolding, and online learning are wrapper/runtime features. They do not require custom `forward(goal=...)` or automatic app startup.
What Makes It Different
Shared-Weight Swarm
Planner, solver, verifier, domain, tool, and editor roles can run over one loaded model instead of separate model copies.
Verified Skills
Math, tool routing, web/search planning, browser mode, IDE/CLI integration, health/legal/finance/security domain policy, and runtime diagnostics can anchor answers.
Agentic Goals
Runtime-only goal state tracks objective, constraints, allowed tools, notes, artifacts, events, and completion status in portable JSON.
Learnable Scaffolding
Scaffold routing learns from successful traces through `scaffold_blueprint.json` without mutating model weights during normal generation.
Final Polish Pass
A safe post-processor can improve wording using only the user prompt and verified final answer. Bad polish is rejected.
For a local clone or downloaded snapshot, replace model_id with the folder path, for example "." from inside the model folder.
Loading note: use `trust_remote_code=True` for `AutoConfig`, `AutoTokenizer`, and `AutoModelForCausalLM`. Without it, Transformers will not know how to construct the custom `swarm_moe` architecture. The optional app/runtime also needs the snapshot files locally available so Python can import the bundled `swarm_moe_model` package.
Quick Start: Use Swarm Runtime
The optional swarm runtime is packaged with the model files. For the cleanest setup, download the snapshot locally so Python can import the included swarm_moe_model runtime package:
Default publish-facing behavior is conservative: verified skills can finish the answer without forcing noisy profile generation. Profile workers can still be activated with return_candidates=True, explicit debate prompts, or enable_profile_generation: true.
Runtime Architecture
mermaid
1flowchart LR
2 U["User Prompt"]--> R["Intent + Skill Router"]3 R --> S["Verified Skills"]4 R --> G["Goal State"]5 R --> C["Learnable Scaffold Blueprint"]6 S --> A["Answer Composer"]7 G --> A
8 C --> W["Dynamic Shared-Weight Workers"]9 W --> N["Bounded Note Pool"]10 N --> A
11 A --> P["Safe Final Polish"]12 P --> O["Final Answer"]
If Mermaid does not render on your viewer, the flow is: prompt -> router -> skills/goals/scaffold/workers -> compact evidence -> final answer -> safe polish.
Goals
Goals are runtime-only and stored as JSON. They do not alter the model API.
python
1import sys
2from pathlib import Path
34sys.path.insert(0,str(Path(".").resolve()))56from swarm_moe_model.swarm_mode import PhillSwarmController, SwarmGoal
78controller = PhillSwarmController.from_pretrained_or_config(".")9goal = SwarmGoal(10 objective="Draft a small CLI plan for using this model with tool calls.",11 constraints=["Keep it cross-platform","Do not assume a hardcoded path"],12 success_criteria=["Shows install","Shows run","Mentions permissions"],13 allowed_tools=["filesystem_read","web_search"],14)1516run = controller.run_goal(goal)17print(run.final_answer)18run.state.to_json("goal_state.json")
Agentic Sessions
Agentic sessions keep multi-turn work coherent without appending every old token forever.
Latest user prompt remains the authority.
Recent turns stay in a rolling window.
Older turns flush into compact summaries.
Tool results, route decisions, and artifacts stay as metadata.
KV cache is used for the active generation window, not falsely persisted across independent turns.
python
1session = controller.create_session("workspace-task")2print(session.ask("Remember that we want a portable CLI setup.", mode="swarm").answer)3print(session.ask("Now give the final install checklist.", mode="swarm").answer)4session.state.to_json("session_state.json")
Skills And Domain Routing
The runtime includes compact verified skills and route anchors. They are designed to reduce prompt overload: the model sees only the selected route and a few verified evidence anchors, not the entire tool registry.
High-stakes use: health, legal, finance, and security routes are policy and safety anchors, not substitutes for qualified professional advice or permissioned security review.
--permission-mode yolo enables stronger browser/tool actions with tracing.
When launched explicitly through the wrapper/app server, it can expose:
/api/status
/api/chat
/api/chat/stream
/api/tools/route
/api/tool/call
Streaming uses Server-Sent Events for route, profile, critic, tool, goal, token, final, and error events. Tool execution remains permission-gated.
Ollama-Compatible Full Runtime
PhillSwarm includes an Ollama-compatible full-runtime bridge. This is the recommended Ollama path when you want coherent PhillSwarm behavior.
Recommended for Ollama users: run the packaged bridge and use model name phillswarm-4b:full. This keeps the full HF checkpoint, swarm controller, verified skills, tools, goals, and vision-sidecar runtime available behind Ollama-style APIs.
Why this exists: PhillSwarm is not only a plain GGUF transformer. It uses bundled HF remote code, shared-expert routing, gated V-norm behavior, a Python swarm controller, goals, app tools, and a vision sidecar. Stock Ollama/llama.cpp does not execute those Python runtime systems inside a .gguf file. The bridge keeps Ollama-style compatibility while preserving the full model system instead of flattening it into a weaker preview.
Run The Coherent Ollama Path
Download or clone the snapshot, then run the one-time setup from inside the model folder.
1curl http://127.0.0.1:11435/api/chat \2 -H "Content-Type: application/json"\3 -d '{"model":"phillswarm-4b:full","stream":false,"messages":[{"role":"user","content":"What is 2+2? Answer in one sentence."}]}'
Ollama-compatible JSON and NDJSON streaming response shapes.
Fast verified-skill routing before heavy model generation when a deterministic answer is already known.
Lazy loading, so /api/tags and /api/show respond quickly while the BF16 model loads only for real generation.
About the GGUF preview: the raw GGUF can be loadable in stock Ollama, but it is not the full intelligence path because stock Ollama cannot run the custom swarm runtime. For coherent outputs, use the bridge or the native HF runtime.
MCP / IDE Bridge
The app exposes a local MCP-style bridge for external agent hosts and IDEs:
Use it with Codex, Claude Code, Cursor, Antigravity-style hosts, or any local MCP/HTTP client that can call a JSON-RPC tool server. The endpoint supports:
initialize
tools/list
tools/call
phill/route
phill/chat
The bridge is private by default because the app binds to 127.0.0.1. To expose it to another machine on your LAN, launch explicitly:
python launch_swarm_app.py --host 0.0.0.0
Then open /api/mcp/status to see the LAN URL. Only use LAN mode on a trusted network. For shared machines or public networks, set mcp_auth_token in swarm_app_config.example.json and send Authorization: Bearer <token> from the client.
For ChatGPT-style use, the intended pattern is different from Codex/Cursor: ChatGPT can remain the language model while calling Phill's app routes for scaffolding, routing, goals, tools, browser observation, and verification. That lets the app act as a local swarm/tool runtime without replacing the external model.
Phill Swarm App settings drawer and workspace
Compact Runtime SettingsMode, persona, depth, goals, route judge, streaming, tools, web search, website drafting, and permissions are available without crowding the main chat.
Phill Swarm App routed tool preview
Real Tool Routing PreviewThe app calls the routed tools endpoint, shows the selected chain, permission blocks, activity events, and goal cards before a full model run.
Phill Swarm App website builder preview
Website Drafting SurfaceThe local site-draft endpoint renders a preview, updates the execution flow, and enables export while keeping actions permission-gated.
Vision Sidecar
This package includes runtime metadata for an optional Qwen3.5-style vision sidecar:
vision_sidecar_enabled: true
vision_sidecar_path: "vision_sidecar"
vision_snapshot_policy: "retain_latest_only"
Vision is runtime sidecar behavior, not ordinary text-generation behavior. The text embedding table is not resized for vision marker tokens; pixel tensors and browser snapshots route through external processor metadata/sidecar paths.
This is zero-extra-model-weight runtime memory. It improves scaffold node selection and confidence without mutating model weights during normal generation.
It receives only the latest user prompt and the verified final answer. It cannot see raw worker notes or rejected candidates. If the polish drifts, changes numbers, becomes too short/long, or loses overlap with the verified answer, the runtime keeps the original verified answer.
Validation Summary
From the included reports:
HF config/tokenizer/model load passed.
CUDA forward passed.
Controller loaded with 40 routed layers.
No-profile swarm smoke returned a verified black-hole answer through science_explanation.
Dynamic profile test showed noisy raw workers are rejected and verified skills preserve the answer.
Final polish test preserved verified answers when the polish attempt failed validation.
Learnable scaffold test saved/reloaded blueprint state.
Auxiliary-loss tiny-model test passed forward/loss/backward.
The package includes detailed reports:
QWEN35_4B_FINAL_REPORT.md
QWEN35_4B_COHERENCE_REPORT.md
DYNAMIC_SWARM_ORCHESTRATION_REPORT.md
AGENTIC_SESSION_RUNTIME_REPORT.md
AGI_SKILL_ROUTE_EXPANSION_REPORT.md
LEARNABLE_SCAFFOLDING_REPORT.md
LEARNABLE_LOSSES_AND_ONLINE_LEARNING_REPORT.md
FINAL_POLISH_PASS_REPORT.md
Known Limits
Raw direct generation can still be weaker than verified runtime answers.
Profile generation is not enabled by default because raw worker text can be noisy.
Online learning is disabled by default and should not be treated as automatic safe self-training.
Vision sidecar is runtime behavior; normal text generation does not become a full browser-vision agent by itself.
This README describes implemented local runtime features, not independent benchmark superiority over frontier commercial systems.
File Map
File
Purpose
config.json
HF model config and passive runtime metadata
model.safetensors
model weights
configuration_swarm_moe.py
HF config remote-code file
modeling_swarm_moe.py
HF model remote-code file
tokenizer.json, tokenizer_config.json
tokenizer assets
swarm_runtime_config.json
wrapper/runtime config
scaffold_blueprint.json
learnable scaffold runtime memory
swarm_moe_model/
optional local runtime package
vision_sidecar.py, vision_sidecar/
optional runtime vision sidecar
swarm_app_config.example.json
app config example
Recommended Use Cases
Local research into sparse MoE routing and shared-weight agent orchestration.
Tool-aware chat wrappers where tool execution is explicit and permissioned.
IDE/CLI assistants that need compact tool manifests and traceable routes.
Agentic task runners that need JSON goal state, session memory, and recoverable progress.
Experiments with scaffold learning and safe online correction workflows.
Educational exploration of MoE, routing losses, and wrapper-based agent design.
Minimal Requirements
Python environment with PyTorch and Transformers.
trust_remote_code=True.
bf16-capable CUDA is recommended for the 4B package.
CPU loading may be possible but will be slow.
Attribution And Development Notes
Phill Swarm-MoE is a custom project by Phillip A. Holland / Ayjays132. This package contains a grown hybrid checkpoint and runtime code intended for local experimentation, HF-style loading, and publishable inspection. It is built to be transparent about what is model behavior, what is runtime orchestration, and what is experimental.
Core principle: keep the model loadable as a normal HF checkpoint, then let users opt into the swarm runtime when they want goals, tools, scaffolds, streaming, sessions, and traceable orchestration.