Spaces:
Runtime error
Runtime error
Keith Hon
commited on
Commit
·
dab87b3
1
Parent(s):
d6314c4
added models
Browse files- app.py +13 -4
- quantized_model/macaw-large-decoder-quantized.onnx +3 -0
- quantized_model/macaw-large-decoder.onnx +3 -0
- quantized_model/macaw-large-encoder-quantized.onnx +3 -0
- quantized_model/macaw-large-encoder.onnx +3 -0
- quantized_model/macaw-large-init-decoder-quantized.onnx +3 -0
- quantized_model/macaw-large-init-decoder.onnx +3 -0
app.py
CHANGED
@@ -1,10 +1,19 @@
|
|
1 |
from fastT5 import get_onnx_model
|
2 |
import gradio as gr
|
|
|
3 |
|
4 |
-
|
|
|
5 |
|
6 |
-
def
|
7 |
-
|
|
|
|
|
|
|
|
|
8 |
|
9 |
-
|
|
|
|
|
|
|
10 |
iface.launch()
|
|
|
1 |
from fastT5 import get_onnx_model
|
2 |
import gradio as gr
|
3 |
+
from transformers import AutoTokenizer
|
4 |
|
5 |
+
tokenizer = AutoTokenizer.from_pretrained('allenai/macaw-large')
|
6 |
+
model = get_onnx_model('allenai/macaw-large', "quantized_model")
|
7 |
|
8 |
+
def infer(context, question, options=None):
|
9 |
+
input_string = "$answer$ ; $context$ = " + context + " ; $question$ = " + question
|
10 |
+
input_ids = tokenizer.encode(input_string, return_tensors="pt")
|
11 |
+
output = model.generate(input_ids, max_length=200)
|
12 |
+
responses = tokenizer.batch_decode(output, skip_special_tokens=True)
|
13 |
+
return responses[0].split(";")[0].split("=")[1].strip()
|
14 |
|
15 |
+
def greet(context, question):
|
16 |
+
return infer(context, question)
|
17 |
+
|
18 |
+
iface = gr.Interface(fn=greet, inputs=["text", "text"], outputs="text")
|
19 |
iface.launch()
|
quantized_model/macaw-large-decoder-quantized.onnx
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c2ce3b042cdd7458895da3cd0b36f0c860639ca319132c53b934e71056ef6eeb
|
3 |
+
size 420450179
|
quantized_model/macaw-large-decoder.onnx
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:160041e55c14e3b10a32e87e193fe170c29ca3c3be9fcc84ac4fc204dab90c47
|
3 |
+
size 1673007329
|
quantized_model/macaw-large-encoder-quantized.onnx
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7caefc2b5a78f122d7752380a5347d71f011c530ae58ebf7290f75f1a8e36e9a
|
3 |
+
size 336512123
|
quantized_model/macaw-large-encoder.onnx
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:26e23970ed6fa45fe90e0bb982c7e3948367850b9bce5e501ed897bf9c6d28cc
|
3 |
+
size 1339889842
|
quantized_model/macaw-large-init-decoder-quantized.onnx
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:55868a5336eec320b0397881e9414b0f0b6f56d138bfbd3a3c8e0f81e4d3eab5
|
3 |
+
size 471092181
|
quantized_model/macaw-large-init-decoder.onnx
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9c48fb09251e12e3dcad583ece401e6d71b3cb27342ee95fbe0cacb156283b68
|
3 |
+
size 1874360180
|