{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-03T18:43:21.422682Z",
     "iopub.status.busy": "2025-06-03T18:43:21.422323Z",
     "iopub.status.idle": "2025-06-03T18:43:21.433788Z",
     "shell.execute_reply": "2025-06-03T18:43:21.433436Z",
     "shell.execute_reply.started": "2025-06-03T18:43:21.422664Z"
    }
   },
   "outputs": [],
   "source": [
    "# setup autoload\n",
    "%load_ext autoreload\n",
    "%autoreload 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-05-16T13:58:21.040680Z",
     "start_time": "2024-05-16T13:58:19.777010Z"
    },
    "execution": {
     "iopub.execute_input": "2025-06-03T18:43:21.434457Z",
     "iopub.status.busy": "2025-06-03T18:43:21.434202Z",
     "iopub.status.idle": "2025-06-03T18:43:23.188013Z",
     "shell.execute_reply": "2025-06-03T18:43:23.187655Z",
     "shell.execute_reply.started": "2025-06-03T18:43:21.434445Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The autoreload extension is already loaded. To reload it, use:\n",
      "  %reload_ext autoreload\n"
     ]
    }
   ],
   "source": [
    "import ast\n",
    "import os\n",
    "import shutil\n",
    "import sys\n",
    "from collections import defaultdict\n",
    "\n",
    "import json\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "\n",
    "sys.path.append(\"/home/tony/Work/tony/Preference\")\n",
    "from preference_data_preparation_4min_30b_task import *\n",
    "from preference_helper import *\n",
    "from sklearn.model_selection import train_test_split\n",
    "from suno_utils.utils.s3 import download_s3_files\n",
    "from suno_utils.utils.text import read_json, read_jsonl, write_json, write_jsonl\n",
    "from tqdm import tqdm\n",
    "\n",
    "pd.set_option(\"display.max_rows\", 500)\n",
    "pd.set_option(\"display.max_columns\", 500)\n",
    "pd.set_option(\"display.width\", 1000)\n",
    "\n",
    "# setup autoload\n",
    "%load_ext autoreload\n",
    "%autoreload 2\n",
    "\n",
    "\n",
    "def custom_parse(x):\n",
    "    try:\n",
    "        return json.loads(x)\n",
    "    except:\n",
    "        return {}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-05-16T13:58:21.082172Z",
     "start_time": "2024-05-16T13:58:21.041926Z"
    },
    "execution": {
     "iopub.execute_input": "2025-06-03T18:43:23.188700Z",
     "iopub.status.busy": "2025-06-03T18:43:23.188396Z",
     "iopub.status.idle": "2025-06-03T18:43:23.245326Z",
     "shell.execute_reply": "2025-06-03T18:43:23.244958Z",
     "shell.execute_reply.started": "2025-06-03T18:43:23.188686Z"
    }
   },
   "outputs": [],
   "source": [
    "OUT_DATA_DIR = \"/app/suno/data/dpo/auk_mix_t1_v14\"\n",
    "os.makedirs(OUT_DATA_DIR, exist_ok=True)\n",
    "shutil.copyfile(\n",
    "    \"/app/suno/data/dpo/7v_v20_full/tokenizer_60k.json\",\n",
    "    os.path.join(OUT_DATA_DIR, \"tokenizer_60k.json\"),\n",
    ")\n",
    "NPZ_DIR = \"/app/suno/data/dpo/30b_npz\"\n",
    "# NOTE FOR 30b we increase this from 6016 up\n",
    "N_TOKENS_AUDIO = 6016"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-05-16T13:58:53.962528Z",
     "start_time": "2024-05-16T13:58:21.105919Z"
    },
    "execution": {
     "iopub.execute_input": "2025-06-03T18:43:23.246328Z",
     "iopub.status.busy": "2025-06-03T18:43:23.246152Z",
     "iopub.status.idle": "2025-06-03T18:43:37.586617Z",
     "shell.execute_reply": "2025-06-03T18:43:37.586255Z",
     "shell.execute_reply.started": "2025-06-03T18:43:23.246316Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Preference data shape (931852, 90)\n"
     ]
    }
   ],
   "source": [
    "df = pd.read_pickle(\n",
    "    \"/home/tony/Data/Preference/30b_v6/interesting_clips_v4_h_t_6_20250501_full_long.pkl\"\n",
    ")\n",
    "print(\"Preference data shape\", df.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-03T18:43:37.587228Z",
     "iopub.status.busy": "2025-06-03T18:43:37.587012Z",
     "iopub.status.idle": "2025-06-03T18:43:39.597769Z",
     "shell.execute_reply": "2025-06-03T18:43:39.597399Z",
     "shell.execute_reply.started": "2025-06-03T18:43:37.587215Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(931852, 90) (465684, 90)\n",
      "after date cut (465684, 90)\n"
     ]
    }
   ],
   "source": [
    "df[\"created_at\"] = pd.to_datetime(df[\"created_at\"], utc=True)\n",
    "cutoff_date = pd.to_datetime(\"2025-04-12\", utc=True)\n",
    "# cutoff_date = pd.to_datetime(\"2025-04-17\", utc=True)\n",
    "print(df.shape, df[df[\"created_at\"] >= cutoff_date].shape)\n",
    "df = df[(df[\"created_at\"] >= cutoff_date)].copy()\n",
    "print(\"after date cut\", df.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-03T18:43:39.602984Z",
     "iopub.status.busy": "2025-06-03T18:43:39.602745Z",
     "iopub.status.idle": "2025-06-03T18:43:40.429557Z",
     "shell.execute_reply": "2025-06-03T18:43:40.429193Z",
     "shell.execute_reply.started": "2025-06-03T18:43:39.602970Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "after dropna (465684, 85)\n"
     ]
    }
   ],
   "source": [
    "df = df.dropna(axis=1, how=\"all\")\n",
    "print(\"after dropna\", df.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-05-16T13:58:56.199480Z",
     "start_time": "2024-05-16T13:58:53.963687Z"
    },
    "execution": {
     "iopub.execute_input": "2025-06-03T18:43:40.430543Z",
     "iopub.status.busy": "2025-06-03T18:43:40.430301Z",
     "iopub.status.idle": "2025-06-03T18:49:02.664583Z",
     "shell.execute_reply": "2025-06-03T18:49:02.664215Z",
     "shell.execute_reply.started": "2025-06-03T18:43:40.430530Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "6442462\n",
      "6442462\n",
      "pre-downloaded df (465684, 85)\n",
      "downloaded df (465683, 85)\n"
     ]
    }
   ],
   "source": [
    "converted_paths = os.listdir(NPZ_DIR)\n",
    "print(len(converted_paths))\n",
    "\n",
    "converted_paths = set([f.replace(\".npz\", \"\") for f in converted_paths])\n",
    "print(len(converted_paths))\n",
    "\n",
    "print(\"pre-downloaded df\", df.shape)\n",
    "df[df[\"s3_id\"].isin(converted_paths)].shape\n",
    "df = df[df[\"s3_id\"].isin(converted_paths)].copy()\n",
    "print(\"downloaded df\", df.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-05-16T13:58:56.467253Z",
     "start_time": "2024-05-16T13:58:56.207647Z"
    },
    "execution": {
     "iopub.execute_input": "2025-06-03T18:49:02.665136Z",
     "iopub.status.busy": "2025-06-03T18:49:02.664973Z",
     "iopub.status.idle": "2025-06-03T18:49:03.822609Z",
     "shell.execute_reply": "2025-06-03T18:49:03.822260Z",
     "shell.execute_reply.started": "2025-06-03T18:49:02.665123Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "is_30b\n",
      "True    465683\n",
      "Name: count, dtype: int64\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "task\n",
       "cover                 256083\n",
       "artist_consistency    182810\n",
       "infill                 26786\n",
       "artist_extend              4\n",
       "Name: count, dtype: int64"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[\"is_30b\"] = df[\"model_name\"].str.contains(\"-t\")\n",
    "print(df[\"is_30b\"].value_counts())\n",
    "df[\"task\"].value_counts()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# LET's do the data prep"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-03T18:49:03.823240Z",
     "iopub.status.busy": "2025-06-03T18:49:03.823001Z",
     "iopub.status.idle": "2025-06-03T18:49:03.836953Z",
     "shell.execute_reply": "2025-06-03T18:49:03.836653Z",
     "shell.execute_reply.started": "2025-06-03T18:49:03.823228Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(465683, 86)\n"
     ]
    }
   ],
   "source": [
    "# drop extend for now\n",
    "# reason is -- cause they are likely caused by extend from 13b\n",
    "# we don't want contamination\n",
    "# df = df[df[\"task\"] != \"extend\"].copy()\n",
    "print(df.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-05-16T13:58:56.592883Z",
     "start_time": "2024-05-16T13:58:56.470781Z"
    },
    "execution": {
     "iopub.execute_input": "2025-06-03T18:49:03.837446Z",
     "iopub.status.busy": "2025-06-03T18:49:03.837271Z",
     "iopub.status.idle": "2025-06-03T18:49:03.996198Z",
     "shell.execute_reply": "2025-06-03T18:49:03.995838Z",
     "shell.execute_reply.started": "2025-06-03T18:49:03.837434Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "preference  model_name    \n",
      "False       chirp-v4-h-t-6    232842\n",
      "True        chirp-v4-h-t-6    232841\n",
      "Name: count, dtype: int64\n",
      "before filter on model name (465683, 86)\n",
      "after filter on model name (465683, 86)\n"
     ]
    }
   ],
   "source": [
    "## for 13b this is easy for now\n",
    "print(df.groupby([\"preference\"])[\"model_name\"].value_counts())\n",
    "print(\"before filter on model name\", df.shape)\n",
    "df = df[df[\"model_name\"].isin([\"chirp-v4-h-t-6\", \"chirp-v3p5-engine-t-6\"])]\n",
    "# df = df[df[\"model_name\"].isin([\"chirp-v3p5-engine-t-6\"])]\n",
    "print(\"after filter on model name\", df.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-03T18:49:03.996770Z",
     "iopub.status.busy": "2025-06-03T18:49:03.996573Z",
     "iopub.status.idle": "2025-06-03T18:49:04.012270Z",
     "shell.execute_reply": "2025-06-03T18:49:04.011995Z",
     "shell.execute_reply.started": "2025-06-03T18:49:03.996758Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "is_public\n",
      "False    454090\n",
      "True      11593\n",
      "Name: count, dtype: int64\n"
     ]
    }
   ],
   "source": [
    "print(df[\"is_public\"].value_counts())\n",
    "# remove public for now cause fucking users\n",
    "# df = df[~df[\"is_public\"]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-05-16T13:58:56.909539Z",
     "start_time": "2024-05-16T13:58:56.595736Z"
    },
    "execution": {
     "iopub.execute_input": "2025-06-03T18:49:04.012734Z",
     "iopub.status.busy": "2025-06-03T18:49:04.012579Z",
     "iopub.status.idle": "2025-06-03T18:49:04.624021Z",
     "shell.execute_reply": "2025-06-03T18:49:04.623628Z",
     "shell.execute_reply.started": "2025-06-03T18:49:04.012723Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "before filter on request id pairs (465683, 86)\n",
      "after filter on request id pairs (465682, 86)\n",
      "preference  model_name    \n",
      "False       chirp-v4-h-t-6    232841\n",
      "True        chirp-v4-h-t-6    232841\n",
      "Name: count, dtype: int64\n"
     ]
    }
   ],
   "source": [
    "print(\"before filter on request id pairs\", df.shape)\n",
    "df = df[\n",
    "    df[\"request_id\"].isin(\n",
    "        df[\"request_id\"].value_counts().index[df[\"request_id\"].value_counts() == 2]\n",
    "    )\n",
    "]\n",
    "print(\"after filter on request id pairs\", df.shape)\n",
    "print(df.groupby([\"preference\"])[\"model_name\"].value_counts())\n",
    "assert df.shape[0] == df[\"request_id\"].nunique() * 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-03T18:49:04.625796Z",
     "iopub.status.busy": "2025-06-03T18:49:04.625607Z",
     "iopub.status.idle": "2025-06-03T18:50:15.511358Z",
     "shell.execute_reply": "2025-06-03T18:50:15.510996Z",
     "shell.execute_reply.started": "2025-06-03T18:49:04.625783Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "unique_requests 232841\n",
      "before removing duplicates (465682, 160)\n",
      "after removing duplicates (465682, 153)\n"
     ]
    }
   ],
   "source": [
    "# Let's use the old selection for now -- for quality assurance\n",
    "# expand the metadata columns -- this takes forever...~ 6 mins\n",
    "# test_slice = df[\"metadata\"].apply(lambda x: ast.literal_eval(str(x)))\n",
    "# test_slice = df[\"metadata\"].apply(lambda x: custom_parse(x))\n",
    "test_slice = df[\"metadata\"]  # .apply(lambda x: custom_parse(x))\n",
    "test_slice_series = test_slice.apply(pd.Series)\n",
    "df = pd.concat([df, test_slice_series], axis=1, join=\"inner\")\n",
    "print(\"unique_requests\", df[\"request_id\"].nunique())\n",
    "# remove the duplicates\n",
    "print(\"before removing duplicates\", df.shape)\n",
    "df = df.loc[:, ~df.columns.duplicated()].copy()\n",
    "print(\"after removing duplicates\", df.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-03T18:50:15.512060Z",
     "iopub.status.busy": "2025-06-03T18:50:15.511749Z",
     "iopub.status.idle": "2025-06-03T18:50:16.319307Z",
     "shell.execute_reply": "2025-06-03T18:50:16.318970Z",
     "shell.execute_reply.started": "2025-06-03T18:50:15.512047Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "task\n",
       "cover                 256082\n",
       "artist_consistency    182810\n",
       "infill                 26786\n",
       "artist_extend              4\n",
       "Name: count, dtype: int64"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[\"task\"].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-03T18:50:16.319885Z",
     "iopub.status.busy": "2025-06-03T18:50:16.319685Z",
     "iopub.status.idle": "2025-06-03T18:50:17.187823Z",
     "shell.execute_reply": "2025-06-03T18:50:17.187497Z",
     "shell.execute_reply.started": "2025-06-03T18:50:16.319873Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "pos_diff_preference\n",
       "1.0    161927\n",
       "2.0     70914\n",
       "Name: count, dtype: int64"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = df.sort_values(by=[\"request_id\", \"preference\", \"diff_preference\"])\n",
    "df[\"pos_diff_preference\"] = df[\"diff_preference\"].diff()\n",
    "# df[\"cer_diff_preference\"] = df[\"cer\"].diff()\n",
    "df[df[\"preference\"]][\"pos_diff_preference\"].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-03T18:50:17.188415Z",
     "iopub.status.busy": "2025-06-03T18:50:17.188181Z",
     "iopub.status.idle": "2025-06-03T18:50:17.489079Z",
     "shell.execute_reply": "2025-06-03T18:50:17.488721Z",
     "shell.execute_reply.started": "2025-06-03T18:50:17.188402Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "positive param_experiment\n",
      "text_1       5758\n",
      "temp_s_80    5605\n",
      "temp_s_70    5489\n",
      "Name: count, dtype: int64\n"
     ]
    }
   ],
   "source": [
    "try:\n",
    "    print(\"positive\", df[df[\"preference\"]][\"param_experiment\"].value_counts())\n",
    "except:\n",
    "    pass"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-03T18:50:17.489680Z",
     "iopub.status.busy": "2025-06-03T18:50:17.489479Z",
     "iopub.status.idle": "2025-06-03T18:50:30.989567Z",
     "shell.execute_reply": "2025-06-03T18:50:30.989209Z",
     "shell.execute_reply.started": "2025-06-03T18:50:17.489667Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Found 39551 duplicated prompts 19776 unique requests\n",
      "Found 9451 request_ids with duplicate prompts but not highest play counts in their group\n",
      "['fa5aba0d-4424-438b-9f87-ba5d0ef503cb', '115a0270-2735-43a2-80d4-05b371926471', '14e7fadb-f34c-4f26-9bda-c378283f529a', '90a5dfe0-d1ba-4a62-9813-936e80ccabb8', '5c18e378-278c-4a9c-a60c-7c9508bbfaf3', 'f3edfa94-39fe-4c6b-b00d-7aea44f16447', '6897cd2a-59ee-4a54-831f-4e0f56ea74e1', '19726b9e-0f6e-4638-91f2-18d0a9d02050', '266d9dbb-ace9-42fe-b92e-e04d0d9bd3a8', 'a982e31f-1ff4-4503-83de-14cbe0a11f55']\n",
      "Before dedup user gen requests 465682\n",
      "After dedup user gen requests 465682\n"
     ]
    }
   ],
   "source": [
    "# Find duplicated prompts with count > 2\n",
    "duplicate_entries = df.groupby(\n",
    "    [\"user_id\", \"prompt_text\", \"tags\", \"task\", \"edited_clip_id\"]\n",
    ").filter(lambda x: len(x) > 2)\n",
    "print(\n",
    "    \"Found\",\n",
    "    len(duplicate_entries),\n",
    "    \"duplicated prompts\",\n",
    "    len(duplicate_entries[\"request_id\"].unique()),\n",
    "    \"unique requests\",\n",
    ")\n",
    "\n",
    "# Group by user_id, prompt_text, and tags to find duplicate prompt groups\n",
    "prompt_groups = duplicate_entries.groupby(\n",
    "    [\"user_id\", \"prompt_text\", \"tags\", \"task\", \"edited_clip_id\"]\n",
    ")\n",
    "\n",
    "# For each prompt group, find the request_id with the highest total reaction_play_count\n",
    "low_play_count_request_ids = []\n",
    "for prompt_key, prompt_group in prompt_groups:\n",
    "    # Get the sum of reaction_play_count for each request_id in this group\n",
    "    request_play_counts = prompt_group.groupby(\"request_id\")[\n",
    "        \"reaction_play_count\"\n",
    "    ].sum()\n",
    "\n",
    "    # Find the max play count in this group\n",
    "    max_play_count = request_play_counts.max()\n",
    "\n",
    "    # Add request_ids that don't have the max play count to our filter list\n",
    "    lower_play_count_request_ids = request_play_counts[\n",
    "        request_play_counts < max_play_count\n",
    "    ].index.tolist()\n",
    "    low_play_count_request_ids.extend(lower_play_count_request_ids)\n",
    "\n",
    "# Display the filtered request IDs\n",
    "print(\n",
    "    f\"Found {len(low_play_count_request_ids)} request_ids with duplicate prompts but not highest play counts in their group\"\n",
    ")\n",
    "print(\n",
    "    low_play_count_request_ids[:10]\n",
    "    if len(low_play_count_request_ids) > 10\n",
    "    else low_play_count_request_ids\n",
    ")\n",
    "print(\"Before dedup user gen requests\", df.shape[0])\n",
    "# df = df[~df[\"request_id\"].isin(low_play_count_request_ids)]\n",
    "print(\"After dedup user gen requests\", df.shape[0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-05-16T13:59:40.799375Z",
     "start_time": "2024-05-16T13:59:36.394236Z"
    },
    "execution": {
     "iopub.execute_input": "2025-06-03T18:50:30.990093Z",
     "iopub.status.busy": "2025-06-03T18:50:30.989949Z",
     "iopub.status.idle": "2025-06-03T18:50:33.107667Z",
     "shell.execute_reply": "2025-06-03T18:50:33.107316Z",
     "shell.execute_reply.started": "2025-06-03T18:50:30.990080Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "11875\n",
      "good_continue_at\n",
      "True    465682\n",
      "Name: count, dtype: int64\n",
      "\n",
      " Check some basics... \n",
      " preference\n",
      "False    232841\n",
      "True     232841\n",
      "Name: count, dtype: int64 is_30b\n",
      "True    465682\n",
      "Name: count, dtype: int64 model_name\n",
      "chirp-v4-h-t-6    465682\n",
      "Name: count, dtype: int64 preference  model_name    \n",
      "False       chirp-v4-h-t-6    232841\n",
      "True        chirp-v4-h-t-6    232841\n",
      "Name: count, dtype: int64\n",
      "task\n",
      "cover                 256082\n",
      "artist_consistency    182810\n",
      "infill                 26786\n",
      "artist_extend              4\n",
      "Name: count, dtype: int64\n"
     ]
    }
   ],
   "source": [
    "df[\"id\"] = df[\"str_id\"]\n",
    "# get the original duration of the clips, if they are concacted\n",
    "df[\"original_duration_s\"] = df[\"total_start_s\"] + df[\"duration\"]\n",
    "# classify the continue at behavoirs by the duration choice\n",
    "audio_prompt_id_to_continue_at = {}\n",
    "\n",
    "for _, row in df[~df[\"continued_parent\"].isna()].iterrows():\n",
    "    audio_prompt_id = row[\"continued_parent\"]\n",
    "    if audio_prompt_id not in audio_prompt_id_to_continue_at:\n",
    "        audio_prompt_id_to_continue_at[audio_prompt_id] = row[\"continue_at\"]\n",
    "    else:\n",
    "        # pick the max\n",
    "        audio_prompt_id = max(\n",
    "            audio_prompt_id_to_continue_at[audio_prompt_id], row[\"continue_at\"]\n",
    "        )\n",
    "print(len(audio_prompt_id_to_continue_at))\n",
    "df[\"has_continue_and_start_continue_at\"] = df[\"id\"].apply(\n",
    "    lambda x: audio_prompt_id_to_continue_at.get(x)\n",
    ")\n",
    "# we want continue at to be at most of the clip...\n",
    "df[\"good_continue_at\"] = (\n",
    "    (df[\"has_continue_and_start_continue_at\"] / df[\"duration\"]) > 0.9\n",
    ") | df[\"has_continue_and_start_continue_at\"].isna()\n",
    "print(df[\"good_continue_at\"].value_counts())\n",
    "\n",
    "\n",
    "print(\n",
    "    \"\\n Check some basics... \\n\",\n",
    "    df[\"preference\"].value_counts(),\n",
    "    df[\"is_30b\"].value_counts(),\n",
    "    df[\"model_name\"].value_counts(),\n",
    "    df.groupby([\"preference\"])[\"model_name\"].value_counts(),\n",
    ")\n",
    "\n",
    "df = df.sort_values(by=[\"request_id\", \"preference\"])\n",
    "df[\"duration_rel_diff\"] = df[\"duration\"].diff()\n",
    "df[\"play_rel_diff\"] = df[\"reaction_play_count\"].diff()\n",
    "print(df[\"task\"].value_counts())\n",
    "\n",
    "df[\"post_infill_duration\"] = (\n",
    "    df[\"duration\"]\n",
    "    + df[\"infill_context_end_s\"]\n",
    "    - df[\"infill_context_start_s\"]\n",
    "    - df[\"include_future_s\"]\n",
    "    - df[\"include_history_s\"]\n",
    "    - df[\"infill_dur_s\"]\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-03T18:50:33.108248Z",
     "iopub.status.busy": "2025-06-03T18:50:33.108048Z",
     "iopub.status.idle": "2025-06-03T18:50:33.276257Z",
     "shell.execute_reply": "2025-06-03T18:50:33.275933Z",
     "shell.execute_reply.started": "2025-06-03T18:50:33.108235Z"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAjAAAAGdCAYAAAAMm0nCAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAtnElEQVR4nO3df3AUdZ7/8dd0fkAgPwiZILKgUkQSDwgJQnGJw2bZFd0S3CrgTqxlRTwKcFmVW1nBYhEIWARc8PDXLRRSrIgseup6/oC6Q+/wsABBi2wONwIRF8LlPCYhMSGBkGT6+wffjJmYkEwymZlP5vmoSlWm+zPdn/d8Anml+9PdDtu2bQEAABjECnUHAAAA/EWAAQAAxiHAAAAA4xBgAACAcQgwAADAOAQYAABgHAIMAAAwDgEGAAAYhwADAACMQ4ABAADGiQ51B3paRUWNgvWwBIdDSklJCOo+Qy0Sa5aom7p7v0isWaLucKi7uS8d6fUBxrYV9MEIxT5DLRJrlqg70kRi3ZFYs0TdJuAUEgAAMA4BBgAAGIcAAwAAjEOAAQAA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q1ev1htvvKG4uDjNmzdP9fX13ja/+c1vVFJSoh07dmjLli367LPPtHLlSu/6S5cuad68eRoyZIjefvttLV26VC+++KJef/31LpQIAAB6G79PIeXl5SkvL6/NdbZta+fOnfrlL3+pO++8U5L0zDPPKDc3Vx9++KGmTp2qr776SgcPHtSbb76pMWPGSJJWrFihBQsWaOnSpbrhhhv07rvvqqGhQevWrVNsbKxuvfVWFRcXa8eOHZo1a1Y3ykWoNV+ZxP1lAADdEdA5MOfPn5fb7VZubq53WUJCgsaOHavjx49r6tSpOn78uBITE73hRZJyc3NlWZaKioo0ZcoUFRYWavz48YqNjfW2cblc2rZtm7799lslJSV1uk8OR8dtAqV5X8HcpynauzIp0IL12Uf6WDsckVV7JI53JNYsUXc41N3ZPgQ0wLjdbklSSkqKz/KUlBSVl5dLksrLyzVw4EDfTkRHKykpyfv+8vJyDR061KeN0+n0rvMnwKSkJPhXRACEYp/hrvWVSd25v0x7kpP7B3R7nRGpYz1gQPA/63AQieMdiTVL1G2CXn8VUkVFjewgXbXrcFwb/GDuM5CioqweDwHNVyZ15f4yHamsrFVTkyfg222L6WPdGdf7eaiqqlVjY3A+63AQCePdWiTWLFF3ONTd3JeOBDTApKamSpIqKio0aNAg7/KKigplZGRIunYk5eLFiz7va2xs1Lfffut9v9Pp9B6xadb8uvlITGfZtoI+GKHYJ65hrIODuiNHJNYsUbcJAjqTcujQoUpNTdXhw4e9yy5duqQ///nPys7OliRlZ2erurpaJ06c8LY5cuSIPB6PMjMzJUlZWVn67LPP1NDQ4G1z6NAhDR8+3K/TRwAAoHfyO8DU1taquLhYxcXFkq5N3C0uLlZZWZkcDofmzJmj3//+9/roo4908uRJLV26VIMGDfJelTRixAhNmjRJTz31lIqKivT5559r7dq1mjp1qm644QZJ0r333quYmBj99re/1enTp7V3717t3LlTDz30UABLBwAApvL7FNKJEyc0Z84c7+uCggJJ0vTp07V+/XrNnz9fly9f1sqVK1VdXa3bb79dL7/8svr06eN9z8aNG7V27Vo9+OCDsix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ptv1tChQ/Xcc89p0KBBuvPOOyVdm/g3adIkPfXUU8rPz1dDQ4PWrl2rqVOn6oYbbghVWR26Xt1JSUl68cUXdffdd8vpdKq0tFS/+93vdPPNN2vSpEmSzK07Pz9f77//vv75n/9Z/fv3957TT0hIUN++fTv1c+1yuZSWlqalS5fqiSeekNvt1ubNmzV79mzFxsaGsLq2dVTzuXPn9N577ykvL08DBgzQyZMnVVBQoAkTJigjI0OSeTVL0qZNm/TDH/5QN954o2pra/X+++/r6NGj2r59e68c52bXq7s3jDVPow6QXbt2afv27XK73brtttu0YsUK7+G43uDXv/61jh07pqqqKg0cOFC33367fv3rX3vPk9bX12v9+vX64IMPdPXqVblcLq1atSosDjN21qeffqo5c+Z8b/n06dO1fv162bat559/Xm+88Yaqq6t1++23a9WqVRo+fLi3bVVVldauXav/+I//kGVZuuuuu7RixQr1798/mKX45Xp1r169Wr/61a/0l7/8RTU1NRo0aJDuuOMOLV682OcUqYl1p6ent7m8oKDA+8dHZ36u/+d//kerV6/W0aNHFRcXp+nTp2vJkiWKjg6/vw87qvl///d/9cQTT+j06dOqq6vTjTfeqDvvvFOLFi1SfHy8t71JNUvS8uXLdeTIEV24cEEJCQlKT0/X/Pnzdccdd0jqfePc7Hp194axJsAAAADjMAcGAAAYhwADAACMQ4ABAADGIcAAAADjEGAAAIBxCDAAAMA4BBgAAGAcAgwAADAOAQYAABiHAAMAAIxDgAEAAMYhwAAAAOP8P9xjGzHkkvXqAAAAAElFTkSuQmCC",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "df[\"post_infill_duration\"].hist(bins=np.linspace(-5, 360, 100))\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-05-16T13:59:41.035167Z",
     "start_time": "2024-05-16T13:59:40.801098Z"
    },
    "execution": {
     "iopub.execute_input": "2025-06-03T18:50:33.276843Z",
     "iopub.status.busy": "2025-06-03T18:50:33.276689Z",
     "iopub.status.idle": "2025-06-03T18:50:34.560313Z",
     "shell.execute_reply": "2025-06-03T18:50:34.559953Z",
     "shell.execute_reply.started": "2025-06-03T18:50:33.276830Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "after duration 0.9955162535807697\n",
      "after infill duration 0.9978977070189529\n",
      "neg_filter_reaction_play_count 1.0\n",
      "neg_filter_upvote_count 0.9901\n",
      "neg_filter_norm_play_frac 1.0\n",
      "neg_filter_continues 1.0\n",
      "----------------\n",
      "pos_filter_continues 1.0\n",
      "pos_filter_reaction_play_count 1.0\n",
      "pos_filter_relative_play_count 0.9744\n",
      "pos_filter_cer_diff_preference 1.0\n",
      "pos_filter_bad_flags 0.9999\n",
      "after filter on play counts 0.9731\n",
      "after filter on higher quality 0.3144\n",
      "----------------\n",
      "negative 229029 positive 63875\n",
      "----------------\n",
      "total pair requests 232841  --> selected pair requests 63272 frac 0.272\n"
     ]
    }
   ],
   "source": [
    "normal_pos_play_count = 3\n",
    "# this is lower, cause a concat is probably already ensuring that it is good\n",
    "concat_pos_play_count = 1\n",
    "# this is a filter on the concated clip\n",
    "concat_total_play_count = 3\n",
    "\n",
    "all_fitlers = (df[\"duration\"] >= 10) & (df[\"duration\"] <= 240)\n",
    "print(\"after duration\", all_fitlers.sum() / df.shape[0])\n",
    "infill_duration_filter = (\n",
    "    ~df[\"task\"].isin(\n",
    "        [\n",
    "            \"infill\",\n",
    "            \"infill_intro\",\n",
    "            \"infill_outro\",\n",
    "        ]\n",
    "    )\n",
    ") | (df[\"post_infill_duration\"] <= 239)\n",
    "print(\"after infill duration\", infill_duration_filter.sum() / df.shape[0])\n",
    "# negative fitlers\n",
    "total_negative = df[~df[\"preference\"]].shape[0]\n",
    "neg_filter_reaction_play_count = (~df[\"preference\"]) & (df[\"reaction_play_count\"] >= 1)\n",
    "print(\n",
    "    \"neg_filter_reaction_play_count\",\n",
    "    round(neg_filter_reaction_play_count.sum() / total_negative, 4),\n",
    ")\n",
    "neg_filter_upvote_count = (~df[\"preference\"]) & (df[\"upvote_count\"] == 0)\n",
    "print(\n",
    "    \"neg_filter_upvote_count\",\n",
    "    round(neg_filter_upvote_count.sum() / total_negative, 4),\n",
    ")\n",
    "neg_filter_norm_play_frac = (~df[\"preference\"]) & (df[\"norm_play_frac\"] <= 3.1)\n",
    "print(\n",
    "    \"neg_filter_norm_play_frac\",\n",
    "    round(neg_filter_norm_play_frac.sum() / total_negative, 4),\n",
    ")\n",
    "neg_filter_continues = (~df[\"preference\"]) & (\n",
    "    df[\"has_continue_and_start_continue_at\"].isna()\n",
    ")\n",
    "print(\n",
    "    \"neg_filter_continues\",\n",
    "    round(neg_filter_continues.sum() / total_negative, 4),\n",
    ")\n",
    "\n",
    "neg_filter_selection_mask = (\n",
    "    all_fitlers\n",
    "    & infill_duration_filter\n",
    "    & neg_filter_reaction_play_count\n",
    "    & neg_filter_upvote_count\n",
    "    & neg_filter_norm_play_frac\n",
    "    & neg_filter_continues\n",
    ")\n",
    "\n",
    "print(\"----------------\")\n",
    "total_positive = df[df[\"preference\"]].shape[0]\n",
    "assert total_positive == total_negative\n",
    "pos_filter_continues = (df[\"preference\"]) & (df[\"good_continue_at\"])\n",
    "print(\"pos_filter_continues\", round(pos_filter_continues.sum() / total_positive, 4))\n",
    "pos_filter_reaction_play_count = (df[\"preference\"]) & (df[\"reaction_play_count\"] >= 1)\n",
    "print(\n",
    "    \"pos_filter_reaction_play_count\",\n",
    "    round(pos_filter_reaction_play_count.sum() / total_positive, 4),\n",
    ")\n",
    "pos_filter_relative_play_count = (df[\"preference\"]) & (df[\"play_rel_diff\"] >= 0)\n",
    "print(\n",
    "    \"pos_filter_relative_play_count\",\n",
    "    round(pos_filter_relative_play_count.sum() / total_positive, 4),\n",
    ")\n",
    "pos_filter_cer_diff_preference = (\n",
    "    df[\n",
    "        \"preference\"\n",
    "    ]  # & (df[\"pos_diff_preference\"] == 2) # & (df[\"cer_diff_preference\"] < 0.5) & (df[\"cer\"] < 0.99)\n",
    ")\n",
    "print(\n",
    "    \"pos_filter_cer_diff_preference\",\n",
    "    round(pos_filter_cer_diff_preference.sum() / total_positive, 4),\n",
    ")\n",
    "pos_filter_bad_flags = (\n",
    "    (df[\"preference\"]) & (df[\"flag_count\"] == 0) & (df[\"dislike_count\"] == 0)\n",
    ")\n",
    "print(\n",
    "    \"pos_filter_bad_flags\",\n",
    "    round(pos_filter_bad_flags.sum() / total_positive, 4),\n",
    ")\n",
    "pos_filter_play_counts = (df[\"preference\"]) & (\n",
    "    (\n",
    "        (df[\"part_of_concat\"])\n",
    "        & (df[\"reaction_play_count\"] >= concat_pos_play_count)\n",
    "        & (df[\"concat_play_counts\"] >= concat_total_play_count)\n",
    "    )\n",
    "    | (\n",
    "        (~df[\"part_of_concat\"]) & (df[\"reaction_play_count\"] >= normal_pos_play_count)\n",
    "        # & (df[\"norm_play_frac\"] >= 2.1)  # this is a bit of a luxury cut...\n",
    "    )\n",
    "    | (df[\"task\"].isin([\"infill\", \"infill_intro\", \"infill_outro\"]))\n",
    ")\n",
    "print(\n",
    "    \"after filter on play counts\",\n",
    "    round(pos_filter_play_counts.sum() / total_positive, 4),\n",
    ")\n",
    "high_quality_tasks_filter = (\n",
    "    (df[\"task\"].isin([\"cover\", \"extend\", \"artist_consistency\", \"\"]))\n",
    "    & (\n",
    "        (df[\"upvote_count\"] >= 1)  # (df[\"upvote_count\"] >= 1)\n",
    "        | (df[\"reaction_play_count\"] >= 5)\n",
    "        | (df[\"concat_play_counts\"] >= 5)\n",
    "    )\n",
    "    & (\n",
    "        (df[\"part_of_concat\"])\n",
    "        | (\n",
    "            (~df[\"part_of_concat\"])\n",
    "            & (df[\"norm_play_frac\"] >= 5.1)  # this is a bit of a luxury cut...\n",
    "            & (\n",
    "                df[\"norm_play_frac\"] >= df[\"reaction_play_count\"] / 3\n",
    "            )  # play duration is not low on average\n",
    "        )\n",
    "    )\n",
    ")\n",
    "medium_quality_tasks_filter = (\n",
    "    df[\"task\"].isin(\n",
    "        [\n",
    "            \"infill\",\n",
    "            \"infill_intro\",\n",
    "            \"infill_outro\",\n",
    "        ]\n",
    "    )\n",
    ") & (  # let more infill through only in this case...\n",
    "    (\n",
    "        df[\"upvote_count\"] >= 0\n",
    "    )  # (df[\"upvote_count\"] >= 1)  (df[\"pos_diff_preference\"] == 2)\n",
    "    | (df[\"reaction_play_count\"] >= 1)\n",
    "    | (df[\"concat_play_counts\"] >= 1)\n",
    ")\n",
    "pos_filter_higher_quality = (df[\"preference\"]) & (\n",
    "    high_quality_tasks_filter | medium_quality_tasks_filter\n",
    ")\n",
    "print(\n",
    "    \"after filter on higher quality\",\n",
    "    round(pos_filter_higher_quality.sum() / total_positive, 4),\n",
    ")\n",
    "\n",
    "user_gen_filter = (\n",
    "    df[\"user_n_clips\"] >= 100\n",
    ")  # user needs to have genereated at least 100 over the time period\n",
    "\n",
    "print(\"----------------\")\n",
    "pos_filter_selectin_mask = (\n",
    "    (df[\"preference\"])  # get basics aligned\n",
    "    & all_fitlers\n",
    "    & infill_duration_filter\n",
    "    & pos_filter_continues\n",
    "    & pos_filter_reaction_play_count\n",
    "    & pos_filter_relative_play_count\n",
    "    & pos_filter_cer_diff_preference\n",
    "    & pos_filter_bad_flags\n",
    "    & pos_filter_play_counts\n",
    "    & pos_filter_higher_quality\n",
    "    & user_gen_filter\n",
    ")\n",
    "print(\n",
    "    \"negative\",\n",
    "    sum(neg_filter_selection_mask),\n",
    "    \"positive\",\n",
    "    sum(pos_filter_selectin_mask),\n",
    ")\n",
    "\n",
    "neg_filter_requests = df[neg_filter_selection_mask][\"request_id\"].unique()\n",
    "pos_filter_requests = df[pos_filter_selectin_mask][\"request_id\"].unique()\n",
    "# looking for very strong signal here:\n",
    "# listen to the positive/negative more than once\n",
    "# disliked one of the clips\n",
    "unique_requests = set(pos_filter_requests).intersection(neg_filter_requests)\n",
    "print(\"----------------\")\n",
    "print(\n",
    "    \"total pair requests\",\n",
    "    df[\"request_id\"].nunique(),\n",
    "    \" --> selected pair requests\",\n",
    "    len(unique_requests),\n",
    "    f\"frac {len(unique_requests) / df['request_id'].nunique():.3f}\",\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-05-16T13:59:41.250737Z",
     "start_time": "2024-05-16T13:59:41.036434Z"
    },
    "execution": {
     "iopub.execute_input": "2025-06-03T18:50:34.560925Z",
     "iopub.status.busy": "2025-06-03T18:50:34.560763Z",
     "iopub.status.idle": "2025-06-03T18:50:35.016290Z",
     "shell.execute_reply": "2025-06-03T18:50:35.015931Z",
     "shell.execute_reply.started": "2025-06-03T18:50:34.560912Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "auk_mix_t1_v14 requests 63272 clips 126544 total khrs 5.382; N gpus for 1000 iters 7.909; 4 gpus for x iters 1977.250; n unique users 26926 n pro users 26111\n"
     ]
    }
   ],
   "source": [
    "df_slice = df[df[\"request_id\"].isin(set(unique_requests))].copy()\n",
    "print(\n",
    "    f\"{os.path.basename(OUT_DATA_DIR)} requests\",\n",
    "    df_slice[\"request_id\"].nunique(),\n",
    "    \"clips\",\n",
    "    df_slice.shape[0],\n",
    "    f\"total khrs {sum(df_slice['duration'] / 3600 / 1000):.3f};\",\n",
    "    f\"N gpus for 1000 iters {df_slice.shape[0] / 8 / 2 / 1000:.3f};\",\n",
    "    f\"4 gpus for x iters {df_slice.shape[0] / 8 / 2 / 4:.3f};\",\n",
    "    f\"n unique users {df_slice['user_id'].nunique()}\",\n",
    "    f\"n pro users {df_slice[df_slice['is_pro_user']]['user_id'].nunique()}\",\n",
    ")\n",
    "# 76171 152342 total khrs 2.880 n gpus for 1250 iters 3.809\n",
    "# v10 has 78866\n",
    "# v14 has 110402\n",
    "# 30b_t4_v12 requests 47755 clips 95510 total khrs 4.555; N gpus for 1000 iters 5.969; 4 gpus for x iters 1492.344; n unique users 13790 n pro users 13526\n",
    "# 30b_t4_v20 requests 18306 clips 36612 total khrs 1.754; N gpus for 1000 iters 2.288; 4 gpus for x iters 572.062; n unique users 6943 n pro users 6714\n",
    "# 30b_t5_v5 requests 21318 clips 42636 total khrs 1.938; N gpus for 1000 iters 2.665; 4 gpus for x iters 666.188; n unique users 11661 n pro users 9347\n",
    "# 30b_t5_v6 requests 22833 clips 45666 total khrs 2.072; N gpus for 1000 iters 2.854; 4 gpus for x iters 713.531; n unique users 12576 n pro users 9910\n",
    "# 30b_t5_v7 requests 33197 clips 66394 total khrs 2.846; N gpus for 1000 iters 4.150; 4 gpus for x iters 1037.406; n unique users 16665 n pro users 13050\n",
    "# 30b_t5_v8 requests 20907 clips 41814 total khrs 1.629; N gpus for 1000 iters 2.613; 4 gpus for x iters 653.344; n unique users 11102 n pro users 9052\n",
    "# 30b_t5_v9 requests 24645 clips 49290 total khrs 1.918; N gpus for 1000 iters 3.081; 4 gpus for x iters 770.156; n unique users 12661 n pro users 10229\n",
    "# 30b_t5_v11 requests 21975 clips 43950 total khrs 1.508; N gpus for 1000 iters 2.747; 4 gpus for x iters 686.719; n unique users 11173 n pro users 9270\n",
    "# 30b_t5_v12 requests 21436 clips 42872 total khrs 1.582; N gpus for 1000 iters 2.679; 4 gpus for x iters 669.875; n unique users 11553 n pro users 9374\n",
    "# 30b_t5_v13 requests 25912 clips 51824 total khrs 1.922; N gpus for 1000 iters 3.239; 4 gpus for x iters 809.750; n unique users 13429 n pro users 10737\n",
    "# 30b_t5_v14 requests 27687 clips 55374 total khrs 2.036; N gpus for 1000 iters 3.461; 4 gpus for x iters 865.219; n unique users 14196 n pro users 11227\n",
    "# 30b_t5_v15 requests 29563 clips 59126 total khrs 2.225; N gpus for 1000 iters 3.695; 4 gpus for x iters 923.844; n unique users 14684 n pro users 11642\n",
    "# 30b_t6_v1 requests 24678 clips 49356 total khrs 1.934; N gpus for 1000 iters 3.085; 4 gpus for x iters 771.188; n unique users 11350 n pro users 10065\n",
    "# 30b_t6_v2 requests 49341 clips 98682 total khrs 4.332; N gpus for 1000 iters 6.168; 4 gpus for x iters 1541.906; n unique users 19992 n pro users 16972\n",
    "# 30b_t6_v3 requests 54967 clips 109934 total khrs 4.826; N gpus for 1000 iters 6.871; 4 gpus for x iters 1717.719; n unique users 21653 n pro users 18266\n",
    "# 30b_t6_v5 requests 29459 clips 58918 total khrs 2.657; N gpus for 1000 iters 3.682; 4 gpus for x iters 920.594; n unique users 14091 n pro users 11884\n",
    "# 30b_t6_v7 requests 40056 clips 80112 total khrs 3.354; N gpus for 1000 iters 5.007; 4 gpus for x iters 1251.750; n unique users 17440 n pro users 14476\n",
    "# 30b_t6_v8 requests 31681 clips 63362 total khrs 2.681; N gpus for 1000 iters 3.960; 4 gpus for x iters 990.031; n unique users 15180 n pro users 15078\n",
    "# 30b_t6_v9 requests 55785 clips 111570 total khrs 4.727; N gpus for 1000 iters 6.973; 4 gpus for x iters 1743.281; n unique users 23114 n pro users 22871\n",
    "# 30b_t6_v10 requests 52209 clips 104418 total khrs 4.515; N gpus for 1000 iters 6.526; 4 gpus for x iters 1631.531; n unique users 22216 n pro users 21893\n",
    "# 30b_t6_v11 requests 31338 clips 62676 total khrs 2.493; N gpus for 1000 iters 3.917; 4 gpus for x iters 979.312; n unique users 15190 n pro users 14973\n",
    "# 30b_t6_v13 requests 50856 clips 101712 total khrs 3.987; N gpus for 1000 iters 6.357; 4 gpus for x iters 1589.250; n unique users 23547 n pro users 23097\n",
    "# 30b_t6_v15 requests 65213 clips 130426 total khrs 5.217; N gpus for 1000 iters 8.152; 4 gpus for x iters 2037.906; n unique users 28763 n pro users 27964\n",
    "# 30b_t6_v16 requests 37907 clips 75814 total khrs 2.956; N gpus for 1000 iters 4.738; 4 gpus for x iters 1184.594; n unique users 18448 n pro users 17212\n",
    "# 30b_t6_v17 requests 51543 clips 103086 total khrs 4.154; N gpus for 1000 iters 6.443; 4 gpus for x iters 1610.719; n unique users 24223 n pro users 21829\n",
    "# 30b_t6_v18 requests 94965 clips 189930 total khrs 7.483; N gpus for 1000 iters 11.871; 4 gpus for x iters 2967.656; n unique users 23852 n pro users 21767\n",
    "# 30b_t6_v19 requests 34289 clips 68578 total khrs 2.846; N gpus for 1000 iters 4.286; 4 gpus for x iters 1071.531; n unique users 11802 n pro users 10830\n",
    "# 30b_t6_v20 requests 53258 clips 106516 total khrs 4.270; N gpus for 1000 iters 6.657; 4 gpus for x iters 1664.312; n unique users 22096 n pro users 21171\n",
    "# 30b_t6_v22 requests 29971 clips 59942 total khrs 1.992; N gpus for 1000 iters 3.746; 4 gpus for x iters 936.594; n unique users 13611 n pro users 13036\n",
    "# 30b_t6_v24 requests 45333 clips 90666 total khrs 3.343; N gpus for 1000 iters 5.667; 4 gpus for x iters 1416.656; n unique users 18853 n pro users 18049\n",
    "# 30b_t6_v25 requests 28154 clips 56308 total khrs 2.401; N gpus for 1000 iters 3.519; 4 gpus for x iters 879.812; n unique users 12946 n pro users 12361\n",
    "# 30b_t6_v26 requests 30428 clips 60856 total khrs 2.599; N gpus for 1000 iters 3.804; 4 gpus for x iters 950.875; n unique users 13822 n pro users 13163\n",
    "# 30b_t6_v27 requests 43731 clips 87462 total khrs 3.862; N gpus for 1000 iters 5.466; 4 gpus for x iters 1366.594; n unique users 17898 n pro users 16865\n",
    "# 30b_t6_v28 requests 56869 clips 113738 total khrs 5.064; N gpus for 1000 iters 7.109; 4 gpus for x iters 1777.156; n unique users 22004 n pro users 20244\n",
    "# 30b_t6_v29 requests 32729 clips 65458 total khrs 2.604; N gpus for 1000 iters 4.091; 4 gpus for x iters 1022.781; n unique users 13739 n pro users 13503\n",
    "# 30b_t6_v30 requests 32553 clips 65106 total khrs 2.592; N gpus for 1000 iters 4.069; 4 gpus for x iters 1017.281; n unique users 13712 n pro users 13478\n",
    "# 30b_t6_v31 requests 41523 clips 83046 total khrs 3.164; N gpus for 1000 iters 5.190; 4 gpus for x iters 1297.594; n unique users 16266 n pro users 15967\n",
    "# 30b_t6_v32 requests 55942 clips 111884 total khrs 4.361; N gpus for 1000 iters 6.993; 4 gpus for x iters 1748.188; n unique users 20808 n pro users 20271\n",
    "# 30b_t6_v33 requests 182096 clips 364192 total khrs 13.745; N gpus for 1000 iters 22.762; 4 gpus for x iters 5690.500; n unique users 40437 n pro users 34524\n",
    "# auk_mix_t1_v2 requests 102002 clips 204004 total khrs 9.191; N gpus for 1000 iters 12.750; 4 gpus for x iters 3187.562; n unique users 36408 n pro users 34038\n",
    "# auk_mix_t1_v13 requests 53011 clips 106022 total khrs 4.496; N gpus for 1000 iters 6.626; 4 gpus for x iters 1656.594; n unique users 23713 n pro users 23117\n",
    "# auk_mix_t1_v14 requests 63272 clips 126544 total khrs 5.382; N gpus for 1000 iters 7.909; 4 gpus for x iters 1977.250; n unique users 26926 n pro users 26111"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-05-16T13:59:41.277006Z",
     "start_time": "2024-05-16T13:59:41.252105Z"
    },
    "execution": {
     "iopub.execute_input": "2025-06-03T18:50:35.016936Z",
     "iopub.status.busy": "2025-06-03T18:50:35.016692Z",
     "iopub.status.idle": "2025-06-03T18:50:35.067301Z",
     "shell.execute_reply": "2025-06-03T18:50:35.066966Z",
     "shell.execute_reply.started": "2025-06-03T18:50:35.016922Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "positive in playlist (13493, 159)\n",
      "task\n",
      "cover                 53704\n",
      "artist_consistency    51122\n",
      "infill                21718\n",
      "Name: count, dtype: int64\n"
     ]
    }
   ],
   "source": [
    "test_mask = (df_slice[\"preference\"]) & (\n",
    "    (df_slice[\"is_in_playlist\"]) | (df_slice[\"concat_in_playlist\"])\n",
    ")\n",
    "print(\"positive in playlist\", df_slice[test_mask].shape)\n",
    "print(df_slice[\"task\"].value_counts())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-03T18:50:35.067867Z",
     "iopub.status.busy": "2025-06-03T18:50:35.067676Z",
     "iopub.status.idle": "2025-06-03T18:50:35.201249Z",
     "shell.execute_reply": "2025-06-03T18:50:35.200924Z",
     "shell.execute_reply.started": "2025-06-03T18:50:35.067854Z"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAjAAAAGeCAYAAACKDztsAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAtTUlEQVR4nO3df3AUZZ7H8c90fkAgPwiZAOZApfiRoBAShGKDk+O4A3dL8KqAO7GWFbFSgosIt6JgsQgJWAS84CHqKYVUFkQOqVX3QKGudG+xsABRiyyFFyGRXQjLWkzCj0ACIWT6/mAzMiEkMzC/nuT9qkqZ6X5m+ulvOuRjP093O2zbtgUAAGAQK9IdAAAACBQBBgAAGIcAAwAAjEOAAQAAxiHAAAAA4xBgAACAcQgwAADAOAQYAABgHAIMAAAwDgEGAAAYJ6AAs379ek2dOlW5ubnKy8vTnDlzdPz4cZ82jz/+uDIzM32+li5d6tPm9OnTmjVrloYPH668vDytXr1a165d82nz5ZdfavLkyRo6dKgmTJigDz/88DZ3EQAAdDSxgTQ+ePCgpk+frmHDhqmpqUmvvvqqCgoK9Mknn6hbt27edo8++qjmzZvnfZ2QkOD9vqmpSbNnz5bT6dS2bdt05swZLVq0SHFxcXruueckSVVVVZo9e7Yee+wxlZSUaP/+/VqyZInS09OVn58f0A7W1FxUOJ/25HBIaWlJYd+uaaiTf6iTf6hT+6iRf6iTf0JZp+bPbk9AAWbjxo0+r1etWqW8vDx9++23GjVqlHd5165dlZ6e3upnfPHFF6qsrFRpaamcTqeGDBmi+fPnq6SkRHPnzlV8fLy2bdumvn376sUXX5QkDRgwQN98841+85vfBBxgbFsROQgjtV3TUCf/UCf/UK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t/X111/f9I+t6dqrkyTl5+f7HF+vvvqqz/qOXqeDBw9q+vTp2r59u0pLS3Xt2jUVFBSovr7e26a937OmpibNnj1bjY2N2rZtm1atWqWPPvpI69ati8QuhYQ/dZKkRx991Od4WrhwoXddZ6hTnz599Pzzz+vDDz/UBx98oJ/85Cd65plnVFFRISkKjyUbQfEv//IvdlFRkfd1U1OT7XK57PXr10ewV5G1bt06+5//+Z9bXVdbW2vff//99u7du73LKisr7cGDB9uHDh0KUw8jb/Dgwfann37qfe3xeOwHH3zQfuedd7zLamtr7aFDh9off/yxbds/1unw4cPeNp9//rmdmZlp//DDD+HrfBi1rJNt2/aiRYvsX/7yl7d8T2esU01NjT148GD74MGDtm3793u2Z88eOysry3a73d42W7dutUeMGGE3NDSEtf/h0rJOtm3bv/jFL+yXX375lu/pjHWybdseNWqUvX379qg8ljgDEwRXr17Vt99+qzFjxniXWZalMWPG6NChQxHsWeSdOHFCLpdL//RP/6QFCxbo9OnTkqQjR46osbHRp2YDBgxQRkaGysrKItTbyDt16pTcbrdPXZKSkjR8+HDvsXTo0CElJydr2LBh3jZjxoyRZVmdbtjy4MGDysvL009/+lMtW7ZM586d867rjHW6ePGiJCklJUWSf79nZWVlGjx4sM9NQl0uly5duqTKysrwdT6MWtap2c6dOzV69GhNmjRJa9as0eXLl73rOludmpqa9Mknn6i+vl65ublReSxF7Z14TXLu3Dk1NTUpLS3NZ3laWtpN46ydSXZ2toqLi9W/f3+53W69+eabmj59unbu3Knq6mrFxcUpOTnZ5z1paWlyu90R6nHkNe97a8dS81hzdXW1evbs6bM+NjZWKSkpnap2+fn5mjBhgvr27auqqiq9+uqreuqpp/T+++8rJiam09XJ4/Fo5cqVGjFihAYPHixJfv2eVVdX33SH8+bXnaVOkjRp0iRlZGSoV69eOnr0qEpKSvSnP/1Jb7zxhqTOU6ejR4/qscceU0NDg7p166Y333xTAwcOVHl5edQdSwQYhMzYsWO932dlZWn48OEaN26cdu/era5du0awZ+gIJk6c6P2+edLl+PHj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vLli3rUKdjW/Pll19qxowZNy2fPHmyVq1aJdu2tW7dOm3fvl21tbV64IEHtGzZMvXv39/b9vz581qxYoX+93//V5Zl6aGHHtKSJUvUvXv3cO5KSLVVp8LCQj3zzDP6v//7P128eFG9evXSgw8+qPnz5/sM23b0OmVmZra6vLi42Ps/T/78nv3lL39RYWGhDh48qISEBE2ePFkLFixQbGzH+H/c9ur017/+VS+88IIqKipUX1+vu+66S+PHj9ecOXOUmJjobd/R67R48WIdOHBAZ86cUVJSkjIzM/XUU0/pwQcflBR9xxIBBgAAGIc5MAAAwDgEGAAAYBwCDAAAMA4BBgAAGIcAAwAAjEOAAQAAxiHAAAAA4xBgAACAcQgwAADAOAQYAABgHAIMAAAwzv8DSdbXU0ZCpP4AAAAASUVORK5CYII=",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "df_slice[\"post_infill_duration\"].hist(bins=np.linspace(-5, 300, 100))\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-05-16T13:59:41.323409Z",
     "start_time": "2024-05-16T13:59:41.278278Z"
    },
    "execution": {
     "iopub.execute_input": "2025-06-03T18:50:35.201815Z",
     "iopub.status.busy": "2025-06-03T18:50:35.201622Z",
     "iopub.status.idle": "2025-06-03T18:50:35.215331Z",
     "shell.execute_reply": "2025-06-03T18:50:35.215061Z",
     "shell.execute_reply.started": "2025-06-03T18:50:35.201801Z"
    }
   },
   "outputs": [],
   "source": [
    "# interesting_clips_must_be_positive_mask = (\n",
    "#     (df_slice[\"upvoted\"] == True)\n",
    "#     | (df_slice[\"has_action\"] == True)\n",
    "#     | (df_slice[\"part_of_concat\"] == True)\n",
    "# )\n",
    "# interesting_clips_must_be_not_negative_mask = (df_slice[\"downvoted\"] == False) # & (df_slice[\"dislike_count\"] < 1)\n",
    "# interesting_clips_mask = interesting_clips_must_be_positive_mask & interesting_clips_must_be_not_negative_mask\n",
    "# assert interesting_clips_mask.eq(df_slice[\"preference\"]).all()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-05-16T13:59:41.392244Z",
     "start_time": "2024-05-16T13:59:41.324472Z"
    },
    "execution": {
     "iopub.execute_input": "2025-06-03T18:50:35.215816Z",
     "iopub.status.busy": "2025-06-03T18:50:35.215644Z",
     "iopub.status.idle": "2025-06-03T18:50:35.225703Z",
     "shell.execute_reply": "2025-06-03T18:50:35.225448Z",
     "shell.execute_reply.started": "2025-06-03T18:50:35.215805Z"
    }
   },
   "outputs": [],
   "source": [
    "# save positive ids\n",
    "# positive_preference_ids = df_slice[df_slice[\"preference\"] == False][\"s3_id\"].to_json(orient='values')\n",
    "# with open('/home/tony/Data/Preference/7b_v2/7v_v20_full_recut_id_negative.json', 'w') as file:\n",
    "#     file.write(positive_preference_ids)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-03T18:50:35.226170Z",
     "iopub.status.busy": "2025-06-03T18:50:35.226004Z",
     "iopub.status.idle": "2025-06-03T18:50:35.235969Z",
     "shell.execute_reply": "2025-06-03T18:50:35.235713Z",
     "shell.execute_reply.started": "2025-06-03T18:50:35.226159Z"
    }
   },
   "outputs": [],
   "source": [
    "# df_slice_2 = pd.read_pickle(\"/home/tony/Data/Preference/30b_v6/interesting_clips_v4_t_6_20241118_full_slice.pkl\")\n",
    "# df_total = pd.concat([df_slice, df_slice_2])\n",
    "# print(df_total.shape)\n",
    "# df_slice = df_total"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-03T18:50:35.236465Z",
     "iopub.status.busy": "2025-06-03T18:50:35.236269Z",
     "iopub.status.idle": "2025-06-03T18:50:35.246348Z",
     "shell.execute_reply": "2025-06-03T18:50:35.246094Z",
     "shell.execute_reply.started": "2025-06-03T18:50:35.236454Z"
    }
   },
   "outputs": [],
   "source": [
    "# df_slice_prev = pd.read_pickle(\n",
    "#     \"/home/tony/Data/Preference/30b_v2/interesting_clips_v4_t_3_v13_20240902_slice.pkl\"\n",
    "# )\n",
    "# df_slice_prev = df_slice_prev[\n",
    "#     (\n",
    "#         (df_slice_prev[\"task\"] != \"infill\")\n",
    "#         & (df_slice_prev[\"task\"] != \"cover\")\n",
    "#         & (df_slice_prev[\"task\"] != \"artist_consistency\")\n",
    "#     )\n",
    "# ].copy()\n",
    "# df_slice = pd.concat([df_slice, df_slice_prev])\n",
    "# print(df_slice.shape)\n",
    "# print(df_slice[\"task\"].value_counts())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-03T18:50:35.246835Z",
     "iopub.status.busy": "2025-06-03T18:50:35.246651Z",
     "iopub.status.idle": "2025-06-03T18:50:35.256718Z",
     "shell.execute_reply": "2025-06-03T18:50:35.256463Z",
     "shell.execute_reply.started": "2025-06-03T18:50:35.246823Z"
    }
   },
   "outputs": [],
   "source": [
    "# df_slice[(df_slice[\"preference\"]) & ((df_slice[\"task\"].str.strip() == \"\") | (df_slice[\"task\"].str.strip() == \"cover\"))].to_pickle(\n",
    "#     \"/home/tony/Data/Preference/30b_v5/interesting_clips_v4_t_5_20241018_full_with_cer_pos_gen.pkl\"\n",
    "# )\n",
    "# df_slice[(df_slice[\"preference\"]) & ((df_slice[\"task\"].str.strip() == \"\") | (df_slice[\"task\"].str.strip() == \"cover\"))].shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-03T18:50:35.257162Z",
     "iopub.status.busy": "2025-06-03T18:50:35.257016Z",
     "iopub.status.idle": "2025-06-03T18:50:35.267032Z",
     "shell.execute_reply": "2025-06-03T18:50:35.266774Z",
     "shell.execute_reply.started": "2025-06-03T18:50:35.257151Z"
    }
   },
   "outputs": [],
   "source": [
    "# df_slice.to_pickle(\"/home/tony/Data/Preference/30b_v6/interesting_clips_v4_h_t_6_20250108_full_slice.pkl\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-03T18:50:35.267490Z",
     "iopub.status.busy": "2025-06-03T18:50:35.267325Z",
     "iopub.status.idle": "2025-06-03T18:50:35.277243Z",
     "shell.execute_reply": "2025-06-03T18:50:35.276985Z",
     "shell.execute_reply.started": "2025-06-03T18:50:35.267479Z"
    }
   },
   "outputs": [],
   "source": [
    "# with open(\"/home/tony/Data/Preference/30b_v6/similarities_30b_t6.json\", \"r\") as fp:\n",
    "#     all_similarities = json.load(fp)\n",
    "\n",
    "# df_slice[\"similarity\"] = df_slice[\"id\"].map(all_similarities)\n",
    "# df_cover = df_slice[df_slice[\"task\"] == \"cover\"].copy()\n",
    "# df_artist = df_slice[df_slice[\"task\"] == \"artist_consistency\"].copy()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-03T18:50:35.277739Z",
     "iopub.status.busy": "2025-06-03T18:50:35.277546Z",
     "iopub.status.idle": "2025-06-03T18:50:35.287627Z",
     "shell.execute_reply": "2025-06-03T18:50:35.287374Z",
     "shell.execute_reply.started": "2025-06-03T18:50:35.277728Z"
    }
   },
   "outputs": [],
   "source": [
    "# df_cover[df_cover[\"preference\"]][\"similarity\"].hist(bins=200, label=\"positive\", alpha=0.5)\n",
    "# df_cover[~df_cover[\"preference\"]][\"similarity\"].hist(bins=200, label=\"negative\", alpha=0.5)\n",
    "# plt.legend()\n",
    "# plt.show()\n",
    "# df_cover[\"similarity_diff\"] = df_cover[\"similarity\"].diff()\n",
    "# df_cover[df_cover[\"preference\"]][\"similarity_diff\"].hist(bins=200)\n",
    "# plt.show()\n",
    "# df_cover[\"continued_parent\"] = None\n",
    "# df_cover[\"continue_at\"] = -1\n",
    "# too_similar = (df_cover[\"similarity\"] >= 0.99)\n",
    "# too_different = ( df_cover[\"similarity\"] < 0.25)\n",
    "# too_big_difference = (df_cover[\"similarity_diff\"] < -0.2)\n",
    "# df_cover_drops_id = df_cover[\n",
    "#     (df_cover[\"preference\"])\n",
    "#     & (too_similar | too_different | too_big_difference)\n",
    "# ][\"s3_id\"].unique()\n",
    "# print(\"total rows\", df_cover.shape[0], \"total drops\", len(df_cover_drops_id))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-03T18:50:35.288082Z",
     "iopub.status.busy": "2025-06-03T18:50:35.287920Z",
     "iopub.status.idle": "2025-06-03T18:50:35.298005Z",
     "shell.execute_reply": "2025-06-03T18:50:35.297748Z",
     "shell.execute_reply.started": "2025-06-03T18:50:35.288071Z"
    }
   },
   "outputs": [],
   "source": [
    "# df_artist[df_artist[\"preference\"]][\"similarity\"].hist(bins=200, label=\"positive\", alpha=0.5)\n",
    "# df_artist[~df_artist[\"preference\"]][\"similarity\"].hist(bins=200, label=\"negative\", alpha=0.5)\n",
    "# plt.legend()\n",
    "# plt.show()\n",
    "# df_artist[\"similarity_diff\"] = df_artist[\"similarity\"].diff()\n",
    "# df_artist[df_artist[\"preference\"]][\"similarity_diff\"].hist(bins=200)\n",
    "# plt.show()\n",
    "# too_similar = (df_artist[\"similarity\"] >= 0.95)\n",
    "# too_different = ( df_artist[\"similarity\"] < 0.4)\n",
    "# too_big_difference = (df_artist[\"similarity_diff\"] < -0.2)\n",
    "# df_artist_drops_id = df_artist[\n",
    "#     (df_artist[\"preference\"])\n",
    "#     & (too_similar | too_different | too_big_difference)\n",
    "# ][\"s3_id\"].unique()\n",
    "# print(\"total rows\", df_artist.shape[0], \"total drops\", len(df_artist_drops_id))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-03T18:50:35.298447Z",
     "iopub.status.busy": "2025-06-03T18:50:35.298301Z",
     "iopub.status.idle": "2025-06-03T18:50:35.308335Z",
     "shell.execute_reply": "2025-06-03T18:50:35.308084Z",
     "shell.execute_reply.started": "2025-06-03T18:50:35.298436Z"
    }
   },
   "outputs": [],
   "source": [
    "# print(\"before filter on cover similarity\", df_slice.shape)\n",
    "# df_slice = df_slice[~df_slice[\"s3_id\"].isin(df_cover_drops_id)].copy()\n",
    "# print(\"after filter on cover similarity\", df_slice.shape)\n",
    "# df_slice = df_slice[~df_slice[\"s3_id\"].isin(df_artist_drops_id)].copy()\n",
    "# print(\"after filter on artist similarity\", df_slice.shape)\n",
    "# df_slice = df_slice[\n",
    "#     df_slice[\"request_id\"].isin(\n",
    "#         df_slice[\"request_id\"].value_counts().index[df_slice[\"request_id\"].value_counts() == 2]\n",
    "#     )\n",
    "# ]\n",
    "# print(\"after filter on request id pairs\", df_slice.shape)\n",
    "# print(df_slice.groupby([\"preference\"])[\"model_name\"].value_counts())\n",
    "# assert df_slice.shape[0] == df_slice[\"request_id\"].nunique() * 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-03T18:50:35.308788Z",
     "iopub.status.busy": "2025-06-03T18:50:35.308627Z",
     "iopub.status.idle": "2025-06-03T18:50:35.319960Z",
     "shell.execute_reply": "2025-06-03T18:50:35.319700Z",
     "shell.execute_reply.started": "2025-06-03T18:50:35.308777Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "is_public\n",
      "False    121494\n",
      "True       5050\n",
      "Name: count, dtype: int64\n"
     ]
    }
   ],
   "source": [
    "print(df_slice[\"is_public\"].value_counts())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-03T18:50:35.320436Z",
     "iopub.status.busy": "2025-06-03T18:50:35.320253Z",
     "iopub.status.idle": "2025-06-03T18:50:35.352175Z",
     "shell.execute_reply": "2025-06-03T18:50:35.351860Z",
     "shell.execute_reply.started": "2025-06-03T18:50:35.320425Z"
    }
   },
   "outputs": [],
   "source": [
    "df_slice[\"npz_path\"] = df_slice[\"s3_id\"].map(lambda x: f\"{NPZ_DIR}/{x}.npz\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-05-16T14:00:20.866354Z",
     "start_time": "2024-05-16T14:00:12.443344Z"
    },
    "execution": {
     "iopub.execute_input": "2025-06-03T18:50:35.352703Z",
     "iopub.status.busy": "2025-06-03T18:50:35.352523Z",
     "iopub.status.idle": "2025-06-03T18:50:35.997156Z",
     "shell.execute_reply": "2025-06-03T18:50:35.995850Z",
     "shell.execute_reply.started": "2025-06-03T18:50:35.352691Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(104826, 160)\n",
      "task\n",
      "cover                 53704\n",
      "artist_consistency    51122\n",
      "Name: count, dtype: int64\n",
      "(104826, 160)\n",
      "task\n",
      "cover                 53704\n",
      "artist_consistency    51122\n",
      "Name: count, dtype: int64\n"
     ]
    },
    {
     "ename": "NameError",
     "evalue": "name 'BREAK' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "Cell \u001b[0;32mIn[37], line 9\u001b[0m\n\u001b[1;32m      7\u001b[0m \u001b[38;5;28mprint\u001b[39m(df_slice\u001b[38;5;241m.\u001b[39mshape)\n\u001b[1;32m      8\u001b[0m \u001b[38;5;28mprint\u001b[39m(df_slice[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mtask\u001b[39m\u001b[38;5;124m\"\u001b[39m]\u001b[38;5;241m.\u001b[39mvalue_counts())\n\u001b[0;32m----> 9\u001b[0m \u001b[43mBREAK\u001b[49m\n",
      "\u001b[0;31mNameError\u001b[0m: name 'BREAK' is not defined"
     ]
    }
   ],
   "source": [
    "# df_slice.to_pickle(\n",
    "#     \"/home/tony/Data/Preference/30b_v6/interesting_clips_v4_h_t_6_20250426_20250501_full_long_slice.pkl\"\n",
    "# )\n",
    "print(df_slice.shape)\n",
    "print(df_slice[\"task\"].value_counts())\n",
    "df_slice = df_slice[df_slice[\"task\"].isin([\"cover\", \"artist_consistency\"])].copy()\n",
    "print(df_slice.shape)\n",
    "print(df_slice[\"task\"].value_counts())\n",
    "BREAK"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-03T18:51:22.836920Z",
     "iopub.status.busy": "2025-06-03T18:51:22.836662Z",
     "iopub.status.idle": "2025-06-03T18:51:29.217557Z",
     "shell.execute_reply": "2025-06-03T18:51:29.217200Z",
     "shell.execute_reply.started": "2025-06-03T18:51:22.836904Z"
    }
   },
   "outputs": [],
   "source": [
    "df_13b_slice = pd.read_pickle(\n",
    "    \"/home/tony/Data/Preference/13b_v32/interesting_clips_v4_h_s_32_20250412_20250501_full_long_slice.pkl\"\n",
    ")\n",
    "print(df_13b_slice.shape)\n",
    "print(df_13b_slice[\"task\"].value_counts())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-03T18:51:29.218356Z",
     "iopub.status.busy": "2025-06-03T18:51:29.218166Z",
     "iopub.status.idle": "2025-06-03T18:51:29.297846Z",
     "shell.execute_reply": "2025-06-03T18:51:29.297497Z",
     "shell.execute_reply.started": "2025-06-03T18:51:29.218343Z"
    }
   },
   "outputs": [],
   "source": [
    "df_30b_slice = df_slice.copy()\n",
    "print(df_30b_slice.shape)\n",
    "print(df_30b_slice[\"task\"].value_counts())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-03T18:51:29.298429Z",
     "iopub.status.busy": "2025-06-03T18:51:29.298226Z",
     "iopub.status.idle": "2025-06-03T18:51:31.598782Z",
     "shell.execute_reply": "2025-06-03T18:51:31.598434Z",
     "shell.execute_reply.started": "2025-06-03T18:51:29.298416Z"
    }
   },
   "outputs": [],
   "source": [
    "df_total = pd.concat([df_13b_slice, df_30b_slice])\n",
    "print(df_total.shape)\n",
    "print(df_total[\"task\"].value_counts())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-03T18:51:31.599367Z",
     "iopub.status.busy": "2025-06-03T18:51:31.599166Z",
     "iopub.status.idle": "2025-06-03T18:51:32.358937Z",
     "shell.execute_reply": "2025-06-03T18:51:32.358525Z",
     "shell.execute_reply.started": "2025-06-03T18:51:31.599353Z"
    }
   },
   "outputs": [],
   "source": [
    "df_slice = df_total.copy()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Need to kick out the ones has gpt prompt -- these are pairs with different text inputs"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-05-16T13:59:41.932296Z",
     "start_time": "2024-05-16T13:59:41.932287Z"
    },
    "execution": {
     "iopub.execute_input": "2025-06-03T18:51:32.360028Z",
     "iopub.status.busy": "2025-06-03T18:51:32.359826Z",
     "iopub.status.idle": "2025-06-03T18:51:32.384119Z",
     "shell.execute_reply": "2025-06-03T18:51:32.383751Z",
     "shell.execute_reply.started": "2025-06-03T18:51:32.360015Z"
    }
   },
   "outputs": [],
   "source": [
    "# don't have continue at\n",
    "df_slice[\"request_id\"] = df_slice[\"request_id\"].astype(str)\n",
    "# df_slice[\"npz_path\"] = df_slice[\"npz_path\"].apply(lambda x: str(x).replace(\"_npz\", \"_npz/\"))\n",
    "# df_slice[df_slice[\"continue_at\"].isna()][\"request_id\"].nunique(), df_slice[\"request_id\"].nunique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-03T18:51:32.384670Z",
     "iopub.status.busy": "2025-06-03T18:51:32.384492Z",
     "iopub.status.idle": "2025-06-03T18:51:33.187908Z",
     "shell.execute_reply": "2025-06-03T18:51:33.187547Z",
     "shell.execute_reply.started": "2025-06-03T18:51:32.384658Z"
    }
   },
   "outputs": [],
   "source": [
    "print(df_slice.shape)\n",
    "df_slice = df_slice[df_slice[\"request_id\"].apply(lambda x: len(x) > 3)]\n",
    "print(df_slice.shape)\n",
    "# df_slice = df_slice[df_slice[\"is_pro_user\"]].copy()\n",
    "print(df_slice.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-05-16T13:59:41.932966Z",
     "start_time": "2024-05-16T13:59:41.932957Z"
    },
    "execution": {
     "iopub.execute_input": "2025-06-03T18:51:33.188429Z",
     "iopub.status.busy": "2025-06-03T18:51:33.188303Z",
     "iopub.status.idle": "2025-06-03T18:51:33.273381Z",
     "shell.execute_reply": "2025-06-03T18:51:33.273015Z",
     "shell.execute_reply.started": "2025-06-03T18:51:33.188416Z"
    }
   },
   "outputs": [],
   "source": [
    "final_filtered_requests = df_slice[\"request_id\"].astype(str).unique()\n",
    "# final_filtered_requests = df_slice[df_slice[\"is_pro_user\"]][\"request_id\"].astype(str).unique()\n",
    "print(len(final_filtered_requests))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-05-16T13:59:41.933558Z",
     "start_time": "2024-05-16T13:59:41.933550Z"
    },
    "execution": {
     "iopub.execute_input": "2025-06-03T18:51:33.273958Z",
     "iopub.status.busy": "2025-06-03T18:51:33.273768Z",
     "iopub.status.idle": "2025-06-03T18:51:33.289902Z",
     "shell.execute_reply": "2025-06-03T18:51:33.289634Z",
     "shell.execute_reply.started": "2025-06-03T18:51:33.273945Z"
    }
   },
   "outputs": [],
   "source": [
    "# df_slice.to_csv(\"/home/tony/Data/Preference/30b_v2/interesting_clips_v4_t_3_20240902_slice.csv\", index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-03T18:51:33.290361Z",
     "iopub.status.busy": "2025-06-03T18:51:33.290209Z",
     "iopub.status.idle": "2025-06-03T18:51:33.300501Z",
     "shell.execute_reply": "2025-06-03T18:51:33.300246Z",
     "shell.execute_reply.started": "2025-06-03T18:51:33.290349Z"
    }
   },
   "outputs": [],
   "source": [
    "# df_slice[\"continue_at\"] = -1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-05-16T13:59:41.934277Z",
     "start_time": "2024-05-16T13:59:41.934268Z"
    },
    "execution": {
     "iopub.execute_input": "2025-06-03T18:51:33.300975Z",
     "iopub.status.busy": "2025-06-03T18:51:33.300802Z",
     "iopub.status.idle": "2025-06-03T18:51:34.807160Z",
     "shell.execute_reply": "2025-06-03T18:51:34.806809Z",
     "shell.execute_reply.started": "2025-06-03T18:51:33.300964Z"
    }
   },
   "outputs": [],
   "source": [
    "train_requests, val_requests = train_test_split(\n",
    "    sorted(list(final_filtered_requests)), test_size=0.01, random_state=42\n",
    ")\n",
    "print(len(train_requests), len(val_requests))\n",
    "\n",
    "train_df = df_slice[df_slice[\"request_id\"].astype(str).isin(set(train_requests))].copy()\n",
    "val_df = df_slice[df_slice[\"request_id\"].astype(str).isin(set(val_requests))].copy()\n",
    "train_df = train_df.sort_values(by=[\"request_id\", \"preference\"])\n",
    "train_df = train_df  # .reset_index()\n",
    "val_df = val_df.sort_values(by=[\"request_id\", \"preference\"])\n",
    "val_df = val_df  # .reset_index()\n",
    "train_df = train_df.reset_index(drop=True)\n",
    "val_df = val_df.reset_index(drop=True)\n",
    "print(train_df.shape, val_df.shape)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Actually make"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-05-16T13:59:41.935620Z",
     "start_time": "2024-05-16T13:59:41.935613Z"
    },
    "execution": {
     "iopub.execute_input": "2025-06-03T18:51:34.807744Z",
     "iopub.status.busy": "2025-06-03T18:51:34.807545Z",
     "iopub.status.idle": "2025-06-03T18:51:41.670198Z",
     "shell.execute_reply": "2025-06-03T18:51:41.669838Z",
     "shell.execute_reply.started": "2025-06-03T18:51:34.807731Z"
    }
   },
   "outputs": [],
   "source": [
    "total_duration = 0\n",
    "for i, row in tqdm(train_df.iterrows(), total=len(train_df)):\n",
    "    # we need to alternate between preference: neg, pos\n",
    "    # print(i, row)\n",
    "    try:\n",
    "        assert row[\"preference\"] == (i % 2 == 1)\n",
    "        total_duration += row[\"duration\"]\n",
    "    except Exception as E:\n",
    "        print(i, row)\n",
    "        print(E)\n",
    "        raise ValueError()\n",
    "\n",
    "print(\n",
    "    f\"{round(total_duration / 60 / 60):,} hours of {train_df.shape[0]} clips, {train_df.shape[0] / 8 / 2 / 1000} nodes, {train_df.shape[0] / 8 / 2 / 6} iters\"\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-05-16T13:59:41.936268Z",
     "start_time": "2024-05-16T13:59:41.936260Z"
    },
    "execution": {
     "iopub.execute_input": "2025-06-03T18:51:41.670782Z",
     "iopub.status.busy": "2025-06-03T18:51:41.670586Z",
     "iopub.status.idle": "2025-06-03T18:52:25.994438Z",
     "shell.execute_reply": "2025-06-03T18:52:25.994082Z",
     "shell.execute_reply.started": "2025-06-03T18:51:41.670768Z"
    }
   },
   "outputs": [],
   "source": [
    "make_dataset(\n",
    "    val_df, OUT_DATA_DIR, is_val=True, npz_dir=NPZ_DIR, t_data_memmap=N_TOKENS_AUDIO\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-03T18:52:25.994970Z",
     "iopub.status.busy": "2025-06-03T18:52:25.994821Z",
     "iopub.status.idle": "2025-06-03T18:52:26.781829Z",
     "shell.execute_reply": "2025-06-03T18:52:26.781430Z",
     "shell.execute_reply.started": "2025-06-03T18:52:25.994958Z"
    }
   },
   "outputs": [],
   "source": [
    "# test_npz = np.load(\"/app/suno/data/dpo/30b_npz/26d19085-18da-4701-af43-122684543891.npz\")\n",
    "# for k in test_npz.keys():\n",
    "#     print(k)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-05-16T13:59:41.936964Z",
     "start_time": "2024-05-16T13:59:41.936957Z"
    },
    "execution": {
     "iopub.execute_input": "2025-06-03T18:52:26.783432Z",
     "iopub.status.busy": "2025-06-03T18:52:26.783241Z",
     "iopub.status.idle": "2025-06-03T20:07:51.453039Z",
     "shell.execute_reply": "2025-06-03T20:07:51.452579Z",
     "shell.execute_reply.started": "2025-06-03T18:52:26.783420Z"
    }
   },
   "outputs": [],
   "source": [
    "make_dataset(\n",
    "    train_df, OUT_DATA_DIR, is_val=False, npz_dir=NPZ_DIR, t_data_memmap=N_TOKENS_AUDIO\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-01-29T19:46:47.549860Z",
     "start_time": "2024-01-29T19:46:47.548015Z"
    }
   },
   "source": [
    "# Validation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-05-16T13:59:41.937879Z",
     "start_time": "2024-05-16T13:59:41.937870Z"
    },
    "execution": {
     "iopub.execute_input": "2025-06-03T20:07:51.453690Z",
     "iopub.status.busy": "2025-06-03T20:07:51.453543Z",
     "iopub.status.idle": "2025-06-03T20:07:52.489344Z",
     "shell.execute_reply": "2025-06-03T20:07:52.488848Z",
     "shell.execute_reply.started": "2025-06-03T20:07:51.453675Z"
    }
   },
   "outputs": [],
   "source": [
    "# verify\n",
    "mm = np.memmap(os.path.join(OUT_DATA_DIR, f\"data_val.bin\"), dtype=np.uint16, mode=\"r\")\n",
    "test_metas = read_jsonl(os.path.join(OUT_DATA_DIR, f\"meta_val.jsonl\"))\n",
    "test_info = read_json(os.path.join(OUT_DATA_DIR, f\"info_val.json\"))\n",
    "mm = mm.reshape(-1, N_TOKENS_AUDIO, 13)\n",
    "assert len(mm) == len(test_metas)\n",
    "assert mm[:100, :, 0].min() >= 0\n",
    "assert mm[:100, :, 0].max() <= 4000\n",
    "assert mm[:100, :, 1:].min() >= 0\n",
    "assert mm[:100, :, 1:].max() <= 2048"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-03T20:07:52.489976Z",
     "iopub.status.busy": "2025-06-03T20:07:52.489841Z",
     "iopub.status.idle": "2025-06-03T20:07:52.508923Z",
     "shell.execute_reply": "2025-06-03T20:07:52.508626Z",
     "shell.execute_reply.started": "2025-06-03T20:07:52.489962Z"
    }
   },
   "outputs": [],
   "source": [
    "task_counts = Counter()\n",
    "for test_meta in test_metas:\n",
    "    task_counts[test_meta.get(\"task\")] += 1\n",
    "print(task_counts)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-05-16T13:59:41.938629Z",
     "start_time": "2024-05-16T13:59:41.938621Z"
    },
    "execution": {
     "iopub.execute_input": "2025-06-03T20:07:52.509393Z",
     "iopub.status.busy": "2025-06-03T20:07:52.509280Z",
     "iopub.status.idle": "2025-06-03T20:07:52.520565Z",
     "shell.execute_reply": "2025-06-03T20:07:52.520277Z",
     "shell.execute_reply.started": "2025-06-03T20:07:52.509381Z"
    }
   },
   "outputs": [],
   "source": [
    "# # randomly listen to some stuff\n",
    "# from suno_utils.tasks.dac_2c_12cb import preload_models as preload_codec_models\n",
    "# from suno_utils.tasks.dac_2c_12cb import (\n",
    "#     encode as codec_encode,\n",
    "#     decode_stream_to_full_audio as codec_decode,\n",
    "#     EMBEDDING_RATE as CODEC_EMBEDDING_RATE,\n",
    "#     decode as decode\n",
    "# )\n",
    "# os.environ[\"CUDA_VISIBLE_DEVICES\"] = \"0\"\n",
    "# _ = preload_codec_models(\"/app/suno/data/dpo/models/dac_2c_25x12.pt\", device=\"cuda\")\n",
    "# assert len(test_metas) == len(mm)\n",
    "# idx_list = list(range(len(test_metas)))\n",
    "# # random.shuffle(idx_list)\n",
    "# # idx_list = [idx for idx in idx_list if \"text\" in test_metas[idx]]\n",
    "# print(len(mm))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-05-16T13:59:41.939205Z",
     "start_time": "2024-05-16T13:59:41.939198Z"
    },
    "execution": {
     "iopub.execute_input": "2025-06-03T20:07:52.521024Z",
     "iopub.status.busy": "2025-06-03T20:07:52.520913Z",
     "iopub.status.idle": "2025-06-03T20:07:52.531794Z",
     "shell.execute_reply": "2025-06-03T20:07:52.531502Z",
     "shell.execute_reply.started": "2025-06-03T20:07:52.521013Z"
    }
   },
   "outputs": [],
   "source": [
    "# import random\n",
    "# idx = random.choice(test_info[\"perference_0\"][\"idx_list\"])\n",
    "# assert \"original_duration_s\" in test_metas[idx]\n",
    "# # positive index should be shifted by 1\n",
    "# pos_idx = idx + 1\n",
    "# print(\n",
    "#     \"tags:\",\n",
    "#     test_metas[idx].get(\"tags\") == test_metas[pos_idx].get(\"tags\"),\n",
    "#     test_metas[idx].get(\"tags\"),\n",
    "# )\n",
    "# arr = mm[idx, 1:].copy().astype(np.int16)[:, 1:]\n",
    "# pos_arr = mm[pos_idx, 1:].copy().astype(np.int16)[:, 1:]\n",
    "# pad_idx_arr = np.where(arr == COARSE_PAD_TOKEN)[0]\n",
    "# if len(pad_idx_arr) > 0:\n",
    "#     arr = arr[: pad_idx_arr[0], :]\n",
    "# pos_pad_idx_arr = np.where(pos_arr == COARSE_PAD_TOKEN)[0]\n",
    "# if len(pos_pad_idx_arr) > 0:\n",
    "#     pos_arr = pos_arr[: pos_pad_idx_arr[0], :]\n",
    "# a = decode(arr)\n",
    "# print(\"\\n negative example \\n\", test_metas[idx])\n",
    "# a.play(compress=False)\n",
    "# pos_a = decode(pos_arr)\n",
    "# print(\"\\n positive example \\n\", test_metas[pos_idx])\n",
    "# pos_a.play(compress=False)\n",
    "# print(\n",
    "#     \"text:\",\n",
    "#     test_metas[idx].get(\"text\") == test_metas[pos_idx].get(\"text\"),\n",
    "#     test_metas[idx].get(\"text\"),\n",
    "# )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-05-16T13:59:41.939977Z",
     "start_time": "2024-05-16T13:59:41.939969Z"
    },
    "execution": {
     "iopub.execute_input": "2025-06-03T20:07:52.532238Z",
     "iopub.status.busy": "2025-06-03T20:07:52.532130Z",
     "iopub.status.idle": "2025-06-03T20:07:52.542621Z",
     "shell.execute_reply": "2025-06-03T20:07:52.542340Z",
     "shell.execute_reply.started": "2025-06-03T20:07:52.532227Z"
    }
   },
   "outputs": [],
   "source": [
    "# val_df[val_df[\"tags\"] == 'a vibrant blend of experimental jazz fusion, drum-and-bass and swagger fuzzed-out guitars']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-05-16T13:59:41.940610Z",
     "start_time": "2024-05-16T13:59:41.940603Z"
    },
    "execution": {
     "iopub.execute_input": "2025-06-03T20:07:52.543056Z",
     "iopub.status.busy": "2025-06-03T20:07:52.542950Z",
     "iopub.status.idle": "2025-06-03T20:07:52.553203Z",
     "shell.execute_reply": "2025-06-03T20:07:52.552918Z",
     "shell.execute_reply.started": "2025-06-03T20:07:52.543045Z"
    }
   },
   "outputs": [],
   "source": [
    "# from collections import Counter\n",
    "# c = Counter()\n",
    "# for _, row in df_slice.iterrows():\n",
    "#     # print(row[\"metadata\"])\n",
    "#     for k in ast.literal_eval(row[\"metadata\"]).keys():\n",
    "#         c[k] += 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-05-16T13:59:41.941167Z",
     "start_time": "2024-05-16T13:59:41.941159Z"
    },
    "execution": {
     "iopub.execute_input": "2025-06-03T20:07:52.553652Z",
     "iopub.status.busy": "2025-06-03T20:07:52.553542Z",
     "iopub.status.idle": "2025-06-03T20:07:52.564230Z",
     "shell.execute_reply": "2025-06-03T20:07:52.563947Z",
     "shell.execute_reply.started": "2025-06-03T20:07:52.553641Z"
    }
   },
   "outputs": [],
   "source": [
    "# original_npz_path = f\"/app/suno/data/dpo/7b_npz/{test_metas[idx]['id']}.npz\"\n",
    "# original_npz_path = \"/app/suno/data/dpo/7b_npz/729c3011-f672-4ccd-8d82-1cbf2b52ff69.npz\"\n",
    "# original_arr = np.load(original_npz_path)[\"v2_raw\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-05-16T13:59:41.941801Z",
     "start_time": "2024-05-16T13:59:41.941793Z"
    },
    "execution": {
     "iopub.execute_input": "2025-06-03T20:07:52.564680Z",
     "iopub.status.busy": "2025-06-03T20:07:52.564572Z",
     "iopub.status.idle": "2025-06-03T20:07:52.579004Z",
     "shell.execute_reply": "2025-06-03T20:07:52.578725Z",
     "shell.execute_reply.started": "2025-06-03T20:07:52.564669Z"
    }
   },
   "outputs": [],
   "source": [
    "def validation_on_metas(input_metas):\n",
    "    total_bad = 0\n",
    "    total_good = 0\n",
    "    for idx in range(len(input_metas)):\n",
    "        if idx % 2 == 0:\n",
    "            pos_idx = idx + 1\n",
    "            if input_metas[idx].get(\"tags\") != input_metas[pos_idx].get(\"tags\"):\n",
    "                # print(test_metas[idx].get(\"text\") == test_metas[pos_idx].get(\"text\"), test_metas[idx].get(\"tags\"), test_metas[pos_idx].get(\"tags\"))\n",
    "                total_bad += 1\n",
    "            else:\n",
    "                total_good += 1\n",
    "    print(total_good, total_bad)\n",
    "    return\n",
    "\n",
    "\n",
    "validation_on_metas(test_metas)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-05-16T13:59:41.942520Z",
     "start_time": "2024-05-16T13:59:41.942511Z"
    },
    "execution": {
     "iopub.execute_input": "2025-06-03T20:07:52.579456Z",
     "iopub.status.busy": "2025-06-03T20:07:52.579345Z",
     "iopub.status.idle": "2025-06-03T20:07:52.616801Z",
     "shell.execute_reply": "2025-06-03T20:07:52.616424Z",
     "shell.execute_reply.started": "2025-06-03T20:07:52.579444Z"
    }
   },
   "outputs": [],
   "source": [
    "train_info = read_json(os.path.join(OUT_DATA_DIR, f\"info_tr.json\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-05-16T13:59:41.943072Z",
     "start_time": "2024-05-16T13:59:41.943065Z"
    },
    "execution": {
     "iopub.execute_input": "2025-06-03T20:07:52.617329Z",
     "iopub.status.busy": "2025-06-03T20:07:52.617210Z",
     "iopub.status.idle": "2025-06-03T20:07:52.644453Z",
     "shell.execute_reply": "2025-06-03T20:07:52.644091Z",
     "shell.execute_reply.started": "2025-06-03T20:07:52.617317Z"
    }
   },
   "outputs": [],
   "source": [
    "n_neg_tr = train_info[\"perference_0\"][\"idx_list\"]\n",
    "n_pos_tr = train_info[\"perference_1\"][\"idx_list\"]\n",
    "assert len(n_pos_tr) == len(n_neg_tr)\n",
    "# make sure they are offset by 1 and exactly 1\n",
    "for i, j in zip(n_neg_tr, n_pos_tr):\n",
    "    assert i == j - 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-05-16T13:59:41.944246Z",
     "start_time": "2024-05-16T13:59:41.944237Z"
    },
    "execution": {
     "iopub.execute_input": "2025-06-03T20:07:52.644970Z",
     "iopub.status.busy": "2025-06-03T20:07:52.644851Z",
     "iopub.status.idle": "2025-06-03T20:07:52.658030Z",
     "shell.execute_reply": "2025-06-03T20:07:52.657745Z",
     "shell.execute_reply.started": "2025-06-03T20:07:52.644957Z"
    }
   },
   "outputs": [],
   "source": [
    "total_iters = len(n_neg_tr) + len(n_pos_tr)\n",
    "print(\"total samples\", total_iters, train_df.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-05-16T13:59:41.945249Z",
     "start_time": "2024-05-16T13:59:41.945241Z"
    },
    "execution": {
     "iopub.execute_input": "2025-06-03T20:07:52.658485Z",
     "iopub.status.busy": "2025-06-03T20:07:52.658373Z",
     "iopub.status.idle": "2025-06-03T20:07:52.669600Z",
     "shell.execute_reply": "2025-06-03T20:07:52.669327Z",
     "shell.execute_reply.started": "2025-06-03T20:07:52.658474Z"
    }
   },
   "outputs": [],
   "source": [
    "print(\"1 epoch per batch 4, total\", total_iters / 8 / 2 / 4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-05-16T13:59:41.945972Z",
     "start_time": "2024-05-16T13:59:41.945964Z"
    },
    "execution": {
     "iopub.execute_input": "2025-06-03T20:07:52.670039Z",
     "iopub.status.busy": "2025-06-03T20:07:52.669932Z",
     "iopub.status.idle": "2025-06-03T20:07:52.680339Z",
     "shell.execute_reply": "2025-06-03T20:07:52.680059Z",
     "shell.execute_reply.started": "2025-06-03T20:07:52.670027Z"
    }
   },
   "outputs": [],
   "source": [
    "# !cd /home/tony/Work/tony/slurm/sem_4p5_dpo && sbatch sbatch_ipo_4p5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-03T20:07:52.680780Z",
     "iopub.status.busy": "2025-06-03T20:07:52.680672Z",
     "iopub.status.idle": "2025-06-03T20:07:52.702362Z",
     "shell.execute_reply": "2025-06-03T20:07:52.702062Z",
     "shell.execute_reply.started": "2025-06-03T20:07:52.680769Z"
    }
   },
   "outputs": [],
   "source": [
    "import shutil\n",
    "\n",
    "# Basic file copy\n",
    "shutil.copy(\n",
    "    \"/home/tony/Work/tony/Preference/make_dataset_auk_mixed_2.ipynb\",\n",
    "    os.path.join(OUT_DATA_DIR, \"make_dataset.ipynb\"),\n",
    ")\n",
    "print(\"Cache kept!\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# some gymathtics loading prev data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-05-16T13:59:41.946562Z",
     "start_time": "2024-05-16T13:59:41.946555Z"
    },
    "execution": {
     "iopub.execute_input": "2025-06-03T20:07:52.702825Z",
     "iopub.status.busy": "2025-06-03T20:07:52.702715Z",
     "iopub.status.idle": "2025-06-03T20:07:52.714040Z",
     "shell.execute_reply": "2025-06-03T20:07:52.713754Z",
     "shell.execute_reply.started": "2025-06-03T20:07:52.702814Z"
    }
   },
   "outputs": [],
   "source": [
    "# prev_v3_data = \"/app/suno/data/dpo/7v_v20_full/\"\n",
    "\n",
    "# test_val_metas = read_jsonl(os.path.join(prev_v3_data, f\"meta_val.jsonl\"))\n",
    "# test_tr_metas = read_jsonl(os.path.join(prev_v3_data, f\"meta_tr.jsonl\"))\n",
    "\n",
    "# all_ids = set()\n",
    "# for meta in test_val_metas:\n",
    "#     all_ids.add(meta[\"id\"])\n",
    "# for meta in test_tr_metas:\n",
    "#     all_ids.add(meta[\"id\"])\n",
    "# print(len(all_ids), len(test_val_metas) + len(test_tr_metas))\n",
    "\n",
    "# all_ids = list(all_ids)\n",
    "# with open(\"/home/tony/Data/Preference/7b_v2/7v_v20_full_recut_id.json\", \"w\") as fp:\n",
    "#     json.dump(all_ids, fp)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-03T20:07:52.714481Z",
     "iopub.status.busy": "2025-06-03T20:07:52.714374Z",
     "iopub.status.idle": "2025-06-03T20:07:52.725047Z",
     "shell.execute_reply": "2025-06-03T20:07:52.724758Z",
     "shell.execute_reply.started": "2025-06-03T20:07:52.714470Z"
    }
   },
   "outputs": [],
   "source": [
    "# x_data = train_df[train_df[\"preference\"]][\"similarity\"]\n",
    "# y_data = train_df[~train_df[\"preference\"]][\"similarity\"]\n",
    "# from matplotlib.colors import LogNorm\n",
    "\n",
    "# fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(24, 10))\n",
    "\n",
    "# # 2D Histogram\n",
    "# h = ax1.hist2d(\n",
    "#     x_data,\n",
    "#     y_data,\n",
    "#     bins=(50, 50),\n",
    "#     cmap=\"coolwarm\",\n",
    "#     range=[[0, 1], [0, 1]],\n",
    "#     norm=LogNorm(),\n",
    "# )\n",
    "\n",
    "# ax1.set_xlabel(\"Semantic Distance (Preferred)\")\n",
    "# ax1.set_ylabel(\"Semantic Distance (Non-Preferred)\")\n",
    "# ax1.set_title(\n",
    "#     \"2D Histogram of Semantic Distances: Preferred vs Non-Preferred (Log Scale)\"\n",
    "# )\n",
    "\n",
    "# cbar1 = plt.colorbar(h[3], ax=ax1)\n",
    "# cbar1.set_label(\"Number of Request IDs (Log Scale)\")\n",
    "\n",
    "# # Scatter plot\n",
    "# ax2.scatter(x_data, y_data, alpha=0.1, s=1)\n",
    "# ax2.set_xlabel(\"Semantic Distance (Preferred)\")\n",
    "# ax2.set_ylabel(\"Semantic Distance (Non-Preferred)\")\n",
    "# ax2.set_title(\"Scatter Plot of Semantic Distances: Preferred vs Non-Preferred\")\n",
    "# ax2.set_xlim(0, 1)\n",
    "# ax2.set_ylim(0, 1)\n",
    "\n",
    "# plt.tight_layout()\n",
    "# plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-03T20:07:52.725490Z",
     "iopub.status.busy": "2025-06-03T20:07:52.725382Z",
     "iopub.status.idle": "2025-06-03T20:07:52.735771Z",
     "shell.execute_reply": "2025-06-03T20:07:52.735493Z",
     "shell.execute_reply.started": "2025-06-03T20:07:52.725478Z"
    }
   },
   "outputs": [],
   "source": [
    "# train_metas = read_jsonl(os.path.join(OUT_DATA_DIR, f\"meta_tr.jsonl\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-03T20:07:52.736200Z",
     "iopub.status.busy": "2025-06-03T20:07:52.736093Z",
     "iopub.status.idle": "2025-06-03T20:07:52.747156Z",
     "shell.execute_reply": "2025-06-03T20:07:52.746905Z",
     "shell.execute_reply.started": "2025-06-03T20:07:52.736189Z"
    }
   },
   "outputs": [],
   "source": [
    "train_info.keys()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "suno_env_dev",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.15"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
