Spaces:
Runtime error
Runtime error
update the api
Browse files
app.py
CHANGED
@@ -4,13 +4,14 @@ from mtranslate import translate
|
|
4 |
import requests
|
5 |
|
6 |
HF_AUTH_TOKEN = os.environ.get("HF_AUTH_TOKEN")
|
7 |
-
|
8 |
-
|
9 |
|
10 |
def get_answer(user_input, decoding_method, num_beams, top_k, top_p, temperature, repetition_penalty, penalty_alpha):
|
11 |
print(user_input, decoding_method, top_k, top_p, temperature, repetition_penalty, penalty_alpha)
|
12 |
-
headers = {'Authorization': 'Bearer ' +
|
13 |
data = {
|
|
|
14 |
"text": user_input,
|
15 |
"min_length": len(user_input) + 50,
|
16 |
"max_length": 300,
|
@@ -23,7 +24,7 @@ def get_answer(user_input, decoding_method, num_beams, top_k, top_p, temperature
|
|
23 |
"repetition_penalty": repetition_penalty,
|
24 |
"penalty_alpha": penalty_alpha
|
25 |
}
|
26 |
-
r = requests.post(
|
27 |
if r.status_code == 200:
|
28 |
result = r.json()
|
29 |
answer = result["generated_text"]
|
@@ -44,17 +45,15 @@ css = """
|
|
44 |
|
45 |
with gr.Blocks(css=css) as demo:
|
46 |
with gr.Row():
|
47 |
-
gr.Markdown("""##
|
48 |
-
|
49 |
-
|
50 |
-
multilingual instructions dataset. The base model is a GPT2-Medium (340M params) which was pretrained with 75GB
|
51 |
-
of Indonesian and English dataset, where English part is only less than 1% of the whole dataset.
|
52 |
""")
|
53 |
with gr.Row():
|
54 |
with gr.Column():
|
55 |
user_input = gr.inputs.Textbox(placeholder="",
|
56 |
-
label="Ask me something
|
57 |
-
default="
|
58 |
decoding_method = gr.inputs.Dropdown(["Beam Search", "Sampling", "Contrastive Search"],
|
59 |
default="Sampling", label="Decoding Method")
|
60 |
num_beams = gr.inputs.Slider(label="Number of beams for beam search",
|
|
|
4 |
import requests
|
5 |
|
6 |
HF_AUTH_TOKEN = os.environ.get("HF_AUTH_TOKEN")
|
7 |
+
text_generator_api = 'https://cahya-indonesian-whisperer.hf.space/api/text-generator/v1'
|
8 |
+
text_generator_api_auth_token = os.getenv("TEXT_GENERATOR_API_AUTH_TOKEN", "")
|
9 |
|
10 |
def get_answer(user_input, decoding_method, num_beams, top_k, top_p, temperature, repetition_penalty, penalty_alpha):
|
11 |
print(user_input, decoding_method, top_k, top_p, temperature, repetition_penalty, penalty_alpha)
|
12 |
+
headers = {'Authorization': 'Bearer ' + text_generator_api_auth_token}
|
13 |
data = {
|
14 |
+
"model_name": "bloomz-1b1-instruct",
|
15 |
"text": user_input,
|
16 |
"min_length": len(user_input) + 50,
|
17 |
"max_length": 300,
|
|
|
24 |
"repetition_penalty": repetition_penalty,
|
25 |
"penalty_alpha": penalty_alpha
|
26 |
}
|
27 |
+
r = requests.post(text_generator_api, headers=headers, data=data)
|
28 |
if r.status_code == 200:
|
29 |
result = r.json()
|
30 |
answer = result["generated_text"]
|
|
|
45 |
|
46 |
with gr.Blocks(css=css) as demo:
|
47 |
with gr.Row():
|
48 |
+
gr.Markdown("""## Bloomz-1b1-Instruct
|
49 |
+
We fine-tuned the BigScience model Bloomz-1b1 with instructions dataset of following languages:
|
50 |
+
English, Indonesian, Malaysian, Vietnam, Hindi, Spanish, German, French, Russian, and Chinese.
|
|
|
|
|
51 |
""")
|
52 |
with gr.Row():
|
53 |
with gr.Column():
|
54 |
user_input = gr.inputs.Textbox(placeholder="",
|
55 |
+
label="Ask me something",
|
56 |
+
default="How old is the universe?")
|
57 |
decoding_method = gr.inputs.Dropdown(["Beam Search", "Sampling", "Contrastive Search"],
|
58 |
default="Sampling", label="Decoding Method")
|
59 |
num_beams = gr.inputs.Slider(label="Number of beams for beam search",
|