Last active
October 8, 2024 06:48
-
-
Save mdouze/b0a65aba70a64b00d6425b0e268a4c80 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 23, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import numpy as np\n", | |
"import faiss\n", | |
"from matplotlib import pyplot" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 24, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"# create an inverted index\n", | |
"nlist = 1024\n", | |
"m = 8\n", | |
"k = 5\n", | |
"d = 64\n", | |
"coarse_quantizer = faiss.IndexFlatL2(d)\n", | |
"index = faiss.IndexIVFPQ(coarse_quantizer, d, nlist, m, 8)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 25, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"# fill it in\n", | |
"xb = faiss.rand((10000, d), 1234)\n", | |
"index.train(xb)\n", | |
"index.add(xb)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 26, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"# if there is a pre-transform, you can also use\n", | |
"# invlists = faiss.extract_index_ivf(index).invlists\n", | |
"invlists = index.invlists" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 27, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAEGCAYAAACKB4k+AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAYx0lEQVR4nO3df5SddX3g8feHXzX8iAHB2RAIwbO0S/xBlDn8ELu9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H+XmWumr5ir83ZwnEuBhxmAkbGan2wpaEGKiMMi4n8X8/s/HBEXFcvHImI0It4WEVuLfzsi4vvF+lMj4usRsSUi7iqmrph+7BMi4p6I+F7xujwiVgH/FTi/OOaiafuMRcRo8X4yIj5RxPbNiBiJiJdHxA8i4oBim0Mj4oliao39jlNMPndz8bM9FBHvL1oTo8AtjWKQOmFR0EJ1LvBUZp6Sma8B/mrqysy8MzNXFRO4fRf40+IP8GeBCzLzVOBGoNFo9/8OfCEzXwfcAlyXmVuBjwK3Fcfd0yK2w4BvFs8euA/495n5kyKOXyu2+U3grsx8ockxVgHLMvM1mfla4KbMvAN4ALikgxikhiwKWqgeAt4SEZ+MiF8t/ujuJyI+BOzJzM8BvwK8Bri7mAL6I9QnKZvuTODW4v2fA2+aYWw/A75avN8CrCje3wZcVLx/R/G5mceBV0XEZyPiXMAZWzUnLApakDLz74FTqReHqyPio9O3iYhzgAuB39m3CHhkXwsiM1+bmb/eyelmGN4L+fP5Zfby8769O4HzIuKoIva/bnrCzGeBU4Ax4L0UD26RZsuioAWpuAPnnzLzL4A/Bd4wbf0JwJ8BvzXlMssO4JiIOLPY5uCIeHWDw/8t9W/yAJcA35iLmIsnl30L+Azw1czc22zbiDgaOCAzvwz8J37+8z0HHDEX8Wg4efeRFqrXAn8SES8BLwC/O239pdSffPU/67Ni81Rmnl901l4XES+n/vvxaeCRafu+D7gxIv4Q+DHw7jmM+zbgS9RnrG1lGXDTvo5p4Mri9Wbgf0TEHuBM+xU0U86SKkkqeflIklSyKEiSShYFSVLJoiBJKlkUJEkli4IkqWRRkCSV/j94IrfrLBNdGwAAAABJRU5ErkJggg==\n", | |
"text/plain": [ | |
"<Figure size 432x288 with 1 Axes>" | |
] | |
}, | |
"metadata": { | |
"needs_background": "light" | |
}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"# invlist sizes histogram\n", | |
"bc = np.bincount([invlists.list_size(l) for l in range(invlists.nlist)])\n", | |
"pyplot.step(np.arange(bc.size), bc)\n", | |
"pyplot.xlabel('size of invlist')\n", | |
"pyplot.ylabel('nb of invlists')\n", | |
"pyplot.grid()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 28, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"def get_invlist(invlists, l):\n", | |
" \"\"\" returns the inverted lists content. \n", | |
" That the data is *not* copied: if the inverted index is deallocated or changes, accessing the array may crash.\n", | |
" To avoid this, just clone the output arrays on output. \"\"\"\n", | |
" ls = invlists.list_size(l)\n", | |
" list_ids = faiss.rev_swig_ptr(invlists.get_ids(l), ls)\n", | |
" list_codes = faiss.rev_swig_ptr(invlists.get_codes(l), ls * invlists.code_size)\n", | |
" return list_ids, list_codes" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 31, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"# get content of inverted list #123\n", | |
"list_ids, list_codes = get_invlist(invlists, 124)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 32, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"array([ 375, 764, 1691, 1736, 2281, 2532, 2573, 2758, 3711, 3791, 6206,\n", | |
" 7364, 8009, 8828, 8849, 8865, 8988])" | |
] | |
}, | |
"execution_count": 32, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"# vector ids in the list\n", | |
"list_ids" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 36, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"array([[124],\n", | |
" [124]])" | |
] | |
}, | |
"execution_count": 36, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"# check that vectors 375 and 764 are indeed quantized to list 124\n", | |
"coarse_quantizer.assign(xb[[375, 764]], 1)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 37, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"array([[135, 86, 175, 251, 122, 220, 0, 250],\n", | |
" [ 22, 168, 238, 229, 218, 24, 93, 209],\n", | |
" [226, 69, 61, 81, 162, 71, 218, 237],\n", | |
" [130, 201, 27, 255, 8, 85, 177, 104],\n", | |
" [ 53, 234, 190, 153, 109, 126, 54, 64],\n", | |
" [124, 124, 34, 124, 205, 124, 124, 54],\n", | |
" [ 92, 225, 123, 105, 152, 116, 26, 118],\n", | |
" [100, 118, 163, 109, 160, 130, 109, 210],\n", | |
" [114, 236, 59, 14, 183, 243, 186, 154],\n", | |
" [160, 95, 1, 31, 23, 82, 232, 251],\n", | |
" [ 98, 235, 85, 201, 87, 231, 139, 1],\n", | |
" [ 42, 58, 54, 51, 13, 217, 23, 217],\n", | |
" [240, 155, 77, 147, 29, 216, 216, 103],\n", | |
" [150, 163, 70, 80, 187, 14, 202, 237],\n", | |
" [ 84, 60, 29, 76, 107, 103, 180, 63],\n", | |
" [ 58, 150, 5, 216, 136, 3, 74, 53],\n", | |
" [ 54, 241, 31, 126, 195, 38, 63, 148]], dtype=uint8)" | |
] | |
}, | |
"execution_count": 37, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"# PQ codes stored in the inverted lists\n", | |
"list_codes.reshape(-1, invlists.code_size)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"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.7.4" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A function that properly copies the data: