Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
codecritic
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ziyuan Nan
codecritic
Commits
4fdf6d7d
Commit
4fdf6d7d
authored
Oct 25, 2024
by
nanziyuan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
step4: test_critic_model fix bugs
parent
b78d979f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
7 deletions
+22
-7
step4_test_critic_model.py
+22
-7
No files found.
step4_test_critic_model.py
View file @
4fdf6d7d
from
utils_vllm
import
vllm_chatcomplete
,
vllm_score
from
utils
import
read_config
from
utils_vllm_bkp
import
vllm_chatcomplete
,
vllm_score
from
utils
import
read_config
,
load_jsonl
,
save_jsonl
from
utils_metric
import
group_results
,
score_pass_at_k
from
utils_preference_dataset
import
mk_critic_verify
from
transformers
import
AutoTokenizer
...
...
@@ -7,19 +9,33 @@ if __name__ == "__main__":
cfg
=
read_config
()
vllm_chatcomplete
(
cfg
[
"critic"
][
"model_path"
],
cfg
[
"
dataset"
][
"minimal_tes
t_path"
],
cfg
[
"
critic"
][
"test"
][
"promp
t_path"
],
cfg
[
"critic"
][
"test"
][
"reason_result_path"
],
cfg
[
"critic"
][
"test"
][
"sampling_params"
]
)
tokenizer
=
AutoTokenizer
.
from_pretrained
(
cfg
[
"model"
])
score_tokens
=
tokenizer
.
encode
(
"Yes"
)
score_tokens
=
tokenizer
.
encode
(
"Yes"
,
add_special_tokens
=
False
)
assert
len
(
score_tokens
)
==
1
score_token
=
score_tokens
[
0
]
reason_results
=
load_jsonl
(
cfg
[
"critic"
][
"test"
][
"reason_result_path"
])
score_prompts
=
[]
for
item
in
reason_results
:
item
[
"messages"
]
+=
mk_critic_verify
()
score_prompts
.
append
(
item
)
save_jsonl
(
score_prompts
,
"test_score_prompt.jsonl"
)
vllm_score
(
cfg
[
"critic"
][
"model_path"
],
cfg
[
"critic"
][
"test"
][
"reason_result_path"
]
,
"test_score_prompt.jsonl"
,
cfg
[
"critic"
][
"test"
][
"score_result_path"
],
score_token
)
\ No newline at end of file
)
results
=
load_jsonl
(
cfg
[
"critic"
][
"test"
][
"score_result_path"
])
groups
=
group_results
(
results
,
cfg
[
"apps"
])
eval_results
=
[
score_pass_at_k
(
groups
,
k
,
"critic"
)
for
k
in
range
(
1
,
16
)]
save_jsonl
(
eval_results
,
cfg
[
"critic"
][
"test"
][
"eval_result_path"
])
print
(
eval_results
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment