Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible wrong implementation of beam search #3802

Closed
4 tasks done
shenjiangqiu opened this issue Oct 26, 2023 · 6 comments
Closed
4 tasks done

Possible wrong implementation of beam search #3802

shenjiangqiu opened this issue Oct 26, 2023 · 6 comments
Labels
bug Something isn't working stale

Comments

@shenjiangqiu
Copy link

Prerequisites

Please answer the following questions for yourself before submitting an issue.

  • I am running the latest code. Development is very rapid so there are no tagged versions as of now.
  • I carefully followed the README.md.
  • I searched using keywords relevant to my issue to make sure that I am creating a new issue that is not already open (or closed).
  • I reviewed the Discussions, and have a new bug or useful enhancement to share.

Expected Behavior

Beam search should use different contexts for each beam.

Current Behavior

In the beam-search.cpp example, the beam search technique applies the identical context across all beams. Understandably, if the scenario presents two beams, namely a-b-c-d-e and a-b-c-f-g, the shared prefix a-b-c is identified so as not to repeat the inference process on this section. Subsequently, separate inferences are conducted on sections d-e and f-g.

However, it's important to note an inefficiency here: during the inference process of d-e, these elements are stored into the key-value (kv) cache. Later, when the program is running the f-g inference, it erroneously accesses the kv-cache which accordingly may include data from the d-e sequence. This is inappropriate since d-e is not relevant to the current beam, hence leading to potential fallacies.

Steps to Reproduce

mkdir build; cd build; cmake ..; make;
./build/bin/beam-search /path-to-gguf/llama-2-7b.Q4_0.gguf 2 "this is a nice day,"

@shenjiangqiu shenjiangqiu added the bug Something isn't working label Oct 26, 2023
@ggerganov
Copy link
Owner

The beam search has to be completely reimplemented and moved out of the library into a separate example.
The new KV cache API (#3228) allows this to be implemented efficiently outside of the core library.

@shenjiangqiu
Copy link
Author

The beam search has to be completely reimplemented and moved out of the library into a separate example. The new KV cache API (#3228) allows this to be implemented efficiently outside of the core library.

Thanks for your reply. It seems currently examples/beam-search is still using the old internal beam_search function in llama.cpp. you mentioned the beam-search has to be completely reimplemented, is there any repo or link someone is working on it?

@ggerganov
Copy link
Owner

AFAIK no body is working on it atm

@matiaslin
Copy link
Contributor

Hey, anybody working on this yet?

@ggerganov
Copy link
Owner

Not that I'm aware of

@github-actions github-actions bot added the stale label Mar 19, 2024
Copy link
Contributor

github-actions bot commented Apr 2, 2024

This issue was closed because it has been inactive for 14 days since being marked as stale.

@github-actions github-actions bot closed this as completed Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working stale
Projects
None yet
Development

No branches or pull requests

3 participants