Such methods are called retrieval-augmented generative models and their objectives are to maximize P (r|q, R), where R is one or a few (at most 3 in practice) retrieved results.
some researchers (Li et al., 2017;Zhuang et al., 2017;Song et al., 2018) build the combination of retrieval and generative models, which retrieve one or a few responses r + , and then feeds both the query q and r + into the generative model to maximize P (r|q, R = r + ).