{"id":28426267,"url":"https://github.com/ajitashwath/sarcasm-detection","last_synced_at":"2026-04-15T13:33:35.188Z","repository":{"id":263174893,"uuid":"889579665","full_name":"ajitashwath/sarcasm-detection","owner":"ajitashwath","description":null,"archived":false,"fork":false,"pushed_at":"2024-12-06T08:18:38.000Z","size":1885,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-15T09:44:23.648Z","etag":null,"topics":["bert-model","nlp-machine-learning","tensorflow"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ajitashwath.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-16T17:30:28.000Z","updated_at":"2026-02-10T18:59:07.000Z","dependencies_parsed_at":"2025-03-22T03:51:52.796Z","dependency_job_id":null,"html_url":"https://github.com/ajitashwath/sarcasm-detection","commit_stats":null,"previous_names":["ajitashwathr10/sarcasm-detection","ajitashwath/sarcasm-detection"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ajitashwath/sarcasm-detection","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajitashwath%2Fsarcasm-detection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajitashwath%2Fsarcasm-detection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajitashwath%2Fsarcasm-detection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajitashwath%2Fsarcasm-detection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ajitashwath","download_url":"https://codeload.github.com/ajitashwath/sarcasm-detection/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajitashwath%2Fsarcasm-detection/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31842937,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-15T13:28:40.153Z","status":"ssl_error","status_checked_at":"2026-04-15T13:28:29.396Z","response_time":63,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bert-model","nlp-machine-learning","tensorflow"],"created_at":"2025-06-05T11:09:27.257Z","updated_at":"2026-04-15T13:33:35.181Z","avatar_url":"https://github.com/ajitashwath.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sarcasm Detection using Deep Learning  \n\nThis project combines traditional machine learning and advanced deep learning techniques to accurately detect sarcasm in text. By leveraging both TF-IDF-based Random Forest models and the power of BERT, it ensures robust performance across various datasets.\n\n## Features  \n\n### 1. Advanced Text Preprocessing  \n- Custom `TextPreprocessor` Class: Handles text cleaning, lemmatization, and tokenization.  \n- Stopword Removal: Removes common words that don’t contribute to meaning.  \n- Special Character Handling: Filters out unnecessary symbols and punctuations.  \n\n### 2. Dual Model Architecture  \n- Traditional ML Model: Uses TF-IDF features and a Random Forest classifier for sarcasm detection.  \n- Deep Learning Model: Implements a fine-tuned BERT model for contextual understanding.  \n- Ensemble Prediction: Combines predictions from both models for improved accuracy.  \n\n### 3. BERT Integration  \n- Pre-Trained Model: Uses BERT for advanced feature extraction.  \n- Custom Dataset Class: Prepares input for BERT with attention masks and tokenization.  \n- Context Understanding: Captures nuanced meanings for accurate sarcasm detection.  \n\n### 4. Better Feature Engineering  \n- TF-IDF Representation: Replaces basic CountVectorizer for better feature weighting.  \n- N-Gram Support: Includes uni-grams, bi-grams, and tri-grams for richer features.  \n- BERT Word Embeddings: Utilizes BERT's contextual embeddings for deep learning.  \n\n### 5. Improved Training Process  \n- Train/Validation Split: Ensures reliable performance evaluation.  \n- Cross-Validation: Supports robust model tuning.  \n- Learning Rate Optimization: Implements dynamic learning rates for faster convergence.  \n- Dropout Regularization: Prevents overfitting in deep learning models.  \n\n### 6. Additional Functionality  \n- Device Support: Compatible with both CPU and GPU for training and inference.  \n- Comprehensive Evaluation Metrics: Includes accuracy, precision, recall, F1-score, and more.  \n- Flexible Predictions: Choose between traditional ML, BERT, or ensemble methods.  \n\n## Requirements  \n- Python 3.12+\n- Jupyter Notebook\n- Libraries:  \n  - TensorFlow / PyTorch  \n  - NLTK  \n  - Transformers  \n  - Scikit-Learn\n  - re\n  - Matplotlib\n  - Collections\n  - Numpy\n  - Pandas\n\n## Installation \n1. Clone the repository\n   ```bash\n   git clone https://github.com/ajitashwathr10/Sarcasm-Detection.git\n   cd Sarcasm-Detection\n   ```\n2. Set up a virtual environment (Optional)\n   ```bash\n   python -m venv venv\n   source venv/bin/activate       # On Linux/Mac\n   venv\\Scripts\\activate          # On Windows\n   ```\n3. Install Dependencies\n   ```bash\n   pip install -r requirements.txt\n   ```\n4. Download Pre-Trained BERT Model\n   - This project uses the Hugging Face Transformers library. Ensure you have internet access when running the model to automatically download the pre-trained BERT weights.\n\n5. Verify Installation\n   ```bash\n   python test_installation.py\n   ```\n### Additional Notes\n- For GPU support, ensure you have CUDA installed and install the GPU-compatible version of TensorFlow or PyTorch\n  ```bash\n  pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu117\n  ```\n  ```bash\n  pip install tensorflow-gpu\n  ```\nNow you're ready to start detecting sarcasm!\n\n## Usage\n1. Preprocess Data\n   - Prepare your dataset using the `TextPreprocessor` class to clean and tokenize text.\n2. Train Models\n   - Train the traditional and deep learning models using the provided training pipelines.\n3. Make Predictions\n   - Use the ensemble or individual models to predict sarcasm in new textual data.\n- Example:\n  ```bash\n  from sarcasm_detector import SarcasmDetector\n  detector = SarcasmDetector()\n  detector.train(\"path/to/dataset.csv\")\n  predictions = detector.predict([\"This is such a great day!\", \"Oh, what a surprise...\"])\n  print(predictions)\n  ```\n\n## Contributing\nWe welcome contributions to enhance this project. Feel free to submit pull requests or raise issues!\n\n## License\nThis project is licensed under the MIT License. See the LICENSE file for details.\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fajitashwath%2Fsarcasm-detection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fajitashwath%2Fsarcasm-detection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fajitashwath%2Fsarcasm-detection/lists"}