Skip to content
/ ai4sci Public

AI for Scientific Discovery and Interpretation

Notifications You must be signed in to change notification settings

visriv/ai4sci

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🧠 ai4sci - reasoning and interpretation for science

*A Modern Agentic AI + LLMOps Project *


🌍 Project Overview

ai4sci is a production-grade LLM Agent designed to perform agentic reasoning and interpretation for scientific discovery. Before jumping into research, we experiemnt and implement the tools used for agentic reasoning for two other tasks:

  1. RCA analysis for ML engineer: given a bunch of logs, identify the root cause
  2. ESG Intelligence: document scoring and auditing

Tech Stack

  • Ollama + Llama 3.1 (local inference)
  • FastAPI (async LLM server)
  • VectorDB-based retrieval pipeline
  • Streaming evaluation + canary testing
  • Custom monitoring layer
  • Streamlit operations dashboard
  • Dockerized deployment
  • Simulated autoscaling

This is Task 1 of a 3-part AI project:

  1. Root Cause Analysis (SciRCA) β€” Completed
  2. ESG Intelligence (GreenDocs) β€” Document parsing, ESG scoring, LLM-based auditing
  3. AI4Science Reasoning Module β€” Model-driven scientific insight & anomaly interpretation

πŸ— Architecture (High-Level)

                β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                β”‚    Client App       β”‚
                β”‚(Streamlit Dashboard)β”‚
                β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                          β”‚  HTTP
                          β–Ό
                β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                β”‚    FastAPI Server   β”‚
                β”‚ - RCA Endpoint      β”‚
                β”‚ - Monitoring Layer  β”‚
                β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                        β”‚ Calls Agent
                        β–Ό
                β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                β”‚     RCA Agent      β”‚
                β”‚ - Tool calls       β”‚
                β”‚ - Multi-step plan  β”‚
                β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                        β”‚ LLM Chat
                        β–Ό
                β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                β”‚   Llama 3.1 (8B)    β”‚
                β”‚     via Ollama      β”‚
                β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ”§ Tech Stack

LLM / Agentic AI

  • Tool-using LLM agent (multi-step reasoning)
  • Local inference via Ollama
  • Chat + tool call parsing
  • RAG pipeline integration

LLMOps

  • FastAPI async server
  • Monitoring:
    • request count
    • latency
    • error rate
  • Canary evaluation
  • Model registry

Optimization

  • Quantized Llama models
  • Async batching of tool calls
  • Local GPU/Metal acceleration

Visualization & Ops

  • Real-time dashboard (Streamlit)
  • Logs viewer
  • Inference tester
  • Latency charts

RAGs

Reasoning

TODO


πŸ“¦ Directory Structure

scirca/
β”‚
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ agent/          ← RCA agent + LLM client
β”‚   β”œβ”€β”€ retriever/      ← RAG embedding + search
β”‚   β”œβ”€β”€ serve/          ← FastAPI server + monitors
β”‚   β”œβ”€β”€ utils/          ← YAML loader, logger
β”‚   └── models/         ← Model registry files
β”‚
β”œβ”€β”€ dashboard/
β”‚   β”œβ”€β”€ app.py          ← Streamlit GUI
β”‚   └── components/     ← metrics, logs, registry, tester
β”‚
β”œβ”€β”€ scripts/            ← CLI scripts (eval, run agent, benchmark)
β”œβ”€β”€ requirements.txt
└── Dockerfile

πŸ§ͺ Running Locally (macOS + Ollama)

1. Install Ollama

brew install ollama

2. Pull the model

ollama pull llama3.1:8b

3. Start Ollama

ollama serve

πŸš€ Start FastAPI Server

uvicorn src.serve.api:app --reload --port 8000

πŸ“Š Start Monitoring Dashboard

streamlit run dashboard/app.py

Open:
πŸ‘‰ http://localhost:8501

Dashboard Features:

  • Metrics (request rate, latency, errors)
  • Logs viewer (Docker/FastAPI logs)
  • Model registry viewer
  • Inference runner for RCA

🐳 Docker Deployment

Build

docker build -t scirca-api .

Run

docker run -p 8000:8000 scirca-api

Run dashboard

streamlit run dashboard/app.py

πŸ›  Example API Call

curl -X POST http://localhost:8000/rca   -H "Content-Type: application/json"   -d '{
        "run_summary": "Training failed with NaN loss",
        "logs": ["loss=0.5", "loss=0.7", "loss=nan"],
        "metrics": {"loss": [0.5, 0.7, "nan"]},
        "model_tag": "rca-v2"
      }'

Load testing via autoscaling

python scripts/load_test.py \
    --api http://localhost:8000 \
    --concurrency 50 \
    --total 500

or (this second one has been tested

bash scripts/run_load_test.sh

🧩 Roadmap (Task 2 & 3)

Task 2 β€” ESG Intelligence (GreenDocs)

Planned capabilities:

  • ESG report ingestion
  • Compliance summarisation
  • Automated ESG scoring
  • Greenwashing detection
  • Multi-document RAG

Task 3 β€” AI4Science Reasoning Module

Planned:

  • Scientific anomaly reasoning
  • Embedding-based pattern detection
  • Hypothesis generation
  • LLM-assisted interpretation of experimental results

About

AI for Scientific Discovery and Interpretation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors