Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
```
|
2 |
+
!pip install transformers
|
3 |
+
!pip install torch
|
4 |
+
```
|
5 |
+
```
|
6 |
+
import torch
|
7 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
8 |
+
tokenizer = AutoTokenizer.from_pretrained("BigSalmon/PointsToParagraphNeo1.3B")
|
9 |
+
model = AutoModelForCausalLM.from_pretrained("BigSalmon/PointsToParagraphNeo1.3B")
|
10 |
+
```
|
11 |
+
|
12 |
+
```
|
13 |
+
prompt = """
|
14 |
+
- advent
|
15 |
+
- podcasts
|
16 |
+
- entertainment
|
17 |
+
- is an industry transformed
|
18 |
+
- no longer
|
19 |
+
- consumers touch clicker or turn on radio
|
20 |
+
- people plug in their earbuds to listen to a podcast
|
21 |
+
- this changing mediums for reasons
|
22 |
+
- can be done anywhere
|
23 |
+
- more optionality in content
|
24 |
+
text: as podcasts have"""
|
25 |
+
input_ids = tokenizer.encode(prompt, return_tensors='pt')
|
26 |
+
outputs = model.generate(input_ids=input_ids,
|
27 |
+
max_length=10 + len(prompt),
|
28 |
+
temperature=1.0,
|
29 |
+
top_k=50,
|
30 |
+
top_p=0.95,
|
31 |
+
do_sample=True,
|
32 |
+
num_return_sequences=5,
|
33 |
+
early_stopping=True)
|
34 |
+
for i in range(5):
|
35 |
+
print(tokenizer.decode(outputs[i]))
|
36 |
+
```
|
37 |
+
Most likely outputs (Disclaimer: I highly recommend using this over just generating):
|
38 |
+
```
|
39 |
+
prompt = """
|
40 |
+
- advent
|
41 |
+
- podcasts
|
42 |
+
- entertainment
|
43 |
+
- is an industry transformed
|
44 |
+
- no longer
|
45 |
+
- consumers touch clicker or turn on radio
|
46 |
+
- people plug in their earbuds to listen to a podcast
|
47 |
+
- this changing mediums for reasons
|
48 |
+
- can be done anywhere
|
49 |
+
- more optionality in content
|
50 |
+
text: as podcasts have"""
|
51 |
+
text = tokenizer.encode(prompt)
|
52 |
+
myinput, past_key_values = torch.tensor([text]), None
|
53 |
+
myinput = myinput
|
54 |
+
myinput= myinput.to(device)
|
55 |
+
logits, past_key_values = model(myinput, past_key_values = past_key_values, return_dict=False)
|
56 |
+
logits = logits[0,-1]
|
57 |
+
probabilities = torch.nn.functional.softmax(logits)
|
58 |
+
best_logits, best_indices = logits.topk(250)
|
59 |
+
best_words = [tokenizer.decode([idx.item()]) for idx in best_indices]
|
60 |
+
text.append(best_indices[0].item())
|
61 |
+
best_probabilities = probabilities[best_indices].tolist()
|
62 |
+
words = []
|
63 |
+
print(best_words)
|
64 |
+
```
|
65 |
+
|
66 |
+
Example:
|
67 |
+
```
|
68 |
+
- advent
|
69 |
+
- podcasts
|
70 |
+
- entertainment
|
71 |
+
- is an industry transformed
|
72 |
+
- no longer
|
73 |
+
- consumers touch clicker or turn on radio
|
74 |
+
- people plug in their earbuds to listen to a podcast
|
75 |
+
- this changing mediums for reasons
|
76 |
+
- can be done anywhere
|
77 |
+
- more optionality in content
|
78 |
+
text: as podcasts have proliferated, the entertainment industry has been fundamentally reshaped. in place of flipping through channels or spinning the dial, consumers are plugging in their earbuds to enjoy audio content. this evolution in media consumption is not without explanation, but rather a function of greater portability and content optionality.
|
79 |
+
|
80 |
+
***
|
81 |
+
|
82 |
+
- newborn
|
83 |
+
- caring for
|
84 |
+
- full-time job
|
85 |
+
- parents
|
86 |
+
- often have to work normal job
|
87 |
+
- paid leave needs to be universal
|
88 |
+
- so parents not overworked
|
89 |
+
- child is cared for
|
90 |
+
- can spend special time together
|
91 |
+
text: tending to a newborn is a full-time job. regrettably, many parents must perform this duty alongside their conventional employment. to spare them from such strain, paid leave must be universal. in this way, children will be provided for, while the parent-child bond will be strengthened.
|
92 |
+
```
|