Overview
The Language Detection evaluator classifies the primary natural language of a conversation session. It chooses the language that carries the most substantive content — even when that share is below half — then maps it to a fixed label set. Supported labels areenglish, mandarin_chinese, hindi, spanish, french, arabic, portuguese, russian, japanese, german, korean, italian, indonesian, bengali, and turkish, plus mixed and other. mixed applies when several languages are approximately equally prevalent and none clearly predominates. other covers a predominant language outside the supported list, and sessions that contain no identifiable natural language.
The evaluator is descriptive. It records which language is primary. It does not judge whether that language was correct, expected, or consistent between the user and the assistant.
Supported Levels
Relevant span kinds: AGENT, CHAIN, and LLM spans that preserve the conversation between the user and the assistant. Leave tool calls, tool results, and retrieved text out of the input.
Input Requirements
Pass both parties. Leave out tool calls, tool results, and retrieved documents. Natural-language prose inside comments counts. Code, JSON, markup, proper nouns, and lone loanwords do not decide the language on their own.
Output Interpretation
The evaluator returns aScore with one label:
Read
label. score is None.
Usage Examples
- Python
- TypeScript
Using a Decision Model
The same evaluator can be backed by a decision model instead of a language model. A decision model picks a label directly and returns per-label probabilities (and a confidence when the provider reports one) but no explanation.- Python
- TypeScript
Viewing and Modifying the Prompt
The default prompt is maintained in the classification evaluator config.- Python
- TypeScript
Configuration
For model and provider options, see Configuring the LLM.Using with Phoenix
Benchmarks
On a 47-example synthetic benchmark overriding EVAL_MODEL=gpt-4o, the default prompt achieves 0.96 accuracy, 0.97 macro precision, 0.95 macro recall, and 0.95 macro F1. See language_detection.eval.ts for the categorized example set. On 50 passages sampled from candradhipa/Language-Detection — 10 each of English, French, Spanish, and Hindi; one each of Portuguese, Italian, Russian, Arabic, Turkish, and German; and one each of Swedish, Dutch, Greek, and Tamil (reported asother) — the same model and prompt achieve 1.00 accuracy, 1.00 macro precision, 1.00 macro recall, and 1.00 macro F1. That dataset has no Mandarin. See language_detection_candradhipa.eval.ts.
API Reference
- Python: LanguageDetectionEvaluator
- TypeScript: createLanguageDetectionEvaluator

