File size: 7,927 Bytes
45f8fc7
 
5b51c97
 
ebbfc4d
5b51c97
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
829d82e
5b51c97
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45f8fc7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5b51c97
 
 
 
 
 
45f8fc7
5b51c97
 
 
 
 
 
 
 
 
 
 
 
45f8fc7
5b51c97
 
 
 
 
 
 
 
1d0d849
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# Arena-Lite (ꡬ Arena-Lite)
μ•„λ ˆλ‚˜-λΌμ΄νŠΈλŠ” ν…ŒμŠ€νŠΈμ…‹ λͺ…λ Ήμ–΄λ³„λ‘œ 비ꡐ할 λͺ¨λΈλ“€μ˜ ν† λ„ˆλ¨ΌνŠΈλ₯Ό μˆ˜ν–‰ν•˜μ—¬ μ •ν™•ν•˜κ²Œ λͺ¨λΈλ“€μ˜ μˆœμœ„λ₯Ό λ§€κΉλ‹ˆλ‹€. 이것은 reference 아웃풋과 λΉ„κ΅ν•˜μ—¬ 승λ₯ μ„ λ§€κΈ°λŠ” 방법보닀 μ •ν™•ν•˜λ©° 쑰금 더 μ €λ ΄ν•©λ‹ˆλ‹€.

