AI-Powered Duplicate News Detection System
Similify Backend is a FastAPI-based NLP service that detects duplicate or highly similar articles using TF-IDF vectorization and cosine similarity scoring.
Similify API allows you to:
- Detect duplicate or near-duplicate articles
- Calculate similarity scores
- Flag content above a configurable threshold
- Integrate easily with web or mobile applications
The system loads a pre-trained TF-IDF vectorizer and similarity matrix to deliver fast, real-time responses.
- Text cleaning & preprocessing
- TF-IDF vector transformation
- Cosine similarity computation
- Ranking top similar articles
- Duplicate detection based on threshold
similify-backend/
│
├── app.py # FastAPI main application
├── utils.py # Cleaning & similarity logic
├── clean_data.csv # Preprocessed dataset
├── tfidf_matrix.pkl # Stored TF-IDF matrix
├── vectorizer.pkl # Saved TF-IDF vectorizer
├── requirements.txt # Project dependencies
└── README.md
- Python
- FastAPI
- Scikit-learn
- Pandas
- NumPy
- Uvicorn
- 🔎 Real-time similarity detection
- 📊 Similarity score percentage output
- 🚨 Configurable duplicate threshold (default: 0.80)
- ⚡ High-speed response using precomputed TF-IDF
- 🌍 RESTful API
- 📁 CSV dataset support
git clone https://github.com/shabbir0000/Similify_Model.git
cd Similify_Modelpython -m venv venvActivate environment:
Windows
venv\Scripts\activatemacOS/Linux
source venv/bin/activatepip install -r requirements.txtuvicorn app:app --reloadServer runs at:
http://127.0.0.1:8000
Swagger Docs available at:
http://127.0.0.1:8000/docs
{
"text": "Man killed after entering perimeter of Trump’s Mar-a-Lago resort",
"top_n": 5
}{
"is_duplicate": true,
"results": [
{
"article_id": 25,
"title": "Government Budget Talks with IMF",
"source_name": "News Agency",
"url": "https://example.com/news",
"similarity_score": 0.87
}
]
}Default threshold:
0.80
Recommended tuning:
- 0.75 → Less strict
- 0.80 → Balanced (Recommended)
- 0.85 → Very strict duplicate detection
Modify inside your similarity function:
duplicate_threshold = 0.80Start server:
uvicorn app:app --reloadThen:
ngrok http 8000Use generated HTTPS URL in your frontend/mobile app.
- News Agencies
- Content Publishing Platforms
- Plagiarism Detection Systems
- AI Content Validation
- SEO Quality Control
- Semantic similarity (BERT / Transformers)
- Database integration (PostgreSQL / MongoDB)
- Elasticsearch support
- Authentication & Rate limiting
- Docker containerization
Muhammad Shabbir AI Engineer | NLP & AI Automation Specialist