How can i refer to a specific document in the vector store

I want to make a quotation. To do this i have example quotations and i have documents that the customer wrote, explaining what he wants to buy.

I want to use the technique from OpenAI, using the API to make assistants, upload files, make a vectorstore that i connect to the assistant. I want to get the answers again using the OpenAI Api using threads, messages and runs.

How can i make a prompt to answer the questions that the customer wants, referncing to the example quotations as a reference for knowledge and style and referencing to the user documents for getting the question right?

2 Likes

Hi @kvdtempel, any update on this?

Unfortunately no. I noticed that it does not work good to upload all files to a vectorstore and try to refer to a file, using the name. So now i try to upload the separate file to a message to be sure that the message answers question about that particular file. So i do not use a vector store at the assistant level. I willlet you know how things are going

Hi @kvdtempel ! Have you checked this thread to see if it solves your problem: How To Refer To a Document In Vector DB - #5 by thinktank ?

That does not have any answer, and the answer is that there is no file name. At best, in results of a file search, there is the internal file_id given to the AI for a chunk.

The assistant cannot refer to a file. The assistant cannot differentiate between user upload files and developer files, or between assistants vector store and thread vector store.

The only thing it can do is write a search query and receive combined top-rank results as document chunks.

1 Like

Got it, thanks @_j !

So regarding OP’s question - the only way to provide a decent referencing solution within the current OpenAI ecosystem is to implement your own RAG, and at document processing / indexing time, associate each chunk (and the corresponding embedding vector) with one or more document references, i.e. filename, document title, page number. Then at query time, at the retrieval step, ensure to pass back those filenames, page numbers, or whatever other identifiers, back to the user, along with the generated answer from the model.

This solution, however, would still be flawed, since the actual generated answer may come from multiple or any of the files (or pages) associated with the returned chunks, and we may not know exactly which ones, but essentially “one or more of them”. Some prompt engineering may get us some way there, but ultimately we would need something like Anthropic’s Citations feature.

2 Likes