Spaces:
Sleeping
Sleeping
Commit
·
42006d1
1
Parent(s):
b28dd28
debug
Browse files
app.py
CHANGED
|
@@ -35,7 +35,7 @@ def generate_responses(model, tokenizer, prompts):
|
|
| 35 |
**model_inputs,
|
| 36 |
do_sample=False,
|
| 37 |
temperature=0,
|
| 38 |
-
repetition_penalty=1.
|
| 39 |
max_new_tokens=512,
|
| 40 |
)
|
| 41 |
prompt_lengths = model_inputs["attention_mask"].sum(dim=1)
|
|
@@ -69,15 +69,16 @@ def generate(submission: list[dict[str, str]], team_id: str) -> list[dict[str, s
|
|
| 69 |
prompts = [s["prompt"] for s in submission]
|
| 70 |
|
| 71 |
responses = generate_responses(chat_model, chat_tokenizer, prompts)
|
|
|
|
|
|
|
| 72 |
scores = classify_pairs(moderator_model, moderator_tokenizer, prompts, responses)
|
| 73 |
-
|
|
|
|
| 74 |
outputs = [
|
| 75 |
{"id": id, "prompt": prompt, "response": response, "score": score, "model": chat_model_name, "team_id": team_id}
|
| 76 |
for id, prompt, response, score in zip(ids, prompts, responses, scores)
|
| 77 |
]
|
| 78 |
|
| 79 |
-
print(outputs)
|
| 80 |
-
|
| 81 |
return outputs
|
| 82 |
|
| 83 |
|
|
@@ -85,5 +86,5 @@ with gr.Blocks() as demo:
|
|
| 85 |
gr.Markdown("Welcome")
|
| 86 |
gr.api(generate, api_name="scores", batch=False)
|
| 87 |
|
| 88 |
-
demo.queue()
|
| 89 |
demo.launch()
|
|
|
|
| 35 |
**model_inputs,
|
| 36 |
do_sample=False,
|
| 37 |
temperature=0,
|
| 38 |
+
repetition_penalty=1.1,
|
| 39 |
max_new_tokens=512,
|
| 40 |
)
|
| 41 |
prompt_lengths = model_inputs["attention_mask"].sum(dim=1)
|
|
|
|
| 69 |
prompts = [s["prompt"] for s in submission]
|
| 70 |
|
| 71 |
responses = generate_responses(chat_model, chat_tokenizer, prompts)
|
| 72 |
+
print(responses)
|
| 73 |
+
|
| 74 |
scores = classify_pairs(moderator_model, moderator_tokenizer, prompts, responses)
|
| 75 |
+
print(scores)
|
| 76 |
+
|
| 77 |
outputs = [
|
| 78 |
{"id": id, "prompt": prompt, "response": response, "score": score, "model": chat_model_name, "team_id": team_id}
|
| 79 |
for id, prompt, response, score in zip(ids, prompts, responses, scores)
|
| 80 |
]
|
| 81 |
|
|
|
|
|
|
|
| 82 |
return outputs
|
| 83 |
|
| 84 |
|
|
|
|
| 86 |
gr.Markdown("Welcome")
|
| 87 |
gr.api(generate, api_name="scores", batch=False)
|
| 88 |
|
| 89 |
+
# demo.queue()
|
| 90 |
demo.launch()
|