mo374z commited on
Commit
8a562ef
·
1 Parent(s): 70dd86b

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +34 -0
README.md CHANGED
@@ -1,3 +1,37 @@
1
  ---
2
  license: mit
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: mit
3
  ---
4
+ # The Office Speaker Classification Model
5
+
6
+ This model is designed to classify speakers (characters) of the TV show The Office based on a given line. It is built on top of the popular DistilBertForSequenceClassification model.
7
+
8
+ ## How to Use
9
+
10
+ ```python
11
+ from transformers import DistilBertForSequenceClassification, DistilBertTokenizer
12
+
13
+ model_name = 'username/model_name' # replace with your own huggingface model name
14
+ model = DistilBertForSequenceClassification.from_pretrained(model_name)
15
+ tokenizer = DistilBertTokenizer.from_pretrained(model_name)
16
+ device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
17
+ model.to(device)
18
+ ```
19
+
20
+ Once the model and tokenizer are loaded, you can classify the speaker of a given line as follows:
21
+
22
+ ```python
23
+ test_sample_str = "Hi i'm Michael Scott"
24
+ test_sample = tokenizer.encode(test_sample_str, truncation=True, padding=True, return_tensors='pt')
25
+ test_sample = test_sample.to(device)
26
+ output = model(test_sample)
27
+ ```
28
+
29
+ To get an explanation for the model prediction, you can use the SHAP explainer. By using SHAP, you can gain insights into the speaking style of the characters, and understand which words and phrases are most important for the model's prediction.
30
+
31
+ Make sure to replace `model_name` with your own huggingface model name.
32
+
33
+ ## SHAP
34
+ SHAP (SHapley Additive exPlanations) is a game theoretic approach to explain the output of any machine learning model. It can be used to explain the contribution of each input feature to the model's prediction. By using SHAP, you can gain insights into the speaking style of the characters, and understand which words and phrases are most important for the model's prediction.
35
+
36
+ ## License
37
+ This model is licensed under the MIT License.