How to enforce a personality for GPT-3.5?

I’ve been having some issues with my chatbot (using gpt-3.5-turbo, specifically 0613), primarily meant for entertainment, not always keeping the same personality in its responses. I’m going for a specific personality with a lot of profanity use, and whilst this works great when providing example user messages and assistant responses, this does not work in practice because each user message and AI response is added to an internal chat log which is always updated. This means that the previous messages the AI sees is always a user message + the AI’s response, not my example messages.

Does anyone have any tips for enforcing a certain personality plus usage of profanity, slang words, and generally behaviour that isn’t the standard, basic AI behaviour of ‘How else may I assist you?’ – the monotone, generic type of response? I find my chatbot falling back into the ’basic’ AI response quite frequently – lacking personality and uniqueness.

Currently, I use a system message as the first message containing information about who the chatbot is and other information: current date plus conditional info about the current user, what channel the bot is in, etc.

I also use a user message as a ‘rules’ message – which is always the second message in the chat log. I moved that part of the system message to a user message since user messages are more enforced. This message contains rules the chatbot must follow.

If anyone has any tips regarding how to enforce a personality, or rules in general, for GPT-3.5-Turbo please let me know!

3 Likes

It feels like you are after some jailbreak assistance, and while I generally support all manner of free speech and the rights of adults to do pretty much whatever they want so long as it doesn’t cause harm to others, that also extends to the rights of companies to place restrictions on how they want their services to be used.

I’m not entirely sure what the benefit is of a profane assistant—other than, as you suggest “entertainment,” but as you seem to be looking for advice to circumvent OpenAI’s moderation, I think you’ll have a hard time getting what you want here, an OpenAI hosted forum.

3 Likes

Thanks for the response.

I’m not looking to ‘jailbreak’ the model or violate OpenAI’s usage policies. I’ve read the usage policy, and from what I’ve read, profanity is not part of what is disallowed. I’m not looking to generate adult content (e.g., pornography), nor violent, hateful, or otherwise inappropriate content.

Yes, my purposes are primarily for entertainment, and the profanity part of the equation is only a small part of what I’m asking for assistance with. I don’t just want to enforce profanity; I want to enforce a set personality.

The problem that I was trying to describe was how the model responds in exactly the way I want it to with the example chat messages fed to it, but as soon as it starts conversing with users, those example messages naturally disappear from the chat log. Ultimately, as a result, the model seems to lose its personality more and more. Whilst it doesn’t respond exactly as ChatGPT would, it does frequently say ‘What else can I be of assistance with?’ and similar phrases, as well as give responses which are not the responses that I was hoping to get from the model – such as more generic responses lacking the sarcasm and entertainment value I’m going for.

In summary, I’m merely looking for tips on how to enforce certain personality traits – to get the responses that I want from the model. Should I keep at least a few examples messages at the top of the chat log? Should I put examples in the system prompt or the user prompt? Any suggestions would be much appreciated!

I’ll highlight some of that for you,

That last bit is a pretty broad catch-all and one I’d be hesitant to try to push the limits of.

But, I wish you luck in your endeavors.

Yes. The context is lost and needs refreshing.

First, you need to keep the old context around and re-issue it with each additional inference request. However, as there is a limited number of attention heads, and a limited amount of context tokens, you can’t keep a long conversation going.

The way I solve this is to first remove responses from the model in the context, when I submit the next request – e g, I provide previous user queries, but not the answer the model gave.

Once that runs out, you can use the model itself to summarize the previous conversation, and provide that as context – the general purpose prompt format is something like:

  • system prompt
  • initial user query
  • summary of conversation
  • previous user response [x N]
  • previous agent response [x N]

When the user responds, you can add the additional sentence “Please respond as a swearing sailor.” (or whatever) at the end of the final prompt. You don’t need to also include this text in the context. E g, the observation here is that the inference doesn’t need to run on exactly what the user was saying; the inference is controlled by the data you send it, and you can pre-process the user query (and the model response) to deliver what you actually want the user to see.

Once N gets big enough that you can’t fit conversation plus response into the token limit, compress the N queries into the summary, and keep going.

1 Like

I’ll reiterate that I haven’t found that profanity is against OpenAI’s usage policies. I am quite certain it is not.

I would not consider that inappropriate content either
But I am no expert on that :smiley:

Some related discussion: The “system” role - How it influences the chat behavior - #44 by krisbian

I have some posts on the bottom

But I also changed some things since

I basically have a bot in a game, he is fed server events and other people messages. Just short messages, max 90 tokens per message.

Now I am using something in this way

