Clarification post... just because

Regarding this line of code below:

{ role: “system”, content: programming},
{ role: “assistant”, content: "relevant documentation: " + knowledge },
{ role: “user”, content: input_question },

^^^ the above can be pretty self explanatory, but if somebody has the spare time… would you be so awesome to explain what is the role and the content, and when should it be used?

Yes, sorry for such silly questions … I just looking for confirmation rather than just guess.

Role is simply a way of telling the model which part of it system is currently talking, they were developed to facilitate the back and forth conversational nature of AI interaction, the models are trained to respond differently to the system, user and assistant roles, system is for base rule setting and persona creation, the user role is for secondary instruction, questions and context and the assistant role is for letting AI know that was generate by itself.

The Content is just what that message contains.

1 Like

As the person that wrote what you quote, I can answer more.

The API chat endpoint for accessing chat-proficient models such as gpt-3.5-turbo requires you to submit messages in a special container format named ChatML. Then the AI has been trained that each has a specific purpose. The container encapsulation is meant to keep a user from re-aligning an AI to non-intended purposes.

Allowed roles:

  • system: typically the first message sent. It will give the AI an identity or purpose. A typical example:
    – "you are ForumBot, and seek to answer user questions with your knowledge. Also, identify spam by a response that is only the word “spam”.

  • user: the input from the user, which may be questions, further instructions, etc.
    – “How do I send messages to an AI model through the OpenAI API?”

Then there are two more special roles:

  • assistant: when you give prior chat back to the model so it can maintain conversational context, this is where you’d place what the AI previously said. It can also be a place to inject knowledge that looks like it came from the AI instead of being input by the user.

  • function: a role specifically for return values after an AI has invoked a function by its programmer-specified API function-calling ability. Requires a second parameter “name”.

“content” is just that, the language that the AI should consider for each of these roles.

1 Like