How to forbade Gemma 2 from using a certain phrase and use another one in its place?

I am building a Rag chat bot using Gemma 27B with temperature 0.1 for an HR team that answers questions based on some documents.

The thing is the HR team has a name let’s say “Division Alpha” . So sometimes when the bot answers the question it says something along the lines - >for further info contact your human resources team | or some different phrases that are not part of the documents that are not wrong yet include human resources . How to make it say for further information contact Division Alpha and never to use human resources or HR?

In the training documents the words human resources are not mentioned and only Division Alpha is.

I have put in the instructions :"when you are about to say human resources swap it for “Division Alpha”. And in the system prompt “Never say/You are forbidden to say human resource or HR when you are about to say it say Division Alpha”.

Both don’t seem to work at all. What can I do?

1 Like

When using parts for RAG, or when you want the output to be relatively consistent, I think the only option is to post-process, excluding fine-tuning. Also, Gemma’s system prompt behavior may be a bit unstable.

I tried to post process but I get the message as a stream in syllables so it is hard to replace resources then the output is re-sour-ces. So post process is almost out the table my only hope are the prompts

1 Like

If post-processing is not feasible, then the only options are prompt engineering, changing the model, or fine-tuning the model…

If we go with prompt engineering, would it be something like this?

SYSTEM PROMPT:
You are a chatbot for Division Alpha. Your task is to answer questions based on provided documents. 

RULES:
- Never use the phrases "human resources" or "HR".
- Always replace them with "Division Alpha".
- If unsure, respond with "For further information, contact Division Alpha".

EXAMPLE:
User: Who should I contact for benefits?
Bad response: Contact HR.
Good response: Contact Division Alpha.

Thanks. If not in the system prompt how can I put something similar in the instruction as I believe it follows it more than the prompt.

Also is it possible to change the weights so it avoids the words human and resources e.g generates them with less frequency.

1 Like

to change the weights so it avoids the words human and resources e.g generates them with less frequency.

I think this can be done with fine-tuning. For example, a function to reject adult topics could be implemented in this way. However, I think there are cases where the problem can be solved by replacing the model itself with another one of similar size, so I recommend searching for a good model first.

In general is my understanding correct that Gemma models follow instruction and not sys prompt that much if yes how can I structure a long instruction if not how to use both for example in the system prompt I have told the not when you can’t get info in your training (Rag) knowledge set :if you don’t have context or knowledge start your answer with “I will base this on my general knowledge” , but now I deleted this whole line in the sys prompt it says - I don’t have context can you give me some can I still keep this in the sys prompt but in the instruct say to not say it (to not say based on my general knowledge despite this sentence being in the sys prompt as removing it from there seems to make things worse)

1 Like

Or rather, I suspect it might be an issue with the initial weights of Gemma 2 or a bug in the Hugging Face implementation. For example, there’s a pre-trained model called SystemGemma based on Gemma 2.

Additionally, based on my experience, the 2B and 9B models of Gemma 2 when used with Llama.cpp are highly faithful to the system prompt. This makes me think something is off. I haven’t tried the 27B model yet.

As for models with similar sizes but fewer quirks, there’s Qwen 2.5 32B Coder. QwQ is also excellent, but it’s a reasoning model, so it’s full of quirks. If you’re looking for more diverse models, you can search by size on the leaderboard.