Chat Markup Language (ChatML), introduced alongside OpenAI's ChatGPT and Whisper APIs on March 1, 2023, is a vital development that promises to enhance the way we interact with AI language models. In this blog post, we will delve into the significance of ChatML and its potential impact on AI-driven conversational interfaces.
Recap of OpenAI's Announcement
The announcement from OpenAI highlighted several key updates:
A dramatic 90% price reduction for the hosted API, ChatGPT, since December 2022.
More granular management and regional/geographic availability zones for APIs hosted on Azure.
Easier implementation and experimentation with the Whisper and ChatGPT APIs, allowing the inclusion of voice data alongside text data.
An increased focus on customer service, fine-tuning, and support for minority languages to differentiate from other ASR vendors.
The option for users to access specific model versions and update as needed, ensuring greater stability for production implementations.
Why ChatML Matters
ChatML is essential for several reasons, the most significant being its ability to protect against prompt injection attacks to a certain extent. It achieves this by segregating conversations into layers or roles, such as System, Assistant, and User.
Although currently at version zero, we can expect further developments and improvements to ChatML in the future. At present, the payload accommodated by ChatML is only text, but OpenAI plans to introduce other data types soon. While users can still opt for the unsafe raw string format, it is more susceptible to injections. OpenAI's introduction of ChatML demonstrates its commitment to guiding and managing the LLM landscape responsibly, setting the standard for application creation.
ChatML Example Code
Here's an example of a ChatML JSON file with the roles defined as System, User, and Assistant:
[
{"role": "system", "content": "You are ChatGPT, a large language model trained by OpenAI. Answer as concisely as possible.\nKnowledge cutoff: 2021-09-01\nCurrent date: 2023-03-02"},
{"role": "user", "content": "How are you?"},
{"role": "assistant", "content": "I am doing well"},
{"role": "user", "content": "What is the mission of the company OpenAI?"}
]
And the corresponding Python code snippet:
pip install openai
import os
import openai
openai.api_key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
completion = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages = [
{"role": "system", "content": "You are ChatGPT, a large language model trained by OpenAI. Answer as concisely as possible.\nKnowledge cutoff: 2021-09-01\nCurrent date: 2023-03-02"},
{"role": "user", "content": "How are you?"},
{"role": "assistant", "content": "I am doing well"},
{"role": "user", "content": "What is the mission of the company OpenAI?"}
]
)
#print(completion)
print(completion)
The output will display the role, model detail (gpt-3.5-turbo-0301), and other relevant information.
Closing Thoughts
Designing a conversational interface based on Large Language Models (LLMs) can be challenging due to the intricacies of sequencing prompt nodes into chains. The unstructured nature of input, often in the form of natural language or conversation, exacerbates this, and hence chatLM is an important development.
Comments