"partial": True to the last message entry with role of assistant to enable Partial Mode.
Note!Do not mix Partial Mode with response_format=json_object, or you may get unexpected model responses.
Examples
JSON Mode
Here is an example of using Partial Mode to achieve JSON Mode.Role-Play
Based on the same principle, we can also enhance role-playing consistency by adding character information in Partial Mode. Let’s use Dr. Kal’tsit from the mobile game Arknights as an example. Note that we can also use the"name":"Kal'tsit" field on top of Partial Mode to better maintain the character’s consistency. Here, the name field can be considered as part of the output prefix.
Other Tips for Maintaining Character Consistency
There are also some general methods to help large models maintain role-playing consistency during long conversations:- Provide clear character descriptions. As we did above, when setting up a character, provide detailed information about their personality, background, and any specific traits or quirks. This helps the model better understand and imitate the character.
- Add details about the character’s speech patterns, style, personality, and background, such as backstory and motives. For example, above we provided some of Kal’tsit’s background information. If there is a lot of information, you can use RAG frameworks to prepare these materials.
- Guide how to act in various situations: If you expect the character to encounter certain types of user input, or if you want to control the model’s output in certain role-playing situations, provide clear instructions and guidelines in the prompt on how the model should act. In some cases, you may also need to use the Tool Use feature.
- If the conversation goes on for many turns, you can periodically reinforce the character’s settings with prompts, especially when the model starts to deviate.