Text Classification
Transformers
Safetensors
bert
Sentiment Analysis
DistilBERT
Text Classification
Hotel Reviews
text-embeddings-inference
Instructions to use kmack/HotelReviewClassifier with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use kmack/HotelReviewClassifier with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="kmack/HotelReviewClassifier")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("kmack/HotelReviewClassifier") model = AutoModelForSequenceClassification.from_pretrained("kmack/HotelReviewClassifier", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Create README.md
Browse files1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677---license: mitdatasets:- Aditya1010/17k-hotel-reviews-datasetmetrics:- accuracybase_model:- distilbert/distilbert-base-uncasedpipeline_tag: text-classificationlibrary_name: transformerstags:- Sentiment Analysis- DistilBERT- Text Classification- Hotel Reviews---# Hotel Review Classifier
This model is a sentiment classification model for hotel reviews, trained to predict whether a review is **positive** or **negative**. The model was fine-tuned using the `distilbert-base-uncased` model architecture, based on the [DistilBERT model](https://huggingface.co/distilbert/distilbert-base-uncased) from Hugging Face, and trained on the [17k Hotel Reviews Dataset](https://huggingface.co/datasets/Aditya1010/17k-hotel-reviews-dataset).
## Model Details- **Model Type**: DistilBERT-based model for sequence classification- **Model Architecture**: `distilbert-base-uncased`- **Number of Parameters**: Approximately 66M parameters- **Training Dataset**: The model was trained on the `17k-hotel-reviews-dataset`, which contains 17,000 hotel reviews with labels for sentiment (positive/negative).- **Fine-Tuning Task**: Sentiment analysis for hotel reviews (positive or negative sentiment)
## Training Data- **Dataset**: [17k Hotel Reviews Dataset](https://huggingface.co/datasets/Aditya1010/17k-hotel-reviews-dataset)- **Data Description**: The dataset consists of 17,000 hotel reviews, each labeled with a sentiment (positive/negative).- **Preprocessing**: The dataset was preprocessed by cleaning the reviews to remove unwanted characters and URLs.
## Training Details- **Training Framework**: Hugging Face Transformers and PyTorch- **Learning Rate**: 2e-5- **Epochs**: 3- **Batch Size**: 16- **Optimizer**: AdamW- **Training Time**: Approximately 2 hours on a GPU
## UsageTo use the model for inference, you can use the following code:
```pythonfrom transformers import AutoModelForSequenceClassification, AutoTokenizerimport torch
# Load the fine-tuned model and tokenizermodel = AutoModelForSequenceClassification.from_pretrained("kmack/HotelReviewClassifier")tokenizer = AutoTokenizer.from_pretrained("kmack/HotelReviewClassifier")
# Example review for predictionreview = "This is the best hotel I've ever stayed in!"
# Tokenize the input textinputs = tokenizer(review, return_tensors="pt", padding=True, truncation=True)
# Get predictionswith torch.no_grad(): outputs = model(**inputs)
# Get the predicted label (0 for negative, 1 for positive)prediction = torch.argmax(outputs.logits, dim=-1)print(f"Predicted sentiment: {'Positive' if prediction == 1 else 'Negative'}")```
## Citation
If you use this model in your research, please cite the following:
```@misc{hotel_review_classifier, author = {Kmack}, title = {Hotel Review Classifier}, year = {2024}, url = {https://huggingface.co/kmack/HotelReviewClassifier}}```README.mdAdded+77