hipnologo commited on
Commit
9308885
1 Parent(s): b830dc7

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +57 -0
README.md ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ datasets:
3
+ - imdb
4
+ language:
5
+ - en
6
+ library_name: transformers
7
+ pipeline_tag: text-classification
8
+ tags:
9
+ - movies
10
+ - gpt2
11
+ - sentiment-analysis
12
+ - fine-tuned
13
+ ---
14
+
15
+ # Fine-tuned GPT-2 Model for IMDb Movie Review Sentiment Analysis
16
+
17
+ ## Model Description
18
+
19
+ This is a GPT-2 model fine-tuned on the IMDb movie review dataset for sentiment analysis. It classifies a movie review text into two classes: "positive" or "negative".
20
+
21
+ ## Intended Uses & Limitations
22
+
23
+ This model is intended to be used for binary sentiment analysis of English movie reviews. It can determine whether a review is positive or negative. It should not be used for languages other than English, or for text with ambiguous sentiment.
24
+
25
+ ## How to Use
26
+
27
+ Here's a simple way to use this model:
28
+
29
+ ```python
30
+ from transformers import GPT2Tokenizer, GPT2ForSequenceClassification
31
+
32
+ tokenizer = GPT2Tokenizer.from_pretrained("hipnologo/gpt2-imdb-finetune")
33
+ model = GPT2ForSequenceClassification.from_pretrained("hipnologo/gpt2-imdb-finetune")
34
+
35
+ text = "Your review text here!"
36
+
37
+ # encoding the input text
38
+ input_ids = tokenizer.encode(text, return_tensors="pt")
39
+
40
+ # Move the input_ids tensor to the same device as the model
41
+ input_ids = input_ids.to(model.device)
42
+
43
+ # getting the logits
44
+ logits = model(input_ids).logits
45
+
46
+ # getting the predicted class
47
+ predicted_class = logits.argmax(-1).item()
48
+
49
+ print(f"The sentiment predicted by the model is: {'Positive' if predicted_class == 1 else 'Negative'}")
50
+ ```
51
+
52
+ ## Training Procedure
53
+ The model was trained using the 'Trainer' class from the transformers library, with a learning rate of 2e-5, batch size of 1, and 3 training epochs.
54
+
55
+ ## Fine-tuning Details
56
+ The model was fine-tuned using the IMDb movie review dataset.
57
+