{"id":1029,"hash":"baa76892f68d8c8b5cf9f929f9bdcf2454ba8dd380c174a9a2f60f5d21bb8f67","pattern":"HuggingFace AutoModelForCasualLM &quot;decoder-only architecture&quot; warning, even after setting padding_side=&#39;left&#39;","full_message":"I'm using\nAutoModelForCausalLM and AutoTokenizer to generate text output with DialoGPT.\n\nFor whatever reason, even when using the provided examples from huggingface I get this warning:\n\nA decoder-only architecture is being used, but right-padding was detected! For correct generation results, please set padding_side='left' when initializing the tokenizer.\n\nfrom transformers import AutoModelForCausalLM, AutoTokenizer\nimport torch\n\ntokenizer = AutoTokenizer.from_pretrained(\"microsoft/DialoGPT-medium\")\nmodel = AutoModelForCausalLM.from_pretrained(\"microsoft/DialoGPT-medium\")\n\n# Let's chat for 5 lines\nfor step in range(5):\n    # encode the new user input, add the eos_token and return a tensor in Pytorch\n    new_user_input_ids = tokenizer.encode(input(\">> User:\") + tokenizer.eos_token, return_tensors='pt')\n\n    # append the new user input tokens to the chat history\n    bot_input_ids = torch.cat([chat_history_ids, new_user_input_ids], dim=-1) if step > 0 else new_user_input_ids\n\n    # generated a response while limiting the total chat history to 1000 tokens, \n    chat_history_ids = model.generate(bot_input_ids, max_length=1000, pad_token_id=tokenizer.eos_token_id)\n\n    # pretty print last ouput tokens from bot\n    print(\"DialoGPT: {}\".format(tokenizer.decode(chat_history_ids[:, bot_input_ids.shape[-1]:][0], skip_special_tokens=True)))\n\nCode provided by microsoft on the model card at huggingface\n\nI've tried adding padding_side='left' to the tokenizer but that doesn't change anything.\nApparently (from some reading) DialoGPT wants the padding on the right side anyways?\nI can't figure this out, there are few results when I tried googling it.\n\nI was able to suppress the warnings like this:\n\nfrom transformers.utils import logging\n\nlogging.set_verbosity_info()\n\nBut this doesn't seem like the best answer?","ecosystem":"pypi","package_name":"machine-learning","package_version":null,"solution":"Padding in this context is referring to the \"tokenizer.eos_token\", and you are currently padding to the right of the user input and the error is saying that for correct results add padding to the left. You need to do this:\n\nnew_user_input_ids = tokenizer.encode(tokenizer.eos_token + input(\">> User:\"), return_tensors='pt')","confidence":0.95,"source":"stackoverflow","source_url":"https://stackoverflow.com/questions/74748116/huggingface-automodelforcasuallm-decoder-only-architecture-warning-even-after","votes":17,"created_at":"2026-04-19T04:52:12.293455+00:00","updated_at":"2026-04-19T04:52:12.293455+00:00"}