AkariAsai / self-rag

This includes the original implementation of SELF-RAG: Learning to Retrieve, Generate and Critique through self-reflection by Akari Asai, Zeqiu Wu, Yizhong Wang, Avirup Sil, and Hannaneh Hajishirzi.
https://selfrag.github.io/
MIT License
1.84k stars 171 forks source link

Questions about Beam search algorithim #90

Open gabbyzyk opened 1 month ago

gabbyzyk commented 1 month ago

Thansk for your great work, how ever I have a question about the use of beam search During the inference , the generative model M sequentially generates textual outputs y, which consist of multiple segments y = [y1, ..., yT]. At each time step t, I want to understand if beam search generates b candidate sequences [y1, y2, ..., yt] based on their scores. After the generation is complete, the sequence with the highest score is selected. I would greatly appreciate it if you could find the time to answer my question.

fate-ubw commented 1 month ago

First of all, if you want to understand the logic of beam search in the selfrag algorithm, then you need to first understand the beam search algorithm based on tokens. The difference between the beam search algorithm used in the long form is that sentence is used as the basic unit. For your question, I have to admit that it is still very difficult to understand the longform beam search in the selfrag algorithm, I think the best way is to compare the code and the paper at the same time, and use debug to understand the reasoning process of the beam search step by step, it is really difficult to explain accurately by language and can be easily understood. There are some bugs in the official selfrag code longform reasoning that can confuse beginners. I fixed some bugs in the selfrag code in raglab, and rewrote this part of the algorithm according to the algorithm proposed in the paper, and implemented the real sentence level beam search, selfrag longform beam search Hopefully, the above answers can help you ~