freQuensy23 commited on
Commit
c86acba
1 Parent(s): d65753c
Files changed (2) hide show
  1. app.py +3 -3
  2. generators.py +6 -16
app.py CHANGED
@@ -15,7 +15,7 @@ async def handle(system_input: str, user_input: str):
15
  generate_mistral_7bvo1(system_input, user_input),
16
  generate_llama2(system_input, user_input),
17
  generate_llama3(system_input, user_input),
18
- generate_mistral_7bvo3(system_input, user_input),
19
  ):
20
  # gpt_output, mistral_output, llama_output, llama2_output, llama3_output, llama4_output = outputs
21
  for i, b in enumerate(buffers):
@@ -30,7 +30,7 @@ with gr.Blocks() as demo:
30
  with gr.Row():
31
  gpt = gr.Textbox(label='gpt-2', lines=4, interactive=False)
32
  mistral = gr.Textbox(label='mistral-v01', lines=4, interactive=False)
33
- mistral_new = gr.Textbox(label='mistral-v03', lines=4, interactive=False)
34
  with gr.Row():
35
  llama2 = gr.Textbox(label='llama-2', lines=4, interactive=False)
36
  llama3 = gr.Textbox(label='llama-3', lines=4, interactive=False)
@@ -42,7 +42,7 @@ with gr.Blocks() as demo:
42
  gen_button.click(
43
  fn=handle,
44
  inputs=[system_input, user_input],
45
- outputs=[gpt, mistral, llama2, llama3, mistral_new, bloom],
46
  )
47
 
48
  demo.launch()
 
15
  generate_mistral_7bvo1(system_input, user_input),
16
  generate_llama2(system_input, user_input),
17
  generate_llama3(system_input, user_input),
18
+ generate_t5(system_input, user_input),
19
  ):
20
  # gpt_output, mistral_output, llama_output, llama2_output, llama3_output, llama4_output = outputs
21
  for i, b in enumerate(buffers):
 
30
  with gr.Row():
31
  gpt = gr.Textbox(label='gpt-2', lines=4, interactive=False)
32
  mistral = gr.Textbox(label='mistral-v01', lines=4, interactive=False)
33
+ t5 = gr.Textbox(label='t5', lines=4, interactive=False)
34
  with gr.Row():
35
  llama2 = gr.Textbox(label='llama-2', lines=4, interactive=False)
36
  llama3 = gr.Textbox(label='llama-3', lines=4, interactive=False)
 
42
  gen_button.click(
43
  fn=handle,
44
  inputs=[system_input, user_input],
45
+ outputs=[gpt, mistral, llama2, llama3, t5, bloom],
46
  )
47
 
48
  demo.launch()
generators.py CHANGED
@@ -38,25 +38,16 @@ async def generate_mistral_7bvo1(system_input, user_input):
38
  yield message.choices[0].delta.content
39
 
40
 
41
- async def generate_mistral_7bvo3(system_input, user_input):
42
- client = AsyncInferenceClient(
43
- "mistralai/Mistral-7B-Instruct-v0.3",
44
- token=os.getenv('HF_TOKEN'),
45
- )
46
-
47
- async for message in await client.chat_completion(
48
- messages=[
49
- {"role": "system", "content": system_input},
50
- {"role": "user", "content": user_input}, ],
51
- max_tokens=256,
52
- stream=True,
53
- ):
54
- yield message.choices[0].delta.content
55
 
56
 
57
  async def generate_gpt2(system_input, user_input):
58
  output = await query_llm({
59
- "inputs": (inputs:=f"{system_input}\n{user_input}"),
60
  }, "openai-community/gpt2")
61
  yield output[0]["generated_text"]
62
 
@@ -103,7 +94,6 @@ def generate_bloom(system_input, user_input):
103
  return tokenizer.decode(output[0], skip_special_tokens=True)
104
 
105
 
106
-
107
  async def generate_llama3(system_input, user_input):
108
  client = AsyncInferenceClient(
109
  "meta-llama/Meta-Llama-3.1-8B-Instruct",
 
38
  yield message.choices[0].delta.content
39
 
40
 
41
+ async def generate_t5(system_input, user_input):
42
+ output = await query_llm({
43
+ "inputs": (inputs := f"{system_input}\n{user_input}"),
44
+ }, "google/flan-t5-large")
45
+ yield output[0]["generated_text"]
 
 
 
 
 
 
 
 
 
46
 
47
 
48
  async def generate_gpt2(system_input, user_input):
49
  output = await query_llm({
50
+ "inputs": (inputs := f"{system_input}\n{user_input}"),
51
  }, "openai-community/gpt2")
52
  yield output[0]["generated_text"]
53
 
 
94
  return tokenizer.decode(output[0], skip_special_tokens=True)
95
 
96
 
 
97
  async def generate_llama3(system_input, user_input):
98
  client = AsyncInferenceClient(
99
  "meta-llama/Meta-Llama-3.1-8B-Instruct",