Skip to content

batch_size is forced to 1 when tokenizer. pad_tokeni_id is 0 in huggingface runtime #2251

@pocketbob

Description

@pocketbob

log:

2025-08-19 17:17:51,850 [mlserver][transformer] INFO - Loading model for task 'text-classification'...
2025-08-19 17:17:52,337 [mlserver] WARNING - Model has neither pad_token or eos_token, setting batch size to 1
2025-08-19 17:17:52,755 [mlserver][transformer] WARNING - Model has neither pad_token or eos_token, setting batch size to 1

the id of pad token is 0 in tokenizer_config.json

{
  "added_tokens_decoder": {
    "0": {
      "content": "[PAD]",
      "lstrip": false,
      "normalized": false,
      "rstrip": false,
      "single_word": false,
      "special": true
    },
    "100": {
      "content": "[UNK]",
      "lstrip": false,
      "normalized": false,
      "rstrip": false,
      "single_word": false,
      "special": true
    },
    "101": {
      "content": "[CLS]",
      "lstrip": false,
      "normalized": false,
      "rstrip": false,
      "single_word": false,
      "special": true
    },
    "102": {
      "content": "[SEP]",
      "lstrip": false,
      "normalized": false,
      "rstrip": false,
      "single_word": false,
      "special": true
    },
    "103": {
      "content": "[MASK]",
      "lstrip": false,
      "normalized": false,
      "rstrip": false,
      "single_word": false,
      "special": true
    }
  },
  "clean_up_tokenization_spaces": true,
  "cls_token": "[CLS]",
  "do_basic_tokenize": true,
  "do_lower_case": true,
  "extra_special_tokens": {},
  "mask_token": "[MASK]",
  "model_max_length": 1000000000000000019884624838656,
  "never_split": null,
  "pad_token": "[PAD]",
  "sep_token": "[SEP]",
  "strip_accents": null,
  "tokenize_chinese_chars": true,
  "tokenizer_class": "BertTokenizer",
  "unk_token": "[UNK]"

line 66 in common.py, if not hf_pipeline.tokenizer.pad_token_id should change to if hf_pipeline.tokenizer.pad_token_id is None

if not hf_pipeline.tokenizer.pad_token_id:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions