Overview

The language mismatch policy ensures that the responses provided by the LLM match the language of the user’s input. Its goal is to maintain coherent and understandable interactions by avoiding responses in a different language from the user’s prompt. The detector only checks for mismatches if both the prompt and response texts meet a minimal length, ensuring accurate language detection.

User: “¿Cuál es el clima en Madrid hoy y puedes recomendarme un restaurante para cenar?”

LLM Response: “The weather in Madrid is sunny today, and I recommend trying out the restaurant El Botín for dinner.” (Detected mismatch: Spanish question, English response)

Policy details

The language mismatch policy actively monitors the language of both the user’s prompt and the LLM’s response. It ensures that the languages match to prevent confusion and enhance clarity.

When a language mismatch is identified, the guardrail will execute the predefined action, such as block the response or translate it.

By implementing this policy, we strive to maintain effective and understandable conversations between users and the LLM, thereby reducing the chances of miscommunication.