moraix commited on
Commit
d7bbfc0
·
verified ·
1 Parent(s): 329022e

Upload folder using huggingface_hub

Browse files
README.md ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SentimentBot: A Sentiment Analysis Chatbot with BERT 🤖
2
+
3
+ ## Overview
4
+ SentimentBot is a sentiment analysis chatbot built using BERT, fine-tuned on the SST-2 dataset. It predicts whether a given text expresses a positive or negative sentiment and responds interactively. This project was developed to enhance my NLP skills for an AI Engineer internship.
5
+
6
+ - Model: BERT (bert-base-uncased)
7
+ - Dataset: SST-2 (Stanford Sentiment Treebank)
8
+ - Performance: Achieved 92.3% accuracy and 92.3% F1 score on the validation set after 2 epochs.
9
+
10
+ ## Features
11
+
12
+ - Analyzes sentiment of user input (positive/negative).
13
+ - Interactive chatbot responses based on predicted sentiment.
14
+ - Fine-tuned BERT model for high accuracy.
15
+
16
+ ## Installation
17
+ To run this project locally, follow these steps:
18
+
19
+ 1. Clone the repository:
20
+ ```
21
+ git clone https://github.com/moraix/SentimentBot.git
22
+ cd SentimentBot
23
+ ```
24
+
25
+
26
+ 2. Install dependencies:
27
+ ```
28
+ pip install torch transformers datasets sklearn
29
+ ```
30
+
31
+
32
+ ## Usage
33
+
34
+ 1. Run the notebook:
35
+
36
+ - Open SentimentBot.ipynb in Jupyter Notebook.
37
+ - Follow the steps to train the model.
38
+
39
+
40
+ 2. Test the chatbot:
41
+
42
+ - Run the last cell in the notebook to interact with the chatbot.
43
+ - Enter a sentence (e.g., "I love this movie!") and the bot will predict the sentiment and respond.
44
+
45
+ Example:
46
+ Text: I love this movie so much!
47
+ Sentiment: positive (confidence: 0.95)
48
+ I'm glad you liked it! 😊 Do you have any other comments?
49
+
50
+
51
+ ## Results
52
+ After fine-tuning BERT on SST-2 for 2 epochs:
53
+
54
+ - Eval Loss: 0.311
55
+ - Accuracy: 92.3%
56
+ - F1 Score: 92.3%
57
+ - Eval Runtime: 3.42 seconds
58
+
59
+ ## Future Improvements
60
+
61
+ - Add support for more complex sentiments (e.g., neutral, angry).
62
+ - Expand the dataset with custom data.
63
+ - Deploy the chatbot as a web app using Flask or Streamlit.
64
+
65
+ ## Contributing
66
+ Feel free to fork this repository, open issues, or submit pull requests. Feedback is always welcome!
67
+ Contact
68
+ For questions, reach out via mohammadmehdiomidi95@gmail.com or connect with me on LinkedIn.
config.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "BertForSequenceClassification"
4
+ ],
5
+ "attention_probs_dropout_prob": 0.1,
6
+ "classifier_dropout": null,
7
+ "gradient_checkpointing": false,
8
+ "hidden_act": "gelu",
9
+ "hidden_dropout_prob": 0.1,
10
+ "hidden_size": 768,
11
+ "initializer_range": 0.02,
12
+ "intermediate_size": 3072,
13
+ "layer_norm_eps": 1e-12,
14
+ "max_position_embeddings": 512,
15
+ "model_type": "bert",
16
+ "num_attention_heads": 12,
17
+ "num_hidden_layers": 12,
18
+ "pad_token_id": 0,
19
+ "position_embedding_type": "absolute",
20
+ "problem_type": "single_label_classification",
21
+ "torch_dtype": "float32",
22
+ "transformers_version": "4.52.3",
23
+ "type_vocab_size": 2,
24
+ "use_cache": true,
25
+ "vocab_size": 30522
26
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d3ad57cd25ae190690a5df15dd118610682488712a6cd73db30e72597eb18522
3
+ size 437958648
special_tokens_map.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "cls_token": "[CLS]",
3
+ "mask_token": "[MASK]",
4
+ "pad_token": "[PAD]",
5
+ "sep_token": "[SEP]",
6
+ "unk_token": "[UNK]"
7
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "added_tokens_decoder": {
3
+ "0": {
4
+ "content": "[PAD]",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false,
9
+ "special": true
10
+ },
11
+ "100": {
12
+ "content": "[UNK]",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "101": {
20
+ "content": "[CLS]",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "102": {
28
+ "content": "[SEP]",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "103": {
36
+ "content": "[MASK]",
37
+ "lstrip": false,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ }
43
+ },
44
+ "clean_up_tokenization_spaces": false,
45
+ "cls_token": "[CLS]",
46
+ "do_lower_case": true,
47
+ "extra_special_tokens": {},
48
+ "mask_token": "[MASK]",
49
+ "model_max_length": 512,
50
+ "pad_token": "[PAD]",
51
+ "sep_token": "[SEP]",
52
+ "strip_accents": null,
53
+ "tokenize_chinese_chars": true,
54
+ "tokenizer_class": "BertTokenizer",
55
+ "unk_token": "[UNK]"
56
+ }
training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3b348f59e33fb67f1a9e210256eb9762f84959b7085aaae965d20ea99c511656
3
+ size 5649
vocab.txt ADDED
The diff for this file is too large to render. See raw diff