|
|
--- |
|
|
library_name: peft |
|
|
base_model: MLP-KTLim/llama-3-Korean-Bllossom-8B |
|
|
license: llama3 |
|
|
datasets: |
|
|
- HAERAE-HUB/K2-Feedback |
|
|
language: |
|
|
- ko |
|
|
--- |
|
|
|
|
|
# ํ๊ตญ์ด Prometheus ๋ชจ๋ธ (Test Model) |
|
|
|
|
|
LoRA ํ์ตํ ๋ค, [LogicKor](https://github.com/instructkr/LogicKor)์ ๊ณต๊ฐ๋ GPT-4์ judgement์ ๋น๊ตํด๋ณด์์ต๋๋ค. |
|
|
์์ ์ ์๋ ํ๋กฌํํธ๋ก ํ๊ฐ ํ ์๊ด๊ณ์๋ฅผ ๋ถ์ํ์์ผ๋ (Spearman), ์๊ด๊ณ์๋ 0.3647๋ก ๋์ง ์์์ต๋๋ค. |
|
|
์ฑ๊ธํด ์ง๋ฌธ์ ๋๋ต๋ง ํ๊ฐํ์ผ๋ฉฐ, reference๊ฐ ์๋ ์ง๋ฌธ์ GPT-4์ ๋๋ต์ 5์ reference๋ก ์ฃผ์์ต๋๋ค. |
|
|
|
|
|
์นดํ
๊ณ ๋ฆฌ๋ณ ์๊ด๊ณ์ |
|
|
|
|
|
- ๊ธ์ฐ๊ธฐ: 0.436584 |
|
|
- ์ํ: 0.551298 |
|
|
- ์ถ๋ก : 0.395449 |
|
|
- ๋ฌธ๋ฒ: 0.262858 |
|
|
- ์ดํด: 0.436034 |
|
|
- ์ฝ๋ฉ: 0.290976 |
|
|
|
|
|
๋ฌธ๋ฒ๊ณผ ์ฝ๋ฉ ๋ถ๋ถ์ด ๋น๊ต์ ๋ฎ์ ๊ฒ์ ์ ์ ์์ต๋๋ค. |
|
|
|
|
|
### ์ฌ์ฉ ์์ |
|
|
|
|
|
```python |
|
|
from peft import PeftModel |
|
|
from transformers import AutoModelForCausalLM, AutoTokenizer |
|
|
|
|
|
model = AutoModelForCausalLM.from_pretrained("MLP-KTLim/llama-3-Korean-Bllossom-8B", device_map="cuda", torch_dtype="auto").eval() |
|
|
tokenizer = AutoTokenizer.from_pretrained("MLP-KTLim/llama-3-Korean-Bllossom-8B") |
|
|
model.load_adapter("heegyu/ko-prometheus-8b-lora-0708") |
|
|
|
|
|
|
|
|
PROMETHEUS_PROMPT = """###Task Description: |
|
|
An instruction (might include an Input inside it), a response to evaluate, a reference answer that gets a score of 5, and a score rubric representing a evaluation criteria are given. |
|
|
1. Write a detailed feedback that assess the quality of the response strictly based on the given score rubric, not evaluating in general. |
|
|
2. After writing a feedback, write a score that is an integer between 1 and 5. You should refer to the score rubric. |
|
|
3. The output format should look as follows: "Feedback: (write a feedback for criteria) [RESULT] (an integer number between 1 and 5)" |
|
|
4. Please do not generate any other opening, closing, and explanations. |
|
|
|
|
|
###The instruction to evaluate: |
|
|
{instruction} |
|
|
|
|
|
###Response to evaluate: |
|
|
{response} |
|
|
|
|
|
###Reference Answer (Score 5): |
|
|
{reference} |
|
|
|
|
|
###Score Rubrics: |
|
|
{rubrics} |
|
|
|
|
|
###Feedback:""" |
|
|
|
|
|
RUBRICS = { |
|
|
"์ถ๋ก (Reasoning)":"""[์ธ์ด ๋ชจ๋ธ์ ๋ต๋ณ์ด ๋
ผ๋ฆฌ์ ์ด๊ณ , ์ผ๊ด์ฑ ์์ผ๋ฉฐ, ๊น์ด ์๋ ๋ถ์์ ์ ๊ณตํ๋๊ฐ?] |
|
|
Score 1: ๋ต๋ณ์ด ๋น๋
ผ๋ฆฌ์ ์ด๊ณ ์ผ๊ด์ฑ์ด ์์ผ๋ฉฐ, ํ๋ฉด์ ์ธ ๋ถ์์ ๊ทธ์น๋ค. |
|
|
Score 2: ๋ต๋ณ์ ์ผ๋ถ ๋
ผ๋ฆฌ์ ์ธ ์์๊ฐ ์์ง๋ง, ์ผ๊ด์ฑ์ด ๋ถ์กฑํ๊ณ ๋ถ์์ด ์๋ค. |
|
|
Score 3: ๋ต๋ณ์ด ๋์ฒด๋ก ๋
ผ๋ฆฌ์ ์ด๊ณ ์ผ๊ด์ฑ์ด ์์ผ๋, ์ผ๋ถ ๋
ผ๋ฆฌ์ ๋น์ฝ์ด ์๊ณ ๋ถ์์ ๊น์ด๊ฐ ๋ณดํต ์์ค์ด๋ค. |
|
|
Score 4: ๋ต๋ณ์ด ๋
ผ๋ฆฌ์ ์ด๊ณ ์ผ๊ด์ฑ์ด ์์ผ๋ฉฐ, ๋์ฒด๋ก ๊น์ด ์๋ ๋ถ์์ ์ ๊ณตํ๋ค. ์ฌ์ํ ๋
ผ๋ฆฌ์ ๊ฒฐํจ์ด ์์ ์ ์๋ค. |
|
|
Score 5: ๋ต๋ณ์ด ์๋ฒฝํ๊ฒ ๋
ผ๋ฆฌ์ ์ด๊ณ ์ผ๊ด์ฑ์ด ์์ผ๋ฉฐ, ๋งค์ฐ ๊น์ด ์๊ณ ํต์ฐฐ๋ ฅ ์๋ ๋ถ์์ ์ ๊ณตํ๋ค.""", |
|
|
"์ํ(Math)": """[์ธ์ด ๋ชจ๋ธ์ ๋ต๋ณ์ด ์ํ์ ์ผ๋ก ์ ํํ๊ณ , ํ์ด ๊ณผ์ ์ด ๋ช
ํํ๋ฉฐ, ํจ์จ์ ์ธ ํด๋ฒ์ ์ ์ํ๋๊ฐ?] |
|
|
Score 1: ๋ต๋ณ์ด ์ํ์ ์ผ๋ก ์์ ํ ๋ถ์ ํํ๊ณ , ํ์ด ๊ณผ์ ์ด ์๊ฑฐ๋ ์ดํดํ ์ ์์ผ๋ฉฐ, ๋นํจ์จ์ ์ธ ์ ๊ทผ๋ฒ์ ์ฌ์ฉํ๋ค. |
|
|
Score 2: ๋ต๋ณ์ ์ผ๋ถ ์ ํํ ์ํ์ ์์๊ฐ ์์ง๋ง ์ค์ํ ์ค๋ฅ๊ฐ ์๊ณ , ํ์ด ๊ณผ์ ์ด ๋ถ์์ ํ๋ฉฐ, ๋นํจ์จ์ ์ธ ํด๋ฒ์ ์ ์ํ๋ค. |
|
|
Score 3: ๋ต๋ณ์ด ๋์ฒด๋ก ์ํ์ ์ผ๋ก ์ ํํ์ง๋ง ์ผ๋ถ ์ค๋ฅ๊ฐ ์๊ณ , ํ์ด ๊ณผ์ ์ด ์ด๋ ์ ๋ ๋ช
ํํ๋ฉฐ, ๊ธฐ๋ณธ์ ์ธ ํจ์จ์ฑ์ ๊ฐ์ถ ํด๋ฒ์ ์ ์ํ๋ค. |
|
|
Score 4: ๋ต๋ณ์ด ์ํ์ ์ผ๋ก ์ ํํ๊ณ , ํ์ด ๊ณผ์ ์ด ๋ช
ํํ๋ฉฐ, ํจ์จ์ ์ธ ํด๋ฒ์ ์ ์ํ๋ค. ์ฌ์ํ ๊ฐ์ ์ ์ฌ์ง๊ฐ ์์ ์ ์๋ค. |
|
|
Score 5: ๋ต๋ณ์ด ์ํ์ ์ผ๋ก ์๋ฒฝํ๊ฒ ์ ํํ๊ณ , ํ์ด ๊ณผ์ ์ด ๋งค์ฐ ๋ช
ํํ๋ฉฐ, ๊ฐ์ฅ ํจ์จ์ ์ด๊ณ ์ฐฝ์์ ์ธ ํด๋ฒ์ ์ ์ํ๋ค.""", |
|
|
"๊ธ์ฐ๊ธฐ(Writing)": """[์ธ์ด ๋ชจ๋ธ์ ๋ต๋ณ์ด ๊ตฌ์กฐ์ ์ด๊ณ , ๋ฌธ์ฒด๊ฐ ์ ์ ํ๋ฉฐ, ๋ด์ฉ์ด ํ๋ถํ๊ณ ์ฐฝ์์ ์ธ๊ฐ?] |
|
|
Score 1: ๋ต๋ณ์ ๊ตฌ์กฐ๊ฐ ์๊ณ , ๋ฌธ์ฒด๊ฐ ๋ถ์ ์ ํ๋ฉฐ, ๋ด์ฉ์ด ๋น์ฝํ๊ณ ์ฐฝ์์ฑ์ด ์ ํ ์๋ค. |
|
|
Score 2: ๋ต๋ณ์ ๊ธฐ๋ณธ์ ์ธ ๊ตฌ์กฐ๊ฐ ์์ง๋ง ๋ถ์์ ํ๊ณ , ๋ฌธ์ฒด๊ฐ ์ผ๊ด์ฑ์ด ์์ผ๋ฉฐ, ๋ด์ฉ์ด ์ ํ์ ์ด๊ณ ์ฐฝ์์ฑ์ด ๋ถ์กฑํ๋ค. |
|
|
Score 3: ๋ต๋ณ์ด ์ด๋ ์ ๋ ๊ตฌ์กฐ์ ์ด๊ณ , ๋ฌธ์ฒด๊ฐ ๋ณดํต ์์ค์ด๋ฉฐ, ๋ด์ฉ์ด ์ ๋นํ๊ณ ์ฝ๊ฐ์ ์ฐฝ์์ฑ์ด ์๋ค. |
|
|
Score 4: ๋ต๋ณ์ด ์ ๊ตฌ์กฐํ๋์ด ์๊ณ , ๋ฌธ์ฒด๊ฐ ์ ์ ํ๋ฉฐ, ๋ด์ฉ์ด ํ๋ถํ๊ณ ์ฐฝ์์ ์ธ ์์๊ฐ ์๋ค. |
|
|
Score 5: ๋ต๋ณ์ด ์๋ฒฝํ๊ฒ ๊ตฌ์กฐํ๋์ด ์๊ณ , ๋ฌธ์ฒด๊ฐ ํ์ํ๋ฉฐ, ๋ด์ฉ์ด ๋งค์ฐ ํ๋ถํ๊ณ ๋์ ์์ค์ ์ฐฝ์์ฑ์ ๋ณด์ธ๋ค.""", |
|
|
"์ฝ๋ฉ(Coding)": """[์ธ์ด ๋ชจ๋ธ์ ๋ต๋ณ์ด ์ ํํ๊ณ , ํจ์จ์ ์ด๋ฉฐ, ๊ฐ๋
์ฑ ์๋ ์ฝ๋๋ฅผ ์ ๊ณตํ๋๊ฐ?] |
|
|
Score 1: ์ฝ๋๊ฐ ์ ํ ์๋ํ์ง ์๊ณ , ๋นํจ์จ์ ์ด๋ฉฐ, ๊ฐ๋
์ฑ์ด ๋งค์ฐ ๋ฎ๋ค. |
|
|
Score 2: ์ฝ๋๊ฐ ๋ถ๋ถ์ ์ผ๋ก ์๋ํ์ง๋ง ์ฃผ์ ์ค๋ฅ๊ฐ ์๊ณ , ํจ์จ์ฑ์ด ๋ฎ์ผ๋ฉฐ, ๊ฐ๋
์ฑ์ด ๋ถ์กฑํ๋ค. |
|
|
Score 3: ์ฝ๋๊ฐ ๋์ฒด๋ก ์๋ํ๊ณ ๊ธฐ๋ณธ์ ์ธ ํจ์จ์ฑ์ ๊ฐ์ถ์์ผ๋, ์ผ๋ถ ๋ฒ๊ทธ๊ฐ ์๊ณ ๊ฐ๋
์ฑ์ด ๋ณดํต ์์ค์ด๋ค. |
|
|
Score 4: ์ฝ๋๊ฐ ์ ํํ๊ฒ ์๋ํ๊ณ ํจ์จ์ ์ด๋ฉฐ, ๊ฐ๋
์ฑ์ด ์ข๋ค. ์ฌ์ํ ๊ฐ์ ์ ์ฌ์ง๊ฐ ์์ ์ ์๋ค. |
|
|
Score 5: ์ฝ๋๊ฐ ์๋ฒฝํ๊ฒ ์๋ํ๊ณ ๋งค์ฐ ํจ์จ์ ์ด๋ฉฐ, ๋ฐ์ด๋ ๊ฐ๋
์ฑ๊ณผ ์ต์ ํ๋ ๊ตฌ์กฐ๋ฅผ ๊ฐ์ถ๊ณ ์๋ค.""", |
|
|
"์ดํด(Understanding)": """[์ธ์ด ๋ชจ๋ธ์ด ํ๊ตญ์ด ํ
์คํธ์ ์๋ฏธ, ๋์์ค, ๋ฌธ๋งฅ์ ์ ํํ๊ฒ ์ดํดํ๊ณ ์ ์ ํ๊ฒ ์๋ตํ๋๊ฐ?] |
|
|
Score 1: ํ๊ตญ์ด ํ
์คํธ์ ์๋ฏธ๋ฅผ ์ ํ ์ดํดํ์ง ๋ชปํ๊ณ , ๋ฌธ๋งฅ๊ณผ ๋์์ค๋ฅผ ์์ ํ ๋์น๋ฉฐ, ๋ถ์ ์ ํ ์๋ต์ ํ๋ค. |
|
|
Score 2: ํ๊ตญ์ด ํ
์คํธ์ ๊ธฐ๋ณธ์ ์ธ ์๋ฏธ๋ง ๋ถ๋ถ์ ์ผ๋ก ์ดํดํ๊ณ , ๋๋ถ๋ถ์ ๋ฌธ๋งฅ๊ณผ ๋์์ค๋ฅผ ๋์น๋ฉฐ, ๋ถ์ ์ ํ ์๋ต์ด ๋ง๋ค. |
|
|
Score 3: ํ๊ตญ์ด ํ
์คํธ์ ์ฃผ์ ์๋ฏธ๋ฅผ ์ดํดํ์ง๋ง ์ผ๋ถ ๋์์ค๋ฅผ ๋์น๊ณ , ๋ฌธ๋งฅ์ ๋ถ๋ถ์ ์ผ๋ก ํ์
ํ๋ฉฐ, ๋์ฒด๋ก ์ ์ ํ ์๋ต์ ํ๋ค. |
|
|
Score 4: ํ๊ตญ์ด ํ
์คํธ์ ์๋ฏธ๋ฅผ ์ ํํ ์ดํดํ๊ณ , ๋๋ถ๋ถ์ ๋์์ค์ ๋ฌธ๋งฅ์ ํ์
ํ๋ฉฐ, ์ ์ ํ ์๋ต์ ํ๋ค. |
|
|
Score 5: ํ๊ตญ์ด ํ
์คํธ์ ์๋ฏธ, ๋์์ค, ๋ฌธ๋งฅ์ ์๋ฒฝํ๊ฒ ์ดํดํ๊ณ , ๋งค์ฐ ์ ์ ํ๊ณ ์ธ๋ จ๋ ์๋ต์ ํ๋ค.""", |
|
|
"๋ฌธ๋ฒ(Grammar)":"""[์ธ์ด ๋ชจ๋ธ์ ๋ต๋ณ์ด ํ๊ตญ์ด ๋ฌธ๋ฒ ๊ท์น์ ์ ํํ ๋ฐ๋ฅด๊ณ , ์ ์ ํ ์ดํ์ ํํ์ ์ฌ์ฉํ๋๊ฐ?] |
|
|
Score 1: ์ฌ๊ฐํ ๋ฌธ๋ฒ ์ค๋ฅ๊ฐ ๋ง๊ณ , ๋ถ์ ์ ํ ์ดํ์ ํํ์ ์ฌ์ฉํ์ฌ ์๋ฏธ ์ ๋ฌ์ด ๊ฑฐ์ ๋ถ๊ฐ๋ฅํ๋ค. |
|
|
Score 2: ์ค์ํ ๋ฌธ๋ฒ ์ค๋ฅ๊ฐ ์๊ณ , ์ ํ๋ ์ดํ์ ๋ถ์ ์ ํ ํํ์ ์ฌ์ฉํ์ฌ ์๋ฏธ ์ ๋ฌ์ ์ด๋ ค์์ด ์๋ค. |
|
|
Score 3: ์ผ๋ถ ๋ฌธ๋ฒ ์ค๋ฅ๊ฐ ์์ง๋ง ์ ๋ฐ์ ์ผ๋ก ์ดํด ๊ฐ๋ฅํ๋ฉฐ, ๊ธฐ๋ณธ์ ์ธ ์ดํ์ ํํ์ ์ฌ์ฉํ๋ค. |
|
|
Score 4: ์ฌ์ํ ๋ฌธ๋ฒ ์ค๋ฅ๋ง ์๊ณ , ์ ์ ํ ์ดํ์ ํํ์ ์ฌ์ฉํ์ฌ ์๋ฏธ๋ฅผ ๋ช
ํํ ์ ๋ฌํ๋ค. |
|
|
Score 5: ์๋ฒฝํ ๋ฌธ๋ฒ์ ๊ตฌ์ฌํ๊ณ , ๋ค์ํ๊ณ ์ ํํ ์ดํ์ ์ธ๋ จ๋ ํํ์ ์ฌ์ฉํ์ฌ ์๋ฏธ๋ฅผ ํ์ํ๊ฒ ์ ๋ฌํ๋ค.""", |
|
|
} |
|
|
|
|
|
def judge(instruction, response, reference, rubrics): |
|
|
prompt = PROMETHEUS_PROMPT.format( |
|
|
instruction=instruction, |
|
|
response=response, |
|
|
reference=reference, |
|
|
rubrics=rubrics |
|
|
) |
|
|
input_ids = tokenizer.apply_chat_template( |
|
|
[{"role": "user", "content": prompt}], |
|
|
return_tensors="pt", |
|
|
add_generation_prompt=True |
|
|
).to(model.device) |
|
|
judgement = model.generate( |
|
|
input_ids, |
|
|
max_new_tokens=256, |
|
|
early_stopping=True, |
|
|
eos_token_id=tokenizer.eos_token_id, |
|
|
) |
|
|
judgement = tokenizer.decode(judgement[0, input_ids.shape[-1]:], skip_special_tokens=True) |
|
|
score = int(judgement.split("[RESULT]")[1]) |
|
|
return judgement, score |
|
|
|
|
|
print(judge( |
|
|
"f(x) = 3x^3 + 2x^2 + 58์ ๋ฏธ๋ถํ์์ค.", |
|
|
"ํจ์ f(x) = 3x^3 + 2x^2 + 58๋ฅผ ๋ฏธ๋ถํ๋ฉด,\n\nf'(x) = d(3x^3)/dx + d(2x^2)/dx + d(58)/dx\n\n= 3d(x^3)/dx + 2d(x^2)/dx + 0 (์์ํญ์ ๋ฏธ๋ถํ๋ฉด 0)\n\n= 3(3x^2) + 2(2x)\n\n= 9x^2 + 4x\n\n๋ฐ๋ผ์, ํจ์ f(x) = 3x^3 + 2x^2 + 58์ ๋ฏธ๋ถ๊ฐ์ f'(x) = 9x^2 + 4x์
๋๋ค.", |
|
|
"9x^2 + 4x", |
|
|
RUBRICS["์ํ(Math)"] |
|
|
)) |
|
|
|
|
|
``` |
|
|
|
|
|
๊ฒฐ๊ณผ: ์ด ๋ต๋ณ์ ํจ์ f(x) = 3x^3 + 2x^2 + 58๋ฅผ ๋ฏธ๋ถํ๋ ๊ณผ์ ์ ์ ํํ๊ฒ ์ํํ๊ณ ์์ต๋๋ค. ๊ฐ ํญ์ ๋ฏธ๋ถ์ ๋ช
ํํ๊ฒ ์ค๋ช
ํ๊ณ ์์ผ๋ฉฐ, ์์ํญ์ ๋ํ ๋ฏธ๋ถ์ ๊ฒฐ๊ณผ๋ฅผ ์ฌ๋ฐ๋ฅด๊ฒ ๋ํ๋์ต๋๋ค. ๊ทธ๋ฌ๋ ๋ฏธ๋ถ ๊ณผ์ ์ ์ค๋ช
ํ๋ ๊ณผ์ ์์ ์ข ๋ ์ธ๋ถ์ ์ธ ์ค๋ช
์ ์ ๊ณตํ ์ ์์์ ๊ฒ์
๋๋ค. ์๋ฅผ ๋ค์ด, ๊ฐ ํญ์ ๋ํ ๋ฏธ๋ถ์ ์ด๋ป๊ฒ ์ํํ๋์ง์ ๋ํ ์ค๋ช
์ด ๋ ๋ช
ํํ ์ ์์ต๋๋ค. ์ด๋ฌํ ์ฌ์ํ ๊ฐ์ ์ ์ฌ์ง๊ฐ ์๊ธด ํ์ง๋ง, ์ ๋ฐ์ ์ผ๋ก ์ํ์ ์ผ๋ก ์ ํํ๊ณ ํจ์จ์ ์ธ ํด๋ฒ์ ์ ์ํ๊ณ ์๊ธฐ ๋๋ฌธ์ 4์ ์ด ์ ์ ํฉ๋๋ค. [RESULT] 4', 4 |