How to avoid creation of embeddings for context

#2
by Puresoul - opened

Let's say I have a document of context which I am going to use as context for everything.

I do not want to create embeddings for context for every time, but to store and use them again and again. How can I acheive this. Sorry if this is a dumb question.

Thanks

Gauss Algorithmic org

Hi @Puresoul ,
If you are referring to this model, note that this is an extractive QA model, that consumes an input containing both context and your question. Internally, the transformer's token representations of both the context and question are dependent on the whole input, so it's not easy to disentangle the representation of context from the output of an extractive QA model.

If you want to pre-encode the contexts with transformers, you need to choose a rather different approach through dense encoders, commonly used in search applications. There, you can train a transformer, e.g. to produce similar embedding for question and context that answers the question. Sentence transformers documentation can show you how to do that, but feel free to ask questions if you like.

@michal-stefanik Thank you so much for your inputs, I'll try that way.

Sign up or log in to comment