IBM / text-generation-inference

IBM development fork of https://github.com/huggingface/text-generation-inference
Apache License 2.0
57 stars 30 forks source link

fix: check for tokenizer eos_token in ModelInfo response #93

Closed tjohnson31415 closed 6 months ago

tjohnson31415 commented 6 months ago

Motivation

The model config may not have the eos_token_id set as it is an optional field. The ModelInfo response from the Server is what the Router uses to determine the EOS token, but it only checks self.model.config.eos_token_id. If config.eos_token_id is None, the eos token id then defaults to 0.

In most places in the Server code that need the EOS token (eg. when creating the next token chooser), the check is:

getattr(tokenizer, 'model_eos_token_id', tokenizer.eos_token_id)

which uses an attribute that is added to the tokenizer in model.py if the model config has the eos token (REF) but also falls back to the tokenizer attribute. ModelInfo should do the same.

Modifications

Use consistent logic to determine the eos_token_id in ModelInfo as it is in other functions by falling back to the tokenizer's eos_token_id attribute if the model config does not have an eos_token_id.

Result

Fixes the behavior for a model that does not have an eos_token_id configured in its config by using the tokenizer configuration instead.

Related Issues

Resolves https://github.com/IBM/text-generation-inference/issues/91