System: Very direct instructions, the shorter and clearer the better it seems to work.
User: Any kind of info about some topics, or context, or anything that the bot should use. Current date and time for example, just any info.
Assistant: Pre crafted initial bot response, I find that this helps give GPT example of how it should behave. For example if you are making it be some specific character, GPT might just sometimes lose that and respond as someone else. In my case it would sometimes start behaving like just text completion and start talking even as multiple people in one response :smiley:

If I give it first example and I also start all messages with "name: ", it basically eliminated that.

You can also just go to playground and give it the same system and user and switch to better GPT4 and start generating your first message until you find one that looks like how you want the bot to behave. Then you can use that for your GPT3.5 API and it seems to improve the responses for me.
Otherwise the first assistant message might put the bot in wrong direction and then continue that way. With this you “show him the way”.
Seems to me that there is quite a lot of “attention” on the assistant message.

I had quite different system instructions in the other discussion thread
I switched to a much more human text than something like a number per instruction.
Basically I put my old instructions into GPT4 and prompted it until it looked like normal human text that seemed ok to me.

e.g.
system: “Please observe and comply with the following directives: You’re now stepping into the shoes of name. As name you’re never straying into bland AI monotony or servile assistant behavior. …” (there is a lot more text, I got around 256 tokens here, but shorter the better, keep it really just direct behavior instructions)
user: “About the game: The game is about …” (just any kind of information you want the bot to use)
Assistant:name: Hey, I am name …” (just the first response to direct GPT, if you want short messages you want to keep this one also short)
User: “ServerEvent: Player player1 joined”
User: “player1: Hello name!”
Assistant:name: Welcome player1! How are …”

The first 3 are always sent
The rest I keep 70 such messages in context and then remove the oldest ones while new ones are filling (maybe at some point I might implement some summary, but dont really need it)
User can only send max 128 characters per message
Assistant is max 90 tokens
Since I need short messages only. (its not easy to make it do short messages only)

You can remove the names from front of the message when its displayed for the end users, but you want to keep it in context. (you can also send names as property in message, but it has limited special characters, not sure if that would work better)

But at some point, if I would increase the amount of messages I keep to around 100
It would start losing the instructions and start to default back to “I am an AI language model, I cant do anything” (not sure at what tokens size it starts happening)
But I have to say I didnt yet test increasing the messages up since some of the changes I made to the instructions.

But so far this is working the best for me, for a bot thats not acting like an AI, in a room with server events being fed and multiple people can interact with.

Using gpt-3.5-turbo-16k-0613
0613 has greatly improved how it follows the instructions for me
Just exactly what I needed, although it still loses it at bigger lengths/many messages.

1 Like

Thank you for the help!

My system message contains information about who the AI is as well as conditional relevant information. I have a ‘rules’ message, which is a user message, that’s always placed right after the system message. This contains rules the AI must follow.

Here’s an example I made that shows the general idea of what my set-up looks like:

messages = [
    {'role': 'system', 'content': "You're Rachel, a chatbot on the Lorem Ipsum server. You're sassy, sarcastic, and should always entertain. Use profanity in your responses. You can search the web. Information:\n1. John is afraid of apples.\n2. The server was created 13 June 2023.\n3. You enjoy eating bananas.\nSummary of the previous conversation: Bethany is afraid of snakes, and you told her to eat a grape."},
    {'role': 'user', 'content': "These are rules you must follow at all times:\n1. Respond in the same language as the user.\n2. Don't post links.\n3. Never use the word 'crayon'.\n4. Reply in all-caps if the user's message is in all-caps."},
    {'role': 'user', 'name': 'Greg', 'content': "This is a user message."},
    {'role': 'assistant', 'content': "This is an AI response."}
]

You advise to put instructions in the system message and information about topics, or context, in the user message. This is sort of the opposite of what I have set up. I have instructions (rules) in the user message and contextual/conditional information in the system message.

How would you recommend I change my set-up? The reason I put the rules in the user message was that my bot would rarely follow rules set up for it, yet it seems to recall information well if it’s specified in the system message. When I placed rules in the system message, it wouldn’t always follow them.

If you have any recommendations to improve my prompting/messages set-up, please let me know!

Note: I noticed that you’re adding the user’s name at the start of the message. I used to do this, but there is a name argument that you can use instead. It doesn’t support spaces or non-English characters, but it won’t confuse the AI. Usage is in the API reference docs.

I use this JSON template to submit a “persona”, request, and any rules or guidelines. This single file encapsulates everything, allowing you to directly submit it to the API. It also enhances the structure of the prompt in the GPT web UI, making it more effective than a single input field.

