Person
Person

Mini 3: Sentiment Analysis API

Overview:

Developed and deployed a user-friendly web application that performs real-time sentiment analysis on user-provided text using a pre-trained RoBERTa model from the Hugging Face ecosystem.

Project Description

This project is an interactive web API for real-time sentiment classification, built to analyze customer feedback in sectors like fintech and e-commerce. Powered by the cardiffnlp/twitter-roberta-base-sentiment model and built with Streamlit, the application provides an intuitive interface for classifying text as Positive, Negative, or Neutral. The project covers the full development lifecycle, from local setup and coding to final deployment on Hugging Face Spaces for public, interactive use.

Problem Statement

Businesses and individuals need accessible tools to quickly gauge public opinion or analyze customer feedback from text data. However, leveraging state-of-the-art NLP models often requires significant technical expertise in machine learning and backend development. This project addresses that gap by creating a ready-to-use web application that abstracts the complexity of a sophisticated RoBERTa model into a simple, interactive interface, allowing anyone to perform high-quality sentiment analysis instantly without any setup.
Car Side View

Methodologies & Project Workflow

  • Phase 1: Local Environment Setup:

    A clean and reproducible development environment was established by creating a dedicated project directory, setting up a Python virtual environment, installing all necessary libraries (streamlit, transformers, torch, etc.), and initializing a Git repository.


  • Phase 2: Streamlit Application Development:

    The core web application (app.py) was coded. This involved integrating the Hugging Face pipeline to load the RoBERTa model, designing a user-friendly UI with Streamlit components, implementing the sentiment analysis logic, and testing all functionalities locally.


  • Phase 3: GitHub Repository Setup:

    A public GitHub repository was created to host and share the project code. The local Git repository was linked to the remote on GitHub, and all project files were pushed, making the code base version-controlled and publicly accessible.

  • Phase 4: Deployment to Hugging Face Spaces:

    The application was deployed to a public cloud platform. A new Hugging Face Space was created, configured for the Streamlit SDK, and the app.py and requirements.txt files were uploaded. The deployment was tested and debugged to ensure the live application was stable and performant.

  • Phase 5: Documentation and Finalization:

    Comprehensive project documentation was created in the form of a README.md file. This file detailed the project's features, setup instructions, model information, and limitations, after which it was pushed to GitHub to finalize the project as a portfolio-ready piece.

Key Results & Model Performance


  • Project-Specific Evaluation: On a custom 100-sample subset from the TweetEval test set (evaluated via app.py), the model achieved ~70% accuracy—solid for a quick prototype, confirming reliable real-time classification in the Streamlit app.

  • Benchmark Context: From research, it is aligns closely with the model's official TweetEval Test Set score of 72.8% Macro-averaged Recall (M-Rec), outperforming baselines like SVM/FastText (both 62.9%) by ~10 points.

  • Selection Justification: RoBERTa-base (Retrained variant) was ideal for its balance of precision/recall on noisy, short tweets, plus efficient CPU inference (~sub-second per query), enabling seamless Hugging Face Spaces deployment.

  • Additional Notes: Full precision/recall/F1 is not yet focus for this mini project; English-focused—fine-tuning for Bahasa Malaysia could boost relevance for Malaysian fintech/e-commerce use cases.

Key Features & Technical Details

  • State-of-the-Art NLP Model: Utilizes cardiffnlp/twitter-roberta-base-sentiment, a powerful RoBERTa model fine-tuned on ~58 million tweets for nuanced sentiment analysis.


  • Interactive & Real-Time Analysis: Provides instant sentiment classification with confidence scores, visualized with dynamic progress bars and charts for a clear breakdown of results .


  • Efficient Model Loading: Implements Streamlit's @st.cache_resource decorator to load the large RoBERTa model only once, ensuring fast performance and a responsive user experience on subsequent analyses.


  • Error Handling: Validates input length (max 512 words) and provides user-friendly error messages.


  • Built-in Performance Evaluation: Includes a feature allowing users to test the model's accuracy on a 100-sample subset of the tweet_eval benchmark dataset directly within the application

Technical Stack

  • Web Framework: Streamlit

  • ML/NLP: Hugging Face (Transformers, Datasets), PyTorch

  • Data Science Libraries: NumPy, SciPy

  • Programming Language: Python

  • Platform & Deployment: Hugging Face Spaces, Git, GitHub

  • Model: cardiffnlp/twitter-roberta-base-sentiment (RoBERTa)

Challenges & Solutions

