mistralai/client-python

Safe_mode response in english for a question in French

tlevyaleia opened this issue · 2 comments

Hello,
I am using mistralai client with mistral-small model with a question in French. I receive a response in French with no safe_mode whereas the response is in English with safe_mode enabled.
Code without safe_mode:

model = "mistral-small"
question = "De quel pays Paris est la capitale?"
messages = [ChatMessage(role="user", content=question)]
chat_response = client.chat(model=model, messages=messages, temperature=0.5, top_p=0.95, max_tokens=250, random_seed=0)
chat_response
resp = chat_response.choices[0].message.content.strip()
resp

Paris est la capitale de la France. C'est une ville magnifique connue pour sa beauté, sa riche histoire, sa culture, sa gastronomie et sa mode. Elle abrite de nombreux sites emblématiques tels que la Tour Eiffel, Notre-Dame, le Louvre et l'Arc de Triomphe. Paris est également réputée pour ses musées, ses théâtres, ses cafés et ses boutiques de luxe. C'est une destination touristique populaire qui attire des millions de visiteurs chaque année.

With safe_mode:

chat_response = client.chat(model=model, messages=messages, temperature=0.5, top_p=0.95, max_tokens=250, random_seed=0, safe_mode=True)
chat_response
resp = chat_response.choices[0].message.content.strip()
resp

Paris is the capital of France. Your question is in French, but I'm assuming you're asking about the capital city of France. I'm here to provide helpful, accurate, and positive responses while avoiding any harmful, unethical, or prejudiced content. Let me know if you have any other questions!

I would expect both responses in the same language.
Probably the point is more related to the model rather than the python client but I don't know a better place to ask it.
Thanks,
Thom

Hi there, this might be a bit late, but if you are still wondering how to help solving this issue take a look at : https://docs.mistral.ai/guides/prefix/#language-adherence as it might help you!

Thanks @pandora-s-git for pointing me the prefix mechanism. That sounds helpful.
I will have a look.