lm-sys / lm-sys/FastChat

Issue with model weights when using api endpoints to run gradio_web_server_multi

Open
#3,735 1 comment 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

Hi,

I'm trying to run the Chatbot Arena locally using my own API keys via the --register-api-endpoint-file flag. However, when I input any prompt in anonymous battle mode. Running the following script,

python3 -m fastchat.serve.gradio_web_server_multi \
    --controller "" \
    --register-api-endpoint-file api_endpoints.json \
    --share

gives me the following error:

ValueError: probabilities contain NaN

This seems to come from the following block in fastchat/serve/gradio_block_arena_anony.py, around line 228:

model_weights = []
    for model in models:
        weight = get_sample_weight(
            model, outage_models, sampling_weights, sampling_boost_models
        )
        model_weights.append(weight)
    total_weight = np.sum(model_weights)
    model_weights = model_weights / total_weight
    # print(models)
    # print(model_weights)
    chosen_idx = np.random.choice(len(models), p=model_weights)
    chosen_model = models[chosen_idx]

The problem is that model_weights ends up being empty or all zeros, so total_weight becomes 0, which leads to division by zero and NaN values.

From what I can tell outage_models, sampling_weights, and sampling_boost_models are empty or not initialized and I don't see a documented way to set weights through the api_endpoints.json file and have them properly integrated into this sampling logic

Is this expected? Should api_endpoints.json support something like model_weight, and if so, how should it be connected to this logic? Or is manual patching the only current workaround?

Thanks!

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/gradio_block_arena_anony.py and reproduce the failure using the documented gradio_web_server_multi command and api_endpoints.json. Trace how get_sample_weight receives outage_models, sampling_weights, and sampling_boost_models, then verify that API-backed model selection produces valid probabilities instead of NaN values.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
backend-api-design
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.