powered by
Creates a properly formatted chat template for Gemma models, which use <start_of_turn> and <end_of_turn> markers instead of ChatML format. This function addresses compatibility issues with apply_chat_template() when used with Gemma models.
apply_gemma_chat_template(messages, add_assistant = TRUE)
A character string with properly formatted Gemma chat template
A list of message objects, each with 'role' and 'content' fields
Whether to add the assistant turn prefix (default: TRUE)
if (FALSE) { messages <- list( list(role = "system", content = "You are a helpful assistant."), list(role = "user", content = "Hello!") ) formatted <- apply_gemma_chat_template(messages) }
Run the code above in your browser using DataLab