Do I understand correctly that the generate_response method is run on every form submission?
Wouldn’t that mean that the text is embedded and stored in a vector store on each new question that the user enters? That would be very inefficient, because isn’t the vector store there so I can store the embedding and don’t have to do the process (which costs both time and money potentially) every time?
I probably miss something, and I would appreciate if anyone could help me on my learning journey here…
You’re absolutely right in your understanding about the efficiency issue. The tutorial was made for the purpose of introducing beginners to build a simple app with less code so they can then venture and build up upon the basic app.
With the current tutorial code, generate_response method is indeed called on every form submission. So for each new question a user asks, the entire document is re-ingested, split into chunks, each chunk is embedded in Chroma even if it has not changed.
There are ways to mitigate this which would introduce more code to handle the complexity. The main idea would be to decouple the document ingestion pipeline from the Q&A/ retrieval process. Some code would assign id to documents uploaded and before each run, the code checks if it has been uploaded before and if true, it retrieves the vector embeddings of that document and passes it to the LLM for a response. If not present, then the initial pipeline is run end-to-end. This is just one of many way to solve this.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.