Challenge: The large size of the RoBERTa model caused slow startup times and high memory usage, as the model would reload on every user interaction without optimization.

  • Solution: Leveraged Streamlit's powerful caching mechanism by decorating the model-loading function with @st.cache_resource. This masterstroke ensures the model is loaded into memory only once when the application starts and is efficiently reused for all subsequent user requests, dramatically improving the app's responsiveness.


Challenge: The initial deployment to Hugging Face Spaces failed due to dependency conflicts, particularly with the torch library and other packages.

  • Solution: Methodically troubleshot the deployment by carefully examining the build logs provided by Hugging Face Spaces. The issue was resolved by pinning exact, compatible library versions in requirements.txt and specifying a CPU-only version of PyTorch (torch==2.4.1+cpu), which is crucial for compatibility with the platform's free hardware tier.

Car Rear Zoom View
Car Front View
Car Front Zoom View
Car Side View

Future Enhancements & Improvement

  • Fine-Tune for Local Context: Fine-tune the model on a custom dataset of Malay-language tweets to significantly improve its performance and relevance for the Malaysian market.


  • Batch Processing: Implement a feature to allow users to upload a CSV or text file to analyze multiple text entries at once instead of one by one.


  • User Feedback Loop: Add a mechanism for users to flag incorrect predictions. This feedback could be collected to create a new dataset for future model improvements.


  • Expanded Language Support: Integrate a multilingual sentiment analysis model to provide support for Bahasa Malaysia and other regional languages.

More Works

(GQ® — 02)

©2024

More Works

(GQ® — 02)

©2024

Person
Person

Mini 3: Sentiment Analysis API

Overview:

Developed and deployed a user-friendly web application that performs real-time sentiment analysis on user-provided text using a pre-trained RoBERTa model from the Hugging Face ecosystem.

Project Description

This project is an interactive web API for real-time sentiment classification, built to analyze customer feedback in sectors like fintech and e-commerce. Powered by the cardiffnlp/twitter-roberta-base-sentiment model and built with Streamlit, the application provides an intuitive interface for classifying text as Positive, Negative, or Neutral. The project covers the full development lifecycle, from local setup and coding to final deployment on Hugging Face Spaces for public, interactive use.

Problem Statement

Businesses and individuals need accessible tools to quickly gauge public opinion or analyze customer feedback from text data. However, leveraging state-of-the-art NLP models often requires significant technical expertise in machine learning and backend development. This project addresses that gap by creating a ready-to-use web application that abstracts the complexity of a sophisticated RoBERTa model into a simple, interactive interface, allowing anyone to perform high-quality sentiment analysis instantly without any setup.
Car Side View

Methodologies & Project Workflow

  • Phase 1: Local Environment Setup:

    A clean and reproducible development environment was established by creating a dedicated project directory, setting up a Python virtual environment, installing all necessary libraries (streamlit, transformers, torch, etc.), and initializing a Git repository.


  • Phase 2: Streamlit Application Development:

    The core web application (app.py) was coded. This involved integrating the Hugging Face pipeline to load the RoBERTa model, designing a user-friendly UI with Streamlit components, implementing the sentiment analysis logic, and testing all functionalities locally.


  • Phase 3: GitHub Repository Setup:

    A public GitHub repository was created to host and share the project code. The local Git repository was linked to the remote on GitHub, and all project files were pushed, making the code base version-controlled and publicly accessible.

  • Phase 4: Deployment to Hugging Face Spaces:

    The application was deployed to a public cloud platform. A new Hugging Face Space was created, configured for the Streamlit SDK, and the app.py and requirements.txt files were uploaded. The deployment was tested and debugged to ensure the live application was stable and performant.

  • Phase 5: Documentation and Finalization:

    Comprehensive project documentation was created in the form of a README.md file. This file detailed the project's features, setup instructions, model information, and limitations, after which it was pushed to GitHub to finalize the project as a portfolio-ready piece.

Key Results & Model Performance


  • Project-Specific Evaluation: On a custom 100-sample subset from the TweetEval test set (evaluated via app.py), the model achieved ~70% accuracy—solid for a quick prototype, confirming reliable real-time classification in the Streamlit app.

  • Benchmark Context: From research, it is aligns closely with the model's official TweetEval Test Set score of 72.8% Macro-averaged Recall (M-Rec), outperforming baselines like SVM/FastText (both 62.9%) by ~10 points.

  • Selection Justification: RoBERTa-base (Retrained variant) was ideal for its balance of precision/recall on noisy, short tweets, plus efficient CPU inference (~sub-second per query), enabling seamless Hugging Face Spaces deployment.

  • Additional Notes: Full precision/recall/F1 is not yet focus for this mini project; English-focused—fine-tuning for Bahasa Malaysia could boost relevance for Malaysian fintech/e-commerce use cases.

