lm-sys / lm-sys/FastChat

`do_sample` is always set to `FALSE` when using Hugging Face API

Open
#2,691 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
39.5k
Forks
4.8k
PR merge metrics
No merged PRs in 30d

Description

The Hugging Face API sample script contains the following lines:

output_ids = model.generate(
        **inputs,
        do_sample=True if args.temperature > 1e-5 else False,
...

and

parser.add_argument("--temperature", type=float, default=0.7)

So clearly do_sample should be on by default, but actually running the script produce the following message:

/envs/pytorch/lib/python3.10/site-packages/transformers/generation/configuration_utils.py:362: 
UserWarning: `do_sample` is set to `False`. However, `temperature` is set to `0.9` -- this flag is only used in sample-based generation modes. 
You should set `do_sample=True` or unset `temperature`. This was detected when initializing the generation config instance, which means the corresponding file may hold incorrect parameterization and should be fixed.

In fact, this message would appear even if I modify the sample script and set do_sample=True in the model.generate() call. I have verified that this is true for fschat=0.2.29-0.2.32 and the newest version of transformers. I have also verified that the Hugging Face version Llama-2 does not show this warning.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with fastchat/serve/huggingface_api.py and its model.generate call, then reproduce the warning using the script's default --temperature. Compare the effective generation settings with the reported warning; the issue is done when the sample no longer reports do_sample=False while temperature is nonzero.

Written by the indexing model from the issue text.

Assessment

Tech stack
huggingface, python
Domain
api, machine-learning
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.