Spaces:
Build error
Build error
Upload 4 files
Browse files- GPT2Tokenizer.pt +3 -0
- app.py +14 -0
- requiremens.txt +1 -0
GPT2Tokenizer.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e7bb2fcbc544bd50ccbeca14449092ef286d44cd0da0cc8a09b2d330d6ffe714
|
3 |
+
size 3095163
|
app.py
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import torch
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
|
5 |
+
model = torch.load("GPT2Model.pt")
|
6 |
+
tokenizer = torch.load("GPT2Tokenizer.pt")
|
7 |
+
def gpt2(prompt):
|
8 |
+
input_ids = tokenizer(prompt, return_tensors="pt").input_ids
|
9 |
+
outputs = model.generate(input_ids, do_sample=False, max_length=30)
|
10 |
+
return tokenizer.batch_decode(outputs, skip_special_tokens=True)[0]
|
11 |
+
|
12 |
+
demo = gr.Interface(fn=gpt2, inputs="text", outputs="text")
|
13 |
+
|
14 |
+
demo.launch()
|
requiremens.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
torch
|