i created a python code that calls gpt api to answer questions based on an embedding file.
the flow is as such . i got a embedding file with all vectors assigned to my teaching data
the first step is that im creating an embedding from my input question then calling a distance function to my embedding source data to match the question ive given to the learnt data.
then i give simple prompts and one of them directs the gpt to answer based on the Context i generated from X answers that are vector closest to my question.
if i ask a single question the gpt returns the right answer based on the learning data. ( the distance is calculated between the question and the learning data)
so for example:
if i ask " how many elderly are in us?" and my learning data have a information regarding this question - it can return me " there are 90 million elderly in us"
then if i ask " how about in England?" then it will try to create a context based on that question alone without knowing that the user means " how many elderly are in England". then it just answers randomly or just says he cant answer
i tried to bypass it by creating the context based on all historical answers so the data will be able to match also to the question of" how many elderly are in us, how about in England". then it answers kind of correctly .
then i encounter another issue. what is the first answer is sufficient then the user asks a whole different question. i don’t want to calculate the context with previous question that got nothing to do with the new one . it results with very bad answers.
does anyone encountered such a use case and knows how to handle this case?
im passing to the gpt the messages as prompts + context that contains the most vector closest of my learning data then the list of questions and answers
in short embedding and keeping context between previous questions/answers