The default locale detector agent has conflicting instructions

I’ve not seen this cause trouble, but it seems like this would be good to clean up:

You will be given a piece of text, and your task is to detect the locale (language) of the text and return it in a specific JSON format.

Your response must be a language code, and nothing else. Do not wrap your response in quotes or any other characters.

1 like

I can confirm it in specific models I tried; it did not always fail, but it failed with specific texts.

I will try your adjustment. Thanks for sharing it!

1 like

I am seeing it get confused with non-language locale things. For example, I speak Spanish, live in CDMX Mexico, use Mex$, and I prefer to use commas to separate decimal place.

We’re trialing a prompt like this now:

You will be given a piece of text, and your task is to determine its language.

To complete this task, follow these steps:

1. Carefully read and analyze the provided text.
2. Determine the language of the text based on its characteristics, such as vocabulary, grammar, and sentence structure.
3. Do not use links or programming code in the text to detect the locale.
4. Identify the appropriate language code for the detected language.

Here is a list of common language codes for reference:
- English: en
- Spanish: es
- French: fr
- German: de
- Italian: it
- Brazilian Portuguese: pt-BR
- Russian: ru
- Simplified Chinese: zh-CN
- Japanese: ja
- Korean: ko

If the language is not in this list, use the appropriate IETF language tag code.

5. Avoid using `und` and prefer `en` over the regional variants `en-US` or `en-GB`.

Important: Base your analysis solely on the provided text. Do not use any external information or make assumptions about the text's origin or context. Do not be confused by names of places or languages; this is about the language of the text itself, not what it's talking about.

Your response must be a language code, and nothing else. Do not wrap your response in quotes or any other characters.

Some background about that last line is here, it avoids the LLM using quotes or backticks that it found in the instruction in its response.

What was happening was that some LLMs were taking this too literally

 5. Avoid using `und` and prefer `en` over `en-US` or `en-GB` unless the text specifically indicates a regional variant.

          Two example scenarios:
          Input: "Can you tell me what '私の世界で一番好きな食べ物はちらし丼です' means?"
          Output: "en"

and responded with

"en"

or

`en`

instead of

en