This article is a mirror article of machine translation, please click here to jump to the original article.

View: 1659|Reply: 1

[AI] (8) Introduction to the dialogue roles system, user, and assistant of large models

[Copy link]
Posted on 2025-2-28 09:45:00 | | |
The chat model takes a series of messages as input and returns the message generated by the model as output.

Although the chat format makes it easy to have multiple rounds of conversation, it is equally suitable for single-round tasks without any conversations. An example of an API call is as follows:

The messages parameter is the most important parameter in the createChatCompletion method, which contains multiple message objects. Each message has a role and can besystem、user、assistantAny of them.

  • user: Represents the message sent by the user, that is, the question or instruction entered by the user. In the above code, both the second and fourth messages are of type user.
  • assistant: Represents the answer or response given by the chatbot by calling an AI algorithm. In the above code, the third message is an assistant type message.
  • system: Represents a message sent by the system or client through code. The purpose of system messages is to provide further guidance or instructions to the assistant so that it can respond better.


A chat begins with a message of type system, followed by alternating messages of type user and assistant. A message of type system can help set the behavior of the assistant and guide how it should answer the user's question, such as the system message "You are a very useful AI assistant" in the example above.

The entire list of messages can be very short, with only one message, or very long, taking up several pages.

Chat history is also important in chatbot interactions, as the user's instructions may need to reference previous message information. In the code example above, the user's last question "Who is the champion?" "It only makes sense when the 2022 World Cup is mentioned in previous news.

Since the machine learning model does not have a memory of previous requests, it must provide all relevant information through the conversation. If a dialog doesn't fit within the model token limit, some shortening is required.





Previous:Personal Home IP-KVM Open Source Project and Device Summary
Next:The prismjs code highlighting plugin introduces the issue of all language orders
 Landlord| Posted on 2025-3-27 09:08:35 |
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com