Skip to content

domsoos/hackathon26

Repository files navigation

🛡️ PostGuard — Privacy-Aware Consequence Intelligence System

CSGS Hackathon Spring 2026 | Track P6: Privacy-Preserving AI

PostGuard warns users about real-world consequences of their social media comments before they hit send — while minimising how much personal data the system needs to do so.


Architecture

User types comment
       ↓
  LLM 1 — Gemini Flash
  Extract violation attributes via context-aware ICL prompt
       ↓
  Embedding Model — text-embedding-004
  Convert RAG query to vector → search news corpus + policies
       ↓
  LLM 2 — Gemini Pro
  Generate user-facing warning with retrieved precedents
       ↓
  Warning shown BEFORE user posts

Two-LLM design

Model Role Why
Gemini Flash Attribute extraction (structured JSON) Fast + cheap for structured tasks
Gemini Pro Warning generation (natural language) Quality matters for user-facing output

Three privacy modes

Mode Data sent Privacy Utility
Anonymous Comment text only High Low — generic warnings
Contextual Comment + platform + role Medium Medium — role-specific
Full Profile Comment + role + org + history Low High — employer-policy specific

This tradeoff is the core P6 contribution.


Prompting strategy

Generalised prompts (not hardcoded to violation types)

All prompts reason from principles, not from a fixed taxonomy of violations. A new case type (e.g. UK NHS opioid disclosure) is handled by the model reasoning by analogy, not by matching a predefined label.

In-context learning (ICL)

Each prompt contains 2-3 worked examples with:

  • Input (comment + context)
  • Reasoning chain (step-by-step)
  • Output (structured JSON or formatted warning)

The model learns the expected reasoning pattern from examples alone. No fine-tuning required.


Setup

# 1. Clone and install
pip install -r requirements.txt

# 2. Configure
cp .env.example .env
# Edit .env with your GCP project ID

# 3. Authenticate
gcloud auth application-default login

# 4. Run the demo
streamlit run demo/app.py

# 5. Run tests
python -m pytest tests/ -v

Data

File Contents
data/social_media_consequences_dataset.json 15 real incidents
data/personas.json 15 synthetic user profiles
data/news_corpus.json 20 articles (15 relevant + 5 noise)
data/user_comment_histories.json 75 synthetic comments (5 per persona, escalating)
data/org_policies.json 15 org policy texts for RAG

Project structure

hackathon26/
├── src/
│   ├── prompts.py        # All prompts — generalised, ICL-powered
│   ├── embeddings.py     # Vertex AI text-embedding-004 wrapper
│   ├── rag.py            # In-memory RAG store with cosine similarity
│   ├── llm_clients.py    # Gemini Flash + Pro wrappers
│   └── pipeline.py       # End-to-end orchestration + privacy-utility measure
├── demo/
│   ├── app.py            # Streamlit demo UI
│   └── demo_cases.py     # Pre-built cases for presentation
├── tests/
│   └── test_retrieval.py # RAG accuracy + generalisation tests
├── data/                 # All JSON datasets
├── requirements.txt
└── .env.example

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors