Skip to main content

Add your description here

Project description

Practical Sentiment and Emotion Analysis with DistilBERT, RoBERTa, and Meta-Llama

Welcome to the Sentiment and Emotion Analysis Application repository! This guide provides a detailed overview of how to run a sentiment and emotion analysis tool using both Streamlit and Gradio interfaces. This project demonstrates how to integrate advanced AI models with user-friendly interfaces for practical natural language processing tasks.

  • Script Folder: This repository contains the scripts required to run the sentiment and emotion analysis application with both Streamlit and Gradio.

Overview

This application utilizes the distilbert-base-multilingual-cased-sentiments-student model for sentiment analysis, the roberta-base-go_emotions model for emotion detection, and the meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo model for personalized advice generation. The sentiment analysis covers three categories: positive, negative, and neutral, while the emotion detection identifies the top six emotions with corresponding scores. The advice generation provides practical suggestions based on the sentiment and emotions detected, incorporating context from the original user prompt.

The application provides two interfaces:

  • Streamlit Interface: For a web-based interactive experience with additional features.
  • Gradio Interface: For a quick and easy web-based demo with suggestion capabilities.

For detailed information about the models used, refer to the used_model_details.ipynb notebook.

This guide covers:

  • Prerequisites: Necessary tools and software.
  • Installation Instructions: How to set up your environment.
  • Running the Application: Detailed commands to launch either interface.
  • Troubleshooting: Common issues and their solutions.
  • Contribution Guidelines: How to contribute to the project.
  • Additional Resources: Links for further reading.

Prerequisites

Before you begin, ensure you have the following tools installed on your system:

  1. Conda: Follow the instructions on the Miniconda installation page to install Conda.
  2. Bash: Bash is typically included with Unix-based systems (Linux, macOS). For Windows users, consider using Git Bash or the Windows Subsystem for Linux (WSL).

Installation Instructions

Follow these steps to set up your environment and install the necessary packages:

  1. Clone the Repository

    Clone this repository to your local machine:

    git clone https://github.com/yourusername/sentiment-analysis-app.git
    cd sentiment-analysis-app
    
  2. Run the Setup Script

    The setup_environment.sh script automates the environment setup process. It creates and activates a Conda environment, installs necessary packages, and provides options to run the application using Streamlit or Gradio.

    bash setup_environment.sh
    

    The script will prompt you with a menu to choose between the following options:

    • Run with Streamlit interface
    • Run with Gradio interface
    • Update dependencies
    • Exit

    Choose the appropriate option to proceed.

Running the Application

You can run the application using the provided script:

Launch Streamlit Interface

To run the application with Streamlit, select the Streamlit interface option from the setup script menu, or use the following command:

python run_sentiment_analysis.py --interface streamlit

This will start a local Streamlit server and open your default web browser to view the application. The Streamlit interface includes:

  • Theme Selection: Choose between Normal, Unnormal, or Fun themes.
  • Sentiment and Emotion History: View past sentiment and emotion analyses.
  • Interactive Tutorial: Get a guided tour of the application.
  • Animated Transitions: Experience dynamic visual effects for sentiment scores.
  • Twitter Sharing: Share your analysis results directly on Twitter.
  • Visualization: Displays sentiment and emotion scores using colorful bar charts.
  • Personalized Advice: Generates advice based on sentiment and emotion analysis using the meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo model.

Launch Gradio Interface

To run the application with Gradio, select the Gradio interface option from the setup script menu, or use the following command:

python run_sentiment_analysis.py --interface gradio

This will start a local Gradio server and open your default web browser to view the application. The Gradio interface features:

  • Twitter Sharing: Share your analysis results directly on Twitter.
  • Visualization: Displays sentiment and emotion scores using bar charts.
  • Suggestion Options: Offers pre-prepared text options that users can pick from to facilitate analysis.

Troubleshooting

  • Streamlit Command Not Found: Ensure Streamlit is installed correctly. Verify by running streamlit --version.
  • Gradio Command Not Found: Ensure Gradio is installed correctly. Verify by running pip show gradio.
  • Environment Activation: Ensure the Conda environment is activated with conda activate sentiment_analysis.

If you encounter issues, verify that you are in the correct directory and that all dependencies are installed.

Contributing

Contributions to enhance this application are welcome! If you have suggestions, improvements, or additional features, please feel free to open an issue or create a pull request. Let's collaborate to make this tool even more useful for sentiment and emotion analysis.

Additional Resources

Explore additional resources to deepen your understanding of sentiment and emotion analysis and the tools used:

License

The content in this repository is licensed under the MIT License. You are free to use, modify, and distribute the code, provided you include the original copyright notice and license.


© 2024 Erfan Shafiee Moghaddam

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sentiment_emotion_detection-0.1.0.tar.gz (167.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sentiment_emotion_detection-0.1.0-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

Details for the file sentiment_emotion_detection-0.1.0.tar.gz.

File metadata

File hashes

Hashes for sentiment_emotion_detection-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b95e29aceaa7b5cb44626cd0eb79de0b2c0102c727485e213181f4a92f258679
MD5 2a48276280896a93421b2941dccb37b2
BLAKE2b-256 eae63d91e6f987af7768cb9a80a1851128e00974c3dae27e2e718d2e70c01c08

See more details on using hashes here.

File details

Details for the file sentiment_emotion_detection-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for sentiment_emotion_detection-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c07ec0feb00fc4ee58d13f0a306bd5a881081ef0912f492e0e32f43bc6323b50
MD5 5b9cd6752ddcc1f91916ab4e0e3df892
BLAKE2b-256 4b3c00add60ea1c0ac3dc69e67379b775130a0724f9d0869c18a4658e4a33c64

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page