Skip to content

Conversation

@pcuenca
Copy link
Member

@pcuenca pcuenca commented Sep 3, 2025

conversational does not always imply chat_template. Example: https://huggingface.co/facebook/blenderbot-400M-distill/blob/main/README.md

In our internal codebase we auto-set conversational if a chat template exists, but the opposite is not always true. The model above has an explicit conversational tag, but no chat template.

See #1722

`model = ${info.auto_model}.from_pretrained("${model.id}"` + remote_code_snippet + ")"
);
if (model.tags.includes("conversational")) {
if (model.tags.includes("conversational") && model.config?.tokenizer_config?.chat_template) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this is populated if i.e. chat_template.jinja exists but it's not in tokenizer_config.json

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I think it's not)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The correct way to check if a chat template is set is:

			(this.config?.tokenizer_config?.chat_template !== undefined ||
				this.config?.processor_config?.chat_template !== undefined ||
				this.config?.chat_template_jinja !== undefined

(taken from internal repo)

Note that this.config?.chat_template_jinja is the most future-proof field (but is not populated for all models with a chat template)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree^

Comment on lines 37 to 39
export interface ProcessorConfig {
chat_template?: string | Array<{ name: string; template: string }>;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, in moon-landing, this one is simply typed (and validated...) like this:

	processor_config?: {
		chat_template?: string;
	};
	chat_template_jinja?:       string;

any reason to differ here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No reason at all, I was trying to mimic what I saw in the other fields but didn't check moon-landing. Changing!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^ much simpler this way, thanks!

Copy link
Member

@julien-c julien-c left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm with my suggestion

Co-authored-by: Julien Chaumond <julien@huggingface.co>
@pcuenca
Copy link
Member Author

pcuenca commented Sep 8, 2025

Waiting in case @Wauplin has time to take a look, otherwise will merge in a day or so.

Copy link
Contributor

@Wauplin Wauplin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking care of it @pcuenca!

Copy link
Member

@julien-c julien-c left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome 👍

@pcuenca pcuenca merged commit f734971 into main Sep 9, 2025
3 of 5 checks passed
@pcuenca pcuenca deleted the conversational-chat-template branch September 9, 2025 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants