NewsLens is a web application that helps users explore how different news sources present the same topic.
The application retrieves relevant news articles, extracts their content, generates concise summaries, and uses a fine-tuned RoBERTa model to classify the political perspective of each article as Left, Center, or Right.
The goal is not to determine whether an article is true or false, but to help users compare different perspectives on the same topic.
-
๐ Search for news topics
-
๐ฐ Retrieve articles from multiple news sources
-
โ๏ธ Generate concise article summaries using BART
-
๐ง Predict political perspective using a fine-tuned RoBERTa model
-
โ๏ธ Classify articles as:
- Left
- Center
- Right
-
๐ Group articles by political perspective
-
๐ React-based user interface
-
โก FastAPI backend for AI inference and news processing
User
โ
โผ
React Frontend
โ
โ HTTP Request
โผ
FastAPI Backend
โ
โผ
NewsAPI
โ
โผ
Article Extraction
โ
โโโโโโโโดโโโโโโโ
โผ โผ
BART Summarizer RoBERTa
โ โ
โผ โผ
Summary Bias Prediction
โ
โโโโโโโโโผโโโโโโโโ
โผ โผ โผ
Left Center Right
โ โ โ
โโโโโโโโโผโโโโโโโโ
โผ
React Frontend
The user enters a search query through the React frontend.
The backend sends the query to NewsAPI and retrieves relevant article metadata and URLs.
The backend extracts the full text from the returned article URLs.
The extracted article text is passed to BART (facebook/bart-large-cnn).
BART generates a shorter summary containing the main information from the article.
Before text is processed by the transformer models, it is converted into tokens using Hugging Face tokenizers.
Raw Text
โ
Tokenizer
โ
Token IDs
โ
Transformer Model
โ
Prediction / Summary
The article text is passed to our fine-tuned RoBERTa classification model.
The model predicts one of three categories:
Left
Center
Right
The predicted category is then returned to the frontend.
| Model | Purpose |
|---|---|
| BART | Abstractive news summarization |
| RoBERTa | Political perspective classification |
facebook/bart-large-cnn is used to generate concise summaries of retrieved news articles.
A RoBERTa-based sequence classification model was fine-tuned using a labeled news-bias dataset to classify articles into Left, Center, and Right political perspectives.
The political perspective classifier was trained using the following dataset:
News Bias Detection Dataset
The dataset contains political perspective categories including:
- Political Left
- Political Center
- Political Right
The dataset provides training, validation, and test splits.
The trained RoBERTa model achieved the following validation results:
| Metric | Score |
|---|---|
| Accuracy | 86.60% |
| Precision | 86.68% |
| Recall | 86.60% |
| F1 Score | 86.60% |
- React
- TypeScript
- Tailwind CSS
- Axios
- Vite
- Python
- FastAPI
- Uvicorn
- Requests
- NewsAPI
- PyTorch
- Hugging Face Transformers
- RoBERTa
- BART
- Hugging Face Tokenizers
- Google Colab
- Git
- GitHub
- VS Code
AI-News-Perspective-Analyzer/
โ
โโโ backend/
โ โโโ routes/
โ โ โโโ search.py
โ โ
โ โโโ services/
โ โ โโโ article_service.py
โ โ โโโ inference_service.py
โ โ โโโ news_service.py
โ โ โโโ summary_service.py
โ โ
โ โโโ models/
โ โ โโโ ...
โ โ
โ โโโ app.py
โ โโโ requirements.txt
โ
โโโ frontend/
โ โโโ src/
โ โ โโโ components/
โ โ โโโ pages/
โ โ โโโ services/
โ โ โโโ types/
โ โ
โ โโโ package.json
โ
โโโ .gitignore
โโโ README.md
Trained model weights are excluded from the Git repository because of their large file size.
git clone <repository-url>
cd AI-News-Perspective-AnalyzerCreate a Python virtual environment:
python -m venv venvActivate it on Windows:
venv\Scripts\activateInstall dependencies:
pip install -r backend/requirements.txtCreate a .env file inside the backend:
NEWS_API_KEY=your_newsapi_keyStart the FastAPI server:
uvicorn app:app --reloadThe backend will run at:
http://127.0.0.1:8000
FastAPI documentation will be available at:
http://127.0.0.1:8000/docs
Navigate to the frontend:
cd frontendInstall dependencies:
npm installStart the development server:
npm run devThe frontend will normally be available at:
http://localhost:5173
The project requires API credentials that should not be committed to Git.
Example:
NEWS_API_KEY=your_api_keyAdd .env to .gitignore.
- Political perspective classification is a model prediction and should not be treated as an objective fact.
- Classification performance depends on the quality and distribution of the training data.
- Article extraction may fail for websites that restrict automated access.
- Summarization quality can vary depending on article structure and length.
- The current system primarily supports English-language news content.
- Improve classification accuracy with larger and more diverse datasets
- Add multilingual news analysis
- Add more news sources and APIs
- Provide confidence visualization for predictions
- Improve long-article summarization using chunking
- Deploy the complete application online
- Add article-to-article comparison
- Provide additional transparency about model predictions
Ganesh Karthik B.Tech Computer Science Engineering IIITDM Jabalpur
GitHub: ganeshkarthik016
This project is licensed under the MIT License.
See LICENSE for details.
NewsLens is an educational and research-oriented project.
The political perspective labels are AI-generated predictions based on patterns learned from the training data. They do not represent an absolute judgment of an article's political ideology, factual accuracy, or credibility.
Users should consult the original articles and multiple reliable sources when evaluating news.