Create visualization for MINT benchmark & upload results (#2)
Browse files- add some outputs (da7aaba4e08844c20e458ec7d554243dfc5349bf)
- add viz tab for mint (38a40d14b423e340d494308aa2871d4736c78053)
- add complete math output for gpt-4o (7d377c3c477760c429dfd7f5583f998a0edf0968)
- add complete mmlu output for gpt-4o (0948b4d436b173e9b5b165a8de4ee2099cd30f33)
- add complete humaneval output for gpt-4o (45710d94e2a58ead357ebdc378981aac09e042e4)
- add complete theoremqa output for gpt-4o (841a9486d33eece9d9cdb03bb15b02093656a1ad)
Co-authored-by: Ryan Tran <ryanhoangt@users.noreply.huggingface.co>
Files changed (20)
- .gitignore+1
- 0_๐_OpenDevin_Benchmark.py+1
- outputs/mint/CodeActAgent/gpt-3.5-turbo-0125_maxiter_5_N_v1.5/math/metadata.jsonAdded+1
- outputs/mint/CodeActAgent/gpt-3.5-turbo-0125_maxiter_5_N_v1.5/math/output.jsonlAdded+3
- outputs/mint/CodeActAgent/gpt-3.5-turbo-0125_maxiter_5_N_v1.5/theoremqa/metadata.jsonAdded+1
- outputs/mint/CodeActAgent/gpt-3.5-turbo-0125_maxiter_5_N_v1.5/theoremqa/output.jsonlAdded+3
- outputs/mint/CodeActAgent/gpt-4o-2024-05-13_maxiter_5_N_v1.5/gsm8k/metadata.jsonAdded+1
- outputs/mint/CodeActAgent/gpt-4o-2024-05-13_maxiter_5_N_v1.5/gsm8k/output.jsonlAdded+3
- outputs/mint/CodeActAgent/gpt-4o-2024-05-13_maxiter_5_N_v1.5/humaneval/metadata.jsonAdded+1
- outputs/mint/CodeActAgent/gpt-4o-2024-05-13_maxiter_5_N_v1.5/humaneval/output.jsonlAdded+3
- outputs/mint/CodeActAgent/gpt-4o-2024-05-13_maxiter_5_N_v1.5/math/metadata.jsonAdded+1
- outputs/mint/CodeActAgent/gpt-4o-2024-05-13_maxiter_5_N_v1.5/math/output.jsonlAdded+3
- outputs/mint/CodeActAgent/gpt-4o-2024-05-13_maxiter_5_N_v1.5/mbpp/metadata.jsonAdded+1
- outputs/mint/CodeActAgent/gpt-4o-2024-05-13_maxiter_5_N_v1.5/mbpp/output.jsonlAdded+3
- outputs/mint/CodeActAgent/gpt-4o-2024-05-13_maxiter_5_N_v1.5/mmlu/metadata.jsonAdded+1
- outputs/mint/CodeActAgent/gpt-4o-2024-05-13_maxiter_5_N_v1.5/mmlu/output.jsonlAdded+3
- outputs/mint/CodeActAgent/gpt-4o-2024-05-13_maxiter_5_N_v1.5/theoremqa/metadata.jsonAdded+1
- outputs/mint/CodeActAgent/gpt-4o-2024-05-13_maxiter_5_N_v1.5/theoremqa/output.jsonlAdded+3
- pages/2_๐_MINTBench_Visualizer.pyAdded+188
- utils/mint.pyAdded+112
6 unmodified lines7896 unmodified lines*.mdreport*summary*6 unmodified lines789106 unmodified lines*.mdreport*summary*__pycache__
23 unmodified lines24252627282923 unmodified lines[Page("0_๐_OpenDevin_Benchmark.py", "Benchmark", "๐"),Page("pages/1_๐_SWEBench_Visualizer.py", "SWE-Bench Visualizer", "๐"),])23 unmodified lines2425262728293023 unmodified lines[Page("0_๐_OpenDevin_Benchmark.py", "Benchmark", "๐"),Page("pages/1_๐_SWEBench_Visualizer.py", "SWE-Bench Visualizer", "๐"),Page("pages/2_๐_MINTBench_Visualizer.py", "MINT-Bench Visualizer", "๐")])
1{"agent_class": "CodeActAgent", "model_name": "gpt-3.5-turbo-0125", "max_iterations": 5, "max_propose_solution": 2, "eval_output_dir": "evaluation/evaluation_outputs/outputs/mint/CodeActAgent/gpt-3.5-turbo-0125_maxiter_5_N_v1.5/math", "start_time": "2024-05-31 03:01:29", "git_commit": "d22c1a25c7ee6c79caf7171c8b9732d6fd76b41e"}123version https://git-lfs.github.com/spec/v1oid sha256:6f64338a4978ac4e13b474053037d69b17c6c9b09a7b9aff8b56f80b20d4aa66size 1145681{"agent_class": "CodeActAgent", "model_name": "gpt-3.5-turbo-0125", "max_iterations": 5, "max_propose_solution": 2, "eval_output_dir": "evaluation/evaluation_outputs/outputs/mint/CodeActAgent/gpt-3.5-turbo-0125_maxiter_5_N_v1.5/theoremqa", "start_time": "2024-05-31 10:08:50", "git_commit": "a0a4634cd7fb4c9b843ae31f5f4f7ee066f90f74"}123version https://git-lfs.github.com/spec/v1oid sha256:683b10ecccc15c2adbe3222437681861ec985b270274606bdc57407b4161c04bsize 1258801{"agent_class": "CodeActAgent", "model_name": "gpt-4o-2024-05-13", "max_iterations": 5, "max_propose_solution": 2, "eval_output_dir": "evaluation/evaluation_outputs/outputs/mint/CodeActAgent/gpt-4o-2024-05-13_maxiter_5_N_v1.5/gsm8k", "start_time": "2024-05-27 17:13:50", "git_commit": "e1bdbcc8da5479b35b8097cb95d53565d8755541"}123version https://git-lfs.github.com/spec/v1oid sha256:c3fa0a2e7eea7a41300dc992f57cde03f45b1225ca5e161fe24fd9d485a890ecsize 502321{"agent_class": "CodeActAgent", "model_name": "gpt-4o-2024-05-13", "max_iterations": 5, "max_propose_solution": 2, "eval_output_dir": "evaluation/evaluation_outputs/outputs/mint/CodeActAgent/gpt-4o-2024-05-13_maxiter_5_N_v1.5/humaneval", "start_time": "2024-06-02 17:16:02", "git_commit": "b0478d28808e3c8405221a7f9d097119f7db501f"}123version https://git-lfs.github.com/spec/v1oid sha256:5b041258277b34422a5585c5b4984c4665a4a12d967f9e3d07dd3b1a4493d412size 9020141{"agent_class": "CodeActAgent", "model_name": "gpt-4o-2024-05-13", "max_iterations": 5, "max_propose_solution": 2, "eval_output_dir": "evaluation/evaluation_outputs/outputs/mint/CodeActAgent/gpt-4o-2024-05-13_maxiter_5_N_v1.5/math", "start_time": "2024-05-31 03:05:52", "git_commit": "d22c1a25c7ee6c79caf7171c8b9732d6fd76b41e"}123version https://git-lfs.github.com/spec/v1oid sha256:c289a823b4b53ad1ad0125ac90a03ccd18ba3abb18e8ae5a318cbc0bc8b4719csize 16998841{"agent_class": "CodeActAgent", "model_name": "gpt-4o-2024-05-13", "max_iterations": 5, "max_propose_solution": 2, "eval_output_dir": "evaluation/evaluation_outputs/outputs/mint/CodeActAgent/gpt-4o-2024-05-13_maxiter_5_N_v1.5/mbpp", "start_time": "2024-05-31 11:37:39", "git_commit": "a0a4634cd7fb4c9b843ae31f5f4f7ee066f90f74"}123version https://git-lfs.github.com/spec/v1oid sha256:1b866e06ec72bdceee0f7009cebeda2c04b86d66296a91024b5c791bda4ffc2asize 993031{"agent_class": "CodeActAgent", "model_name": "gpt-4o-2024-05-13", "max_iterations": 5, "max_propose_solution": 2, "eval_output_dir": "evaluation/evaluation_outputs/outputs/mint/CodeActAgent/gpt-4o-2024-05-13_maxiter_5_N_v1.5/mmlu", "start_time": "2024-05-31 01:37:59", "git_commit": "d22c1a25c7ee6c79caf7171c8b9732d6fd76b41e"}123version https://git-lfs.github.com/spec/v1oid sha256:21526f146aa383b4917bf67c310b0f4431720e6c05f1f5700c4150f90388f10esize 21649151{"agent_class": "CodeActAgent", "model_name": "gpt-4o-2024-05-13", "max_iterations": 5, "max_propose_solution": 2, "eval_output_dir": "evaluation/evaluation_outputs/outputs/mint/CodeActAgent/gpt-4o-2024-05-13_maxiter_5_N_v1.5/theoremqa", "start_time": "2024-06-02 19:08:15", "git_commit": "b0478d28808e3c8405221a7f9d097119f7db501f"}123version https://git-lfs.github.com/spec/v1oid sha256:6a866ab17815ddb3ce01ad845f887f09e682100263104d2d9c046d206164a3besize 885308123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188"""Streamlit visualizer for the evaluation model outputs.
Run the following command to start the visualizer: streamlit run app.py --server.port 8501 --server.address 0.0.0.0NOTE: YOU SHOULD BE AT THE ROOT OF THE REPOSITORY TO RUN THIS COMMAND.
Mostly borrow from: https://github.com/xingyaoww/mint-bench/blob/main/scripts/visualizer.py"""
import random
import pandas as pdimport streamlit as st
from utils import filter_dataframe, dataframe_with_selectionsfrom utils.mint import ( load_filepaths, load_df_from_selected_filepaths, agg_stats)
st.set_page_config( layout='wide', page_title='๐ OpenDevin MINT Benchmark Output Visualizer', page_icon='๐',)st.write('# ๐ OpenDevin MINT Benchmark Output Visualizer')
if __name__ == '__main__':
# ===== Select a file to visualize ===== filepaths = load_filepaths() filepaths = filter_dataframe(filepaths) # Make these two buttons are on the same row # col1, col2 = st.columns(2) col1, col2 = st.columns([0.15, 1]) select_all = col1.button('Select all') deselect_all = col2.button('Deselect all') selected_values = st.query_params.get('filepaths', '').split(',') selected_values = filepaths['filepath'].tolist() if select_all else selected_values selected_values = [] if deselect_all else selected_values
selection = dataframe_with_selections( filepaths, selected_values=selected_values, selected_col='filepath', ) st.write("Your selection:") st.write(selection) select_filepaths = selection['filepath'].tolist() # update query params st.query_params['filepaths'] = select_filepaths
df = load_df_from_selected_filepaths(select_filepaths) st.write(f'{len(df)} rows found.')
# ===== Task-level dashboard ===== st.markdown('---') st.markdown('## Aggregated Stats') # convert df to python array data = df.to_dict(orient='records') # TODO: add other stats to visualize stats_df = agg_stats(data) if len(stats_df) == 0: st.write("No data to visualize.") st.stop() success_count = stats_df["success"].sum() st.markdown( f"**Success Rate: {success_count / len(data):2%}**: {success_count} / {len(data)} rows are successful." )
# ===== Select a row to visualize ===== st.markdown('---') st.markdown('## Visualize a Row') # Add a button to randomly select a row if st.button('Randomly Select a Row'): row_id = random.choice(stats_df['idx'].values) st.query_params['row_idx'] = str(row_id)
if st.button('Clear Selection'): st.query_params['row_idx'] = ''
selected_row = dataframe_with_selections( stats_df, list( filter( lambda x: x is not None, map( lambda x: int(x) if x else None, st.query_params.get('row_idx', '').split(','), ), ) ), selected_col='idx', ) if len(selected_row) == 0: st.write('No row selected.') st.stop() elif len(selected_row) > 1: st.write('More than one row selected.') st.stop() row_id = selected_row['idx'].values[0]
# update query params st.query_params['filepaths'] = select_filepaths st.query_params['row_idx'] = str(row_id)
row_id = st.number_input( 'Select a row to visualize', min_value=0, max_value=len(df) - 1, value=row_id ) row = df.iloc[row_id]
# ===== Visualize the row ===== st.write(f'Visualizing row `{row_id}`') row_dict = df.iloc[row_id]
n_turns = len(row_dict['history']) st.write(f'Number of turns: {n_turns}')
with st.expander('Raw JSON', expanded=False): st.markdown('### Raw JSON') st.json(row_dict.to_dict()) def visualize_action(action): if action['action'] == 'run': thought = action['args'].get('thought', '') if thought: st.markdown(thought) st.code(action['args']['command'], language='bash') elif action['action'] == 'run_ipython': thought = action['args'].get('thought', '') if thought: st.markdown(thought) st.code(action['args']['code'], language='python') elif action['action'] == 'talk': st.markdown(action['args']['content']) elif action['action'] == 'message': st.markdown(action['args']['content']) else: st.json(action)
def visualize_obs(observation): if 'content' in observation: num_char = len(observation['content']) st.markdown(rf'\# characters: {num_char}') if observation['observation'] == 'run': st.code(observation['content'], language='plaintext') elif observation['observation'] == 'run_ipython': st.code(observation['content'], language='python') elif observation['observation'] == 'message': st.markdown(observation['content']) elif observation['observation'] == 'null': st.markdown('null observation') else: st.json(observation)
def visualize_row(row_dict): st.markdown('### Test Result') test_result = row_dict['test_result'] st.write(pd.DataFrame([test_result]))
if row_dict['error']: st.markdown('### Error') st.code(row_dict['error'], language='plaintext')
st.markdown('### Interaction History') with st.expander('Interaction History', expanded=True): st.code(row_dict['instruction'], language='plaintext') history = row['history'] for i, (action, observation) in enumerate(history): st.markdown(f'#### Turn {i + 1}') st.markdown('##### Action') visualize_action(action) st.markdown('##### Observation') visualize_obs(observation)
st.markdown('### Test Output') with st.expander('Test Output', expanded=False): st.code(row_dict['test_result'], language='plaintext')
visualize_row(row_dict)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112import jsonimport reimport os
import pandas as pdfrom glob import globimport streamlit as st
def parse_filepath(filepath: str): splited = ( filepath.removeprefix('outputs/') .removesuffix('output.jsonl') .removesuffix('output.merged.jsonl') .strip('/') .split('/') )
metadata_path = os.path.join(os.path.dirname(filepath), 'metadata.json') with open(metadata_path, 'r') as f: metadata = json.load(f) try: benchmark = splited[0] agent_name = splited[1] subset = splited[3] # gpt-4-turbo-2024-04-09_maxiter_50(optional)_N_XXX # use regex to match the model name & maxiter matched = re.match(r'(.+)_maxiter_(\d+)(_.+)?', splited[2]) model_name = matched.group(1) maxiter = matched.group(2) note = '' if matched.group(3): note += matched.group(3).removeprefix('_N_') assert len(splited) == 4 return { 'benchmark': benchmark, 'subset': subset, 'agent_name': agent_name, 'model_name': model_name, 'maxiter': maxiter, 'note': note, 'filepath': filepath, **metadata, } except Exception as e: st.write([filepath, e, splited])
def load_filepaths(): # FIXME: # glob_pattern = 'outputs/**/output.merged.jsonl' glob_pattern = 'outputs/mint/**/output.jsonl' filepaths = list(set(glob(glob_pattern, recursive=True))) filepaths = pd.DataFrame(list(map(parse_filepath, filepaths))) filepaths = filepaths.sort_values( [ 'benchmark', 'subset', 'agent_name', 'model_name', 'maxiter', ] ) st.write(f'Matching glob pattern: `{glob_pattern}`. **{len(filepaths)}** files found.') return filepaths
def load_df_from_selected_filepaths(select_filepaths): data = [] if isinstance(select_filepaths, str): select_filepaths = [select_filepaths] for filepath in select_filepaths: with open(filepath, 'r') as f: for line in f.readlines(): d = json.loads(line) # # clear out git patch # if 'git_patch' in d: # d['git_patch'] = clean_git_patch(d['git_patch']) # d['history'] = reformat_history(d['history']) d['task_name'] = filepath.split('/')[-2] data.append(d) df = pd.DataFrame(data) return df
def agg_stats(data): stats = []
for idx, entry in enumerate(data): # if len(entry["state"]["history"]) % 2 != 0: continue task = { k: v for k, v in entry.items() if k not in ["state", "test_result"] } # if "metadata" in task: # for k, v in task["metadata"].items(): # task[k] = v # del task["metadata"]
stats.append( { "idx": idx, "success": entry["test_result"], "task_name": entry["task_name"], # TODO: add `task_name` after merging all subtasks # "n_turns": len(entry["state"]["history"]) // 2, # "terminate_reason": entry["state"]["terminate_reason"], # "agent_action_count": entry["state"]["agent_action_count"], # **task, } ) return pd.DataFrame(stats).gitignore+1
0_๐_OpenDevin_Benchmark.py+1
outputs/mint/CodeActAgent/gpt-3.5-turbo-0125_maxiter_5_N_v1.5/math/metadata.jsonAdded+1
outputs/mint/CodeActAgent/gpt-3.5-turbo-0125_maxiter_5_N_v1.5/math/output.jsonlAdded+3
outputs/mint/CodeActAgent/gpt-3.5-turbo-0125_maxiter_5_N_v1.5/theoremqa/metadata.jsonAdded+1
outputs/mint/CodeActAgent/gpt-3.5-turbo-0125_maxiter_5_N_v1.5/theoremqa/output.jsonlAdded+3
outputs/mint/CodeActAgent/gpt-4o-2024-05-13_maxiter_5_N_v1.5/gsm8k/metadata.jsonAdded+1
outputs/mint/CodeActAgent/gpt-4o-2024-05-13_maxiter_5_N_v1.5/gsm8k/output.jsonlAdded+3
outputs/mint/CodeActAgent/gpt-4o-2024-05-13_maxiter_5_N_v1.5/humaneval/metadata.jsonAdded+1
outputs/mint/CodeActAgent/gpt-4o-2024-05-13_maxiter_5_N_v1.5/humaneval/output.jsonlAdded+3
outputs/mint/CodeActAgent/gpt-4o-2024-05-13_maxiter_5_N_v1.5/math/metadata.jsonAdded+1
outputs/mint/CodeActAgent/gpt-4o-2024-05-13_maxiter_5_N_v1.5/math/output.jsonlAdded+3
outputs/mint/CodeActAgent/gpt-4o-2024-05-13_maxiter_5_N_v1.5/mbpp/metadata.jsonAdded+1
outputs/mint/CodeActAgent/gpt-4o-2024-05-13_maxiter_5_N_v1.5/mbpp/output.jsonlAdded+3
outputs/mint/CodeActAgent/gpt-4o-2024-05-13_maxiter_5_N_v1.5/mmlu/metadata.jsonAdded+1
outputs/mint/CodeActAgent/gpt-4o-2024-05-13_maxiter_5_N_v1.5/mmlu/output.jsonlAdded+3
outputs/mint/CodeActAgent/gpt-4o-2024-05-13_maxiter_5_N_v1.5/theoremqa/metadata.jsonAdded+1
outputs/mint/CodeActAgent/gpt-4o-2024-05-13_maxiter_5_N_v1.5/theoremqa/output.jsonlAdded+3
pages/2_๐_MINTBench_Visualizer.pyAdded+188
utils/mint.pyAdded+112