Think clearer, argue better.
LogicLens is an intelligent reasoning assistant that helps users detect logical fallacies, strengthen arguments, and improve critical thinking skills. It combines a local ELECTRA-based ML model with LLM capabilities to provide comprehensive argument analysis using the Toulmin argumentation framework.
- Fallacy Detection: Local ML model trained on 4000+ samples, detecting 13 types of logical fallacies
- Toulmin Analysis: Break down arguments into Claim, Data, Warrant, Backing, Qualifier, and Rebuttal
- Dual-Mode Analysis:
- Support Mode: Get constructive feedback to strengthen your argument
- Defence Mode: Receive counter-arguments to stress-test your reasoning
- Real-time Scoring: Clarity, Logical Consistency, and Fallacy Resistance metrics
- Web Application - Full-featured chat interface for argument analysis
- Browser Extension - Analyze arguments anywhere on the web with a floating chatbot
- REST API - Unified backend serving both web and extension
LogicLens/
├── backend/ # Flask API Server
│ ├── gem_app.py # Main Flask application
│ ├── services/
│ │ ├── core_service.py # Core analysis logic
│ │ └── llm_client.py # LLM integration (OpenRouter)
│ ├── extension/
│ │ └── routes.py # Extension API routes
│ └── templates.json # Prompt templates
│
├── extension/ # Chrome Extension (Manifest V3)
│ ├── manifest.json
│ ├── popup.html/js # Extension popup UI
│ ├── content.js # Content script with floating chatbot
│ ├── background.js # Service worker
│ └── styles.css
│
├── public/ # Web Frontend
│ ├── index.html # Landing page
│ ├── chat.html # Main chat interface
│ ├── fallacies.html # Fallacy reference guide
│ └── data/
│ └── db.json # Chat history & insights storage
│
├── saved_models/ # Local ML Models
│ └── electra-logic/ # Fine-tuned ELECTRA for fallacy detection
│
└── requirements.txt # Python dependencies
- Python 3.10+
- Node.js (optional, for development)
- Chrome/Edge browser (for extension)
# Clone the repository
git clone <repository-url>
cd LogicLens
# Create virtual environment
python -m venv venv
# Activate virtual environment
# Windows:
.\venv\Scripts\activate
# Linux/Mac:
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Set up environment variables
cd backend
cp .env.example .env
# Edit .env with your API key (OpenRouter)Create backend/.env:
OPENROUTER_API_KEY=your_openrouter_api_key_herecd backend
python gem_app.pyServer runs at: http://localhost:5001
cd public
python -m http.server 3000Web app available at: http://localhost:3000
- Open Chrome →
chrome://extensions/ - Enable "Developer mode"
- Click "Load unpacked"
- Select the
extension/folder
| Endpoint | Method | Description |
|---|---|---|
/api/analyze_dual |
POST | Full dual-mode analysis (support + defence) |
/api/support_mode |
POST | Supportive analysis only |
/api/oppose_mode |
POST | Counter-argument generation |
/api/evaluate_user_response |
POST | Evaluate user's response to counter-argument |
| Endpoint | Method | Description |
|---|---|---|
/api/analyze |
POST | Quick argument analysis |
/api/detect-fallacies |
POST | Fallacy detection only |
/api/rewrite |
POST | Improve argument phrasing |
| Endpoint | Method | Description |
|---|---|---|
/api/recalculate_insights |
GET/POST | Recalculate global performance metrics |
LogicLens uses the Toulmin argumentation model to analyze arguments:
| Element | Description |
|---|---|
| Claim | The main assertion or conclusion |
| Data | Evidence or facts supporting the claim |
| Warrant | The logical connection between data and claim |
| Backing | Additional support for the warrant |
| Qualifier | Words that limit the claim's strength |
| Rebuttal | Conditions where the claim might not hold |
The local ML model detects 13 types of logical fallacies:
- Ad Hominem - Personal attacks
- Ad Populum - Appeal to popularity
- Appeal to Emotion - Emotional manipulation
- Circular Reasoning - Assuming the conclusion
- Equivocation - Ambiguous terms
- Fallacy of Credibility - False authority
- Fallacy of Extension - Straw man
- Fallacy of Logic - Non-sequitur
- Fallacy of Relevance - Red herring
- False Causality - Correlation ≠ causation
- False Dilemma - Either/or fallacy
- Faulty Generalization - Hasty conclusions
- Intentional Fallacy - Misrepresenting intent
- Backend: Flask, Python 3.10+
- ML Model: ELECTRA (fine-tuned), PyTorch, Transformers
- LLM: OpenRouter API (Gemma 3 27B)
- Frontend: Vanilla HTML/CSS/JS, Chart.js
- Extension: Chrome Manifest V3
- Database: JSON file storage
The app tracks your argumentation skills over time:
- Fallacy Resistance Score - How well you avoid logical fallacies
- Logical Consistency Score - Coherence of your arguments
- Clarity Score - How clearly you express ideas
- Radar Chart - Toulmin element strengths
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project was created for KU Hackfest 2025.
GENESIS
- Live Demo: Try LogicLens
- API Documentation: See API Endpoints section above
- Fallacy Guide: Fallacies Reference