Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,11 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
model = AutoModelForCausalLM.from_pretrained("instruction-pretrain/instruction-synthesizer")
|
|
|
|
| 5 |
tokenizer = AutoTokenizer.from_pretrained("instruction-pretrain/instruction-synthesizer")
|
| 6 |
|
| 7 |
def parse_pred(pred):
|
|
@@ -39,6 +43,7 @@ def get_instruction_response_pairs(context):
|
|
| 39 |
pred = tokenizer.decode(outputs[pred_start:], skip_special_tokens=True)
|
| 40 |
return parse_pred(pred)
|
| 41 |
|
|
|
|
| 42 |
def generate_pairs(context):
|
| 43 |
instruction_response_pairs = get_instruction_response_pairs(context)
|
| 44 |
output = ""
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 3 |
+
import spaces
|
| 4 |
+
|
| 5 |
+
|
| 6 |
|
| 7 |
model = AutoModelForCausalLM.from_pretrained("instruction-pretrain/instruction-synthesizer")
|
| 8 |
+
model.to('cuda')
|
| 9 |
tokenizer = AutoTokenizer.from_pretrained("instruction-pretrain/instruction-synthesizer")
|
| 10 |
|
| 11 |
def parse_pred(pred):
|
|
|
|
| 43 |
pred = tokenizer.decode(outputs[pred_start:], skip_special_tokens=True)
|
| 44 |
return parse_pred(pred)
|
| 45 |
|
| 46 |
+
@spaces.GPU
|
| 47 |
def generate_pairs(context):
|
| 48 |
instruction_response_pairs = get_instruction_response_pairs(context)
|
| 49 |
output = ""
|