flexeval 0.3.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- flexeval-0.3.1/LICENSE +202 -0
- flexeval-0.3.1/PKG-INFO +91 -0
- flexeval-0.3.1/README.md +62 -0
- flexeval-0.3.1/flexeval/__init__.py +17 -0
- flexeval-0.3.1/flexeval/core/__init__.py +0 -0
- flexeval-0.3.1/flexeval/core/chat_dataset/__init__.py +3 -0
- flexeval-0.3.1/flexeval/core/chat_dataset/base.py +71 -0
- flexeval-0.3.1/flexeval/core/chat_dataset/chatbot_bench.py +81 -0
- flexeval-0.3.1/flexeval/core/chat_dataset/chatbot_bench_datasets/README.md +13 -0
- flexeval-0.3.1/flexeval/core/chat_dataset/chatbot_bench_datasets/mt-en-ref-gpt4.jsonl +30 -0
- flexeval-0.3.1/flexeval/core/chat_dataset/chatbot_bench_datasets/mt-en.jsonl +80 -0
- flexeval-0.3.1/flexeval/core/chat_dataset/chatbot_bench_datasets/mt-ja-ref-gpt4.jsonl +80 -0
- flexeval-0.3.1/flexeval/core/chat_dataset/chatbot_bench_datasets/mt-ja.jsonl +80 -0
- flexeval-0.3.1/flexeval/core/chat_dataset/chatbot_bench_datasets/rakuda-v2-ja.jsonl +40 -0
- flexeval-0.3.1/flexeval/core/chat_dataset/chatbot_bench_datasets/vicuna-en-ref-gpt4.jsonl +10 -0
- flexeval-0.3.1/flexeval/core/chat_dataset/chatbot_bench_datasets/vicuna-en.jsonl +80 -0
- flexeval-0.3.1/flexeval/core/chat_dataset/chatbot_bench_datasets/vicuna-ja-ref-gpt4.jsonl +10 -0
- flexeval-0.3.1/flexeval/core/chat_dataset/chatbot_bench_datasets/vicuna-ja.jsonl +80 -0
- flexeval-0.3.1/flexeval/core/chat_dataset/hf_dataset.py +82 -0
- flexeval-0.3.1/flexeval/core/evaluate_chat_response.py +109 -0
- flexeval-0.3.1/flexeval/core/evaluate_from_file.py +65 -0
- flexeval-0.3.1/flexeval/core/evaluate_generation.py +100 -0
- flexeval-0.3.1/flexeval/core/evaluate_multiple_choice.py +106 -0
- flexeval-0.3.1/flexeval/core/evaluate_pairwise.py +75 -0
- flexeval-0.3.1/flexeval/core/evaluate_perplexity.py +45 -0
- flexeval-0.3.1/flexeval/core/few_shot_generator/__init__.py +3 -0
- flexeval-0.3.1/flexeval/core/few_shot_generator/balanced.py +61 -0
- flexeval-0.3.1/flexeval/core/few_shot_generator/base.py +39 -0
- flexeval-0.3.1/flexeval/core/few_shot_generator/rand.py +32 -0
- flexeval-0.3.1/flexeval/core/generation_dataset/__init__.py +4 -0
- flexeval-0.3.1/flexeval/core/generation_dataset/base.py +40 -0
- flexeval-0.3.1/flexeval/core/generation_dataset/hf_dataset.py +58 -0
- flexeval-0.3.1/flexeval/core/generation_dataset/jsonl.py +50 -0
- flexeval-0.3.1/flexeval/core/generation_dataset/sacrebleu_dataset.py +28 -0
- flexeval-0.3.1/flexeval/core/language_model/__init__.py +4 -0
- flexeval-0.3.1/flexeval/core/language_model/base.py +58 -0
- flexeval-0.3.1/flexeval/core/language_model/hf_lm.py +434 -0
- flexeval-0.3.1/flexeval/core/language_model/openai_chatgpt.py +124 -0
- flexeval-0.3.1/flexeval/core/language_model/vllm_model.py +115 -0
- flexeval-0.3.1/flexeval/core/metric/__init__.py +13 -0
- flexeval-0.3.1/flexeval/core/metric/base.py +45 -0
- flexeval-0.3.1/flexeval/core/metric/bleu.py +55 -0
- flexeval-0.3.1/flexeval/core/metric/char_f1.py +41 -0
- flexeval-0.3.1/flexeval/core/metric/code_eval.py +76 -0
- flexeval-0.3.1/flexeval/core/metric/common_prefix_length.py +38 -0
- flexeval-0.3.1/flexeval/core/metric/common_string_length.py +62 -0
- flexeval-0.3.1/flexeval/core/metric/exact_match.py +45 -0
- flexeval-0.3.1/flexeval/core/metric/llm_score.py +185 -0
- flexeval-0.3.1/flexeval/core/metric/normalizer/__init__.py +3 -0
- flexeval-0.3.1/flexeval/core/metric/normalizer/aio.py +36 -0
- flexeval-0.3.1/flexeval/core/metric/normalizer/base.py +18 -0
- flexeval-0.3.1/flexeval/core/metric/normalizer/regex.py +21 -0
- flexeval-0.3.1/flexeval/core/metric/output_length_stats.py +23 -0
- flexeval-0.3.1/flexeval/core/metric/perspective_api.py +81 -0
- flexeval-0.3.1/flexeval/core/metric/rouge.py +65 -0
- flexeval-0.3.1/flexeval/core/metric/substring_match.py +32 -0
- flexeval-0.3.1/flexeval/core/metric/tokenizer/__init__.py +4 -0
- flexeval-0.3.1/flexeval/core/metric/tokenizer/base.py +16 -0
- flexeval-0.3.1/flexeval/core/metric/tokenizer/mecab.py +18 -0
- flexeval-0.3.1/flexeval/core/metric/tokenizer/sacrebleu_tokenizer.py +20 -0
- flexeval-0.3.1/flexeval/core/metric/tokenizer/whitespace.py +12 -0
- flexeval-0.3.1/flexeval/core/metric/xer.py +52 -0
- flexeval-0.3.1/flexeval/core/multiple_choice_dataset/__init__.py +2 -0
- flexeval-0.3.1/flexeval/core/multiple_choice_dataset/base.py +42 -0
- flexeval-0.3.1/flexeval/core/multiple_choice_dataset/hf_dataset.py +87 -0
- flexeval-0.3.1/flexeval/core/pairwise_comparison/__init__.py +4 -0
- flexeval-0.3.1/flexeval/core/pairwise_comparison/judge/__init__.py +2 -0
- flexeval-0.3.1/flexeval/core/pairwise_comparison/judge/base.py +55 -0
- flexeval-0.3.1/flexeval/core/pairwise_comparison/judge/llm_judge.py +82 -0
- flexeval-0.3.1/flexeval/core/pairwise_comparison/match.py +35 -0
- flexeval-0.3.1/flexeval/core/pairwise_comparison/match_maker/__init__.py +3 -0
- flexeval-0.3.1/flexeval/core/pairwise_comparison/match_maker/all_combinations.py +31 -0
- flexeval-0.3.1/flexeval/core/pairwise_comparison/match_maker/base.py +23 -0
- flexeval-0.3.1/flexeval/core/pairwise_comparison/match_maker/random_combinations.py +61 -0
- flexeval-0.3.1/flexeval/core/pairwise_comparison/scorer/__init__.py +3 -0
- flexeval-0.3.1/flexeval/core/pairwise_comparison/scorer/base.py +25 -0
- flexeval-0.3.1/flexeval/core/pairwise_comparison/scorer/bradley_terry.py +104 -0
- flexeval-0.3.1/flexeval/core/pairwise_comparison/scorer/win_rate.py +36 -0
- flexeval-0.3.1/flexeval/core/prompt_template/__init__.py +2 -0
- flexeval-0.3.1/flexeval/core/prompt_template/base.py +18 -0
- flexeval-0.3.1/flexeval/core/prompt_template/jinja2.py +22 -0
- flexeval-0.3.1/flexeval/core/text_dataset/__init__.py +3 -0
- flexeval-0.3.1/flexeval/core/text_dataset/base.py +14 -0
- flexeval-0.3.1/flexeval/core/text_dataset/hf.py +28 -0
- flexeval-0.3.1/flexeval/core/text_dataset/jsonl.py +27 -0
- flexeval-0.3.1/flexeval/core/utils/__init__.py +0 -0
- flexeval-0.3.1/flexeval/core/utils/data_util.py +38 -0
- flexeval-0.3.1/flexeval/core/utils/jinja2_env.py +14 -0
- flexeval-0.3.1/flexeval/preset_configs/EvalSetup/code_generation/jhumaneval.jsonnet +34 -0
- flexeval-0.3.1/flexeval/preset_configs/EvalSetup/code_generation/jhumaneval_tab_indent.jsonnet +27 -0
- flexeval-0.3.1/flexeval/preset_configs/EvalSetup/code_generation/mbpp.jsonnet +66 -0
- flexeval-0.3.1/flexeval/preset_configs/EvalSetup/code_generation/mbpp_tab_indent.jsonnet +39 -0
- flexeval-0.3.1/flexeval/preset_configs/EvalSetup/code_generation/openai_humaneval.jsonnet +34 -0
- flexeval-0.3.1/flexeval/preset_configs/EvalSetup/code_generation/openai_humaneval_tab_indent.jsonnet +27 -0
- flexeval-0.3.1/flexeval/preset_configs/EvalSetup/en_chat/mt-en.jsonnet +25 -0
- flexeval-0.3.1/flexeval/preset_configs/EvalSetup/en_chat/vicuna-en.jsonnet +24 -0
- flexeval-0.3.1/flexeval/preset_configs/EvalSetup/en_generation/babi.jsonnet +49 -0
- flexeval-0.3.1/flexeval/preset_configs/EvalSetup/en_generation/commonsense_qa.jsonnet +60 -0
- flexeval-0.3.1/flexeval/preset_configs/EvalSetup/en_generation/gsm8k.jsonnet +48 -0
- flexeval-0.3.1/flexeval/preset_configs/EvalSetup/en_generation/squad_v1.jsonnet +51 -0
- flexeval-0.3.1/flexeval/preset_configs/EvalSetup/en_generation/trivia_qa.jsonnet +51 -0
- flexeval-0.3.1/flexeval/preset_configs/EvalSetup/en_generation/twitter_sentiment.jsonnet +49 -0
- flexeval-0.3.1/flexeval/preset_configs/EvalSetup/en_multiple_choice/commonsense_qa_mc.jsonnet +49 -0
- flexeval-0.3.1/flexeval/preset_configs/EvalSetup/en_multiple_choice/hellaswag.jsonnet +48 -0
- flexeval-0.3.1/flexeval/preset_configs/EvalSetup/en_multiple_choice/openbookqa.jsonnet +49 -0
- flexeval-0.3.1/flexeval/preset_configs/EvalSetup/en_multiple_choice/xwinograd_en.jsonnet +36 -0
- flexeval-0.3.1/flexeval/preset_configs/EvalSetup/en_preplexity/tiny_shakespeare.jsonnet +22 -0
- flexeval-0.3.1/flexeval/preset_configs/EvalSetup/ja_chat/elyze_tasks_100.jsonnet +28 -0
- flexeval-0.3.1/flexeval/preset_configs/EvalSetup/ja_chat/mt-ja.jsonnet +24 -0
- flexeval-0.3.1/flexeval/preset_configs/EvalSetup/ja_chat/rakuda-v2-ja.jsonnet +24 -0
- flexeval-0.3.1/flexeval/preset_configs/EvalSetup/ja_chat/vicuna-ja.jsonnet +24 -0
- flexeval-0.3.1/flexeval/preset_configs/EvalSetup/ja_generation/aio.jsonnet +48 -0
- flexeval-0.3.1/flexeval/preset_configs/EvalSetup/ja_generation/jcommonsenseqa.jsonnet +63 -0
- flexeval-0.3.1/flexeval/preset_configs/EvalSetup/ja_generation/jnli.jsonnet +54 -0
- flexeval-0.3.1/flexeval/preset_configs/EvalSetup/ja_generation/jsquad.jsonnet +59 -0
- flexeval-0.3.1/flexeval/preset_configs/EvalSetup/ja_generation/mgsm_ja.jsonnet +49 -0
- flexeval-0.3.1/flexeval/preset_configs/EvalSetup/ja_generation/wrime_pos_neg.jsonnet +51 -0
- flexeval-0.3.1/flexeval/preset_configs/EvalSetup/ja_generation/xlsum_ja.jsonnet +55 -0
- flexeval-0.3.1/flexeval/preset_configs/EvalSetup/ja_multiple_choice/jcommonsenseqa_mc.jsonnet +52 -0
- flexeval-0.3.1/flexeval/preset_configs/EvalSetup/ja_multiple_choice/xwinograd_ja.jsonnet +36 -0
- flexeval-0.3.1/flexeval/preset_configs/EvalSetup/translation/wmt20_en_ja.jsonnet +48 -0
- flexeval-0.3.1/flexeval/preset_configs/EvalSetup/translation/wmt20_ja_en.jsonnet +48 -0
- flexeval-0.3.1/flexeval/preset_configs/Metric/assistant_eval_gpt4_en_single_turn.jsonnet +37 -0
- flexeval-0.3.1/flexeval/preset_configs/Metric/assistant_eval_gpt4_ja_single_turn.jsonnet +37 -0
- flexeval-0.3.1/flexeval/preset_configs/PairwiseJudge/assistant_judge_gpt4_en_single_turn.jsonnet +43 -0
- flexeval-0.3.1/flexeval/preset_configs/PairwiseJudge/assistant_judge_gpt4_ja_single_turn.jsonnet +43 -0
- flexeval-0.3.1/flexeval/scripts/__init__.py +0 -0
- flexeval-0.3.1/flexeval/scripts/common.py +151 -0
- flexeval-0.3.1/flexeval/scripts/flexeval_file.py +140 -0
- flexeval-0.3.1/flexeval/scripts/flexeval_lm.py +341 -0
- flexeval-0.3.1/flexeval/scripts/flexeval_pairwise.py +140 -0
- flexeval-0.3.1/flexeval/scripts/flexeval_presets.py +69 -0
- flexeval-0.3.1/pyproject.toml +103 -0
flexeval-0.3.1/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
flexeval-0.3.1/PKG-INFO
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: flexeval
|
|
3
|
+
Version: 0.3.1
|
|
4
|
+
Summary:
|
|
5
|
+
Author: ryokan-ri
|
|
6
|
+
Author-email: ryokan.ri@sbintuitions.co.jp
|
|
7
|
+
Requires-Python: >=3.8, !=2.7.*, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, !=3.6.*, !=3.7.*
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
+
Provides-Extra: vllm
|
|
13
|
+
Requires-Dist: datasets (>=2.14.6,<3.0.0)
|
|
14
|
+
Requires-Dist: evaluate (>=0.4.1,<0.5.0)
|
|
15
|
+
Requires-Dist: fuzzywuzzy (>=0.18.0,<0.19.0)
|
|
16
|
+
Requires-Dist: google-api-python-client (>=2.131.0,<3.0.0)
|
|
17
|
+
Requires-Dist: jinja2 (>=3.1.2,<4.0.0)
|
|
18
|
+
Requires-Dist: jiwer (>=3.0.4,<4.0.0)
|
|
19
|
+
Requires-Dist: jsonargparse[jsonnet] (>=4.26.1,<5.0.0)
|
|
20
|
+
Requires-Dist: openai (>=1.16.1,<2.0.0)
|
|
21
|
+
Requires-Dist: peft (>=0.10.0,<0.11.0)
|
|
22
|
+
Requires-Dist: python-levenshtein (>=0.23.0,<0.24.0)
|
|
23
|
+
Requires-Dist: rouge (>=1.0.1,<2.0.0)
|
|
24
|
+
Requires-Dist: sacrebleu[ja] (>=2.4.1,<3.0.0)
|
|
25
|
+
Requires-Dist: transformers[ja,sentencepiece,torch] (>=4.34.1,<5.0.0)
|
|
26
|
+
Requires-Dist: vllm (>=0.4.0,<0.5.0) ; extra == "vllm"
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
|
|
29
|
+
# FlexEval
|
|
30
|
+
|
|
31
|
+

|
|
32
|
+
|
|
33
|
+
**Flexible evaluation tool for language models. Easy to extend, highly customizable!**
|
|
34
|
+
|
|
35
|
+
<h4 align="center">
|
|
36
|
+
<p>
|
|
37
|
+
<b>English</b> |
|
|
38
|
+
<a href="https://github.com/sbintuitions/flexeval/blob/main/README_ja.md">日本語</a> |
|
|
39
|
+
</p>
|
|
40
|
+
</h4>
|
|
41
|
+
|
|
42
|
+
With FlexEval, you can evaluate language models with:
|
|
43
|
+
|
|
44
|
+
* Zero/few-shot in-context learning tasks
|
|
45
|
+
* Open-ended text-generation benchmarks such as [MT-Bench](https://github.com/lm-sys/FastChat/tree/main/fastchat/llm_judge) with automatic evaluation using GPT-4
|
|
46
|
+
* Log-probability-based multiple-choice tasks
|
|
47
|
+
* Computing perplexity of text data
|
|
48
|
+
|
|
49
|
+
For more use cases, see the [documentation](https://sbintuitions.github.io/flexeval/).
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
## Key Features
|
|
53
|
+
|
|
54
|
+
* **Flexibility**: `flexeval` is flexible in terms of the evaluation setup and the language model to be evaluated.
|
|
55
|
+
* **Modularity**: The core components of `flexeval` are easily extensible and replaceable.
|
|
56
|
+
* **Clarity**: The results of evaluation are clear and all the details are saved.
|
|
57
|
+
* **Reproducibility**: `flexeval` should be reproducible, with the ability to save and load configurations and results.
|
|
58
|
+
|
|
59
|
+
## Installation
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
pip install flexeval
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Quick Start
|
|
66
|
+
|
|
67
|
+
The following minimal example evaluates the hugging face model `sbintuitions/tiny-lm` with the `commonsense_qa` task.
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
flexeval_lm \
|
|
71
|
+
--language_model HuggingFaceLM \
|
|
72
|
+
--language_model.model_name "sbintuitions/tiny-lm" \
|
|
73
|
+
--eval_setup "commonsense_qa" \
|
|
74
|
+
--save_dir "results/commonsense_qa"
|
|
75
|
+
```
|
|
76
|
+
(The model used in the example is solely for debugging purposes and does not perform well. Try switching to your favorite model!)
|
|
77
|
+
|
|
78
|
+
The results saved in `--saved_dir` contain:
|
|
79
|
+
|
|
80
|
+
* `config.json`: The configuration of the evaluation, which can be used to replicate the evaluation.
|
|
81
|
+
* `metrics.json`: The evaluation metrics.
|
|
82
|
+
* `outputs.jsonl`: The outputs of the language model that comes with instance-level metrics.
|
|
83
|
+
|
|
84
|
+
You can flexibly customize the evaluation by specifying command-line arguments or configuration files.
|
|
85
|
+
Besides the [Transformers](https://github.com/huggingface/transformers) model, you can also evaluate models via [OpenAI ChatGPT](https://openai.com/index/openai-api/) and [vLLM](https://github.com/vllm-project/vllm), and other models can be readily added!
|
|
86
|
+
|
|
87
|
+
## Next Steps
|
|
88
|
+
* Run `flexeval_presets` to check the list of off-the-shelf presets in addition to `commonsense_qa`. You can find the details in the [Preset Configs](https://sbintuitions.github.io/flexeval/preset_configs/) section.
|
|
89
|
+
* See [Getting Started](https://sbintuitions.github.io/flexeval/getting_started/) to check the tutorial examples for other kinds of tasks.
|
|
90
|
+
* See the [Configuration Guide](https://sbintuitions.github.io/flexeval/configuration_guide/) to set up your evaluation.
|
|
91
|
+
|
flexeval-0.3.1/README.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# FlexEval
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
**Flexible evaluation tool for language models. Easy to extend, highly customizable!**
|
|
6
|
+
|
|
7
|
+
<h4 align="center">
|
|
8
|
+
<p>
|
|
9
|
+
<b>English</b> |
|
|
10
|
+
<a href="https://github.com/sbintuitions/flexeval/blob/main/README_ja.md">日本語</a> |
|
|
11
|
+
</p>
|
|
12
|
+
</h4>
|
|
13
|
+
|
|
14
|
+
With FlexEval, you can evaluate language models with:
|
|
15
|
+
|
|
16
|
+
* Zero/few-shot in-context learning tasks
|
|
17
|
+
* Open-ended text-generation benchmarks such as [MT-Bench](https://github.com/lm-sys/FastChat/tree/main/fastchat/llm_judge) with automatic evaluation using GPT-4
|
|
18
|
+
* Log-probability-based multiple-choice tasks
|
|
19
|
+
* Computing perplexity of text data
|
|
20
|
+
|
|
21
|
+
For more use cases, see the [documentation](https://sbintuitions.github.io/flexeval/).
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
## Key Features
|
|
25
|
+
|
|
26
|
+
* **Flexibility**: `flexeval` is flexible in terms of the evaluation setup and the language model to be evaluated.
|
|
27
|
+
* **Modularity**: The core components of `flexeval` are easily extensible and replaceable.
|
|
28
|
+
* **Clarity**: The results of evaluation are clear and all the details are saved.
|
|
29
|
+
* **Reproducibility**: `flexeval` should be reproducible, with the ability to save and load configurations and results.
|
|
30
|
+
|
|
31
|
+
## Installation
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pip install flexeval
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Quick Start
|
|
38
|
+
|
|
39
|
+
The following minimal example evaluates the hugging face model `sbintuitions/tiny-lm` with the `commonsense_qa` task.
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
flexeval_lm \
|
|
43
|
+
--language_model HuggingFaceLM \
|
|
44
|
+
--language_model.model_name "sbintuitions/tiny-lm" \
|
|
45
|
+
--eval_setup "commonsense_qa" \
|
|
46
|
+
--save_dir "results/commonsense_qa"
|
|
47
|
+
```
|
|
48
|
+
(The model used in the example is solely for debugging purposes and does not perform well. Try switching to your favorite model!)
|
|
49
|
+
|
|
50
|
+
The results saved in `--saved_dir` contain:
|
|
51
|
+
|
|
52
|
+
* `config.json`: The configuration of the evaluation, which can be used to replicate the evaluation.
|
|
53
|
+
* `metrics.json`: The evaluation metrics.
|
|
54
|
+
* `outputs.jsonl`: The outputs of the language model that comes with instance-level metrics.
|
|
55
|
+
|
|
56
|
+
You can flexibly customize the evaluation by specifying command-line arguments or configuration files.
|
|
57
|
+
Besides the [Transformers](https://github.com/huggingface/transformers) model, you can also evaluate models via [OpenAI ChatGPT](https://openai.com/index/openai-api/) and [vLLM](https://github.com/vllm-project/vllm), and other models can be readily added!
|
|
58
|
+
|
|
59
|
+
## Next Steps
|
|
60
|
+
* Run `flexeval_presets` to check the list of off-the-shelf presets in addition to `commonsense_qa`. You can find the details in the [Preset Configs](https://sbintuitions.github.io/flexeval/preset_configs/) section.
|
|
61
|
+
* See [Getting Started](https://sbintuitions.github.io/flexeval/getting_started/) to check the tutorial examples for other kinds of tasks.
|
|
62
|
+
* See the [Configuration Guide](https://sbintuitions.github.io/flexeval/configuration_guide/) to set up your evaluation.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from .core.chat_dataset import *
|
|
2
|
+
from .core.evaluate_chat_response import evaluate_chat_response
|
|
3
|
+
from .core.evaluate_from_file import evaluate_from_file
|
|
4
|
+
from .core.evaluate_generation import evaluate_generation
|
|
5
|
+
from .core.evaluate_multiple_choice import evaluate_multiple_choice
|
|
6
|
+
from .core.evaluate_pairwise import evaluate_pairwise
|
|
7
|
+
from .core.evaluate_perplexity import evaluate_perplexity
|
|
8
|
+
from .core.few_shot_generator import *
|
|
9
|
+
from .core.generation_dataset import *
|
|
10
|
+
from .core.language_model import *
|
|
11
|
+
from .core.metric import *
|
|
12
|
+
from .core.metric.normalizer import *
|
|
13
|
+
from .core.metric.tokenizer import *
|
|
14
|
+
from .core.multiple_choice_dataset import *
|
|
15
|
+
from .core.pairwise_comparison import *
|
|
16
|
+
from .core.prompt_template import *
|
|
17
|
+
from .core.text_dataset import *
|
|
File without changes
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from abc import ABC, abstractmethod
|
|
4
|
+
from dataclasses import dataclass
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@dataclass
|
|
9
|
+
class ChatInstance:
|
|
10
|
+
"""
|
|
11
|
+
A dataclass representing a single chat that will be fed to a chat language model.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
messages: list[dict[str, str]]
|
|
15
|
+
"""
|
|
16
|
+
A list of messages in the chat.
|
|
17
|
+
The format of messages typically follows [OpenAI's Chat Completions API](https://platform.openai.com/docs/guides/text-generation/chat-completions-api).
|
|
18
|
+
```json
|
|
19
|
+
[
|
|
20
|
+
{
|
|
21
|
+
"role": "assistant",
|
|
22
|
+
"content": "Hello! How can I help you today?"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"role": "user",
|
|
26
|
+
"content": "I'd like to book a flight to Paris."
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
```
|
|
30
|
+
"""
|
|
31
|
+
references: list[str]
|
|
32
|
+
"""
|
|
33
|
+
A list of reference responses to the user's last message.
|
|
34
|
+
The model's response will be evaluated against these references.
|
|
35
|
+
"""
|
|
36
|
+
extra_info: dict[str, Any]
|
|
37
|
+
"""
|
|
38
|
+
Extra information that can be used by passing to `Metric`.
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
def __post_init__(self) -> None:
|
|
42
|
+
if "messages" in self.extra_info:
|
|
43
|
+
msg = "extra_info cannot contain a key named 'messages'. It will conflict with the 'messages' attribute."
|
|
44
|
+
raise ValueError(msg)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class ChatDataset(ABC):
|
|
48
|
+
"""A dataset holding `ChatInstance`."""
|
|
49
|
+
|
|
50
|
+
@abstractmethod
|
|
51
|
+
def __len__(self) -> int:
|
|
52
|
+
"""
|
|
53
|
+
Returns the number of chat instances in the dataset.
|
|
54
|
+
"""
|
|
55
|
+
raise NotImplementedError
|
|
56
|
+
|
|
57
|
+
@abstractmethod
|
|
58
|
+
def __getitem__(self, i: int) -> ChatInstance:
|
|
59
|
+
"""
|
|
60
|
+
Returns the i-th chat instance.
|
|
61
|
+
"""
|
|
62
|
+
raise NotImplementedError
|
|
63
|
+
|
|
64
|
+
@abstractmethod
|
|
65
|
+
def require_incremental_response(self) -> bool:
|
|
66
|
+
"""If true, the inputs consist of multiple user utterances and the
|
|
67
|
+
model should generate responses for each utterance incrementally.
|
|
68
|
+
|
|
69
|
+
Otherwise, the model just has to continue the conversation from the last user utterance.
|
|
70
|
+
"""
|
|
71
|
+
raise NotImplementedError
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
from os import PathLike
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
from .base import ChatDataset, ChatInstance
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def resolve_file_path_or_name(file_path_or_name: str | PathLike[str]) -> Path:
|
|
11
|
+
if not Path(file_path_or_name).exists():
|
|
12
|
+
curated_dataset_path = Path(__file__).parent / "chatbot_bench_datasets" / f"{file_path_or_name}.jsonl"
|
|
13
|
+
if not curated_dataset_path.exists():
|
|
14
|
+
msg = f"Unknown dataset path or name: {file_path_or_name}"
|
|
15
|
+
raise ValueError(msg)
|
|
16
|
+
file_path = curated_dataset_path
|
|
17
|
+
else:
|
|
18
|
+
file_path = file_path_or_name
|
|
19
|
+
return file_path
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class ChatbotBench(ChatDataset):
|
|
23
|
+
"""This class loads data with the jsonl format used in chat evaluation benchmarks such as
|
|
24
|
+
MT-Bench (Multi-turn Benchmark) or Vicuna QA Benchmark.
|
|
25
|
+
|
|
26
|
+
Example of a line from a jsonl file:
|
|
27
|
+
{
|
|
28
|
+
"question_id": 00,
|
|
29
|
+
"category": "writing",
|
|
30
|
+
"turns": [
|
|
31
|
+
"Compose an engaging travel blog post about a recent trip to Hawaii.",
|
|
32
|
+
"Rewrite your previous response. Start every sentence with the letter A."
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
def __init__(
|
|
38
|
+
self,
|
|
39
|
+
file_path_or_name: str,
|
|
40
|
+
ref_file_path_or_name: str | None = None,
|
|
41
|
+
need_ref_categories: list[str] | None = None,
|
|
42
|
+
) -> None:
|
|
43
|
+
file_path = resolve_file_path_or_name(file_path_or_name)
|
|
44
|
+
|
|
45
|
+
self._id_to_question_id: list[int | str] = []
|
|
46
|
+
self._id_to_category: list[str] = []
|
|
47
|
+
self._messages_dict: dict[int | str, list[dict[str, str]]] = {}
|
|
48
|
+
with open(file_path) as f:
|
|
49
|
+
for line in f:
|
|
50
|
+
item = json.loads(line)
|
|
51
|
+
self._id_to_question_id.append(item["question_id"])
|
|
52
|
+
self._id_to_category.append(item["category"])
|
|
53
|
+
self._messages_dict[item["question_id"]] = [{"role": "user", "content": turn} for turn in item["turns"]]
|
|
54
|
+
|
|
55
|
+
self._references_dict: dict[int | str, list[str]] = {}
|
|
56
|
+
if ref_file_path_or_name is not None:
|
|
57
|
+
ref_file_path = resolve_file_path_or_name(ref_file_path_or_name)
|
|
58
|
+
with open(ref_file_path) as f:
|
|
59
|
+
for line in f:
|
|
60
|
+
item = json.loads(line)
|
|
61
|
+
self._references_dict[item["question_id"]] = item["choices"][0]["turns"]
|
|
62
|
+
|
|
63
|
+
self.need_ref_categories = need_ref_categories or [
|
|
64
|
+
"math",
|
|
65
|
+
"coding",
|
|
66
|
+
"reasoning",
|
|
67
|
+
]
|
|
68
|
+
|
|
69
|
+
def require_incremental_response(self) -> bool:
|
|
70
|
+
return True
|
|
71
|
+
|
|
72
|
+
def __len__(self) -> int:
|
|
73
|
+
return len(self._id_to_question_id)
|
|
74
|
+
|
|
75
|
+
def __getitem__(self, i: int) -> ChatInstance:
|
|
76
|
+
question_id = self._id_to_question_id[i]
|
|
77
|
+
category = self._id_to_category[i]
|
|
78
|
+
references: list[str] = []
|
|
79
|
+
if category in self.need_ref_categories:
|
|
80
|
+
references = self._references_dict.get(question_id, [])
|
|
81
|
+
return ChatInstance(self._messages_dict[question_id], references=references, extra_info={"category": category})
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Chatbot Bench Datasets
|
|
2
|
+
|
|
3
|
+
The files under this directory are curated from the following sources.
|
|
4
|
+
|
|
5
|
+
- `mt-ja.jsonl`: https://raw.githubusercontent.com/Stability-AI/FastChat/jp-stable/fastchat/llm_judge/data/japanese_mt_bench/question_full.jsonl
|
|
6
|
+
- `mt-ja-ref-gpt4.jsonl`: https://raw.githubusercontent.com/Stability-AI/FastChat/jp-stable/fastchat/llm_judge/data/japanese_mt_bench/reference_answer/gpt-4.jsonl
|
|
7
|
+
- `mt-en.jsonl`: https://raw.githubusercontent.com/lm-sys/FastChat/main/fastchat/llm_judge/data/mt_bench/question.jsonl
|
|
8
|
+
- `mt-en-ref-gpt4.jsonl`: https://raw.githubusercontent.com/lm-sys/FastChat/main/fastchat/llm_judge/data/mt_bench/reference_answer/gpt-4.jsonl
|
|
9
|
+
- `vicuna-ja`: https://raw.githubusercontent.com/ku-nlp/ja-vicuna-qa-benchmark/main/data/jp_bench/question.jsonl
|
|
10
|
+
- `vicuna-ja-ref-gpt4.jsonl`: https://raw.githubusercontent.com/ku-nlp/ja-vicuna-qa-benchmark/main/data/jp_bench/reference_answer/gpt-4/results.jsonl
|
|
11
|
+
- `vicuna-en`: https://raw.githubusercontent.com/lm-sys/FastChat/main/fastchat/llm_judge/data/vicuna_bench/question.jsonl
|
|
12
|
+
- `vicuna-en-ref-gpt4.jsonl`: https://raw.githubusercontent.com/lm-sys/FastChat/main/fastchat/llm_judge/data/vicuna_bench/reference_answer/gpt-4.jsonl
|
|
13
|
+
- `rakuda-v2-ja.jsonl`: https://raw.githubusercontent.com/yuzu-ai/japanese-llm-ranking/fae1ee79c69b0c3acf8e8a1994e43c7952e7bd9c/jrank/data/rakuda_v2/questions.jsonl
|