Autonomous, GPU-Accelerated Research Discovery Pipeline on Google Cloud Run
"In a world drowning in information, the future belongs to systems that can think for themselves."
Project ECHO is a fully autonomous AI research intelligence system that crawls academic sources (arXiv, PubMed), analyzes papers using GPU-accelerated embeddings (Gemma 2B), clusters them with cosine similarity, summarizes with Gemini 1.5 Flash, and delivers weighted intelligence reports—all running serverless on Google Cloud Run with zero human intervention.
Key Innovation: Real-time, self-organizing topic discovery using online clustering with mathematical precision.
┌─────────────┐ Pub/Sub ┌──────────────┐ Pub/Sub ┌──────────────┐
│ │ echo-ingest │ │ echo-analyzed │ │
│ Crawler ├───────────────────>│ Analyzer ├──────────────────>│ Summarizer │
│ (Job) │ │ (GPU/L4) │ │ (Gemini) │
└─────────────┘ └──────────────┘ └──────────────┘
│
│ Pub/Sub
│ echo-summarized
v
┌──────────────┐
│ │
│ Reporter │
│ (Weighted) │
└──────┬───────┘
│
v
┌──────────────┐
│ │
│ Dashboard │
│ (Next.js) │
└──────────────┘
All services communicate via Pub/Sub push subscriptions with OIDC authentication. All data persists in Firestore.
- Project ID:
echo-476821 - Region:
europe-west4 - Execution: Cloud Run Gen2
- GPU: NVIDIA L4 (analyzer only)
- Artifact Registry:
echo-repo
For each document
Where
Compute similarity between embeddings:
Centroid Matching: For each new document embedding
Where
Threshold Decision: If $S(\mathbf{v}i, \mathbf{c}{k^*}) < \tau$ (where
Centroid Update: Use exponential moving average:
Where
For daily report, weight each topic by relative frequency:
Where
Generate abstractive summary using Gemini 1.5 Flash:
Where
# Install gcloud CLI
# https://cloud.google.com/sdk/docs/install
# Authenticate
gcloud auth login
gcloud auth application-default login
# Set project
gcloud config set project echo-476821
# Set Gemini API key
export GEMINI_API_KEY="your-gemini-api-key"# 1. Create Pub/Sub topics
./infra/scripts/create_topics.sh
# 2. Build all Docker images
./infra/scripts/build_all.sh # Takes ~15-20 minutes
# 3. Deploy all services
./infra/scripts/deploy_all_v1.sh
# 4. Create service account and bind
./infra/scripts/create_sa_and_bind.sh
# 5. Create Pub/Sub subscriptions
./infra/scripts/create_subscriptions.sh
# 6. Verify deployment
./infra/scripts/post_deploy_verify.sh# Execute crawler to fetch papers
gcloud run jobs execute crawler --region=europe-west4 --project=echo-476821
# Wait ~3-5 minutes for pipeline to complete
# View latest report
REPORTER_URL=$(gcloud run services describe reporter --region=europe-west4 --format='value(status.url)')
curl -s ${REPORTER_URL}/latest | jq '.html' -r
# Open dashboard
DASHBOARD_URL=$(gcloud run services describe dashboard --region=europe-west4 --format='value(status.url)')
open $DASHBOARD_URL- Function: Fetches arXiv RSS feed
- Publishes to:
echo-ingest - Schedule: On-demand via
gcloud run jobs execute - Output:
{doc_id, title, link, source, timestamp}
- GPU: NVIDIA L4
- Model: Gemma 2B (embeddings)
- Function: Generate embeddings, cluster documents, assign topics
- Subscribes to:
echo-ingest - Publishes to:
echo-analyzed - Storage: Firestore
analyses,centroids
Key Features:
- CUDA-accelerated inference
- Online centroid learning
- Automatic topic creation (max 20)
- Cosine similarity threshold: 0.8
- Model: Gemini 1.5 Flash
- Function: Generate abstractive summaries conditioned on topics
- Subscribes to:
echo-analyzed - Publishes to:
echo-summarized - Storage: Firestore
summaries
Prompt Engineering:
You are a research summarizer. Given the following research paper details,
create a concise, professional summary in ONE sentence.
Title: {title}
Abstract: {abstract}
Assigned Topics: {topics}
Provide a single-sentence summary that captures the key contribution
and relates to the assigned topics. Be precise and academic.
- Function: Aggregate summaries into weighted HTML digest
- Subscribes to:
echo-summarized - Storage: Firestore
reports - Endpoints:
GET /latest- Returns latest report with metadataGET /healthz- Health checkPOST /report- Generate report (Pub/Sub push)
Features:
- Time-windowed aggregation (24h)
- Topic weighting using
$\alpha_k = |C_k| / \sum_j |C_j|$ - Grouped by topic with percentages
- Framework: Next.js 15
- Function: Display latest report, system status, topic charts
- Features:
- Real-time data fetching with SWR
- Topic distribution pie charts
- Service health monitoring
- Material 3 design system
- Dark mode
| Component | Technology |
|---|---|
| AI/ML | Gemma 2B, Gemini 1.5 Flash, PyTorch, Transformers |
| Backend | Python 3.11, FastAPI, Uvicorn |
| Frontend | Next.js 15, React 19, TypeScript |
| Cloud | Google Cloud Run Gen2, Pub/Sub, Firestore |
| GPU | NVIDIA L4, CUDA 12.1 |
| Infra | Docker, Cloud Build, Artifact Registry |
| Auth | OIDC service account authentication |
documents
{
"doc_id": "arxiv-2501-12345",
"title": "Attention Is All You Need",
"link": "https://arxiv.org/abs/...",
"summary": "Abstract text...",
"source": "arxiv",
"timestamp": "2025-11-01T00:00:00Z"
}centroids
{
"topic_id": "topic_01",
"vector": [0.123, -0.456, ...], // n-dimensional
"dimension": 768,
"updated_at": "2025-11-01T12:00:00Z"
}analyses
{
"doc_id": "arxiv-2501-12345",
"topics": ["topic_01"],
"score": 92.5,
"embedding_ref": "embeddings/arxiv-2501-12345",
"analysis_time": 2.34,
"created_at": "2025-11-01T00:05:00Z"
}summaries
{
"doc_id": "arxiv-2501-12345",
"summary": "This paper introduces the Transformer architecture...",
"topics": ["topic_01"],
"model_used": "gemini-1.5-flash",
"summary_time": 1.23,
"created_at": "2025-11-01T00:06:00Z"
}reports
{
"html": "<h1>ECHO Research Intelligence Report</h1>...",
"created_at": "2025-11-01T06:00:00Z",
"topic_count": 5,
"summary_count": 23,
"version": "v1.0"
}- Pub/Sub Push: OIDC authentication with dedicated service account
- Service Account:
pubsub-push@echo-476821.iam.gserviceaccount.com - IAM Role:
roles/run.invokeron all services - Cloud Run: Public endpoints (can be restricted in production)
| Resource | Configuration | Monthly Cost (est.) |
|---|---|---|
| Analyzer (GPU) | L4, min=0, max=2 | $20-50 (pay per use) |
| Summarizer | CPU, min=0 | $5-10 |
| Reporter | CPU, min=0 | $2-5 |
| Dashboard | CPU, min=0 | $2-5 |
| Firestore | <1GB | Free tier |
| Pub/Sub | <10k messages | Free tier |
| Total | $30-70/month |
Key Optimizations:
- All services scale to zero when idle
- GPU only allocated during inference
- Lazy model initialization
- Efficient batch processing
- Embedding Generation: ~2s per paper (GPU)
- Summarization: ~1-2s per paper (Gemini)
- End-to-End Latency: ~5-7s per paper
- Throughput: 10+ papers/minute
- Cold Start: <30s (GPU model loading)
# Check all services
ANALYZER_URL=$(gcloud run services describe analyzer --region=europe-west4 --format='value(status.url)')
SUMMARIZER_URL=$(gcloud run services describe summarizer --region=europe-west4 --format='value(status.url)')
REPORTER_URL=$(gcloud run services describe reporter --region=europe-west4 --format='value(status.url)')
curl $ANALYZER_URL/healthz
curl $SUMMARIZER_URL/healthz
curl $REPORTER_URL/healthz# Publish synthetic document
gcloud pubsub topics publish echo-ingest \
--message='{"doc_id":"seed-001","title":"Sample AI Paper","link":"https://example.com","source":"seed","timestamp":"2025-11-01T00:00:00Z"}' \
--project=echo-476821
# Tail logs
gcloud beta logging tail 'resource.type=cloud_run_revision AND (resource.labels.service_name=analyzer OR resource.labels.service_name=summarizer OR resource.labels.service_name=reporter)' \
--project=echo-476821
# Check report
curl -s $REPORTER_URL/latest | jq '.html' -r# Check analyzer logs
gcloud beta logging tail 'resource.type=cloud_run_revision AND resource.labels.service_name=analyzer' --project=echo-476821
# Should see: "CUDA detected! Using GPU: Tesla L4"# Check subscription status
gcloud pubsub subscriptions describe sub-analyze --project=echo-476821
# Verify service account binding
gcloud run services get-iam-policy analyzer --region=europe-west4 --project=echo-476821# Ensure GEMINI_API_KEY is set
gcloud run services describe summarizer --region=europe-west4 --format='value(spec.template.spec.containers[0].env)'- Architecture Deep Dive: docs/arch.md
- Deployment Guide: DEPLOY.md
- API Reference: See service
main.pyfiles
- All services respond 200 on
/and/healthz - Analyzer runs on GPU and logs "CUDA detected"
- Pub/Sub push works with OIDC
- Firestore populated in all collections
- Dashboard renders latest report
- Docker images build reproducibly
- Scripts succeed on clean machine
- No mock data anywhere - all real AI
project-echo/
├── services/
│ ├── analyzer/ # GPU embeddings + clustering
│ ├── summarizer/ # Gemini summarization
│ ├── reporter/ # Weighted aggregation
│ └── crawler/ # ArXiv RSS fetcher
├── dashboard/ # Next.js frontend
├── infra/scripts/ # Deployment automation
├── docs/ # Architecture docs
└── README.md # This file
- Real AI: Gemma 2B embeddings, Gemini 1.5 Flash summaries
- Mathematical Rigor: Cosine similarity, online clustering, weighted aggregation
- Production Ready: Serverless, auto-scaling, GPU-accelerated
- Cost Efficient: ~$40/month, scales to zero
- Fully Autonomous: Zero human intervention
- End-to-End Working: Live demo available
MIT License - Built for $20K Hackathon Submission
- Google Cloud Platform
- Gemini AI
- Hugging Face Transformers
- FastAPI & Next.js communities
Project ECHO - Autonomous Research Intelligence for the AI Age
Built with ❤️ for the future of academic discovery