{"id":16388567,"url":"https://github.com/phact/neighborhoodwatch","last_synced_at":"2025-08-03T14:31:45.314Z","repository":{"id":213143087,"uuid":"688142940","full_name":"phact/neighborhoodwatch","owner":"phact","description":"gpu powered brute force knn ground truth dataset generator","archived":false,"fork":false,"pushed_at":"2024-09-20T14:32:55.000Z","size":975,"stargazers_count":5,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-11-29T17:47:43.170Z","etag":null,"topics":["gpu","knn","vector-search"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phact.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-06T18:33:46.000Z","updated_at":"2024-09-20T14:32:59.000Z","dependencies_parsed_at":"2023-12-18T21:05:20.716Z","dependency_job_id":"234f59e6-5bbf-4173-89a2-0a7984fb7882","html_url":"https://github.com/phact/neighborhoodwatch","commit_stats":null,"previous_names":["phact/neighborhoodwatch"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phact%2Fneighborhoodwatch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phact%2Fneighborhoodwatch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phact%2Fneighborhoodwatch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phact%2Fneighborhoodwatch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phact","download_url":"https://codeload.github.com/phact/neighborhoodwatch/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228548593,"owners_count":17935223,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gpu","knn","vector-search"],"created_at":"2024-10-11T04:29:25.176Z","updated_at":"2024-12-07T01:56:59.970Z","avatar_url":"https://github.com/phact.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## NeighborhoodWatch\n\nNeighborhoodWatch (`nw`) is a GPU powered brute force knn ground truth dataset generator\n\n### Set Up the Environment\n\nAt high level, in order to run this program, the following prerqusites need to be satsified:\n* One computing instance with Nividia GPU (e.g. AWS `p3.8xlarge` instance type)\n* Nivdia CUDA toolkit and driver 12 installed ([link](https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html))\n* Nividia cuDNN library installed ([link](https://docs.nvidia.com/deeplearning/cudnn/install-guide/index.html))\n* Nividia NCCL library installed ([link](https://docs.nvidia.com/deeplearning/nccl/install-guide/index.html))\n* Python version 3.10\n   * A python virtual environemtn (e.g. MiniConda) is highly recommended\n* Poetry Python dependency management\n\nAn example of setting up a bare-metal environment on an AWS `p3.8xlarge` instance with `Ubuntun 22.04` OS is provided in the following script:\n* [install_baremetal_env.sh](bash/install_baremetal_env.sh)\n\nFor convenience purposes, a [Dockerfile](./Dockerfile) is also provided which allows you to build a docker image allows you to run the `nw` program within a docker container with all the required driver and library dependencies. For more detailed information, please refer to the [nw_docker](./nw_docker.md) document\n\n---\n\n### Run the Program\n\nFirst check and install Python dependencies by running the following commands in the home directory of this program:\n\n```\npoetry lock \u0026\u0026 poetry install\n```\n\nThen run the program with `poetry run nw \u003cinput parameter list\u003e` command. The available input parameter list is as below:\n```\n$ poetry run nw -h\nusage: nw [-h] [-m MODEL_NAME] [-rd REDUCED_DIMENSION_SIZE] [-k K] [--data_dir DATA_DIR] [--use-dataset-api | --no-use-dataset-api] [--gen-hdf5 | --no-gen-hdf5]\n          [--post-validation | --no-post-validation] [--enable-memory-tuning] [--disable-memory-tuning]\n          query_count base_count\n\nnw (neighborhood watch) uses GPU acceleration to generate ground truth KNN datasets\n\npositional arguments:\n  query_count           number of query vectors to generate\n  base_count            number of base vectors to generate\n\noptions:\n  -h, --help            show this help message and exit\n  -m MODEL_NAME, --model_name MODEL_NAME\n                        model name to use for generating embeddings, i.e. text-embedding-ada-002, textembedding-gecko, or intfloat/e5-large-v2\n  -rd REDUCED_DIMENSION_SIZE, --reduced_dimension_size REDUCED_DIMENSION_SIZE\n                        Reduced (output) dimension size. Only supported in models (e.g. OpenAI text-embedding-3-xxx) that have this feature. Ignored otherwise!\n  -k K, --k K           number of neighbors to compute per query vector\n  --data_dir DATA_DIR   Directory to store the generated data (default: knn_dataset)\n  --use-dataset-api, --no-use-dataset-api\n                        Use 'pyarrow.dataset' API to read the dataset (default: True). Recommended for large datasets. (default: False)\n  --gen-hdf5, --no-gen-hdf5\n                        Generate hdf5 files (default: True) (default: True)\n  --post-validation, --no-post-validation\n                        Validate the generated files (default: False) (default: False)\n  --enable-memory-tuning\n                        Enable memory tuning\n  --disable-memory-tuning\n                        Disable memory tuning (useful for very small datasets)\n\nSome example commands:\n\n    nw 1000 10000 -k 100 -m 'textembedding-gecko' --disable-memory-tuning\n    nw 1000 10000 -k 100 -m 'intfloat/e5-large-v2' --disable-memory-tuning\n    nw 1000 10000 -k 100 -m 'intfloat/e5-small-v2' --disable-memory-tuning\n    nw 1000 10000 -k 100 -m 'intfloat/e5-base-v2' --disable-memory-tuning\n```\n\n### Generated Datasets\n\nAfter the program is successfully run, it will generate a set of data sets under a spcified folder which is default to `knn_dataset` subfolder. \nYou can override the output directory using the `--data_dir \u003cdir_name\u003e` option.\n\nIn particular, the following datasets include the KNN ground truth results:\n| file format | dataset name | dataset file | \n| ----------- | ------------ | ------------ | \n| `fvec` | `train` dataset (base) | `\u003cmodel_name\u003e_\u003cbase_count\u003e_base_vectors` |\n| `fvec` | `test` dataset (query)| `\u003cmodel_name\u003e_\u003cbase_count\u003e_query_vectors_\u003cquery_count\u003e` |\n| `fvec` | `distances` dataset (distances) | `\u003cmodel_name\u003e_\u003cbase_count\u003e_distances_\u003cquery_count\u003e` |\n| `ivec` | `neighors` dataset (indices) | `\u003cmodel_name\u003e_\u003cbase_count\u003e_indices_query_\u003cquery_count\u003e` |\n| `hdf5` | consolidated hdf5 dataset of the above 4 datasets | `\u003cmodel_name\u003e_base_\u003cbase_count\u003e_query_\u003cquery_count\u003e` |\n\n\n### Run the Tests\n\n```\npoetry run pytest\n```\n\n#### cli:\n\n![cli](docs/cli.png)\n\n#### nvtop:\n\n![nvtop](docs/nvtop.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphact%2Fneighborhoodwatch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphact%2Fneighborhoodwatch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphact%2Fneighborhoodwatch/lists"}