Find answers from the community

Updated last year

I am running into a weird issue with

I am running into a weird issue with PGVector I was hoping someone might be able to assist with
I have a separate file to pre-process some data into my postgres database
Plain Text
documents = SimpleDirectoryReader(DATA_FOLDER + COLLECTION_NAME).load_data()

url = make_url(f"postgresql://...")
vector_store = PGVectorStore.from_params(
    #database conn details...
    table_name=TABLE_NAME,
    #embed_dim=1536,  # openai embedding dimension
    embed_dim=768, # bge-base-en 
)

service_context = ServiceContext.from_defaults(embed_model=load_embedding_model(), llm=load_llm_model())

storage_context = StorageContext.from_defaults(vector_store=vector_store)
index = VectorStoreIndex.from_documents(
    documents, storage_context=storage_context, show_progress=True, service_context=service_context
)

query_engine = index.as_query_engine()
response = query_engine.query("What buildings did UBS management buy?")
print(response)

A response is actually generated in this file, meaning my embeddings in my postgres database are working and can be indexed

When I now use a separate file to try and query this table (which I have confirmed exists, and has the correct number of rows of data in it) I am returned 0 nodes
Plain Text
vector_store = PGVectorStore.from_params(
    #database_conn_details...
    table_name=TABLE_NAME,
    #embed_dim=1536,  # openai embedding dimension
    embed_dim=768
)

service_context = ServiceContext.from_defaults(embed_model=load_embedding_model(), llm=load_llm_model())

index = VectorStoreIndex.from_vector_store(
    vector_store=vector_store, service_context=service_context
)

query_engine = index.as_query_engine()
response = query_engine.query("What building did UBS management buy?")
print(response)


Just wondering if I've done anything wrong? As far as I can tell when the index is created directly there's no problem but trying to create an index from an existing vector store doesn't seem to work
j
1 comment
I did find the issue, turns out the PGVector class automatically prepends "data_" to your table names in ALL cases. So if you created your table_name without data, ensure that you do not manually add it in yourself after the fact when trying to read from the table just let llama handle it all
Add a reply
Sign up and join the conversation on Discord