Skip to content
This repository has been archived by the owner on Oct 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #32 from shing100/main
Browse files Browse the repository at this point in the history
feat: update score, add tqdm
  • Loading branch information
StableFluffy authored Jun 24, 2024
2 parents 51b0329 + 1ce9572 commit cd32ad8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
7 changes: 4 additions & 3 deletions generator_openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from openai import OpenAI
import time
import os
from tqdm import tqdm

MAX_MODEL_LEN = 1600
# MODEL = "solar-1-mini-chat"
Expand All @@ -19,7 +20,7 @@ def format_single_turn_question(question):
single_turn_questions = df_questions['questions'].map(format_single_turn_question)
single_turn_outputs = []

for question in single_turn_questions:
for question in tqdm(single_turn_questions, desc="Processing Single Turn Questions"):
response = client.chat.completions.create(
model=MODEL,
messages=[
Expand All @@ -39,7 +40,7 @@ def format_double_turn_question(question, single_turn_output):

multi_turn_questions = df_questions[['questions', 'id']].apply(lambda x: format_double_turn_question(x['questions'], single_turn_outputs[x['id']-1]), axis=1)
multi_turn_outputs = []
for question in multi_turn_questions:
for question in tqdm(multi_turn_questions, desc="Processing Multi Turn Questions"):
response = client.chat.completions.create(
model=MODEL,
messages=[
Expand All @@ -56,4 +57,4 @@ def format_double_turn_question(question, single_turn_output):
multi_turn_outputs.append(response.choices[0].message.content.strip())

df_output = pd.DataFrame({'id': df_questions['id'], 'category': df_questions['category'], 'questions': df_questions['questions'], 'outputs': list(zip(single_turn_outputs, multi_turn_outputs)), "references": df_questions['references']})
df_output.to_json(f'{str(MODEL).replace("/", "_")}.jsonl', orient='records', lines=True, force_ascii=False)
df_output.to_json(f'{str(MODEL).replace("/", "_")}.jsonl', orient='records', lines=True, force_ascii=False)
25 changes: 20 additions & 5 deletions score.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,31 @@
total_single_scores.append(single_score)
total_multi_scores.append(multi_score)

# 카테고리별 평균 점수 계산
# 표의 헤더 생성
table_header = "| Category | Single turn | Multi turn |\n|---|---|---|"

# 표의 내용 생성
table_rows = []
for category, scores in category_scores.items():
avg_single = sum(scores['single_scores']) / len(scores['single_scores'])
avg_multi = sum(scores['multi_scores']) / len(scores['multi_scores'])
print(f"카테고리: {category}, 싱글 점수 평균: {avg_single:.2f}, 멀티 점수 평균: {avg_multi:.2f}")
table_rows.append(f"| {category} | {avg_single:.2f} | {avg_multi:.2f} |")

total_single_scores.extend(scores['single_scores'])
total_multi_scores.extend(scores['multi_scores'])

# 카테고리별 점수 평균 출력
print(table_header)
for row in table_rows:
print(row)

# 전체 점수의 평균 계산 및 출력
avg_total_single = sum(total_single_scores) / len(total_single_scores)
avg_total_multi = sum(total_multi_scores) / len(total_multi_scores)
avg_total = (avg_total_single + avg_total_multi) / 2
print(f"전체 싱글 점수 평균: {avg_total_single:.2f}")
print(f"전체 멀티 점수 평균: {avg_total_multi:.2f}")
print(f"전체 점수: {avg_total:.2f}")

# 전체 점수 평균 출력
print(f"\n| Category | Score |\n|---|---|")
print(f"| Single turn | {avg_total_single:.2f} |")
print(f"| Multi turn | {avg_total_multi:.2f} |")
print(f"| Overall | {avg_total:.2f} |")

0 comments on commit cd32ad8

Please sign in to comment.