cbspace commited on
Commit ·
6c044bb
1
Parent(s): 7d722c8
App added
Browse files- app.py +14 -0
- requirements.txt +3 -0
app.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
import gradio as gr
|
| 3 |
+
from transformers import AutoModelForCausalLM
|
| 4 |
+
|
| 5 |
+
model = AutoModelForCausalLM.from_pretrained('cbspace/gpt')
|
| 6 |
+
tokenizer = tiktoken.encoding_for_model('gpt2')
|
| 7 |
+
|
| 8 |
+
def generate(prompt):
|
| 9 |
+
inputs = tokenizer.encode(prompt)
|
| 10 |
+
outputs = model.generate(inputs, 42, greedy=False)
|
| 11 |
+
return outputs
|
| 12 |
+
|
| 13 |
+
app = gr.Interface(fn=generate, inputs='text', outputs='text')
|
| 14 |
+
app.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
torch
|
| 2 |
+
transformers
|
| 3 |
+
tiktoken
|