2 1 month ago

PathOS - AI Pathologist for H&E Histopathology

vision tools thinking audio 4b
ollama run dhairyapandya/pathos

Applications

Claude Code
Claude Code ollama launch claude --model dhairyapandya/pathos
Codex App
Codex App ollama launch codex-app --model dhairyapandya/pathos
OpenClaw
OpenClaw ollama launch openclaw --model dhairyapandya/pathos
Hermes Agent
Hermes Agent ollama launch hermes --model dhairyapandya/pathos
Codex
Codex ollama launch codex --model dhairyapandya/pathos
OpenCode
OpenCode ollama launch opencode --model dhairyapandya/pathos

Models

View all →

Readme

image.png

PathOS - AI Pathologist for H&E Histopathology

Offline AI diagnostic assistant that runs on any laptop via Ollama. No GPU required.

PathOS is a distilled Gemma 4 model fine-tuned for H&E stained histopathology analysis. It produces definitive, structured diagnoses with <answer> tags — no hedging, no “cannot determine”.

Quick Start (2 commands)

# Install Ollama (if not installed)
# Windows: winget install Ollama.Ollama
# macOS:   brew install ollama
# Linux:   curl -fsSL https://ollama.com/install.sh | sh

# Run PathOS (default Q8_0, ~3GB) - downloads automatically on first run
ollama run dhairyapandya/pathos

# Or run the lighter 4-bit version (~2.5GB) for very constrained hardware
ollama run dhairyapandya/pathos:4b

That’s it. You now have a local AI pathologist.


Analyzing Digitized Slides

Text-only questions

ollama run dhairyapandya/pathos "What are the features of colorectal adenocarcinoma?"

With slide images

# Analyze a single slide
ollama run dhairyapandya/pathos "Is malignancy present?" --images slide.png

# Tissue identification
ollama run dhairyapandya/pathos "What tissue type is present?" --images biopsy_patch.jpg

# Check for specific features
ollama run dhairyapandya/pathos "Is nuclear pleomorphism present?" --images tumor_section.png

# Open-ended analysis
ollama run dhairyapandya/pathos "Describe the key histological features." --images tissue.png

Interactive session (multiple slides)

# Start interactive mode
ollama run dhairyapandya/pathos

# Then type questions at the prompt:
>>> Is malignancy present? [attach image via drag-drop]
>>> What tissue type is this? [attach another image]
>>> /bye

Using the API (for integration)

# Start Ollama server
ollama serve

# Call the API
curl http://localhost:11434/api/generate -d '{
  "model": "dhairyapandya/pathos",
  "prompt": "Is malignancy present?",
  "images": ["<base64_encoded_image>"],
  "stream": false
}'

Supported Question Types

Type Example Response Format
Yes/No “Is malignancy present?” Yes. <answer>yes</answer> Evidence...
Tissue ID “What tissue type is present?” Features: ... <answer>tissue name</answer>
Open-ended “What is the primary finding?” Description. <answer>finding</answer>

Example Questions for Diagnostics

Is malignancy present?
What tissue type is present in this histopathology patch?
Is nuclear pleomorphism present?
Are mitotic figures visible?
Is necrosis present?
Are goblet cells visible?
Is lymphocytic infiltrate present?
Is desmoplastic stroma present?
What is the primary clinical finding?
Is carcinoma in situ present?
Are glandular structures regular or irregular?
Is there evidence of invasion beyond the basement membrane?

For Labs - Deployment Guide

Option 1: Direct from Ollama Registry (easiest)

ollama run dhairyapandya/pathos
# or for the 4-bit version:
ollama run dhairyapandya/pathos:4b

Option 2: Custom Modelfile (with enhanced system prompt)

# Download from HuggingFace
wget https://huggingface.co/dhairyapandya/pathos-gemma4-distilled-GGUF/resolve/main/pathos-Q8_0.gguf
wget https://huggingface.co/dhairyapandya/pathos-gemma4-distilled-GGUF/resolve/main/Modelfile

# Create local model with custom system prompt
ollama create pathos -f Modelfile

# Run
ollama run pathos "Is malignancy present?" --images slide.png

Option 3: llama.cpp (no Ollama needed)

# Install llama.cpp
# Windows: winget install llama.cpp
# macOS:   brew install llama.cpp

# Run with web UI
llama-server -hf dhairyapandya/pathos-gemma4-distilled-GGUF:Q8_0

# Or direct CLI
llama-cli -hf dhairyapandya/pathos-gemma4-distilled-GGUF:Q8_0

Option 4: Docker

docker model run hf.co/dhairyapandya/pathos-gemma4-distilled-GGUF:Q8_0

💻 Hardware Requirements

Component Minimum Recommended
RAM 4 GB (for 4b model) 8 GB+ (for Q8 model)
GPU Not required Any (speeds up inference)
Disk 3 GB free (for 4b model) 5 GB+ free
OS Windows 10+, macOS 12+, Linux, Raspberry Pi OS Any

🚀 Edge Deployment (Raspberry Pi & SBCs)

Because of the extreme efficiency of the Gemma 4 E2B architecture combined with 4-bit quantization, the 4b model is specifically designed for Edge AI deployment.

You can run PathOS as a local, offline AI pathologist on resource-constrained devices like the Raspberry Pi 5 (8GB) or Jetson Nano.

Performance estimates (No GPU, CPU only):

Hardware Model Version Speed
Modern laptop (16GB RAM) latest (Q8_0) ~5-8 tokens/sec
Desktop with GPU latest (Q8_0) ~20-30 tokens/sec
Older laptop (8GB RAM) 4b (Q4_K_M) ~5-10 tokens/sec
Raspberry Pi 5 (8GB) 4b (Q4_K_M) ~2-3 tokens/sec

Note: Running on a Raspberry Pi is slower, but it allows for a completely offline, battery-powered diagnostic assistant in remote or low-resource clinical settings.


🧠 What’s Inside

PathOS is a Gemma 4 E2B (2.6B params) model with 6 inference-time techniques distilled into the weights:

  1. Constrained decoding : always produces <answer> tags
  2. Anti-hedging : never says “cannot determine” or “uncertain”
  3. Static RAG : few-shot exemplars embedded in training
  4. CoT routing : adapts reasoning depth to question complexity
  5. Per-type templates : separate formats for YN/tissue/open-ended
  6. Format compliance : trained via GRPO reward shaping

Training Pipeline

google/gemma-4-e2b-it (base)
    ↓ SFT on 19.5K histopathology examples
    ↓ GRPO with format/accuracy rewards (150 samples)
    ↓ LoRA merge + GGUF Q8_0 quantization
    = PathOS (~3GB, runs on any laptop)

Links

Resource URL
Ollama Model dhairyapandya/pathos
GGUF Model (Q8_0) dhairyapandya/pathos-gemma4-distilled-GGUF
GGUF Model (4B) dhairyapandya/pathos-gemma4-distilled-rl-4B-GGUF
LoRA Adapter dhairyapandya/pathos-gemma4-distilled-rl-histopathology
Base Model google/gemma-4-e2b-it

Disclaimer

PathOS is a research tool for educational and assistive purposes only. It is NOT a certified medical device, it works as an advisory assistance to a certified pathologist, it’s use case is to fasten the process for a professional and not replace them. All outputs must be reviewed by a qualified pathologist before clinical use.

License

Apache 2.0