Skip to content

Instantly share code, notes, and snippets.

View rudrakshkarpe's full-sized avatar
💭
OSSNomad! 🚀

Rudraksh Karpe rudrakshkarpe

💭
OSSNomad! 🚀
View GitHub Profile

Documentation: Explaining Chat Templates for Transformers

Starting from Transformers version 4.42, the library requires a chat template for chat-based models. This configuration, defined in the Jinja format, specifies constraints for chat message inputs. Understanding and implementing these templates is crucial for optimal performance across various Large Language Models (LLMs) such as OpenAI's ChatGPT, Anthropic's Claude, and Google's Gemini.

What is a Chat Template?

A chat template is a configuration file that defines how chat messages are structured and passed to the underlying model. This structure ensures that the model receives well-defined inputs for optimal performance. The template is written in the Jinja templating language, allowing for flexible and reusable configurations.

Key Features of Chat Templates:

  1. Message Role Specification: Defines whether a message is from the system, user, or assistant.
  2. Input Formatting: Ensures the input adheres to the expected format by the ch
@rudrakshkarpe
rudrakshkarpe / GSoC'24.md
Last active January 1, 2025 19:35
Google Summer of Code Final Report: Analytics Edge Ecosystem GenAI workloads

Google Summer of Code'24 Final Report

This report summarizes the work done by [me][res-github-rudraksh] in the [Google Summer of Code][res-gsoc] 2024 program as a contributor for the the project [Analytics Edge Ecosystem Workloads using Rancher][res-gsoc-project] at openSUSE Project.

@rudrakshkarpe
rudrakshkarpe / gist gi.md
Created October 4, 2023 07:18
The code creates a conference with a name, date, and number of tickets. It then prompts users to enter their information and books tickets for them until all tickets are sold out, storing each booking in a slice. It also prints the remaining tickets and This code snippet creates a list of bookings with their first name, last name, email address,…

fmt

Preview:
package main

import (
	"fmt"
	"strings"
)