I am getting error running the Index code - Exception has occurred: AssertionError

#1
by sungkim - opened

I am getting an error running the code - Exception has occurred: AssertionError - File "", line 1, in (Current frame) on this line.

indexer.index(name=index_name, collection=documents)

sungkim changed discussion title from I am getting error running the code - Exception has occurred: AssertionError to I am getting error running the Index code - Exception has occurred: AssertionError
sungkim changed discussion status to closed
sungkim changed discussion status to open

Sorry, this is likely because our model uses custom code. We have submitted a PR that adapts to our model in ColBERT's GitHub repo, but it has not been merged yet. We will push this matter forward as soon as possible to ensure that the model works correctly!

Ohh, I just realized that the PR has been merged. So you will need to use the latest code to run our model.

If you have other questions, feel free to ask us :)

I have updated the repo by running " pip install git+https://github.com/stanford-futuredata/ColBERT.git " again. I am getting same error message.

Could you give more details about the error?

I updated the index code example in the README and added if __name__ == "__main__". Could you try to see if the current code works correctly? And remember to delete the previous index folder before you run the coder, or set the overwrite parameter like indexer.index(name=index_name, collection=documents, overwrite=True).

Same error message

Exception has occurred: AssertionError
/path/
File "/path/file.py", line 21, in
indexer.index(name=index_name, collection=documents)
AssertionError: /path/

Can you provide colab example?

The example works correctly for me, so I'm not sure what happened if you delete the previous index folder before running.

And we are planning to make a colab notebook example, but it will need some time :)

They have been set - I just replaced my path with path and file before sharing.

Ok - I fixed the error. The error was caused by an existing index. When I deleted that folder, it is working.

liuqi6777 changed discussion status to closed
sungkim changed discussion status to open

This code runs forever...

[Feb 14, 05:18:48] [0] # of sampled PIDs = 2 sampled_pids[:3] = [1, 0]
[Feb 14, 05:18:48] [0] #> Encoding 2 passages..
[Feb 14, 05:18:49] [0] avg_doclen_est = 19.0 len(local_sample) = 2
[Feb 14, 05:18:49] [0] Creating 64 partitions.
[Feb 14, 05:18:49] [0] Estimated 38 embeddings.
[Feb 14, 05:18:49] [0] #> Saving the indexing plan to /path/plan.json ....

It is still running...

Then failed:

RuntimeError: Error in void faiss::Clustering::train_encoded(faiss::Clustering::idx_t, const uint8_t*, const faiss::Index*, faiss::Index&, const float*) at /project/faiss/faiss/Clustering.cpp:283: Error: 'nx >= k' failed: Number of training points (37) should be at least as large as number of clusters (64)

this is because the number of documents is too small, you can try to add more document, like in the latest readme

The first time running will be long because ColBERT code uses C extensions and need to compile them. It will be faster when you run again.

So, I repeated the documents 5 times and I get:

[Feb 14, 05:39:15] [0] # of sampled PIDs = 35 sampled_pids[:3] = [26, 0, 19]
[Feb 14, 05:39:15] [0] #> Encoding 35 passages..
[Feb 14, 05:39:16] [0] avg_doclen_est = 19.714284896850586 len(local_sample) = 35
[Feb 14, 05:39:16] [0] Creating 256 partitions.
[Feb 14, 05:39:16] [0] Estimated 689 embeddings.
[Feb 14, 05:39:16] [0] #> Saving the indexing plan to /home/llm/mediumworx/colbert/index/indexes/words_colbert/plan.json ..
WARNING clustering 656 points to 256 centroids: please provide at least 9984 training points
Clustering 656 points in 128D to 256 clusters, redo 1 times, 4 iterations
Preprocessing in 0.00 s
Faiss assertion 'err == CUBLAS_STATUS_SUCCESS' failed in void faiss::gpu::runMatrixMult(faiss::gpu::Tensor<float, 2, true>&, bool, faiss::gpu::Tensor<T, 2, true>&, bool, faiss::gpu::Tensor<IndexType, 2, true>&, bool, float, float, cublasHandle_t, cudaStream_t) [with AT = float; BT = float; cublasHandle_t = cublasContext*; cudaStream_t = CUstream_st*] at /project/faiss/faiss/gpu/utils/MatrixMult-inl.cuh:265; details: cublas failed (13): (512, 128) x (256, 128)' = (512, 256) gemm params m 256 n 512 k 128 trA T trB N lda 128 ldb 128 ldc 256

Emm this error is from faiss, I guess it's because the installed version of faiss has some incompatibilities. I just checked my python environment and I use faiss 1.7.4, but the pip-installed version should be 1.7.2. It was our mistake not to have pointed out this issue in advance.

A quick solution is to use conda to install it: conda install -c conda-forge faiss-gpu.

It worked! Thank you!

P.S. It was also really painful.

sungkim changed discussion status to closed

Sign up or log in to comment