Appearance
GhostScience (PhD Mode)
GhostScience is GhostAI's PhD-level scientific computing engine. It provides structured tools for symbolic math, numerical methods, optimization, statistics, control systems, signal processing, simulation, and method comparison -- all running inside a PII-protected sandbox with a regulatory-grade computation provenance ledger.
Architecture
User Input (LaTeX / MATLAB / Python / natural language)
│
v
DSL Parser ── syntax detection + normalization
│
v
PII Detection + Tokenization (PreDact middleware)
│
v
LLM Reasoning Layer (problem classification, method selection)
│
v
Scientific Orchestrator (code generation, cache check, sandbox dispatch)
│
v
PhD Sandbox Container (50+ libraries, gVisor isolation)
│
v
Output PII Scan
│
v
Structured Result (LaTeX + plots + units + uncertainty + provenance)GhostScience is a capability layer within GhostAI, not a standalone application. Every security, compliance, and observability feature of the platform applies automatically to scientific computation.
Scientific Tools
GhostScience provides eight structured tools that the AI reasoning layer invokes based on problem analysis:
| Tool | Capabilities |
|---|---|
| Symbolic Mathematics | Solve, integrate, differentiate, simplify, series expand, Laplace/Fourier transforms. Accepts any syntax. Returns LaTeX with step-by-step derivation. |
| Numerical Methods | ODE/PDE systems, linear algebra, eigenvalue problems, root finding. Returns solutions with error bounds, condition numbers, and convergence history. |
| Optimization | Convex (CVXPy), nonlinear (SciPy), multi-objective (pymoo). Auto-classifies convexity. Returns optimal values, Lagrange multipliers, Pareto fronts. |
| Control Systems | Transfer function and state-space analysis. Bode, Nyquist, root locus. Stability margins. Controller design (PID, LQR, H-infinity). |
| Signal Processing | FFT/STFT, wavelet transforms, filter design, spectral density. Returns spectrum plots, filter coefficients, time-frequency representations. |
| Statistical Analysis | Hypothesis testing, regression, time series, Bayesian inference, survival analysis. Auto-propagates uncertainty. Returns test statistics and diagnostic plots. |
| Simulation | Dynamic systems (continuous, discrete, hybrid), Monte Carlo, sensitivity analysis. Returns time series, phase portraits, and uncertainty bounds. |
| Method Comparison | Solve the same problem with multiple methods. Compare accuracy, speed, memory, and stability side-by-side with a recommendation and rationale. |
Using GhostScience from Chat
When PhD Mode is enabled and the sandbox is available, the eight scientific tools are registered as LLM tool calls in the chat interface. Ask a scientific question in any notation:
- LaTeX: "Evaluate $\int_0^\infty e^{-x^2} dx$"
- MATLAB-style: "Solve the transfer function tf([1 2], [1 3 2]) and plot the Bode diagram"
- Natural language: "Integrate x squared plus 3x with respect to x"
- Python: "Use scipy to solve the Lorenz attractor ODE system"
The LLM classifies the problem, selects the appropriate tool, and invokes it through the scientific orchestrator. Results are rendered with interactive Plotly charts, KaTeX-formatted equations, and step-by-step explanations.
See DSL Syntax Guide for the full input format reference.
AI-Powered Scientific Reasoning
The LLM reasoning layer adds capabilities that traditional tools lack:
- Problem classification -- identifies PDE type, detects stiffness, classifies optimization convexity before selecting a solver
- Method selection -- chooses solvers based on problem structure, explains the choice, and compares alternatives
- Numerical awareness -- monitors condition numbers, convergence rates, and truncation errors
- Validation -- substitutes results back into original equations, checks conservation laws, compares with limiting cases
- Physical intuition -- tracks units via Pint, references CODATA physical constants, catches dimensional inconsistencies
- Research continuity -- remembers variable definitions, model structures, and method preferences across sessions
PhD Sandbox
The sandbox is a hardened Docker container running a curated scientific Python stack with 50+ libraries across 17 domains:
| Domain | Libraries |
|---|---|
| Symbolic Math | SymPy, galgebra |
| Numerical Computing | JAX, SciPy, NumPy |
| Optimization | CVXPy, pymoo |
| Control Systems | python-control, slycot |
| Signal Processing | PyWavelets, librosa |
| Statistics | statsmodels, PyMC, ArviZ |
| Uncertainty | uncertainties, SALib |
| Units | pint, scipy.constants |
| Visualization | Plotly, PyVista, matplotlib |
The full library stack is listed in requirements-phd.txt and requirements-phd-full.txt (extended stack). See the PhD Sandbox Deployment Guide for Docker image details.
Security
The PhD sandbox inherits and extends the Code Interpreter security model:
- gVisor isolation -- intercepts syscalls at the kernel boundary
- Custom seccomp profile -- allows computation syscalls, denies network and ptrace
- Read-only filesystem -- only
/workspaceand/tmpare writable - No network -- blocked at the kernel level
- Resource caps -- CPU, memory, and execution time are hard-limited per container
- Supply chain -- all packages pinned with SHA-256 hashes, images scanned with Trivy/Grype
Provenance
Every computation produces an immutable provenance record containing the tool name, parameters, generated code, environment hash, execution metrics, result hash, method rationale, unit verification, uncertainty summary, and data lineage. Records satisfy FDA 21 CFR Part 11, SOX Section 404, HIPAA, and NERC CIP audit requirements.
See Provenance & Export for the full record schema and export formats.
Reproducibility
GhostScience guarantees bitwise-identical results for deterministic computations:
- All generated code sets explicit random seeds
- NumPy and SciPy random generators are seeded from the provenance record
- The environment hash (image ID + library versions + config) is stored
- A verification endpoint (
POST /api/phd/reproduce/{id}) re-executes a computation and compares result hashes
Configuration
| Variable | Default | Description |
|---|---|---|
PHD_MODE_ENABLED | false | Master toggle for GhostScience |
PHD_SANDBOX_IMAGE | ghostai-phd-sandbox:latest | CPU sandbox Docker image |
PHD_SANDBOX_GPU_IMAGE | ghostai-phd-sandbox-gpu:latest | GPU sandbox image (CUDA 12.2) |
PHD_SANDBOX_TIMEOUT | 300 | Max execution time (seconds) |
PHD_SANDBOX_MEMORY_LIMIT | 4g | Container memory limit |
PHD_SANDBOX_CPU_LIMIT | 2.0 | CPU cores per container |
PHD_PARALLEL_MAX | 4 | Max concurrent PhD executions |
PHD_GPL_FREE | false | Exclude GPL-licensed libraries |
PHD_MAX_SESSIONS_PER_USER | 3 | Persistent session limit per user |
PHD_MAX_SESSIONS_PER_ORG | 20 | Persistent session limit per org |
PHD_SESSION_TTL_HOURS | 24 | Session expiry |
PhD Mode also requires the general sandbox to be enabled (SANDBOX_ENABLED=true).
Related
- DSL Syntax Guide -- input format reference
- Clean Room -- federated multi-org computation
- Workspaces -- persistent notebook-style workspaces
- Provenance & Export -- audit trail and export formats
- Examples -- 32 runnable example scripts
- PhD API Reference -- programmatic API
- SDK Reference -- Python client library
- PhD Sandbox Deployment -- Docker image setup
- Admin Configuration -- environment variables and limits
- GhostScience Whitepaper -- full technical whitepaper