Inspiration
Every creator has posted something they thought would work — and watched it flop. Existing tools only tell you what happened after you posted. Generic advice like "use hashtags" and "be consistent" doesn't help when you're staring at a draft right now, wondering if it's worth publishing.
We wanted to build something that answers one question before you hit publish: will this specific post work, on this specific platform, right now — and exactly what to change if it won't.
What it does
PreViral is a pre-publication social media performance predictor powered by Gemini. Paste your caption, upload your thumbnail, select your platform — and in seconds you get:
- Viral confidence score — HIGH/MEDIUM/LOW with calibrated percentage, trained on 350K+ real social media posts across 6 platforms
- Causal "What to Change" suggestions — not generic tips, but specific counterfactual explanations powered by DICE-ML (e.g., "add 5-10 hashtags", "add a face to thumbnail", "add a CTA") — the exact changes that flip your score
- AI Content Director — Gemini reads your caption and thumbnail together as a multimodal input, rewrites your content, and the rewrite is re-scored by the ML model to prove it actually improved — no fake "+49%" claims
- 10-day reach trajectory — platform-specific impression curves shaped by content type (Reel vs Carousel, Short vs Long-form) and creator size
- Live trending hashtags — Gemini Search Grounding pulls real-time trend data for your niche
How we built it
ML Pipeline:
- LightGBM classifier trained on 352,000+ real posts from Instagram, TikTok, YouTube, Twitter/X, LinkedIn, and Facebook
- 22-feature vector: NLP (hook strength, sentiment, readability, emoji density), timing (hour/day/timezone optimization), hashtag quality (competition scores, trend velocity), and vision features
- DICE-ML counterfactual engine generates causal explanations — not correlations
- LSTM trajectory model for 10-day reach forecasting, calibrated per platform
Gemini Integration (5 deep integrations, not just chat):
- Multimodal Feature Extraction — caption + thumbnail analyzed together in one API call via
gemini-flash-lite-latest, extracting cross-modal alignment signals no text-only model can see - AI Content Director — 2-iteration model-validated rewrite loop: Gemini rewrites → LightGBM re-scores → best version selected. When the rewrite scores lower, we honestly tell you
- Search Grounding — real-time hashtag trend intelligence via Gemini's search capabilities
- Content Safety — uploaded images flagged for inappropriate content
- Visual Description Fallback — creators who don't want to upload images can describe their visual in text; Gemini estimates visual-caption alignment from the description
Infrastructure:
- FastAPI backend on Google Cloud Run (Mumbai region)
- Vanilla HTML/CSS/JS frontend — no framework overhead
- Parallel async pipeline: LightGBM + Gemini + trend grounding run concurrently
Challenges we ran into
- Thinking model token exhaustion:
gemini-flash-latestuses internal reasoning tokens before producing output. Withmax_output_tokens=4096, the model would "think" through its entire budget and return empty JSON — silently failing. We had to increase token headroom to 8192 and add explicit empty-response detection. - Honest AI evaluation: Gemini's self-estimated "+49% improvement" often contradicted our ML model's actual re-score. Rather than hiding this, we built the "Model-Validated Score Journey" that shows the real LightGBM delta and warns users when Gemini's creative instinct diverges from algorithmic optimization.
- Mega-creator trajectory calibration: Our trajectory model was trained on mid-tier creators. When testing against a 59M-subscriber YouTube channel, the model predicted 200K views for a video that got 25M. We added dynamic reach caps that scale with follower count and platform.
Accomplishments that we're proud of
- Honesty as a feature: When the AI rewrite scores lower than the original, we say so — and explain why. No other tool does this.
- Real validation: Tested against real creators — a 122K-subscriber YouTube channel and a 59M-subscriber channel — and refined our models based on actual outcomes, not just test-set metrics.
- True multimodal fusion: Gemini receives caption text and thumbnail image simultaneously in one API call, enabling cross-modal analysis that neither text-only nor image-only tools can produce.
What we learned
- LLMs are brilliant creative writers but unreliable self-evaluators. The only way to trust an AI rewrite is to score it with an independent model.
- "Accuracy" means nothing without honest calibration. Our F1 score on the test set was 84.89%, but real-world edge cases (niche vocabulary, mega-creators) exposed gaps we could only find by testing against real posts.
- Content moderation is a product design problem, not just a technical one — privacy-conscious creators need a "describe your visual" option, not a forced upload.
What's next for PreViral
- Expand real-world validation across more creators and platforms
- Add historical performance tracking (post it → see how your prediction held up)
- Instagram API integration for direct post scheduling
- Fine-tune the ML model on niche-specific training data to better handle subculture vocabulary
Built With
- dice-ml
- fastapi
- gemini-api
- google-cloud-run
- html
- javascript
- lightgbm
- lstm
- python
- pytorch
- sentence-transformers
Log in or sign up for Devpost to join the conversation.