bert base multilingual uncased sentiment

nlptown

Introduction

The BERT-BASE-MULTILINGUAL-UNCASED-SENTIMENT model is a fine-tuned version of the BERT model, specifically designed for sentiment analysis on product reviews. It supports six languages: English, Dutch, German, French, Spanish, and Italian. The model predicts the sentiment as a star rating from 1 to 5.

Architecture

The model is based on the BERT architecture and is multilingual, supporting six different languages. It is uncased, meaning it treats uppercase and lowercase letters as identical. This model was finetuned for sentiment analysis, allowing it to predict star ratings for product reviews.

Training

The model was finetuned using a dataset of product reviews in six languages. The number of product reviews used for each language is as follows:

  • English: 150,000 reviews
  • Dutch: 80,000 reviews
  • German: 137,000 reviews
  • French: 140,000 reviews
  • Italian: 72,000 reviews
  • Spanish: 50,000 reviews

The model's accuracy was evaluated on 5,000 held-out reviews per language, achieving the following results:

  • English: 67% exact, 95% off-by-1
  • Dutch: 57% exact, 93% off-by-1
  • German: 61% exact, 94% off-by-1
  • French: 59% exact, 94% off-by-1
  • Italian: 59% exact, 95% off-by-1
  • Spanish: 58% exact, 95% off-by-1

Guide: Running Locally

  1. Install Required Libraries: Ensure you have transformers and torch installed. Use the command:

    pip install transformers torch
    
  2. Download Model: Use the Hugging Face Transformers library to download the model.

    from transformers import AutoTokenizer, AutoModelForSequenceClassification
    
    tokenizer = AutoTokenizer.from_pretrained("nlptown/bert-base-multilingual-uncased-sentiment")
    model = AutoModelForSequenceClassification.from_pretrained("nlptown/bert-base-multilingual-uncased-sentiment")
    
  3. Run Inference: Tokenize your input text and use the model to obtain predictions.

    inputs = tokenizer("Your text here", return_tensors="pt")
    outputs = model(**inputs)
    
  4. Consider Cloud GPUs: For faster inference, especially with large datasets, consider using cloud-based GPUs from providers like AWS, Google Cloud, or Azure.

License

The model is licensed under the MIT License, allowing for broad use and modification with minimal restrictions.

More Related APIs in Text Classification