{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import rich\n", "import weave\n", "from dotenv import load_dotenv\n", "\n", "from medrag_multi_modal.retrieval import BM25sRetriever" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Logged in as Weights & Biases user: geekyrakshit.\n", "View Weave data at https://wandb.ai/ml-colabs/medrag-multi-modal/weave\n" ] }, { "data": { "text/plain": [ "" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "load_dotenv()\n", "weave.init(project_name=\"ml-colabs/medrag-multi-modal\")" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "\u001b[34m\u001b[1mwandb\u001b[0m: Using wandb-core as the SDK backend. Please refer to https://wandb.me/wandb-core for more information.\n", "\u001b[34m\u001b[1mwandb\u001b[0m: 7 of 7 files downloaded. \n" ] } ], "source": [ "retriever = BM25sRetriever.from_wandb_artifact(\n", " index_artifact_address=\"ml-colabs/medrag-multi-modal/grays-anatomy-bm25s:v2\"\n", ")" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "6247f921c889469283505348967807da", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Split strings: 0%| | 0/1 [00:00<class 'dict'>\n", "\n" ], "text/plain": [ "\u001b[1m<\u001b[0m\u001b[1;95mclass\u001b[0m\u001b[39m \u001b[0m\u001b[32m'dict'\u001b[0m\u001b[1m>\u001b[0m\n" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "rich.print(list(list(results['results'])[0])[0])" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "2" ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "len()" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[0.4504720866680145, 0.3982057571411133]" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "results[\"scores\"].flatten().tolist()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": ".venv", "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.12.7" } }, "nbformat": 4, "nbformat_minor": 2 }