INSPIRATION

About 3 years ago, I started a PhD in Chemical Engineering with a dream to change the world. This decision was driven by a life-changing experience with COVID in 2020. When COVID hit, the world became sick with a disease that wiped out about 7.1 million people, of which about 17.1% of those deaths happened in the US alone. The experience was overwhelming and the way forward — unclear. Pharmaceutical companies raced against time to develop solutions. Pfizer and BioNTech developed Comirnaty, one of the first mRNA drugs authorized by the FDA in 2020, along with Paxlovid, an oral antiviral for patients already affected. These drugs teach your body to generate its own antibodies. But it wasn't enough — patients with weaker immune systems often died before their bodies got the chance to fight back. Research scientist knew this wasn't sustainable, so they developed monoclonal antibodies (mAbs) that could immediately protect individuals upon administration. Eli Lilly developed bamlanivimab, the first mAb product used in the US. Genentech repurposed Actemra, originally an arthritis drug, to treat severely hospitalized COVID patients. In both cases, mAbs were the key to better outcomes but it came with its own challenges.

mAbs are proteins, and they often change shape during development and delivery. This conformational change reduces drug efficacy — sometimes rendering the treatment useless. In the early phase of my research, I spent long hours trying to understand why mAbs change shape and how to stabilize them. It was an iterative, manual process that could have been solved using AI, but I didn't have a way to do it efficiently — until today.

WHAT STABILITY AI DOES

mAb StabilityAI is a five-module scientific platform that predicts and validates monoclonal antibody structural stability:

1) Stability Risk Analysis — Input formulation parameters (mAb concentration, pH, buffer system, protein stabilizer, temperature, and interface type) and receive an AI-generated risk assessment with a visual gauge chart, color-coded risk badge, and a five-axis formulation score breakdown. The AI identifies specific degradation mechanisms, evaluates formulation choices, and provides actionable recommendations grounded in scientific literature.

2) Mechanism Explorer — Select any interface type (air-liquid, silicone oil, glass, stainless steel, ice-liquid, rubber stopper, or plastic) and receive a detailed scientific explanation of how that interface causes mAb instability — from molecular adsorption forces to aggregation pathways to real-world manufacturing implications.

3) Formulation Comparison — Enter two formulations side-by-side and the app generates a radar chart overlaying their scores across five stability dimensions, composite scores out of 50, an AI-powered verdict identifying which formulation is superior, and specific recommendations for improving the weaker one.

4) Literature & Research — Query Gemini 3 Pro's scientific knowledge base on any topic related to mAb stability, HIPE model systems, or analytical techniques, and receive a structured literature review with key findings, relevant references, and connections to experimental work.

5) HIPE Experimental Pipeline — This is the core scientific engine of Stability AI. Upload or generate NMR DOSY diffusion data, Circular Dichroism spectra, or microscopy timeline observations. The app automatically fits mathematical models (mono-exponential for free diffusion, bi-exponential for restricted diffusion, selected via AIC model comparison), generates interactive visualisations, and sends the quantitative results to Gemini 3 Pro for expert-level interpretation — translating HIPE experimental findings into mAb stability predictions.

HOW I BUILT IT

To study mAb stability without the prohibitive cost of working with actual monoclonal antibodies, I used protein-stabilized HIPEs (High Internal Phase Emulsions) as a model system. Proteins such as BSA and lysozyme act as emulsifiers in these systems, mimicking how mAbs adsorb and behave at interfaces. The idea was simple: if I could ensure HIPEs are stable under different experimental conditions, I could predict the same for mAbs. The app was built with Streamlit for the frontend, Google Gemini 3 Pro as the AI reasoning engine, and Python (NumPy, SciPy, Plotly) for the scientific computation layer. The architecture separates concerns cleanly: prompts.py — Eight carefully engineered prompt templates that encode domain expertise as structured instructions for Gemini 3 Pro, ensuring scientifically rigorous and consistently formatted outputs.

