Simon Salmon commited on
Commit
1741106
1 Parent(s): 5d95541

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +44 -0
README.md ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ This can be used to paraphrase. I recommend using the code I have attached below. You can generate it without using LogProbs, but you are likely to be best served by manually examining the most likely outputs.
2
+
3
+ ```
4
+ from transformers import AutoTokenizer, AutoModelWithLMHead
5
+ tokenizer = AutoTokenizer.from_pretrained("gpt2")
6
+ model = AutoModelWithLMHead.from_pretrained("BigSalmon/ParaphraseParentheses2.0")
7
+ ```
8
+
9
+ Example Prompt:
10
+ ```
11
+ the nba is [mask] [mask] viewership.
12
+ the nba is ( facing / witnessing / confronted with / suffering from / grappling with ) ( lost / tanking ) viewership...
13
+
14
+ ai is certain to [mask] the third industrial revolution.
15
+ ai is certain to ( breed / catalyze / inaugurate / catalyze / usher in / call forth / turn loose / lend its name to ) the third industrial revolution.
16
+
17
+ the modern-day knicks are a disgrace to [mask].
18
+ the modern-day knicks are a disgrace to the franchise's ( rich legacy / tradition of excellence / uniquely distinguished record ).
19
+
20
+ HuggingFace is [mask].
21
+ HuggingFace is ( an amazing company /
22
+ ```
23
+
24
+ ```
25
+ import torch
26
+ prompt = "Insert Your Prompt Here. It is Best To Have a Few Examples Before Like The Example Prompt Shows."
27
+ text = tokenizer.encode(prompt)
28
+ myinput, past_key_values = torch.tensor([text]), None
29
+ myinput = myinput
30
+ myinput= myinput.to(device)
31
+ logits, past_key_values = model(myinput, past_key_values = past_key_values, return_dict=False)
32
+ logits = logits[0,-1]
33
+ probabilities = torch.nn.functional.softmax(logits)
34
+ best_logits, best_indices = logits.topk(500)
35
+ best_words = [tokenizer.decode([idx.item()]) for idx in best_indices]
36
+ text.append(best_indices[0].item())
37
+ best_probabilities = probabilities[best_indices].tolist()
38
+ words = []
39
+ for i in range(500):
40
+ m = ([best_words[i]])
41
+ m = str(m)
42
+ m = m.replace("[' ", "").replace("']", "")
43
+ print(m)
44
+ ```