| @@ 724-762 (lines=39) @@ | ||
| 721 | return index_params |
|
| 722 | ||
| 723 | ||
| 724 | def gen_index(): |
|
| 725 | nlists = [1, 1024, 16384] |
|
| 726 | pq_ms = [128, 64, 32, 16, 8, 4] |
|
| 727 | Ms = [5, 24, 48] |
|
| 728 | efConstructions = [100, 300, 500] |
|
| 729 | search_lengths = [10, 100, 300] |
|
| 730 | out_degrees = [5, 40, 300] |
|
| 731 | candidate_pool_sizes = [50, 100, 300] |
|
| 732 | knngs = [5, 100, 300] |
|
| 733 | ||
| 734 | index_params = [] |
|
| 735 | for index_type in all_index_types: |
|
| 736 | if index_type in ["FLAT", "BIN_FLAT", "BIN_IVF_FLAT"]: |
|
| 737 | index_params.append({"index_type": index_type, "index_param": {"nlist": 1024}}) |
|
| 738 | elif index_type in ["IVF_FLAT", "IVF_SQ8", "IVF_SQ8_HYBRID"]: |
|
| 739 | ivf_params = [{"index_type": index_type, "index_param": {"nlist": nlist}} \ |
|
| 740 | for nlist in nlists] |
|
| 741 | index_params.extend(ivf_params) |
|
| 742 | elif index_type == "IVF_PQ": |
|
| 743 | IVFPQ_params = [{"index_type": index_type, "index_param": {"nlist": nlist, "m": m}} \ |
|
| 744 | for nlist in nlists \ |
|
| 745 | for m in pq_ms] |
|
| 746 | index_params.extend(IVFPQ_params) |
|
| 747 | elif index_type in ["HNSW", "RHNSW_SQ", "RHNSW_PQ"]: |
|
| 748 | hnsw_params = [{"index_type": index_type, "index_param": {"M": M, "efConstruction": efConstruction}} \ |
|
| 749 | for M in Ms \ |
|
| 750 | for efConstruction in efConstructions] |
|
| 751 | index_params.extend(hnsw_params) |
|
| 752 | elif index_type == "NSG": |
|
| 753 | nsg_params = [{"index_type": index_type, |
|
| 754 | "index_param": {"search_length": search_length, "out_degree": out_degree, |
|
| 755 | "candidate_pool_size": candidate_pool_size, "knng": knng}} \ |
|
| 756 | for search_length in search_lengths \ |
|
| 757 | for out_degree in out_degrees \ |
|
| 758 | for candidate_pool_size in candidate_pool_sizes \ |
|
| 759 | for knng in knngs] |
|
| 760 | index_params.extend(nsg_params) |
|
| 761 | ||
| 762 | return index_params |
|
| 763 | ||
| 764 | ||
| 765 | def gen_simple_index(): |
|
| @@ 802-840 (lines=39) @@ | ||
| 799 | return index_params |
|
| 800 | ||
| 801 | ||
| 802 | def gen_index(): |
|
| 803 | nlists = [1, 1024, 16384] |
|
| 804 | pq_ms = [128, 64, 32, 16, 8, 4] |
|
| 805 | Ms = [5, 24, 48] |
|
| 806 | efConstructions = [100, 300, 500] |
|
| 807 | search_lengths = [10, 100, 300] |
|
| 808 | out_degrees = [5, 40, 300] |
|
| 809 | candidate_pool_sizes = [50, 100, 300] |
|
| 810 | knngs = [5, 100, 300] |
|
| 811 | ||
| 812 | index_params = [] |
|
| 813 | for index_type in all_index_types: |
|
| 814 | if index_type in ["FLAT", "BIN_FLAT", "BIN_IVF_FLAT"]: |
|
| 815 | index_params.append({"index_type": index_type, "index_param": {"nlist": 1024}}) |
|
| 816 | elif index_type in ["IVF_FLAT", "IVF_SQ8", "IVF_SQ8_HYBRID"]: |
|
| 817 | ivf_params = [{"index_type": index_type, "index_param": {"nlist": nlist}} \ |
|
| 818 | for nlist in nlists] |
|
| 819 | index_params.extend(ivf_params) |
|
| 820 | elif index_type == "IVF_PQ": |
|
| 821 | IVFPQ_params = [{"index_type": index_type, "index_param": {"nlist": nlist, "m": m}} \ |
|
| 822 | for nlist in nlists \ |
|
| 823 | for m in pq_ms] |
|
| 824 | index_params.extend(IVFPQ_params) |
|
| 825 | elif index_type in ["HNSW", "RHNSW_SQ", "RHNSW_PQ"]: |
|
| 826 | hnsw_params = [{"index_type": index_type, "index_param": {"M": M, "efConstruction": efConstruction}} \ |
|
| 827 | for M in Ms \ |
|
| 828 | for efConstruction in efConstructions] |
|
| 829 | index_params.extend(hnsw_params) |
|
| 830 | elif index_type == "NSG": |
|
| 831 | nsg_params = [{"index_type": index_type, |
|
| 832 | "index_param": {"search_length": search_length, "out_degree": out_degree, |
|
| 833 | "candidate_pool_size": candidate_pool_size, "knng": knng}} \ |
|
| 834 | for search_length in search_lengths \ |
|
| 835 | for out_degree in out_degrees \ |
|
| 836 | for candidate_pool_size in candidate_pool_sizes \ |
|
| 837 | for knng in knngs] |
|
| 838 | index_params.extend(nsg_params) |
|
| 839 | ||
| 840 | return index_params |
|
| 841 | ||
| 842 | ||
| 843 | def gen_simple_index(): |
|