Aditya1010/17k-hotel-reviews-dataset
Viewer • Updated • 17.8k • 25 • 1
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") # Load model directly
from transformers import AutoTokenizer, AutoModelForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained("kmack/HotelReviewClassifier")
model = AutoModelForSequenceClassification.from_pretrained("kmack/HotelReviewClassifier")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 from Hugging Face, and trained on the 17k Hotel Reviews Dataset.
distilbert-base-uncased17k-hotel-reviews-dataset, which contains 17,000 hotel reviews with labels for sentiment (positive/negative).To use the model for inference, you can use the following code:
from transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch
# Load the fine-tuned model and tokenizer
model = AutoModelForSequenceClassification.from_pretrained("kmack/HotelReviewClassifier")
tokenizer = AutoTokenizer.from_pretrained("kmack/HotelReviewClassifier")
# Example review for prediction
review = "This is the best hotel I've ever stayed in!"
# Tokenize the input text
inputs = tokenizer(review, return_tensors="pt", padding=True, truncation=True)
# Get predictions
with 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'}")
If you use this model in your research, please cite the following:
author = {Kmack},
title = {Hotel Review Classifier},
year = {2024},
url = {https://huggingface.co/kmack/HotelReviewClassifier}
}
Base model
distilbert/distilbert-base-uncased