graphrag: [Bug]: TypeError: Query column vector must be a vector. Got list.
Do you need to file an issue?
- I have searched the existing issues and this bug is not already filed.
- My model is hosted on OpenAI or Azure. If not, please look at the “model providers” issue and don’t file a new one here.
- I believe this is a legitimate bug, not just a question. If this is a question, please use the Discussions area.
Describe the bug
I attempted to refer to https://github.com/microsoft/graphrag/blob/main/docs/examples_notebooks/local_search.ipynb to write a Python file for running local search but failed. However, using https://github.com/microsoft/graphrag/blob/main/docs/examples_notebooks/global_search.ipynb as a reference, I successfully wrote a Python file to run global search. Additionally, I successfully ran the local search by referring to https://github.com/microsoft/graphrag/blob/94f1e62e5c06795fc8c361dba6580bb76d6e77ce/docs/get_started.md. Below is the error message:
Entity count: 3 Relationship count: 2 Report records: 1 Text unit records: 1 Traceback (most recent call last): File “/data/zelongzheng/graphrag-main/local_search.py”, line 172, in <module> asyncio.run(main()) File “/home/zelongzheng/anaconda3/envs/graphrag/lib/python3.11/asyncio/runners.py”, line 190, in run return runner.run(main) ^^^^^^^^^^^^^^^^ File “/home/zelongzheng/anaconda3/envs/graphrag/lib/python3.11/asyncio/runners.py”, line 118, in run return self._loop.run_until_complete(task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/home/zelongzheng/anaconda3/envs/graphrag/lib/python3.11/asyncio/base_events.py”, line 654, in run_until_complete return future.result() ^^^^^^^^^^^^^^^ File “/data/zelongzheng/graphrag-main/local_search.py”, line 167, in main result = await search_engine.asearch(“what is the relationship between xiaozhang and xiaoming?”) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/data/zelongzheng/graphrag-main/graphrag/query/structured_search/local_search/search.py”, line 67, in asearch context_text, context_records = self.context_builder.build_context( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/data/zelongzheng/graphrag-main/graphrag/query/structured_search/local_search/mixed_context.py”, line 140, in build_context selected_entities = map_query_to_entities( ^^^^^^^^^^^^^^^^^^^^^^ File “/data/zelongzheng/graphrag-main/graphrag/query/context_builder/entity_extraction.py”, line 57, in map_query_to_entities search_results = text_embedding_vectorstore.similarity_search_by_text( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/data/zelongzheng/graphrag-main/graphrag/vector_stores/lancedb.py”, line 136, in similarity_search_by_text return self.similarity_search_by_vector(query_embedding, k) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/data/zelongzheng/graphrag-main/graphrag/vector_stores/lancedb.py”, line 115, in similarity_search_by_vector .to_list() ^^^^^^^^^ File “/home/zelongzheng/anaconda3/envs/graphrag/lib/python3.11/site-packages/lancedb/query.py”, line 320, in to_list return self.to_arrow().to_pylist() ^^^^^^^^^^^^^^^ File “/home/zelongzheng/anaconda3/envs/graphrag/lib/python3.11/site-packages/lancedb/query.py”, line 647, in to_arrow return self.to_batches().read_all() ^^^^^^^^^^^^^^^^^ File “/home/zelongzheng/anaconda3/envs/graphrag/lib/python3.11/site-packages/lancedb/query.py”, line 678, in to_batches result_set = self._table._execute_query(query, batch_size) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/home/zelongzheng/anaconda3/envs/graphrag/lib/python3.11/site-packages/lancedb/table.py”, line 1742, in _execute_query return ds.scanner( ^^^^^^^^^^^ File “/home/zelongzheng/anaconda3/envs/graphrag/lib/python3.11/site-packages/lance/dataset.py”, line 369, in scanner builder = builder.nearest(**nearest) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/home/zelongzheng/anaconda3/envs/graphrag/lib/python3.11/site-packages/lance/dataset.py”, line 2449, in nearest raise TypeError( TypeError: Query column vector must be a vector. Got list<item: double>.
Steps to reproduce
1.pip install graphrag==0.3.6
2.Build the graph and use the command python -m graphrag.query --root ./ragtest --method local "what is the relationship between xiaozhang and xiaoming?" to confirm successful execution.
3.Write a python file using https://github.com/microsoft/graphrag/blob/main/docs/examples_notebooks/local_search.ipynb as a reference. Modify certain parts of this file: change INPUT_DIR, comment out all variables related to covariates since no related files were generated when building the graph, set API_KEY, llm_model (deepseek-chat), embedding_model (text-embedding-3-small), and api_base=“https://api.agicto.cn/v1”.
4.Run the file using Python.
Expected Behavior
I expect it will response for what I ask.
GraphRAG Config Used
graphrag=0.3.6
llm = "deepseek-chat"
embedding_model = "text-embedding-3-small"
api_base = "https://api.agicto.cn/v1"
Logs and screenshots
Additional Information
- GraphRAG Version : 0.3.6
- Operating System : Ubuntu 20.04.4 LTS
- Python Version : 3.11.10
- Related Issues:
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 3
- Comments: 33
I was able to find a workaround. Seems like a minor bug in lancedb code
I changed the schema to this:
where N is the length of embedding vector produced by whatever embedding model you are using in your settings.yml file. I am using “text-embedding-3-large” from openai hence the number is 3072.
Location of the file to edit –
i’m still encountering the same issue too with version 0.5.0. When using the CLI, I am able to get the results. However, when I define a code for context builder and use search engine for query as demonstrated in some of the examples above, I encounter the following error:
Query column vector must be a vector. Got list<item: double>.
I also tried the suggested approach of setting the embedding size in LanceDB to N = 3072 (for large embeddings) or N = 1536 (for small embeddings). While this resolves the error and generates results, I noticed that both context_data and context_text are empty upon inspection. This leads me to believe that the embedding or LanceDB setup is not functioning correctly
I still encounter the same issue with
v0.5.0. The CLI command for local search works, so it still is an API related problem, or maybe the documentation is not yet up to date. I have followed https://github.com/microsoft/graphrag/blob/main/docs/examples_notebooks/local_search.ipynb and it doesn’t work.I had fix this issue,in
schema,need set vector_size,pa.field("vector", pa.list_(pa.float32(), list_size=DIM_VALUE)),Thanks everyone. We are planning to update the notebook examples very soon which may solve this problem.
While we are still in the pre-v1 release, we are making significant changes that at times will not be backwards compatible. We do our best to preserve backwards compatibility between releases but cannot guarantee it just yet.
Our cicd runs tests against the notebooks to confirm their functionality but we currently do not test against indexes from prior releases.
Setting the
list_sizebreaks context building as @lcazevedo noted. Looking at the lancedb, thedefault-entity-descriptioncollection is empty. That causes no entities and relationships to be found when building context.EDIT: At some point I picked up the following code, which clears the collection:
Removing that fixes context building for me.
Sorry!
I’m getting the same error when using the local search example notebook code. Not only does it fail when running the code, it also seems to corrupts the index causing the CLI to fail with the same error. Need to re-index for it to work again. I’m using the latest 0.5.0 version.
Using the api in a notebook does work however. This is the code that worked:
Maybe the ipynb examples should be retired or updated?
TLDR: Don’t use scripts in notebook examples since they are outdated. You can just call graphrag.api.global_search() directly. See examples in graphrag/cli/query.py.
This is due to backward compatibility things related to lancedb. There’re some code patching lancedb files. You’ll need to handle this kind of things if you decide to call lower level APIs like read_indexer_entities()
locol_query.log
When I used the local_search query example shown at “https://microsoft.github.io/graphrag/examples_notebooks/local_search/”, I encountered the same error as @zel2023. Here is my code:
Here is the error log:
The command I used to generate the index is
graphrag index --root ./ragtest, and the version of graphrag is 0.4.0.When i use
I can get right result:
However, when i try to use:
Errors still appear extensively:
I tried to fix each error individually, but this led to a series of new errors.
In summary, it seems that
--method localis not well-supported. Both the example provided in the notebook and directly using the related command result in errors:Even the indexing process worked great with the api object and the graphrag_config (After running the Cli init command) .
Here is the code:
It appears that the example notebooks are out of date. Above version 0.3.0 (0.9.0 here) I was only able to perform searches using the API object directly, as shown in this example:
example
My final code looks like this for local and global searches (After indexing):
I have done extensive testing I believe this is the line that causes all the trouble:
entity_description_embeddings = store_entity_semantic_embeddings( entities=entities, vectorstore=description_embedding_store )
Basically, the CLI would work perfectly before this line was run. And it would stop working after this line is run. Roll back to the previous LanceDB would solve this problem.
In v0.9, this line will directly throw a bug on my side due to LanceDB’s updated sanity check (seems like some len(data) would throw a zero)
can confirm this restored context for me after removing this line. Thank you!!!
This gives us a way forward patching the dimension into lancedb.py as our current experiment is local only.
报错日志最后指向了这里,这里的代码会判断"storage_type"是否是固定大小:
以overwrite=True为例。在构建知识图谱时data不为空,走的是if的逻辑;查询时data为空,走的是else的逻辑。 schema定义那里,pa.list_()的第二个参数list_size默认值是-1,也就是没有固定大小。所以查询时,list_size需要设置为一个固定值,才不会报错。
修改后,local查询通过。

For me, both without and with the workaround of explicitly declaring the
pyarrowlist length as 1536 foropenai-embedding-3-smallproduces the “Query column vector must be a vector” error message.Same problema here: SO=linux gaphrag=0.5.0 lancedb=0.13.0