OptimalScale / OptimalScale/LMFlow

[BUG] Do not use generation of hf model in inferencers

Open
#920 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

pending
Dominant language
Python
Stars
8.5k
Forks
822
PR merge metrics
No merged PRs in 30d

Description

Describe the bug
As I mentioned in this issue, the default value of top_p and temperature is not guaranteed to be 1. Therefore, the code below will get a modified logits, i.e., a distribution processed depending on generation_config from hf end.
https://github.com/OptimalScale/LMFlow/blob/1b223f7693c2b8b91c7b6dfb7d7c48ab2d040834/src/lmflow/models/hf_decoder_model.py#L382-L405

Much worse, you applied top_p and temperature again in score_to_prob, resulting unexpected distribution:
https://github.com/OptimalScale/LMFlow/blob/1b223f7693c2b8b91c7b6dfb7d7c48ab2d040834/src/lmflow/pipeline/inferencer.py#L435-L440

Contributor guide

Open the contributing guide

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

Read src/lmflow/models/hf_decoder_model.py at lines 382-405 and src/lmflow/pipeline/inferencer.py at lines 435-440. Trace how logits are produced and passed to score_to_prob, then verify the resulting distribution is not generation-processed and that top_p and temperature are not applied twice. Done means inference returns the intended unmodified distribution.

Written by the indexing model from the issue text.

Assessment

Tech stack
huggingface, python, pytorch
Domain
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.