notes73 commited on
Commit
8d3f5be
·
1 Parent(s): 12d3b66

Updated tokenizer & fixed sentiment labels

Browse files
New Text Document.txt ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+
3
+ # Load the model from Hugging Face
4
+ model_name = "DilipKY/my-text-classifier" # Ensure this matches your model name
5
+ classifier = pipeline("text-classification", model=model_name)
6
+
7
+ # Test with a sample text
8
+ sample_text = "This movie was amazing! The plot was so engaging and the acting was superb."
9
+ result = classifier(sample_text)
10
+
11
+ # Print the output
12
+ print(result)
special_tokens_map.json ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cls_token": {
3
+ "content": "[CLS]",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "mask_token": {
10
+ "content": "[MASK]",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "pad_token": {
17
+ "content": "[PAD]",
18
+ "lstrip": false,
19
+ "normalized": false,
20
+ "rstrip": false,
21
+ "single_word": false
22
+ },
23
+ "sep_token": {
24
+ "content": "[SEP]",
25
+ "lstrip": false,
26
+ "normalized": false,
27
+ "rstrip": false,
28
+ "single_word": false
29
+ },
30
+ "unk_token": {
31
+ "content": "[UNK]",
32
+ "lstrip": false,
33
+ "normalized": false,
34
+ "rstrip": false,
35
+ "single_word": false
36
+ }
37
+ }
test_model.py CHANGED
@@ -1,16 +1,20 @@
1
  from transformers import pipeline, AutoTokenizer
2
 
 
3
  model_name = "DilipKY/my-text-classifier"
4
- tokenizer_name = "bert-base-uncased" # Use "bert-base-cased" if your model is case-sensitive
5
-
6
- # Load the correct tokenizer
7
- tokenizer = AutoTokenizer.from_pretrained(tokenizer_name)
8
-
9
- # Load the model with the tokenizer
10
  classifier = pipeline("text-classification", model=model_name, tokenizer=tokenizer)
11
 
12
- # Test the model
13
- sample_text = "I love this product! It's amazing."
 
 
 
14
  result = classifier(sample_text)
15
 
 
 
 
 
 
16
  print(result)
 
1
  from transformers import pipeline, AutoTokenizer
2
 
3
+ # Load model
4
  model_name = "DilipKY/my-text-classifier"
5
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
 
 
 
 
 
6
  classifier = pipeline("text-classification", model=model_name, tokenizer=tokenizer)
7
 
8
+ # Label mapping (adjust if necessary)
9
+ label_map = {"LABEL_0": "NEGATIVE", "LABEL_1": "POSITIVE"}
10
+
11
+ # Test with input text
12
+ sample_text = "I love this movie!"
13
  result = classifier(sample_text)
14
 
15
+ # Convert label
16
+ result[0]['label'] = label_map.get(result[0]['label'], result[0]['label'])
17
+
18
+ # Print the result
19
+ print("\n🔍 Sentiment Classification Result:")
20
  print(result)
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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": true,
45
+ "cls_token": "[CLS]",
46
+ "do_basic_tokenize": true,
47
+ "do_lower_case": true,
48
+ "extra_special_tokens": {},
49
+ "mask_token": "[MASK]",
50
+ "model_max_length": 512,
51
+ "never_split": null,
52
+ "pad_token": "[PAD]",
53
+ "sep_token": "[SEP]",
54
+ "strip_accents": null,
55
+ "tokenize_chinese_chars": true,
56
+ "tokenizer_class": "DistilBertTokenizer",
57
+ "unk_token": "[UNK]"
58
+ }
vocab.txt ADDED
The diff for this file is too large to render. See raw diff