Vercel Python serverless functions cap deployment size at 250MB unzipped.
torch + numpy + model.pkl exceed this by 2-3x. Confirmed not feasible to
run the neural path (inference/solve.py) inside a Vercel function.
Chosen approach: Production (Vercel) runs FallbackSolver and optionally
GroqSolver only. The PyTorch neural model is scoped as a local
development and research tool.
- FallbackSolver (deterministic, pure-Python): Handles
diff,partial,integrate,gradient,tangent_linefor polynomial expressions. - GroqSolver (optional, LLM-based): Activated when
GROQ_API_KEYenv var is set. Uses Groq API for broader expression support. - No torch/numpy in
requirements.txt.
- Neural mode (
model/,train.py,checkpoints/): Gated behindrequirements-neural.txt. Used for training experiments and accuracy research. checkpoints/final/best.pt: Produced bytrain.py, used for local evaluation viarun_pipeline.py. Not deployed to Vercel.
FallbackSolver covers the full scope described in README.md's
"Key Features" for polynomial expressions. Neural mode is an accuracy
upgrade for non-polynomial rules (trig, exp, log) -- not a hard
requirement for the current launch.
Consider self-hosting the neural model (Render, Fly.io, HF Spaces) if:
- Non-polynomial rule support (trig, exp, log, chain rule) becomes a hard product requirement.
- The model demonstrates >90% accuracy on non-polynomial benchmarks.
- Latency from an external model service is acceptable (<2s p95).
At that point, deploy the PyTorch model as a separate microservice with
MODEL_PATH pointing to the hosted checkpoint, and route neural requests
from the Vercel API via HTTP.