Fix mCORA, add Gemma preset
Browse files- .gitignore +3 -0
- app.py +23 -2
- presets.py +10 -0
.gitignore
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
*.pyc
|
2 |
+
*.html
|
3 |
+
*.json
|
app.py
CHANGED
@@ -20,6 +20,7 @@ from presets import (
|
|
20 |
set_mmt_preset,
|
21 |
set_towerinstruct_preset,
|
22 |
set_zephyr_preset,
|
|
|
23 |
)
|
24 |
from style import custom_css
|
25 |
from utils import get_formatted_attribute_context_results
|
@@ -115,7 +116,7 @@ def pecore(
|
|
115 |
out = attribute_context_with_model(pecore_args, loaded_model)
|
116 |
tuples = get_formatted_attribute_context_results(loaded_model, out.info, out)
|
117 |
if not tuples:
|
118 |
-
msg = "
|
119 |
tuples = [(msg, None)]
|
120 |
return tuples, gr.Button(visible=True), gr.Button(visible=True)
|
121 |
|
@@ -217,7 +218,7 @@ with gr.Blocks(css=custom_css) as demo:
|
|
217 |
"Multilingual MT", variant="secondary"
|
218 |
)
|
219 |
gr.Markdown(
|
220 |
-
"
|
221 |
)
|
222 |
with gr.Column(scale=1):
|
223 |
chatml_template = gr.Button("Qwen ChatML", variant="secondary")
|
@@ -231,6 +232,14 @@ with gr.Blocks(css=custom_css) as demo:
|
|
231 |
gr.Markdown(
|
232 |
"Preset for models using the <a href='https://huggingface.co/Unbabel/TowerInstruct-7B-v0.1' target='_blank'>Unbabel TowerInstruct</a> conversational template.\nUses <code><|im_start|></code>, <code><|im_end|></code> special tokens."
|
233 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
234 |
gr.Markdown("## βοΈ PECoRe Parameters")
|
235 |
with gr.Row(equal_height=True):
|
236 |
with gr.Column():
|
@@ -512,6 +521,18 @@ with gr.Blocks(css=custom_css) as demo:
|
|
512 |
input_template,
|
513 |
contextless_input_current_text,
|
514 |
decoder_input_output_separator,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
515 |
],
|
516 |
).success(preload_model, inputs=load_model_args)
|
517 |
|
|
|
20 |
set_mmt_preset,
|
21 |
set_towerinstruct_preset,
|
22 |
set_zephyr_preset,
|
23 |
+
set_gemma_preset,
|
24 |
)
|
25 |
from style import custom_css
|
26 |
from utils import get_formatted_attribute_context_results
|
|
|
116 |
out = attribute_context_with_model(pecore_args, loaded_model)
|
117 |
tuples = get_formatted_attribute_context_results(loaded_model, out.info, out)
|
118 |
if not tuples:
|
119 |
+
msg = f"Output: {out.output_current}\nWarning: No pairs were found by PECoRe. Try adjusting Results Selection parameters."
|
120 |
tuples = [(msg, None)]
|
121 |
return tuples, gr.Button(visible=True), gr.Button(visible=True)
|
122 |
|
|
|
218 |
"Multilingual MT", variant="secondary"
|
219 |
)
|
220 |
gr.Markdown(
|
221 |
+
"Preset for multilingual MT models such as <a href='https://huggingface.co/facebook/nllb-200-distilled-600M' target='_blank'>NLLB</a> and <a href='https://huggingface.co/facebook/mbart-large-50-many-to-many-mmt' target='_blank'>mBART</a> using language tags."
|
222 |
)
|
223 |
with gr.Column(scale=1):
|
224 |
chatml_template = gr.Button("Qwen ChatML", variant="secondary")
|
|
|
232 |
gr.Markdown(
|
233 |
"Preset for models using the <a href='https://huggingface.co/Unbabel/TowerInstruct-7B-v0.1' target='_blank'>Unbabel TowerInstruct</a> conversational template.\nUses <code><|im_start|></code>, <code><|im_end|></code> special tokens."
|
234 |
)
|
235 |
+
with gr.Row(equal_height=True):
|
236 |
+
with gr.Column(scale=1):
|
237 |
+
gemma_template = gr.Button(
|
238 |
+
"Gemma Chat Template", variant="secondary"
|
239 |
+
)
|
240 |
+
gr.Markdown(
|
241 |
+
"Preset for <a href='https://huggingface.co/google/gemma-2b-it' target='_blank'>Gemma</a> instruction-tuned models."
|
242 |
+
)
|
243 |
gr.Markdown("## βοΈ PECoRe Parameters")
|
244 |
with gr.Row(equal_height=True):
|
245 |
with gr.Column():
|
|
|
521 |
input_template,
|
522 |
contextless_input_current_text,
|
523 |
decoder_input_output_separator,
|
524 |
+
special_tokens_to_keep,
|
525 |
+
],
|
526 |
+
).success(preload_model, inputs=load_model_args)
|
527 |
+
|
528 |
+
gemma_template.click(**reset_kwargs).then(
|
529 |
+
set_gemma_preset,
|
530 |
+
outputs=[
|
531 |
+
model_name_or_path,
|
532 |
+
input_template,
|
533 |
+
contextless_input_current_text,
|
534 |
+
decoder_input_output_separator,
|
535 |
+
special_tokens_to_keep,
|
536 |
],
|
537 |
).success(preload_model, inputs=load_model_args)
|
538 |
|
presets.py
CHANGED
@@ -55,4 +55,14 @@ def set_towerinstruct_preset():
|
|
55 |
"<|im_start|>user\nSource: {current}\nContext: {context}\nTranslate the above text into French. Use the context to guide your answer.\nTarget:<|im_end|>\n<|im_start|>assistant\n", # input_template
|
56 |
"<|im_start|>user\nSource: {current}\nTranslate the above text into French.\nTarget:<|im_end|>\n<|im_start|>assistant\n", # input_current_text_template
|
57 |
"", # decoder_input_output_separator
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
)
|
|
|
55 |
"<|im_start|>user\nSource: {current}\nContext: {context}\nTranslate the above text into French. Use the context to guide your answer.\nTarget:<|im_end|>\n<|im_start|>assistant\n", # input_template
|
56 |
"<|im_start|>user\nSource: {current}\nTranslate the above text into French.\nTarget:<|im_end|>\n<|im_start|>assistant\n", # input_current_text_template
|
57 |
"", # decoder_input_output_separator
|
58 |
+
["<|im_start|>", "<|im_end|>"], # special_tokens_to_keep
|
59 |
+
)
|
60 |
+
|
61 |
+
def set_gemma_preset():
|
62 |
+
return (
|
63 |
+
"google/gemma-2b-it", # model_name_or_path
|
64 |
+
"<start_of_turn>user\n{context}\n{current}<end_of_turn>\n<start_of_turn>model\n", # input_template
|
65 |
+
"<start_of_turn>user\n{current}<end_of_turn>\n<start_of_turn>model\n", # input_current_text_template
|
66 |
+
"", # decoder_input_output_separator
|
67 |
+
["<start_of_turn>", "<end_of_turn>"], # special_tokens_to_keep
|
68 |
)
|