{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Defaulting to user installation because normal site-packages is not writeable\n", "Requirement already satisfied: pandas in /Users/picocreator/Library/Python/3.9/lib/python/site-packages (2.2.0)\n", "Requirement already satisfied: tzdata>=2022.7 in /Users/picocreator/Library/Python/3.9/lib/python/site-packages (from pandas) (2024.1)\n", "Requirement already satisfied: numpy<2,>=1.22.4 in /Users/picocreator/Library/Python/3.9/lib/python/site-packages (from pandas) (1.26.1)\n", "Requirement already satisfied: python-dateutil>=2.8.2 in /Users/picocreator/Library/Python/3.9/lib/python/site-packages (from pandas) (2.8.2)\n", "Requirement already satisfied: pytz>=2020.1 in /Users/picocreator/Library/Python/3.9/lib/python/site-packages (from pandas) (2024.1)\n", "Requirement already satisfied: six>=1.5 in /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/site-packages (from python-dateutil>=2.8.2->pandas) (1.15.0)\n", "\u001b[33mWARNING: You are using pip version 21.2.4; however, version 24.2 is available.\n", "You should consider upgrading via the '/Library/Developer/CommandLineTools/usr/bin/python3 -m pip install --upgrade pip' command.\u001b[0m\n" ] } ], "source": [ "!pip3 install pandas" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Get the filelist\n", "\n", "For the full results.json" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Found 6263 results.json files\n" ] } ], "source": [ "import glob\n", "\n", "# Specify the path to the folder containing the results.json files\n", "folder_path = \"lm-eval-output\"\n", "\n", "# Use glob to find all the results.json files\n", "results_json_files = glob.glob(f\"{folder_path}/**/results.json\", recursive=True)\n", "\n", "# Show total number of results.json files found\n", "print(f\"Found {len(results_json_files)} results.json files\")\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Process all the results.json\n", "\n", "One file at a time" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Processed example: {'name': 'mistralai/Mistral-7B-Instruct-v0.2', 'config': {'dtype=bfloat16,trust_remote_code=True': {'confStr': 'dtype=bfloat16,trust_remote_code=True', 'confObj': {'dtype': 'bfloat16', 'trust_remote_code': 'True'}, 'results': {'cola': {'mcc,none': 0.12965656914783247, 'mcc_stderr,none': 0.032433640730190394, 'alias': 'cola'}}, 'groups': {}}}}\n" ] } ], "source": [ "import json\n", "\n", "# Global result map if it's not set\n", "if 'global_result_map' not in globals():\n", " global_result_map = {}\n", "\n", "#\n", "# Function to process the results.json file\n", "#\n", "def process_results_json(file_path):\n", " with open(file_path) as f:\n", " data = json.load(f)\n", "\n", " # Model args, presplit by ','\n", " model_args = data['config']['model_args'].split(',')\n", "\n", " # Extract the pretrained value from config.model_args\n", " modelname = model_args[0].split('=')[1]\n", "\n", " # Opt array\n", " confArgsArr = model_args[1:]\n", "\n", " # Sort the opt array\n", " confArgsArr.sort()\n", " # Convert it to a string\n", " confStr = ','.join(confArgsArr)\n", "\n", " # Convert the option array of key=value strings to a dictionary\n", " confObj = { }\n", " for o in confArgsArr:\n", " k, v = o.split('=')\n", " confObj[k] = v\n", " \n", " # Create a dictionary to store the results, or use the existing one if it exists\n", " if modelname in global_result_map:\n", " modelObj = global_result_map[modelname]\n", " else:\n", " modelObj = {\n", " 'name': modelname,\n", " 'config': { }\n", " }\n", " \n", " # Get the opt object for the model\n", " if confStr in modelObj['config']:\n", " confSet = modelObj['config'][confStr]\n", " else:\n", " confSet = {\n", " 'confStr': confStr,\n", " 'confObj': confObj,\n", " 'results': {},\n", " 'groups': {}\n", " }\n", "\n", " # Iterate over the results and extract the result object for each test/group\n", " if 'results' in data:\n", " for test, result in data['results'].items():\n", " confSet['results'][test] = result\n", " if 'groups' in data:\n", " for test, result in data['groups'].items():\n", " confSet['groups'][test] = result\n", " \n", " # Update the global result map object\n", " modelObj['config'][confStr] = confSet\n", " global_result_map[modelname] = modelObj\n", " return modelObj\n", "\n", "# Lets test the function with the first results.json file\n", "first_result = process_results_json(results_json_files[0])\n", "print(f\"Processed example: \", first_result)\n" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Found 134 models\n", "Models: \n", "['mistralai/Mistral-7B-Instruct-v0.2', 'mistralai/Mistral-7B-v0.1', 'mosaicml/mpt-7b-instruct', 'mosaicml/mpt-7b', 'mosaicml/mpt-7b-chat', 'bigscience/bloom-7b1', 'bigscience/bloomz-7b1-mt', 'bigscience/bloomz-7b1', 'EleutherAI/pythia-2.8b', 'EleutherAI/pythia-1.4b', 'EleutherAI/gpt-j-6b', 'EleutherAI/pythia-6.9b', 'google/flan-t5-base', 'google/gemma-2b', 'google/gemma-2b-it', 'google/gemma-7b', 'google/gemma-7b-it', 'google/flan-t5-large', 'microsoft/phi-1_5', 'microsoft/phi-2', 'microsoft/phi-1', 'allenai/OLMo-7B', 'TinyLlama/TinyLlama-1.1B-intermediate-step-1431k-3T', 'TinyLlama/TinyLlama-1.1B-Chat-v1.0', 'RWKV/rwkv-5-world-1b5', 'RWKV/rwkv-5-world-3b', 'RWKV/rwkv-4-world-3b', 'RWKV/v5-EagleX-v2-7B-HF', 'RWKV/rwkv-6-world-1b6', 'RWKV/rwkv-4-world-1b5', 'RWKV/v5-Eagle-7B-HF', 'RWKV/v6-Finch-7B-HF', 'RWKV/rwkv-6-world-3b-v2.1', 'RWKV/rwkv-4-world-7b', 'RWKV/v6-Finch-14B-HF', 'RWKV/rwkv-raven-7b', 'RWKV/rwkv-6-world-3b', 'aisingapore/sealion7b', 'aisingapore/sealion3b', './rwkv-x-dev/1_3-C5-rwkv-270_pth', './rwkv-x-dev/225-EagleX-PreFT-C', './rwkv-x-dev/225-EagleX-PreFT-D', './rwkv-x-dev/1_0_pth', './rwkv-x-dev/chunk4-0_85_pth', './rwkv-x-dev/1_3-C1-rwkv-340_pth', './rwkv-x-dev/chunk1-0_8_pth', './rwkv-x-dev/chunk0-0_8_pth', './rwkv-x-dev/225-EagleX-PreFT-E', './rwkv-x-dev/225-EagleX-PreFT-B', './rwkv-x-dev/blink4-final_pth', './rwkv-x-dev/chunk2-0_8_pth', './rwkv-x-dev/chunk3-0_8_pth', './rwkv-x-dev/r3-4k-test2-fix3-blink-final_pth', './rwkv-x-dev/R4-7B-15t-With-Mask_pth', './rwkv-x-dev/r3-testchunk-1-8_pth', './rwkv-x-dev/R4-with-shuffle-rwkv-53_pth', './rwkv-x-dev/chunk7-2-0_85_pth', './rwkv-x-dev/EagleX-1_7T_pth', './rwkv-x-dev/r3-testchunk2-blink-fixed_pth', './rwkv-x-dev/r3-testchunk2-blink_pth', './rwkv-x-dev/rwkv-230_pth', './rwkv-x-dev/1_3-C0-rwkv-60_pth', './rwkv-x-dev/chunk5-0_85_pth', './rwkv-x-dev/R4-7B-Base-No-Mask_pth', './rwkv-x-dev/RWKV-5-World-1B5-v2-20231025-ctx4096', './rwkv-x-dev/R4-1B5-No-Mask_pth', './rwkv-x-dev/RWKV-32K-5B-RW_pth', './rwkv-x-dev/R4-7B-15t-32k-No-Mask_pth', './rwkv-x-dev/1_3-C0-PRERUN-rwkv-60_pth', './rwkv-x-dev/EagleX_1-7T_Chat_pth', './rwkv-x-dev/1_3-C1-rwkv-390_pth', './rwkv-x-dev/1_3-C1-rwkv-20_pth', './rwkv-x-dev/chunk8-1-0_85_pth', './rwkv-x-dev/R4-7B-Base-32k-No-Mask_pth', './rwkv-x-dev/R4-no-shuffle-rwkv-53_pth', './rwkv-x-dev/1_3-C2-rwkv-648_pth', './rwkv-x-dev/1_3-C2-rwkv-250_pth', './rwkv-x-dev/r3-testchunk-1-8-no-cuda-with-warmup_pth', './rwkv-x-dev/1_3-C0-rwkv-140_pth', './rwkv-x-dev/bruber_9b', './rwkv-x-dev/Eagle-225-1FT', './rwkv-x-dev/225-EagleX-PreFT-A', './rwkv-x-dev/225-EagleX-PreFT-F', './rwkv-x-dev/r3-c1-8_pth', './rwkv-x-dev/1_3-C0-PRERUN-rwkv-450_pth', './rwkv-x-dev/RWKV-5-World-3B-v2-20231118-ctx16k', './rwkv-x-dev/1_3-C0-PREPRERUN-rwkv-40_pth', './rwkv-x-dev/RWKV-5-World-7B-v2-20240128-ctx4096', './rwkv-x-dev/R4-7B-15t-No-Mask_pth', './rwkv-x-dev/1_0-c1-290_pth', './rwkv-x-dev/R4-1B5-With-Mask_pth', './rwkv-x-dev/Quetzal-N8-1', './rwkv-x-dev/1_3-C0-PREPRERUN-rwkv-30_pth', './rwkv-x-dev/1_3-C0-rwkv-70_pth', './rwkv-x-dev/chunk6-0_85_pth', './rwkv-x-dev/R4-7B-Base-With-Mask_pth', 'rwkv-x-dev/v5-Eagle-7B-1_0T-HF', './rwkv-x-dev/1_3-C0-PRERUN-rwkv-30_pth', './rwkv-x-dev/chunk7-1-0_85_pth', './rwkv-x-dev/1_3-C1-rwkv-190_pth', './rwkv-x-dev/R4-7B-15t-extd-e3_pth', './rwkv-x-dev/r3-testchunk2_pth', './rwkv-x-dev/Hermes-RWKV-v5-7B_pth', './rwkv-x-dev/1_3-C0-rwkv-153_pth', './rwkv-x-dev/R4-7B-15t-extd-e2_pth', './rwkv-x-dev/r3-testchunk-blink_pth', 'SmerkyG/rwkv-5-world-1b5', 'SmerkyG/rwkv6-world-1b6', 'SmerkyG/rwkv6-world-3b', 'SmerkyG/rwkv-5-world-3b', 'SmerkyG/rwkv-5-world-7b', 'SmerkyG/rwkv5-world-7b', 'togethercomputer/RedPajama-INCITE-7B-Base', 'togethercomputer/RedPajama-INCITE-7B-Instruct', 'togethercomputer/RedPajama-INCITE-7B-Chat', 'facebook/opt-2.7b', 'facebook/opt-6.7b', 'facebook/opt-1.3b', 'tiiuae/falcon-7b-instruct', 'tiiuae/falcon-rw-1b', 'tiiuae/falcon-rw-7b', 'tiiuae/falcon-7b', 'm8than/Finch-14B-Final2', 'm8than/Finch-14B-Continued', 'm8than/Finch-14B-Final', 'm8than/mistral-7b-instruct-0.2', 'm8than/Finch-14B-Continued-10', 'm8than/FinchX-Med', 'TimeMobius/Mobius-RWKV-Chat-12B-128k-v4-HF', 'huggyllama/llama-7b', 'meta-llama/Llama-2-7b-chat-hf', 'meta-llama/Llama-2-7b-hf', 'state-spaces/mamba-2.8b-hf', 'state-spaces/mamba-1.4b-hf']\n", "Saved to compiled-lm-eval-results.json\n" ] } ], "source": [ "# Lets reset and reprocess all the results.json files\n", "global_result_map = {}\n", "\n", "# Process all the results.json files\n", "for file in results_json_files:\n", " process_results_json(file)\n", "\n", "# Show high level list of models\n", "print(f\"Found {len(global_result_map)} models\")\n", "print(f\"Models: \\n{list(global_result_map.keys())}\")\n", "\n", "# Save the result map to a file\n", "with open('summary/compiled-lm-eval-results.json', 'w') as f:\n", " json.dump(global_result_map, f, sort_keys=True, indent='\\t')\n", "\n", "# Echo that its been saved to json\n", "print(f\"Saved to compiled-lm-eval-results.json\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Convert the results into CSV table formats" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/var/folders/71/91hw6kks41v97jkjp028xxbr0000gp/T/ipykernel_39274/788387412.py:2: DeprecationWarning: \n", "Pyarrow will become a required dependency of pandas in the next major release of pandas (pandas 3.0),\n", "(to allow more performant data types, such as the Arrow string type, and better interoperability with other libraries)\n", "but was not found to be installed on your system.\n", "If this would cause problems for you,\n", "please provide us feedback at https://github.com/pandas-dev/pandas/issues/54466\n", " \n", " import pandas as pd\n" ] }, { "data": { "text/html": [ "
\n", " | model | \n", "avg_acc | \n", "avg_acc_stderr | \n", "xcopa (acc) | \n", "xcopa (acc_stderr) | \n", "
---|---|---|---|---|---|
0 | \n", "mistralai/Mistral-7B-Instruct-v0.2 | \n", "0.000000 | \n", "0.000000 | \n", "NaN | \n", "NaN | \n", "
1 | \n", "mistralai/Mistral-7B-v0.1 | \n", "0.559455 | \n", "0.053879 | \n", "0.559455 | \n", "0.053879 | \n", "
2 | \n", "mosaicml/mpt-7b-instruct | \n", "0.537091 | \n", "0.041919 | \n", "0.537091 | \n", "0.041919 | \n", "
3 | \n", "mosaicml/mpt-7b | \n", "0.536000 | \n", "0.042339 | \n", "0.536000 | \n", "0.042339 | \n", "
4 | \n", "mosaicml/mpt-7b-chat | \n", "0.538000 | \n", "0.047059 | \n", "0.538000 | \n", "0.047059 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
60 | \n", "huggyllama/llama-7b | \n", "0.541818 | \n", "0.040718 | \n", "0.541818 | \n", "0.040718 | \n", "
61 | \n", "meta-llama/Llama-2-7b-chat-hf | \n", "0.559818 | \n", "0.054954 | \n", "0.559818 | \n", "0.054954 | \n", "
62 | \n", "meta-llama/Llama-2-7b-hf | \n", "0.566727 | \n", "0.052515 | \n", "0.566727 | \n", "0.052515 | \n", "
63 | \n", "state-spaces/mamba-2.8b-hf | \n", "0.552909 | \n", "0.035570 | \n", "0.552909 | \n", "0.035570 | \n", "
64 | \n", "state-spaces/mamba-1.4b-hf | \n", "0.544182 | \n", "0.031390 | \n", "0.544182 | \n", "0.031390 | \n", "
65 rows × 5 columns
\n", "