Views
No views yet
1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2
3# Load model and tokenizer
4model_name = "Qiegu/fake-review-detection-bert"
5tokenizer = AutoTokenizer.from_pretrained(model_name)
6model = AutoModelForSequenceClassification.from_pretrained(model_name)
7
8# Classify a review
9text = "This product is amazing! I love it so much!"
10inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True)
11outputs = model(**inputs)
12prediction = outputs.logits.argmax(dim=1).item()
13
14# 0 = Real review, 1 = Fake review
15result = "Fake" if prediction == 1 else "Real"
16print(f"Review classification: {result}")1@misc{fake-review-detection-bert,
2 title={Fake Review Detection BERT Model},
3 author={Your Name},
4 year={2024},
5 publisher={Hugging Face},
6 url={https://huggingface.co/Qiegu/fake-review-detection-bert}
7}