Key Features & Technical Details

  • State-of-the-Art NLP Model: Utilizes cardiffnlp/twitter-roberta-base-sentiment, a powerful RoBERTa model fine-tuned on ~58 million tweets for nuanced sentiment analysis.


  • Interactive & Real-Time Analysis: Provides instant sentiment classification with confidence scores, visualized with dynamic progress bars and charts for a clear breakdown of results .


  • Efficient Model Loading: Implements Streamlit's @st.cache_resource decorator to load the large RoBERTa model only once, ensuring fast performance and a responsive user experience on subsequent analyses.


  • Error Handling: Validates input length (max 512 words) and provides user-friendly error messages.


  • Built-in Performance Evaluation: Includes a feature allowing users to test the model's accuracy on a 100-sample subset of the tweet_eval benchmark dataset directly within the application

Technical Stack

  • Web Framework: Streamlit

  • ML/NLP: Hugging Face (Transformers, Datasets), PyTorch

  • Data Science Libraries: NumPy, SciPy

  • Programming Language: Python

  • Platform & Deployment: Hugging Face Spaces, Git, GitHub

  • Model: cardiffnlp/twitter-roberta-base-sentiment (RoBERTa)

Challenges & Solutions

Challenge: The large size of the RoBERTa model caused slow startup times and high memory usage, as the model would reload on every user interaction without optimization.

  • Solution: Leveraged Streamlit's powerful caching mechanism by decorating the model-loading function with @st.cache_resource. This masterstroke ensures the model is loaded into memory only once when the application starts and is efficiently reused for all subsequent user requests, dramatically improving the app's responsiveness.


Challenge: The initial deployment to Hugging Face Spaces failed due to dependency conflicts, particularly with the torch library and other packages.

  • Solution: Methodically troubleshot the deployment by carefully examining the build logs provided by Hugging Face Spaces. The issue was resolved by pinning exact, compatible library versions in requirements.txt and specifying a CPU-only version of PyTorch (torch==2.4.1+cpu), which is crucial for compatibility with the platform's free hardware tier.

Car Rear Zoom View
Car Front View
Car Front Zoom View
Car Side View

Future Enhancements & Improvement

  • Fine-Tune for Local Context: Fine-tune the model on a custom dataset of Malay-language tweets to significantly improve its performance and relevance for the Malaysian market.


  • Batch Processing: Implement a feature to allow users to upload a CSV or text file to analyze multiple text entries at once instead of one by one.


  • User Feedback Loop: Add a mechanism for users to flag incorrect predictions. This feedback could be collected to create a new dataset for future model improvements.


  • Expanded Language Support: Integrate a multilingual sentiment analysis model to provide support for Bahasa Malaysia and other regional languages.

More Works

(GQ® — 02)

©2024

Person
Person

Mini 3: Sentiment Analysis API

Overview:

Developed and deployed a user-friendly web application that performs real-time sentiment analysis on user-provided text using a pre-trained RoBERTa model from the Hugging Face ecosystem.

Project Description

This project is an interactive web API for real-time sentiment classification, built to analyze customer feedback in sectors like fintech and e-commerce. Powered by the cardiffnlp/twitter-roberta-base-sentiment model and built with Streamlit, the application provides an intuitive interface for classifying text as Positive, Negative, or Neutral. The project covers the full development lifecycle, from local setup and coding to final deployment on Hugging Face Spaces for public, interactive use.

Problem Statement

Businesses and individuals need accessible tools to quickly gauge public opinion or analyze customer feedback from text data. However, leveraging state-of-the-art NLP models often requires significant technical expertise in machine learning and backend development. This project addresses that gap by creating a ready-to-use web application that abstracts the complexity of a sophisticated RoBERTa model into a simple, interactive interface, allowing anyone to perform high-quality sentiment analysis instantly without any setup.
Car Side View

