Spaces:
Runtime error
Runtime error
visualize beam in output
Browse files
app.py
CHANGED
@@ -6,7 +6,7 @@ import gradio as gr
|
|
6 |
def translate(input_txt,prefix,suffix,num_beams,topk,beta):
|
7 |
dictToSend = {'input':input_txt,'prefix':prefix,'suffix':suffix,'num_beams':num_beams,'alpha': (1-beta),'beta':beta,'topk':topk}
|
8 |
res = requests.post('https://d7bf-141-3-25-29.ngrok-free.app/generate', json=dictToSend)
|
9 |
-
return res.text
|
10 |
|
11 |
prefix= "<s>[INST] <<SYS>>\nYou are a professional translator from English to German. You translate the sentences to only Formal German even if the English sentence is Informal.\n<</SYS>>\nEnglish: "
|
12 |
#self.prefix = "Translate from English to German:\nEnglish: "
|
@@ -21,8 +21,8 @@ example_informal = ["Where are you going today?",prefix,suffix,5,5,1]
|
|
21 |
|
22 |
iface = gr.Interface(
|
23 |
fn=translate,
|
24 |
-
inputs=[gr.Textbox(lines=1, placeholder="Enter your English Sentences that you want to translate", label="English Sentence"), gr.Textbox(lines=5, placeholder=prefix,label="Prefix for LLM Prompt - Replace formal and informal here to control Formality
|
25 |
-
outputs=gr.Textbox(lines=1,placeholder="Enter your inputs and click submit!",label="LLM Guided NLLB German Translation"),
|
26 |
examples=[example_formal,example_informal],
|
27 |
title="Ensembling NLLB 3.3B with LLama2 13B by Guided Decoding",
|
28 |
)
|
|
|
6 |
def translate(input_txt,prefix,suffix,num_beams,topk,beta):
|
7 |
dictToSend = {'input':input_txt,'prefix':prefix,'suffix':suffix,'num_beams':num_beams,'alpha': (1-beta),'beta':beta,'topk':topk}
|
8 |
res = requests.post('https://d7bf-141-3-25-29.ngrok-free.app/generate', json=dictToSend)
|
9 |
+
return res.text,res.beam_img
|
10 |
|
11 |
prefix= "<s>[INST] <<SYS>>\nYou are a professional translator from English to German. You translate the sentences to only Formal German even if the English sentence is Informal.\n<</SYS>>\nEnglish: "
|
12 |
#self.prefix = "Translate from English to German:\nEnglish: "
|
|
|
21 |
|
22 |
iface = gr.Interface(
|
23 |
fn=translate,
|
24 |
+
inputs=[gr.Textbox(lines=1, placeholder="Enter your English Sentences that you want to translate", label="English Sentence"), gr.Textbox(lines=5, placeholder=prefix,label="Prefix for LLM Prompt - Replace formal and informal here to control Formality Level"),gr.Textbox(lines=2, placeholder=suffix, label="DONT CHANGE!!"),gr.Slider(label='Select beam size',value=5,minimum=1,maximum=5,step=1),gr.Slider(label="TopK for rescoring",value=5,minimum=5,maximum=10,step=1),gr.Slider(label="LLM weight when rescoring, 1 for complete LLM scoring, 0 for NLLB Decoding without LLM",value=1,minimum=0,maximum=1,step=0.1)],
|
25 |
+
outputs=[gr.Textbox(lines=1,placeholder="Enter your inputs and click submit!",label="LLM Guided NLLB German Translation"),gr.Image(label="Beam Visualization")],
|
26 |
examples=[example_formal,example_informal],
|
27 |
title="Ensembling NLLB 3.3B with LLama2 13B by Guided Decoding",
|
28 |
)
|