| |
|
|
| |
| |
|
|
| import json |
| import random |
| import pandas as pd |
| import streamlit as st |
| from datasets import load_dataset |
|
|
| st.title("Code Arena") |
|
|
| with st.spinner("Loading data...", show_time=True): |
| problem_dict = dict() |
| ds = load_dataset("Elfsong/leetcode_data", split='train') |
| for problem in ds: |
| problem_id = problem["problem_id"] |
| problem_dict[problem_id] = problem |
| problem_count = len(problem_dict) |
|
|
|
|
| if "problem" in st.query_params: |
| problem_id = int(st.query_params["problem"]) |
| problem_instance = problem_dict[problem_id] |
|
|
| with st.container(border=True): |
| st.write(f"Problem [{problem_id}]") |
| |
| with st.expander("Problem Description"): |
| st.markdown(problem_instance["question_content"]) |
|
|
| with st.expander("Test Cases"): |
| test_cases = json.loads(problem_instance["test_cases"]) |
| df = pd.DataFrame( |
| { |
| "input": [test_case['input'] for test_case in test_cases], |
| "output": [test_case['output'] for test_case in test_cases], |
| } |
| ) |
| st.dataframe( |
| df, |
| column_config={ |
| "input": st.column_config.TextColumn("Input"), |
| "output": st.column_config.TextColumn("Output"), |
| }, |
| column_order=("input", "output"), |
| ) |
| |
| else: |
| tab_problem, tab_submission, tab_model = st.tabs(["Problems", "Submissions", "Models"]) |
|
|
| with tab_problem: |
| with st.spinner("Loading Framework...", show_time=True): |
| df = pd.DataFrame( |
| { |
| "problem_id": [int(problem['problem_id']) for problem in ds], |
| "problem_link": ["https://huggingface.co/spaces/Elfsong/CodeArena/?problem=" + str(problem['problem_id']) for problem in ds], |
| "dynamic_point": [[random.randint(0, 5000) for _ in range(30)] for problem in ds], |
| } |
| ) |
| st.dataframe( |
| df, |
| column_config={ |
| "problem_id": st.column_config.NumberColumn("Problem ID"), |
| "dynamic_point": st.column_config.LineChartColumn("Dynamic Point", y_min=0, y_max=5000), |
| "problem_link": st.column_config.LinkColumn("Link", display_text="Open"), |
| }, |
| height=600, |
| column_order=("problem_id", "dynamic_point", "problem_link"), |
| hide_index=True, |
| ) |
|
|
| with tab_submission: |
| st.header("Submissions") |
|
|
| with tab_model: |
| model_list = [ |
| "deepSeek-Coder", |
| "GPT-4o", |
| "Claude-3-5-sonnet", |
| "Gemini-1.5-flash", |
| "DeepSeek-Coder-V2-Lite", |
| "Claude-3-Opus", |
| "Gemini-1.5-pro", |
| "Llama-3.1-8B", |
| "Llama-3-8B", |
| "GPT-4-Turbo", |
| "GPT-3.5-Turbo", |
| "Mistral-Nemo", |
| "CodeLlama-13b", |
| "Claude-3-Haiku", |
| "Mistral-7B-v0.3", |
| "Codestral-22B-v0.1", |
| "Claude-3-sonnet", |
| "CodeLlama-34b", |
| "CodeLlama-7b" |
| ] |
|
|
|
|
| df = pd.DataFrame( |
| { |
| "model_name": [model_name for model_name in model_list], |
| "dynamic_point": [0 for model_name in model_list], |
| "pass@1": [0 for model_name in model_list], |
| "beyond@t": [0 for model_name in model_list], |
| "beyond@m": [0 for model_name in model_list], |
| "model_progress": [random.randint(0, problem_count+1) for model_name in model_list], |
| } |
| ) |
|
|
| st.dataframe( |
| df, |
| column_config={ |
| "model_name": st.column_config.TextColumn("Model Name"), |
| "dynamic_point": st.column_config.NumberColumn("Dynamic Point"), |
| "pass@1": st.column_config.NumberColumn("Pass@k"), |
| "beyond@t": st.column_config.NumberColumn("Beyond@Time"), |
| "beyond@m": st.column_config.NumberColumn("Beyond@Memory"), |
| "model_progress": st.column_config.ProgressColumn("Progress", min_value=0, max_value=problem_count, format="plain"), |
| }, |
| column_order=("model_name", "pass@1", "beyond@t", "beyond@m", "model_progress"), |
| hide_index=True, |
| ) |
|
|