From 71ad7a4736c8dfed1cec352dd9918d6c299f7657 Mon Sep 17 00:00:00 2001 From: Saarth Deshpande Date: Tue, 14 May 2024 10:49:56 -0700 Subject: [PATCH 1/5] Missed printing 'D' 'I' was printed twice and 'D' was not printed. Fixed. --- tutorial/cpp/6-HNSW.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tutorial/cpp/6-HNSW.cpp b/tutorial/cpp/6-HNSW.cpp index 1b3434a433..dba0285dd2 100644 --- a/tutorial/cpp/6-HNSW.cpp +++ b/tutorial/cpp/6-HNSW.cpp @@ -57,10 +57,10 @@ int main() { index.search(nq, xq, k, D, I); - printf("I=\n"); + printf("D=\n"); for (int i = nq - 5; i < nq; i++) { for (int j = 0; j < k; j++) - printf("%5zd ", I[i * k + j]); + printf("%5zd ", D[i * k + j]); printf("\n"); } From d53776c6eb37c4851ba4a690a1c71bd153f8946f Mon Sep 17 00:00:00 2001 From: Saarth Deshpande Date: Tue, 14 May 2024 11:07:37 -0700 Subject: [PATCH 2/5] Remove duplicate search, nlist The index search operation was repeated, and nlist isn't used in HNSW. --- tutorial/cpp/6-HNSW.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/tutorial/cpp/6-HNSW.cpp b/tutorial/cpp/6-HNSW.cpp index dba0285dd2..51e9da822d 100644 --- a/tutorial/cpp/6-HNSW.cpp +++ b/tutorial/cpp/6-HNSW.cpp @@ -55,8 +55,6 @@ int main() { printf("\n"); } - index.search(nq, xq, k, D, I); - printf("D=\n"); for (int i = nq - 5; i < nq; i++) { for (int j = 0; j < k; j++) From cf7a8f099633dabe6d8cb7c68a34c9906a6e3032 Mon Sep 17 00:00:00 2001 From: Saarth Deshpande Date: Fri, 17 May 2024 12:38:56 -0700 Subject: [PATCH 3/5] format specifier for printing D --- tutorial/cpp/6-HNSW.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorial/cpp/6-HNSW.cpp b/tutorial/cpp/6-HNSW.cpp index 51e9da822d..9bd8cd3faa 100644 --- a/tutorial/cpp/6-HNSW.cpp +++ b/tutorial/cpp/6-HNSW.cpp @@ -58,7 +58,7 @@ int main() { printf("D=\n"); for (int i = nq - 5; i < nq; i++) { for (int j = 0; j < k; j++) - printf("%5zd ", D[i * k + j]); + printf("%5f ", D[i * k + j]); printf("\n"); } From cccaed49ac76876c1e071c9462b84b0972cf5598 Mon Sep 17 00:00:00 2001 From: Saarth Deshpande Date: Fri, 17 May 2024 12:40:55 -0700 Subject: [PATCH 4/5] Same changes as HNSW for IVFFlat --- tutorial/cpp/2-IVFFlat.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tutorial/cpp/2-IVFFlat.cpp b/tutorial/cpp/2-IVFFlat.cpp index febd5be049..86530ae985 100644 --- a/tutorial/cpp/2-IVFFlat.cpp +++ b/tutorial/cpp/2-IVFFlat.cpp @@ -61,13 +61,10 @@ int main() { printf("\n"); } - index.nprobe = 10; - index.search(nq, xq, k, D, I); - - printf("I=\n"); + printf("D=\n"); for (int i = nq - 5; i < nq; i++) { for (int j = 0; j < k; j++) - printf("%5zd ", I[i * k + j]); + printf("%5f ", D[i * k + j]); printf("\n"); } From 1c63a1c95368436feb5d306e5e7735bef2cc86f2 Mon Sep 17 00:00:00 2001 From: Saarth Deshpande Date: Fri, 17 May 2024 12:41:30 -0700 Subject: [PATCH 5/5] Print D instead of duplicate I --- tutorial/cpp/1-Flat.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tutorial/cpp/1-Flat.cpp b/tutorial/cpp/1-Flat.cpp index 819e419573..147fa89bc0 100644 --- a/tutorial/cpp/1-Flat.cpp +++ b/tutorial/cpp/1-Flat.cpp @@ -83,10 +83,10 @@ int main() { printf("\n"); } - printf("I (5 last results)=\n"); + printf("D (5 last results)=\n"); for (int i = nq - 5; i < nq; i++) { for (int j = 0; j < k; j++) - printf("%5zd ", I[i * k + j]); + printf("%5f ", D[i * k + j]); printf("\n"); }