Spaces:
Runtime error
Runtime error
monsoon-nlp
commited on
Commit
•
20ed203
1
Parent(s):
a990b71
trip output pad and sep
Browse files
app.py
CHANGED
@@ -12,7 +12,10 @@ model = EncoderDecoderModel.from_encoder_decoder_pretrained(
|
|
12 |
def flip(content):
|
13 |
input_ids = torch.tensor(tokenizer.encode(content)).unsqueeze(0)
|
14 |
generated = model.generate(input_ids, decoder_start_token_id=model.config.decoder.pad_token_id)
|
15 |
-
|
|
|
|
|
|
|
16 |
|
17 |
iface = gr.Interface(fn=flip,
|
18 |
inputs=gr.inputs.Textbox(label="Original Spanish text"),
|
12 |
def flip(content):
|
13 |
input_ids = torch.tensor(tokenizer.encode(content)).unsqueeze(0)
|
14 |
generated = model.generate(input_ids, decoder_start_token_id=model.config.decoder.pad_token_id)
|
15 |
+
op = tokenizer.decode(generated.tolist()[0][1:])
|
16 |
+
if '[SEP]' in op:
|
17 |
+
return op[:op.index('[SEP]')]
|
18 |
+
return op
|
19 |
|
20 |
iface = gr.Interface(fn=flip,
|
21 |
inputs=gr.inputs.Textbox(label="Original Spanish text"),
|