Update app.py
Browse files
app.py
CHANGED
@@ -8,7 +8,7 @@ input_text = st.text_input("Enter text to translate:")
|
|
8 |
# Create a list of options for the select box
|
9 |
options = ["German", "Romanian", "English", "French", "Spanish"]
|
10 |
langs = {"English":"en", "Romanian":"ro", "German":"de", "French":"fr", "Spanish":"es", "Italian":"it"}
|
11 |
-
models = ["Helsinki-NLP", "t5-base", "t5-small", "t5-large", "Unbabel/TowerInstruct-7B-v0.2"]
|
12 |
|
13 |
# Create two columns
|
14 |
scol, tcol = st.columns(2)
|
@@ -62,7 +62,7 @@ if submit_button:
|
|
62 |
# Decode the translated text
|
63 |
translated_text = tokenizer.decode(output_ids[0], skip_special_tokens=True)
|
64 |
else:
|
65 |
-
pipe = pipeline("text-generation", model=
|
66 |
# We use the tokenizer’s chat template to format each message - see https://huggingface.co/docs/transformers/main/en/chat_templating
|
67 |
messages = [
|
68 |
{"role": "user", "content": f"Translate the following text from {sselected_language} into {tselected_language}.\n{sselected_language}: {input_text}.\n{tselected_language}:"},
|
|
|
8 |
# Create a list of options for the select box
|
9 |
options = ["German", "Romanian", "English", "French", "Spanish"]
|
10 |
langs = {"English":"en", "Romanian":"ro", "German":"de", "French":"fr", "Spanish":"es", "Italian":"it"}
|
11 |
+
models = ["Helsinki-NLP", "t5-base", "t5-small", "t5-large", "Unbabel/TowerInstruct-7B-v0.2", "Unbabel/TowerInstruct-Mistral-7B-v0.2"]
|
12 |
|
13 |
# Create two columns
|
14 |
scol, tcol = st.columns(2)
|
|
|
62 |
# Decode the translated text
|
63 |
translated_text = tokenizer.decode(output_ids[0], skip_special_tokens=True)
|
64 |
else:
|
65 |
+
pipe = pipeline("text-generation", model=model_name, torch_dtype=torch.bfloat16, device_map="auto")
|
66 |
# We use the tokenizer’s chat template to format each message - see https://huggingface.co/docs/transformers/main/en/chat_templating
|
67 |
messages = [
|
68 |
{"role": "user", "content": f"Translate the following text from {sselected_language} into {tselected_language}.\n{sselected_language}: {input_text}.\n{tselected_language}:"},
|