-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Description
Motivation.
As the openai o1 series of models gave us a peek on the great potential of RL, the interest on reward model, as a core component of model RL algorithms, are rising. Recently, we have tried to introduce new reward models into vllm by reusing embedding APIs (#8896) and have ongoing RFC to discuss a better server API for reward model specifically (#8967).
This RFC is trying to introduce a broader class of RMs by making all generation models be able to be served as embedding models. In this way, vllm could easily support process-supervised reward model (PRM).
PRM is a kind of rewad model that will give reward score on the intermediate steps of an llm response. For example, in cot, when the model is thinking step by step, prm could make a judgement on each thinking step, which gives a finer granularity for RL optimization. Also, many are guessing that PRM is a cruial component to replicate o1, e.g. GAIR-NLP/O1-Journey.
A common way to train PRM is to add an special token after each step, and use the output logits of the special token, to be more specific, select some tokens as the scoring levels and train an classifier on the logits of those tokens. This is called hard estimation in PRM training (contrary to soft estimation, which will do a regression instead of a classfication) and is used in the famous Let's Verify Step by Step (https://arxiv.org/abs/2305.20050) by openai, who also open sourced the PRM800K dataset along with the paper (https://github.com/openai/prm800k), and also Math-Shepherd (https://arxiv.org/abs/2312.08935). Take Math-Shepherd as a further illustration on how to train PRM, they were using Mistral 7B as the base model, using a ки
as the special token, and +
, -
as the scoring tokens, so that whenever the PRM meet a ки
, we can check the logits of +
and -
to see how good the previous step is. The PRM model of Math-Shepherd is open sourced here math-shepherd-mistral-7b-prm.
To support this kind of PRMs, we can simply add an default pooler
method to all models (because we can see that math-shepherd-mistral-7b-prm is just a LlamaForCausalLM
) and allow users to set the scoring tokens to truncate the logits (otherwise the vocab_size would be too large).
Proposed Change.
- Change the model classification from
_GENERATION_MODELS
and_EMBEDDING_MODELS
into model that can or cannot do generation (that all models can be embedding model). - Add a default
pooler
function to_GENERATION_MODELS
. An example can be
def pooler(
self,
hidden_states: torch.Tensor,
pooling_metadata: PoolingMetadata,
) -> Optional[PoolerOutput]:
# we can trim the lm_head by calculating the hidden_states @ lm_head
# and doing pooling at the same time.
return self._pooler(self.lm_head, hidden_states, pooling_metadata)
where, the self._pooler
will trim the logits with the scoring tokens provided by pooling_metadata
.
3. Use the reward model of Math-Shepherd, i.e. math-shepherd-mistral-7b-prm as an example.
Feedback Period.
No response
CC List.
cc @DarkLight1337 @mgoin @youkaichao @noamgat @natolambert
Any Other Things.
Thank you for your time on this RFC:)
Before submitting a new issue...
- Make sure you already searched for relevant issues, and asked the chatbot living at the bottom right corner of the documentation page, which can answer lots of frequently asked questions.