gemini_client.py — API abstraction layer with streaming responses, exponential backoff retry logic, content safety handling, and zero UI coupling.

hipe_analysis.py — The scientific computation engine: curve fitting (mono-exponential and bi-exponential decay models), automatic model selection via Akaike Information Criterion (AIC), CD spectrum analysis, microscopy timeline processing, and robust CSV parsing.

app.py — The Streamlit interface with five tabs, interactive Plotly charts (risk gauges, radar comparisons, DOSY decay curves, CD spectra, microscopy timelines), session state caching, and formulation scoring heuristics grounded in biopharmaceutical best practices.

CHALLENGES I RAN INTO

Crash-proofing for live demo ; The Gemini API can return 429 (rate limited), 500, 503, or 504 errors mid-stream. If the app retries after partial content has already been displayed, the output gets duplicated and corrupted. We solved this with a chunks_yielded flag that prevents retries once any content has been streamed to the user.

Bi-exponential curve fitting ; Fitting a four-parameter model (I0, xi, Df, Ds) to noisy experimental data is numerically unstable. Initial parameter guesses and bounds had to be carefully tuned, and we implemented automatic model selection using AIC to prevent overfitting when the simpler mono-exponential model is sufficient.

Encoding edge cases: Real-world CSV files from lab instruments come with BOM markers, semicolon delimiters, latin-1 encoding, and header rows. The parser had to handle all of these gracefully without crashing.

Content safety filters: The Google API occasionally blocks scientific content. We added specific error handling that catches these blocks and provides a clear user-facing message instead of a cryptic stack trace.

ACCOMPLISHMENTS I AM PROUD OF

The HIPE-to-mAb bridge — This is the first tool to codify the scientific insight that protein-stabilized HIPE experiments can predict mAb stability behavior, turning months of PhD research into an accessible AI-powered platform.

1) Automatic model selection via AIC — The app doesn't just fit one model — it fits both mono-exponential and bi-exponential decay, compares them using the Akaike Information Criterion, checks that the Df/Ds ratio exceeds 2x (ensuring the two diffusion pools are physically distinct), and explains why it chose the model it did.

2) Zero crashes in testing — After comprehensive crash-proofing (10 distinct failure vectors identified and patched across 3 files), the app handles rate limits, network errors, safety filters, division by zero, encoding issues, and empty responses gracefully.

3) Visual impact — Interactive risk gauge charts, radar comparison plots, DOSY decay curves with fitted overlays, CD spectra with annotated bands, and microscopy timelines — all in a dark-themed, publication-quality interface.

WHAT WE LEARNED

1) Domain expertise is the real differentiator: Anyone can call an LLM API. What makes this tool valuable is the structured scientific prompts, the HIPE experimental pipeline, and the scoring heuristics, all grounded in real biopharmaceutical research.

2) Streaming AI responses need careful error handling — You can't just retry on failure. If content has already been shown to the user, retrying would duplicate it. This subtle bug would have crashed our demo if we hadn't caught it.

3) AIC beats manual model selection: Instead of asking users to choose between mono-exponential and bi-exponential fits, letting the math decide (with a physical sanity check on the Df/Ds ratio) produces better results and a cleaner user experience.

WHATS NEXT FOR PROJECT STABLE mAb

1) Real experimental data integration — Connect directly to NMR spectrometer output formats (Bruker TopSpin, JEOL Delta) and CD spectrophotometer exports for seamless lab-to-AI workflows. Predictive degradation modeling.

2) Use Gemini to build time-series stability predictions: given a formulation, forecast aggregation rates, shelf life, and optimal storage conditions over months.

3) Multi-antibody comparison database — Build a persistent database of analyzed formulations so researchers can compare against historical results and identify optimal parameter combinations across antibody classes.

4) Collaboration with pharma partners — Validate the HIPE-to-mAb correlation engine against real mAb stability data from pharmaceutical development pipelines, turning this proof-of-concept into a validated industry tool.

Built With

Share this project:

Updates