Methodologies & Project Workflow

  • Phase 1: Local Environment Setup:

    A clean and reproducible development environment was established by creating a dedicated project directory, setting up a Python virtual environment, installing all necessary libraries (streamlit, transformers, torch, etc.), and initializing a Git repository.


  • Phase 2: Streamlit Application Development:

    The core web application (app.py) was coded. This involved integrating the Hugging Face pipeline to load the RoBERTa model, designing a user-friendly UI with Streamlit components, implementing the sentiment analysis logic, and testing all functionalities locally.


  • Phase 3: GitHub Repository Setup:

    A public GitHub repository was created to host and share the project code. The local Git repository was linked to the remote on GitHub, and all project files were pushed, making the code base version-controlled and publicly accessible.

  • Phase 4: Deployment to Hugging Face Spaces:

    The application was deployed to a public cloud platform. A new Hugging Face Space was created, configured for the Streamlit SDK, and the app.py and requirements.txt files were uploaded. The deployment was tested and debugged to ensure the live application was stable and performant.

  • Phase 5: Documentation and Finalization:

    Comprehensive project documentation was created in the form of a README.md file. This file detailed the project's features, setup instructions, model information, and limitations, after which it was pushed to GitHub to finalize the project as a portfolio-ready piece.

Key Results & Model Performance


  • Project-Specific Evaluation: On a custom 100-sample subset from the TweetEval test set (evaluated via app.py), the model achieved ~70% accuracy—solid for a quick prototype, confirming reliable real-time classification in the Streamlit app.

  • Benchmark Context: From research, it is aligns closely with the model's official TweetEval Test Set score of 72.8% Macro-averaged Recall (M-Rec), outperforming baselines like SVM/FastText (both 62.9%) by ~10 points.

  • Selection Justification: RoBERTa-base (Retrained variant) was ideal for its balance of precision/recall on noisy, short tweets, plus efficient CPU inference (~sub-second per query), enabling seamless Hugging Face Spaces deployment.

  • Additional Notes: Full precision/recall/F1 is not yet focus for this mini project; English-focused—fine-tuning for Bahasa Malaysia could boost relevance for Malaysian fintech/e-commerce use cases.

Key Features & Technical Details

  • State-of-the-Art NLP Model: Utilizes cardiffnlp/twitter-roberta-base-sentiment, a powerful RoBERTa model fine-tuned on ~58 million tweets for nuanced sentiment analysis.


  • Interactive & Real-Time Analysis: Provides instant sentiment classification with confidence scores, visualized with dynamic progress bars and charts for a clear breakdown of results .


  • Efficient Model Loading: Implements Streamlit's @st.cache_resource decorator to load the large RoBERTa model only once, ensuring fast performance and a responsive user experience on subsequent analyses.


  • Error Handling: Validates input length (max 512 words) and provides user-friendly error messages.


  • Built-in Performance Evaluation: Includes a feature allowing users to test the model's accuracy on a 100-sample subset of the tweet_eval benchmark dataset directly within the application

Technical Stack

  • Web Framework: Streamlit

  • ML/NLP: Hugging Face (Transformers, Datasets), PyTorch

  • Data Science Libraries: NumPy, SciPy

  • Programming Language: Python

  • Platform & Deployment: Hugging Face Spaces, Git, GitHub

  • Model: cardiffnlp/twitter-roberta-base-sentiment (RoBERTa)

Challenges & Solutions

Challenge: The large size of the RoBERTa model caused slow startup times and high memory usage, as the model would reload on every user interaction without optimization.

  • Solution: Leveraged Streamlit's powerful caching mechanism by decorating the model-loading function with @st.cache_resource. This masterstroke ensures the model is loaded into memory only once when the application starts and is efficiently reused for all subsequent user requests, dramatically improving the app's responsiveness.


Challenge: The initial deployment to Hugging Face Spaces failed due to dependency conflicts, particularly with the torch library and other packages.

  • Solution: Methodically troubleshot the deployment by carefully examining the build logs provided by Hugging Face Spaces. The issue was resolved by pinning exact, compatible library versions in requirements.txt and specifying a CPU-only version of PyTorch (torch==2.4.1+cpu), which is crucial for compatibility with the platform's free hardware tier.

Car Rear Zoom View
Car Front View
Car Front Zoom View
Car Side View

Future Enhancements & Improvement

  • Fine-Tune for Local Context: Fine-tune the model on a custom dataset of Malay-language tweets to significantly improve its performance and relevance for the Malaysian market.


  • Batch Processing: Implement a feature to allow users to upload a CSV or text file to analyze multiple text entries at once instead of one by one.


  • User Feedback Loop: Add a mechanism for users to flag incorrect predictions. This feedback could be collected to create a new dataset for future model improvements.


  • Expanded Language Support: Integrate a multilingual sentiment analysis model to provide support for Bahasa Malaysia and other regional languages.

More Works

©2024

Create a free website with Framer, the website builder loved by startups, designers and agencies.