Reggie commited on
Commit
0c0544e
·
1 Parent(s): a794268

Update README.md

Browse files

About this model.

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
+ language:
4
+ - en
5
  ---
6
+
7
+ ### What is this?
8
+ A detector based on Facebook's [RoBerta-MUPPET](https://huggingface.co/facebook/muppet-roberta-base) to detect "narrative-style" jokes, stories and anecdotes i.e. they are narrated as a story. See the example in the How to use.
9
+
10
+ This has not been trained or tested on one-liners, puns or Reddit-style language-manipulation jokes such as knock-knock, Q&A jokes etc.
11
+
12
+ This model has been developed to detect jokes & anecdotes spoken during speeches or conversations etc.
13
+
14
+ ### Install these first
15
+ You'll need to pip install transformers & maybe sentencepiece
16
+
17
+ ### How to use
18
+ ```python
19
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
20
+ import torch, time
21
+ device = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu")
22
+ model_name = '/path/to/model'
23
+ max_seq_len = 510
24
+
25
+ tokenizer = AutoTokenizer.from_pretrained(model_name, model_max_length=max_seq_len)
26
+ model = AutoModelForSequenceClassification.from_pretrained(model_name).to(device)
27
+
28
+ premise = """A nervous passenger is about to book a flight ticket, and he asks the airlines' ticket seller, "I hope your planes are safe. Do they have a good track record for safety?" The airline agent replies, "Sir, I can guarantee you, we've never had a plane that has crashed more than once." """
29
+ hypothesis = ""
30
+
31
+ input = tokenizer(premise, hypothesis, truncation=True, return_tensors="pt")
32
+ output = model(input["input_ids"].to(device)) # device = "cuda:0" or "cpu"
33
+ prediction = torch.softmax(output["logits"][0], -1).tolist()
34
+ is_joke = True if prediction[0] < prediction[1] else False
35
+
36
+ print(is_joke)
37
+ ```