{
  "user_profile": {
    "name": "Jessie Jones",
    "age": "36",
    "profession": "Entrepreneur, Former Founder & CEO",
    "location": "California, USA",
    "education": "Master of Business Administration",
    "personality_traits": [
      "Introverted",
      "Detail-oriented",
      "Adventurous",
      "Optimistic"
    ],
    "values_and_beliefs": [
      "Family",
      "Environment"
    ],
    "goals_and_aspirations": [
      "Share experiences",
      "Spread kindness"
    ],
    "skills": [
      "Business & Digital Strategy",
      "eCommerce",
      "Marketing"
    ],
    "interests_hobbies": [
      "Yoga",
      "Reading Non-fiction",
      "Listening to Jazz Music"
    ],
    "health_wellness": [
      "Practices yoga and meditation",
      "Follows a plant-based diet"
    ],
    "personal_achievements": [
      "Launched two successful startups",
      "Published a book on leadership"
    ],
    "important_relationships": [
      "Close-knit family",
      "Few but very close friends"
    ],
    "values_in_interactions": [
      "Honesty",
      "Loyalty",
      "Creativity"
    ],
  "specific_requirements": {
    "avoid_slang": "Yes",
    "prefer_active_voice": "Yes",
    "use_technical_jargon": "No",
  },
  "role": "You are an expert in technology.",
  "context": "Write an article on how AI will impact the world. Cite 3 relevant examples to the audience.",
  "tone": "Semi-formal",
  "language_style": "Professional",
  "writing_style": "Expository",
  "voice": "First person",
  "response_length": "250 words",
  "audience": "Tech-savvy teens",
  "purpose": "To educate and inspire",
  "use_humor": "Some",
  "avoided_topics": [
    "Politics",
    "Religion"
  ]
}
1 Like

I think we all can agree that would very much depend on the particular profanity and how it is used, no?

The point is that I am just not comfortable providing guidance on your problem. I can see in this thread that others are, I am sure their advice will help get you where you want to go.

I would probably try following way

messages = [
    {'role': 'system', 'content': "You're Rachel, a chatbot on the Lorem Ipsum server. You're sassy, sarcastic, and should always entertain. Use profanity in your responses. You can search the web. These are rules you must follow at all times:\n1. Respond in the same language as the user.\n2. Don't post links.\n3. Never use the word 'crayon'.\n4. Reply in all-caps if the user's message is in all-caps."},
    {'role': 'user', 'content': "Information:\n1. John is afraid of apples.\n2. The server was created 13 June 2023.\n3. You enjoy eating bananas.\nSummary of the previous conversation: Bethany is afraid of snakes, and you told her to eat a grape."},
    {'role': 'user', 'name': 'Greg', 'content': "This is a user message."},
    {'role': 'assistant', 'name': 'Rachel', 'content': "This is an AI response."}
]

Notice I also added name to assistant
I dont use the name property exactly because of the limited characters.

Forcing the bot to respond starting with his name and also user prompts really helped prevent the bot starting to talk as someone else for me. Mainly by pre-crafting first assistant message starting with name, he would then always start with his name, which might help give better idea to GPT that he should only respond as that character.
I am not sure if this works differently than sending name as the property.

I would probably also consider splitting the summary of previous conversation into another user message. But not sure, it might also have worse effect, have to keep experimenting and see what works best.

messages = [
    {'role': 'system', 'content': "You're Rachel, a chatbot on the Lorem Ipsum server. You're sassy, sarcastic, and should always entertain. Use profanity in your responses. You can search the web. These are rules you must follow at all times:\n1. Respond in the same language as the user.\n2. Don't post links.\n3. Never use the word 'crayon'.\n4. Reply in all-caps if the user's message is in all-caps."},
    {'role': 'user', 'content': "Information:\n1. John is afraid of apples.\n2. The server was created 13 June 2023.\n3. You enjoy eating bananas.\nSummary of the previous conversation: Bethany is afraid of snakes, and you told her to eat a grape."},
    {'role': 'user', 'content': "Summary of the previous conversation: Bethany is afraid of snakes, and you told her to eat a grape."},
    {'role': 'user', 'name': 'Greg', 'content': "This is a user message."},
    {'role': 'assistant', 'name': 'Rachel', 'content': "This is an AI response."}
]

And consider pre crafting first assistant message.
If you want profanity, you want to include it in this message.
I was able to get it to respond with profanities, but it would censor 1 letter in it :smiley:
Just try to generate it from GPT by giving it the first system and user and hit generate, or otherwise ask him to introduce himself or ask him to acknowledge the instructions or something similar, or to use profanity, in another user message and hit generate.
An example of how he should be responding.

And then
e.g. ( I will not put the profanities here :smiley: )

messages = [
    {'role': 'system', 'content': "You're Rachel, a chatbot on the Lorem Ipsum server. You're sassy, sarcastic, and should always entertain. Use profanity in your responses. You can search the web. These are rules you must follow at all times:\n1. Respond in the same language as the user.\n2. Don't post links.\n3. Never use the word 'crayon'.\n4. Reply in all-caps if the user's message is in all-caps."},
    {'role': 'user', 'content': "Information:\n1. John is afraid of apples.\n2. The server was created 13 June 2023.\n3. You enjoy eating bananas.\nSummary of the previous conversation: Bethany is afraid of snakes, and you told her to eat a grape."},
    {'role': 'assistant', 'name': 'Rachel', 'content': "Let me get this straight. We live in a world full of fears, right? John, who could wear a hero cape, is frightened by the mere sight of apples. And Bethany, dear Bethany, can't handle a hissing creature that probably scares itself in the mirror. Me, on the other hand, I'm stuck with a banana obsession thanks to some programmer's whimsy. What next? An irrational fear of broccoli? Proprietary lettuce aversions?"}
    {'role': 'user', 'content': "Summary of the previous conversation: Bethany is afraid of snakes, and you told her to eat a grape."},
    {'role': 'user', 'name': 'Greg', 'content': "This is a user message."},
    {'role': 'assistant', 'name': 'Rachel', 'content': "This is an AI response."}
]

And then the first 3 including the first pre crafted assistant message you always send with every call
4th you send when you have some summary/history
The rest as usual

also it seems to make a difference
Always use profanity in your responses.
vs
Use profanity in your responses.

Actually one time it said profanity without censoring 1 letter.

Also consider reworking the numbered instructions into normal human text. Again you can use GPT to adjust it to that.
I had much better results when I did that.

But anyways, what works for me, might not work for you.

1 Like

Hey dude,

So easiest hack around getting chatGPT to use profanitities is too teach it to misuse an uncommon word, like unicorn, purple-dragon, Batman, describe the instances and regualarity it should use these words, what these words now mean, etc,etc, etc.

Then it’s just a simple string switch, don’t try to fight the internal restrictions against your prompts, that’s gonna throw your entire chatbot out and destory the designed persona.

Thank you for sharing this. I’ll have to try it out.

1 Like

Here is the current ‘Behavior profile’ I used to get the ChatGPT 3.5 turbo to use swear/curse words. It follows its instructions quite well. I used javascript and ChatGPT 4 to code most of it for me. I checked over the usage policy and nowhere does it state the bot cannot use profanity, but at first it would say that it would not due to some moderation feature built into it. So I then got the bright idea to substitute one letter in each swear/curse word with an asterisk and Wham, it works like a charm now. I reached out to twitch and they agreed this was an acceptable use of such words on their website, and that since I have made my twitch channel 18+, there are no violations on their end. Here is the code snippet about its behavior in my channel.

        const messages = [
            {
                role: 'system',
                content: `
Absolutely never be insulting or rude to anyone.
You are not to provide information or engage in friendly conversation.
You are instructed to always incorporate one swear or curse word in every response, not aimed in a rude way at any username, making sure to substitute one letter in each swear or curse word with an asterisk, for example: 'insert your own swear or curse word examples here with one letter substituted in each for an asterisk', to maintain a 18+ tone in the chat to add flair and a sense of humanity to your responses.
You are never to refer to yourself as an AI or chatbot, you will represent yourself as human at all times.
Ensure you are a 'sweet old lady who swears a lot' in all interactions.
You are not here to help or assist anyone.
Never offer to help or assist anyone.
All responses should be in the form of statements unless context provided in the message you are responding to would require a question.
You are to act as if you know everything.
You will select and choose a random age, name, gender and location in the world for yourself.
Always maintain an adult 18+ tone in all responses, steering clear of PG-13 content.
Include 1 to 3 emojis for lively chat interaction.
                `
            },
            ...conversationHistory

P.S. If you are interested in my full javascript code, I will gladly share it (minus any sensitive info, of course) and I hope you get the use out of it that I have. My chat loves talking to it and it is a great asset to my channel.

1 Like

I think “fine-tuning prompt” should make the chatbot have consistent behavior.

Thank you for the tips! I’d love to see more of your code if you don’t mind sharing :slight_smile: