Skip to content

Commit d69af13

Browse files
committed
Merge branch 'main' into update-lb
2 parents c90f9ca + 3e21ddc commit d69af13

File tree

3 files changed

+26
-12
lines changed

3 files changed

+26
-12
lines changed

fastchat/serve/monitor/elo_analysis.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ def construct_style_matrices(
597597
style_elements=STYLE_CONTROL_ELEMENTS_V1,
598598
add_one=True,
599599
):
600-
models = pd.concat([battles["model_a"], battles["model_b"]]).unique()
600+
models = pd.concat([df["model_a"], df["model_b"]]).unique()
601601
models = pd.Series(np.arange(len(models)), index=models)
602602

603603
# duplicate battles
@@ -656,12 +656,17 @@ def construct_style_matrices(
656656
def get_bootstrap_result_style_control(X, Y, models, func_compute_elo, num_round=1000):
657657
elos = []
658658
coefs = []
659+
assert X.shape[0] % 2 == 0 and X.shape[0] == Y.shape[0]
660+
k = int(
661+
X.shape[0] / 2
662+
) # Since we duplicate the battles when constructing X and Y, we don't want to sample the duplicates
663+
659664
for _ in tqdm(range(num_round), desc="bootstrap"):
660-
indices = np.random.choice(
661-
list(range(len(battles))), size=(len(battles)), replace=True
662-
)
663-
_X = X[indices]
664-
_Y = Y[indices]
665+
indices = np.random.choice(list(range(k)), size=(k), replace=True)
666+
_X = np.concatenate([X[indices], X[indices]])
667+
_Y = np.concatenate([Y[indices], Y[indices]])
668+
assert _X.shape == X.shape and _Y.shape == Y.shape
669+
665670
states = ~_X[:, : len(models)].any(axis=0)
666671

667672
elo, coef = func_compute_elo(_X, _Y, models=models[~states])

fastchat/serve/vision/create_vqa_examples_dir.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,14 @@ def download_images_and_create_json(
104104
"subset": False,
105105
"split": "test",
106106
},
107+
"NewYorker": {
108+
"path": "jmhessel/newyorker_caption_contest",
109+
"image_key": "image",
110+
"question_key": "questions",
111+
"id_key": "index",
112+
"subset": "explanation",
113+
"split": "train",
114+
},
107115
}
108116

109117
download_images_and_create_json(
@@ -114,7 +122,7 @@ def download_images_and_create_json(
114122
with open(f"{args.output_dir}/{dataset_name}/data.json") as f:
115123
data = json.load(f)
116124
print(f"Dataset: {dataset_name}, Number of examples: {len(data)}")
117-
dataset_json.extend(np.random.choice(data, 500))
125+
dataset_json.extend(data)
118126

119127
with open(f"{args.output_dir}/metadata_sampled.json", "w") as f:
120128
json.dump(dataset_json, f, indent=4)

fastchat/serve/vision/create_vqa_examples_json.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@
1717
args = parser.parse_args()
1818

1919
dataset_prop = {
20-
"DocVQA": 500,
21-
"ChartQA": 500,
22-
"NewYorker": 1000,
23-
"WikiArt": 500,
24-
"TextVQA": 500,
20+
"realworldqa": 500,
21+
"Memes": 500,
22+
"Floorplan": 500,
23+
"Website": 500,
24+
"IllusionVQA": 500,
25+
"NewYorker": 500,
2526
}
2627

2728
dataset_json = []

0 commit comments

Comments
 (0)