danyaljj commited on
Commit
4c14fe7
1 Parent(s): 8a70b74

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +28 -0
README.md ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ West et al.'s model from their "reflective decoding" paper.
2
+
3
+ Sample usage:
4
+
5
+ ```python
6
+ import torch
7
+ from modeling_opengpt2 import OpenGPT2LMHeadModel
8
+ from padded_encoder import Encoder
9
+
10
+ path_to_backward = 'danyaljj/opengpt2_pytorch_backward'
11
+
12
+ encoder = Encoder()
13
+ model_backward = OpenGPT2LMHeadModel.from_pretrained(path_to_backward)
14
+
15
+ input = "until she finally won."
16
+ input_ids = encoder.encode(input)
17
+ input_ids = torch.tensor([input_ids[::-1] ], dtype=torch.int)
18
+ print(input_ids)
19
+
20
+ output = model_backward.generate(input_ids)
21
+
22
+ output_text = encoder.decode(output.tolist()[0][::-1])
23
+
24
+ print(output_text)
25
+ ```
26
+
27
+ Download the additional files from here: https://github.com/peterwestuw/GPT2ForwardBackward
28
+