TrendAnalysis / README.md
lization's picture
Rename README (1).md to README.md
348fd08 verified
|
Raw
History Blame Contribute Delete
2.58 kB

A newer version of the Gradio SDK is available: 6.25.0

Upgrade
metadata
title: Trend Longevity Analyser
emoji: πŸ“Š
colorFrom: blue
colorTo: indigo
sdk: gradio
app_file: app.py
pinned: true

πŸ“Š Trend Longevity Analyser

A RAG-powered trend intelligence tool that classifies whether any topic is Early, Rising, at Peak, Declining, or Fading β€” using live news data.

How It Works

This tool implements a full 6-step RAG (Retrieval-Augmented Generation) pipeline:

Step What Happens
1. Fetch NewsAPI pulls up to 50 recent articles on your topic
2. Chunk LangChain splits articles into overlapping 400-character chunks
3. Embed all-MiniLM-L6-v2 encodes each chunk into a 384-dim vector
4. Store ChromaDB holds all vectors in an in-memory collection
5. Retrieve Semantic search returns the 10 most relevant chunks
6. Generate Gemini analyses the retrieved context and returns a structured trend signal

Tech Stack

Setup

Running Locally

git clone https://huggingface.co/spaces/lization/trend-longevity-analyser
cd trend-longevity-analyser
pip install -r requirements.txt
export NEWSAPI_KEY=your_key_here
export ANTHROPIC_API_KEY=your_key_here
python app.py

HF Space Secrets

Set NEWSAPI_KEY and GEMINI_API_KEY as Space Secrets under Settings β†’ Variables and Secrets. If not set, users can enter keys directly in the UI.

Get Your Free API Keys

Why RAG (Not Just a Prompt)?

Instead of passing all 50 articles to Claude (expensive, noisy, hits context limits), the RAG approach:

  1. Embeds every chunk as a vector
  2. Retrieves only the 10 most semantically relevant chunks via cosine similarity
  3. Passes those to Claude for analysis

This gives more focused, accurate, and cost-efficient results β€” and is directly analogous to production social listening systems used in enterprise contexts.


Built by Sammie Wong