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

beam search support #722

Closed
leiwen83 opened this issue Jul 28, 2023 · 8 comments
Closed

beam search support #722

leiwen83 opened this issue Jul 28, 2023 · 8 comments
Labels

Comments

@leiwen83
Copy link

Feature request

Beam search is useful feature provided by transformer library, but it seem it is missing in TGI?
Would it be supported?

Motivation

beam search would be helpful for response quality.

Your contribution

I'd have a try if this feature is implemented

@Narsil
Copy link
Collaborator

Narsil commented Jul 31, 2023

Hi @leiwen83

Indeed beam search is not implemented however we have a different algorithm which seems to work just as good or even better.

best_of taking the best of n potential sampling replies: #736 (comment)

Is that option what you could be looking for.
It seems to perform better with current LLMs where sampling is better than greedy for most answers.

@jiguanglizipao
Copy link

I vote for Beam Search. In the case of using Page Attention, Beam Search can share one Prifill operation and save computation with long prompts.

@Quang-elec44
Copy link

@jiguanglizipao I agree with you, it seems that the argument "best_of" does not provide good results. Moreover, in the case of my model, using "do_sample" leads to unwanted results

@PawelFaron
Copy link

PawelFaron commented Sep 18, 2023

Would ge great to have. best_of is great but way to slow.
With best_of=1 I have time_per_token="92.055402ms"
With best_of=2 I have time_per_token="307.8662ms"

@Narsil
Copy link
Collaborator

Narsil commented Sep 19, 2023

Beam search is much worse than best_of performance wise.

The timing difference you show here a surprisingly different. How did you measure
(model, harward, where did you get the timing information from)?

@PawelFaron
Copy link

PawelFaron commented Sep 19, 2023

@Narsil Thanks for your response. Probably you are right, just saying my observations so far.

The timing is from the docker container itself. It prints that after it generates text.
More about my setup:
Using the g2-standard-4 instance from GCP that has T4 GPU.

Starting the docker like this:

model=meta-llama/Llama-2-13b-chat-hf
volume=$PWD/data # share a volume with the Docker container to avoid downloading weights every run
token=$token

docker run --gpus all --shm-size 1g -e HUGGING_FACE_HUB_TOKEN=$token -p 4000:80 -v $volume:/data ghcr.io/huggingface/text-generation-inference:1.0.3 --model-id $model --quantize bitsandbytes-nf4 --max-input-length=4095 --max-total-tokens=4096 --trust-remote-code

Testing with that:

curl 127.0.0.1:4000 \
    -X POST \
    -d '{"inputs":"What is Deep Learning?","parameters":{"max_new_tokens":2048, "temperature": 0.8, "best_of": 2, "do_sample": true}}' \
    -H 'Content-Type: application/json'

@Narsil
Copy link
Collaborator

Narsil commented Sep 19, 2023

Oh I see bnb-nf4 is just super slow on anything above batch_size=1.

It has nothing to do with best_of.

Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the Stale label Apr 19, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants