Spaces:
Sleeping
Sleeping
Delete README.md
Browse files
README.md
DELETED
|
@@ -1,71 +0,0 @@
|
|
| 1 |
-
---
|
| 2 |
-
title: Trend Longevity Analyser
|
| 3 |
-
emoji: π
|
| 4 |
-
colorFrom: blue
|
| 5 |
-
colorTo: indigo
|
| 6 |
-
sdk: gradio
|
| 7 |
-
sdk_version: 4.44.0
|
| 8 |
-
app_file: app.py
|
| 9 |
-
pinned: true
|
| 10 |
-
---
|
| 11 |
-
|
| 12 |
-
# π Trend Longevity Analyser
|
| 13 |
-
|
| 14 |
-
A **RAG-powered trend intelligence tool** that classifies whether any topic is *Early, Rising, at Peak, Declining, or Fading* β using live news data.
|
| 15 |
-
|
| 16 |
-
## How It Works
|
| 17 |
-
|
| 18 |
-
This tool implements a full 6-step RAG (Retrieval-Augmented Generation) pipeline:
|
| 19 |
-
|
| 20 |
-
| Step | What Happens |
|
| 21 |
-
|------|-------------|
|
| 22 |
-
| **1. Fetch** | NewsAPI pulls up to 50 recent articles on your topic |
|
| 23 |
-
| **2. Chunk** | LangChain splits articles into overlapping 400-character chunks |
|
| 24 |
-
| **3. Embed** | `all-MiniLM-L6-v2` encodes each chunk into a 384-dim vector |
|
| 25 |
-
| **4. Store** | ChromaDB holds all vectors in an in-memory collection |
|
| 26 |
-
| **5. Retrieve** | Semantic search returns the 10 most relevant chunks |
|
| 27 |
-
| **6. Generate** | Claude analyses the retrieved context and returns a structured trend signal |
|
| 28 |
-
|
| 29 |
-
## Tech Stack
|
| 30 |
-
|
| 31 |
-
- **Retrieval:** [ChromaDB](https://www.trychroma.com) (vector store) + [Sentence Transformers](https://sbert.net) (embeddings)
|
| 32 |
-
- **Orchestration:** [LangChain](https://langchain.com) text splitting
|
| 33 |
-
- **News Data:** [NewsAPI](https://newsapi.org) (free tier)
|
| 34 |
-
- **Generation:** [Anthropic Claude](https://anthropic.com)
|
| 35 |
-
- **UI:** [Gradio](https://gradio.app)
|
| 36 |
-
|
| 37 |
-
## Setup
|
| 38 |
-
|
| 39 |
-
### Running Locally
|
| 40 |
-
|
| 41 |
-
```bash
|
| 42 |
-
git clone https://huggingface.co/spaces/lization/trend-longevity-analyser
|
| 43 |
-
cd trend-longevity-analyser
|
| 44 |
-
pip install -r requirements.txt
|
| 45 |
-
export NEWSAPI_KEY=your_key_here
|
| 46 |
-
export ANTHROPIC_API_KEY=your_key_here
|
| 47 |
-
python app.py
|
| 48 |
-
```
|
| 49 |
-
|
| 50 |
-
### HF Space Secrets
|
| 51 |
-
|
| 52 |
-
Set `NEWSAPI_KEY` and `ANTHROPIC_API_KEY` as Space Secrets under **Settings β Variables and Secrets**. If not set, users can enter keys directly in the UI.
|
| 53 |
-
|
| 54 |
-
## Get Your Free API Keys
|
| 55 |
-
|
| 56 |
-
- **NewsAPI:** [newsapi.org/register](https://newsapi.org/register) β free tier, 100 requests/day, last 30 days of articles
|
| 57 |
-
- **Anthropic:** [console.anthropic.com](https://console.anthropic.com) β Claude API
|
| 58 |
-
|
| 59 |
-
## Why RAG (Not Just a Prompt)?
|
| 60 |
-
|
| 61 |
-
Instead of passing all 50 articles to Claude (expensive, noisy, hits context limits), the RAG approach:
|
| 62 |
-
|
| 63 |
-
1. Embeds every chunk as a vector
|
| 64 |
-
2. Retrieves only the **10 most semantically relevant chunks** via cosine similarity
|
| 65 |
-
3. Passes those to Claude for analysis
|
| 66 |
-
|
| 67 |
-
This gives more focused, accurate, and cost-efficient results β and is directly analogous to production social listening systems used in enterprise contexts.
|
| 68 |
-
|
| 69 |
-
---
|
| 70 |
-
|
| 71 |
-
Built by [Sammie Wong](https://linkedin.com/in/sammie-wong/)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|