더 μžμ„Έν•œ λ‚΄μš©μ— λŒ€ν•΄μ„œλŠ” μ•„λž˜μ˜ 링크λ₯Ό μ°Έμ‘°ν•˜μ‹œλ©΄ λ©λ‹ˆλ‹€.
* [λ…Όλ¬Έ](https://arxiv.org/abs/2411.01281)
* [μ—”μ”¨μ†Œν”„νŠΈ ν…Œν¬λΈ”λ‘œκ·Έ (KR)](https://ncsoft.github.io/ncresearch/12cc62c1ea0d981971a8923401e8fe6a0f18563d)


## Quickstart
### λ‘œμ»¬μ—μ„œ 슀트림릿 μ•±μœΌλ‘œ μ‹œμž‘ν•˜κΈ° (μΆ”μ²œ!)
```bash
git clone [THIS_REPO]
# install requirements below. we recommend miniforge to manage environment
cd streamlit_app_local
bash run.sh
```
더 μžμ„Έν•œ λ‚΄μš©μ€ `[THIS_REPO]/streamlit_app_local/README.md` 을 μ°Έμ‘°ν•˜μ„Έμš”!

### CLI μ‚¬μš©
* cli와 μ›Ή 앱은 μ„œλ‘œ 같은 μ½”λ“œλ₯Ό ν™œμš©ν•˜λ©°, μ•„λž˜μ˜ 디렉토리에 μžˆμŠ΅λ‹ˆλ‹€.
  * `varco_arena/`
* vscode μƒμ—μ„œ 디버깅을 μœ„ν•œ 프리셋 ν”„λ‘¬ν”„νŠΈλ³„ ν…ŒμŠ€νŠΈ λͺ…λ Ήμ–΄λŠ” λ‹€μŒ νŒŒμΌμ— μ ν˜€μžˆμŠ΅λ‹ˆλ‹€.
  * `varco_arena/.vscode/launch.json`
```bash
## gpt-4o-mini as a judge
python main.py -i "./some/dirpath/to/jsonl/files" -o SOME_REL_PATH_TO_CREATE -m tournament -e "gpt-4o-mini"
## vllm-openai served LLM as a judge
python main.py -i "./some/dirpath/to/jsonl/files" -o SOME_REL_PATH_TO_CREATE -e SOME_MODEL_NAME_SERVED -m tournament -u "http://url_to/your/vllm_openai_server:someport"

# dbg lines
## openai api judge dbg
python main.py -i "rsc/inputs_for_dbg/dbg_400_error_inputs/" -o SOME_WANTED_TARGET_DIR -e gpt-4o-mini
## other testing lines
python main.py -i "rsc/inputs_for_dbg/[SOME_DIRECTORY]/" -o SOME_WANTED_TARGET_DIR -e gpt-4o-mini
## dummy judge dbg (checking errors without api requests)
python main.py -i "rsc/inputs_for_dbg/dbg_400_error_inputs/" -o SOME_WANTED_TARGET_DIR -e debug
```

## Requirements
```
pip install -r requirements.txt # python 3.11

# Linux인 경우
uvloop
# Windows인 경우
winloop
```

#### Argument
- -i, --input : μž…λ ₯ 파일 or 디렉토리 or 파일λͺ…에 λŒ€ν•œ μ •κ·œ ν‘œν˜„μ‹
- -o, --output_dir : 좜λ ₯ 파일이 μ €μž₯λ˜λŠ” 디렉토리
- -e, --evaluation : 평가 λͺ¨λΈ (e.g. "gpt-4o-2024-05-13", "gpt-4o-mini", vllmμ—μ„œ λ„μš΄ λͺ¨λΈ λͺ… λ“±)
- -m, --matching_method: 맀치 방식 (κΈ°λ³Έκ°’ "tournament", "league" (λΉ„μΆ”μ²œ) )
- -k, --openai_api_key : OpenAI API Key
- -u, --openai_url: 둜컬 vLLM OpenAI μ„œλ²„ μ‚¬μš© μ‹œ URL(ipμ£Όμ†Œ+포트)

#### advanced
- -j, --n_jobs : asyncio.semaphore()에 전달될 인자. Arenaκ°€ μ§„ν–‰λ˜μ§€ μ•ŠλŠ”λ‹€λ©΄ 기본값인 32 μ΄ν•˜λ‘œ λ‚΄λ €λ³΄μž
- -p, --evalprompt : [ν•΄λ‹Ή 디렉토리 μ°Έμ‘°](./varco_arena/prompts/*.yaml)
- -lr, --limit_requests : vLLM OpenAI μ„œλ²„ μš”μ²­ μ œν•œ (default: 7,680)
- -lt, --limit_tokens : vLLM OpenAI μ„œλ²„ 토큰 μ œν•œ (default: 15,728,640)

#### Input Data Format
[input jsonl κ°€μ΄λ“œ 링크](./streamlit_app_local/guide_mds/input_jsonls_kr.md)



## Contributing & Customizing
#### git clone 및 dependency μ„€μΉ˜ 후에 ν•  일
```bash
pip install pre-commit
pre-commit install
```
#### commit ν•˜κΈ° 전에 ν•  일
```bash
bash precommit.sh # 이게 μ½”λ“œλ“€μ„ λ‹€ λ¦¬ν¬λ§·ν•΄μ€„κ±°μž„
```

### πŸ“ μ»€μŠ€ν…€ ν”„λ‘¬ν”„νŠΈ μΆ”κ°€ν•˜κΈ°

μƒˆλ‘œμš΄ 평가 ν”„λ‘¬ν”„νŠΈλ₯Ό μΆ”κ°€ν•˜λŠ” 과정은 λ‹€μŒκ³Ό κ°™μŠ΅λ‹ˆλ‹€. 졜근 Judge 둜직이 `parsed_output` λ©”μ†Œλ“œλ§Œ μ‚¬μš©ν•˜λ„λ‘ κ°„μ†Œν™”λ˜μ–΄ 이전보닀 μ‰½κ²Œ ν”„λ‘¬ν”„νŠΈλ₯Ό μΆ”κ°€ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

κ°€μž₯ κ°„λ‹¨ν•œ 방법은 `llmbar_brief.py`와 `llmbar_brief.yaml` νŒŒμΌμ„ λ³΅μ‚¬ν•˜μ—¬ μžμ‹ λ§Œμ˜ ν”„λ‘¬ν”„νŠΈλ₯Ό λ§Œλ“œλŠ” κ²ƒμž…λ‹ˆλ‹€.

#### 1. ν”„λ‘¬ν”„νŠΈ `.py` 및 `.yaml` 파일 생성

-   `varco_arena/varco_arena_core/prompts/` κ²½λ‘œμ— `my_prompt.py`와 `my_prompt.yaml`처럼 νŒŒμΌμ„ μƒμ„±ν•©λ‹ˆλ‹€.
-   **`my_prompt.py`**:
    -   `ComparisonPromptBase`λ₯Ό μƒμ†λ°›λŠ” 클래슀λ₯Ό μ •μ˜ν•©λ‹ˆλ‹€.
    -   `parsed_output(self, response)` λ©”μ†Œλ“œλ₯Ό λ°˜λ“œμ‹œ κ΅¬ν˜„ν•΄μ•Ό ν•©λ‹ˆλ‹€. 이 ν•¨μˆ˜λŠ” LLM Judge의 응닡(`response`)을 λ°›μ•„, 승자λ₯Ό λ‚˜νƒ€λ‚΄λŠ” κ²°μ • 토큰(예: `'a'`, `'b'`)을 λ°˜ν™˜ν•΄μ•Ό ν•©λ‹ˆλ‹€.
-   **`my_prompt.yaml`**:
    -   `sampling_parameters`, `decision_tokens`, `prompt_template` λ“± ν”„λ‘¬ν”„νŠΈμ— ν•„μš”ν•œ μš”μ†Œλ“€μ„ μ •μ˜ν•©λ‹ˆλ‹€.
    -   `prompt_template` 에 λ“€μ–΄κ°€λŠ” λ¬Έμžμ—΄μ€ `string.Template`으둜 처리되며 `BasePrompt.complete_prompt()` ν•¨μˆ˜λ₯Ό 톡해 `eval_utils.py`μ—μ„œ μ΅œμ’… μ™„μ„±λ©λ‹ˆλ‹€.
    -   `${task}, ${generated}, ${model_id}`λ₯Ό `prompt_template`에 μ‚¬μš©ν•˜μ§€ λ§ˆμ„Έμš”. μ˜ˆμ•½λœ ν‚€μ›Œλ“œλ“€μž…λ‹ˆλ‹€.

#### 2. `prompts/__init__.py`에 ν”„λ‘¬ν”„νŠΈ 등둝

-   μƒμ„±ν•œ ν”„λ‘¬ν”„νŠΈ 클래슀λ₯Ό `import` ν•©λ‹ˆλ‹€.
    ```python
    from .my_prompt import MyPrompt
    ```
-   `NAME2PROMPT_CLS` λ”•μ…”λ„ˆλ¦¬μ— μƒˆ ν”„λ‘¬ν”„νŠΈ 이름과 클래슀 객체λ₯Ό μΆ”κ°€ν•©λ‹ˆλ‹€.
    ```python
    NAME2PROMPT_CLS = dict(
        # ... κΈ°μ‘΄ ν”„λ‘¬ν”„νŠΈλ“€
        my_prompt=MyPrompt(),
    )
    ```
-   `load_prompt` ν•¨μˆ˜μ˜ `promptname` 인자의 `Literal` νƒ€μž… νžŒνŠΈμ— μƒˆ ν”„λ‘¬ν”„νŠΈ 이름을 μΆ”κ°€ν•©λ‹ˆλ‹€.
    ```python
    def load_prompt(
        promptname: Literal[
            # ... κΈ°μ‘΄ ν”„λ‘¬ν”„νŠΈ 이름듀
            "my_prompt",
        ],
        # ...
    ):
    ```

#### 3. `eval_prompt_list.txt`에 ν”„λ‘¬ν”„νŠΈ μΆ”κ°€

-   ν”„λ‘œμ νŠΈ 루트의 `eval_prompt_list.txt` νŒŒμΌμ„ μ—΄κ³ , μƒˆ ν”„λ‘¬ν”„νŠΈμ˜ 이름(`my_prompt`)을 μƒˆ 쀄에 μΆ”κ°€ν•©λ‹ˆλ‹€.

#### 4. (ꢌμž₯) ν…ŒμŠ€νŠΈ 및 디버깅

-   ν”„λ‘¬ν”„νŠΈκ°€ μ˜λ„λŒ€λ‘œ μž‘λ™ν•˜λŠ”μ§€ ν™•μΈν•˜κΈ° μœ„ν•΄ 디버깅을 ꢌμž₯ν•©λ‹ˆλ‹€.
-   `.vscode/launch.json` 파일의 `"VA"` μ„€μ •μ—μ„œ `args`λ₯Ό λ‹€μŒκ³Ό 같이 μˆ˜μ •ν•©λ‹ˆλ‹€.
    -   `"-p", "translation_fortunecookie"` 뢀뢄을 `"-p", "my_prompt"`둜 λ³€κ²½ν•©λ‹ˆλ‹€.
    -   ν•„μš”μ‹œ `"-i", "..."` 뢀뢄에 μƒˆ ν”„λ‘¬ν”„νŠΈμ— μ ν•©ν•œ ν…ŒμŠ€νŠΈ 데이터 경둜λ₯Ό μ§€μ •ν•©λ‹ˆλ‹€.
-   VS Code의 `Run and Debug` νƒ­(Ctrl+Shift+D)으둜 μ΄λ™ν•˜μ—¬ "VA" 섀정을 μ„ νƒν•˜κ³  F5 ν‚€λ₯Ό 눌러 디버거λ₯Ό μ‹€ν–‰ν•©λ‹ˆλ‹€.
-   `-o` 뒀에 λͺ…μ‹œν•œ output 디렉토리 μ•ˆμ—μ„œ `result.json` λ₯Ό μ°Ύμ•„μ„œ μ›ν•˜λŠ”λŒ€λ‘œ λ™μž‘ν–ˆλŠ”μ§€ ν™•μΈν•΄λ³΄μ„Έμš”. λͺ¨λ“  judge와 λ§€μΉ˜μ— ν™œμš©λœ ν”„λ‘¬ν”„νŠΈ 정보가 λ‹΄κ²¨μžˆμŠ΅λ‹ˆλ‹€. 

문의: 손선일
* λ‚΄κ°€ λ§Œλ“  ν”„λ‘¬ν”„νŠΈλ₯Ό μ‚¬μš©ν•˜κ³  μ‹Άμ–΄μš”
  * [`./varco_arena/prompts/`](./varco_arena_core/prompts/__init__.py) 에선 각쒅 ν”„λ‘¬ν”„νŠΈ 클래슀 및 `yaml` 파일 ν˜•νƒœλ‘œ μ •μ˜λœ ν”„λ‘¬ν”„νŠΈλ₯Ό λ‘œλ“œν•©λ‹ˆλ‹€. 프리셋을 μ°Έμ‘°ν•˜μ—¬ μž‘μ„±ν•˜μ‹œλ©΄ λ©λ‹ˆλ‹€.
* ν…ŒμŠ€νŠΈμ…‹ λ³„λ‘œ λ‹€λ₯Έ 평가 ν”„λ‘¬ν”„νŠΈλ₯Ό μ‚¬μš©ν•˜κ³  μ‹Άμ–΄μš” (e.g. μž‘μ—…μ— 따라 λ‹€λ₯Έ ν”„λ‘¬ν”„νŠΈλ₯Ό μ‚¬μš©ν•˜κ³  μ‹Άμ–΄μš”)
  * μœ„ κ±Έμ–΄λ“œλ¦° 링크의 `load_prompt` λ₯Ό ν†΅ν•΄μ„œ `promptname` + `task` ν˜•νƒœλ‘œ [`./varco_arena_core/manager.py:async_run`](./varco_arena_core/manager.py) ν”„λ‘¬ν”„νŠΈκ°€ λ‘œλ“œλ˜λ„λ‘ ν•΄λ†“μ•˜μŠ΅λ‹ˆλ‹€.


## Special Thanks to (contributors)
- 이민호 (@λŒ€ν™”λͺ¨λΈνŒ€, NCSOFT) [github](https://github.com/minolee/)
  - query wrapper
  - rag prompt
- 였주민 (@생성λͺ¨λΈνŒ€, NCSOFT)
  - overall prototyping of the system in haste

## Citation
저희 μž‘μ—…λ¬Όμ΄ 도움이 λ˜μ—ˆλ‹€λ©΄ 저희도 도움을 λ°›μ•„λ³Ό 수 μžˆμ„κΉŒμš”?πŸ˜‰
```
@misc{son2024varcoarenatournamentapproach,
      title={VARCO Arena: A Tournament Approach to Reference-Free Benchmarking Large Language Models},
      author={Seonil Son and Ju-Min Oh and Heegon Jin and Cheolhun Jang and Jeongbeom Jeong and Kuntae Kim},
      year={2024},
      eprint={2411.01281},
      archivePrefix={arXiv},
      primaryClass={cs.CL},
      url={https://arxiv.org/abs/2411.01281},
}
```

## 페이퍼 μ‹€ν—˜ 데이터 (μž¬ν˜„μš©)
https://huggingface.co/datasets/fgenie777/Arena-Lite-Experiments-Result-Data/tree/main