Rule-based evaluation dimensions use algorithms to directly compute scores without a judge model, supporting both string matching and text similarity, making them the lowest-cost evaluation method.
Rule-based evaluation overview
Rule-based evaluation uses algorithms to directly compute scores without a judge model, incurs no scoring costs, and is the fastest and lowest-cost evaluation method:
- Rule-based evaluation - string matching: Programmatically determines the exact match relationship (Equal/Not Equal/Include) between the model output and the reference text. Suitable for scenarios with deterministic standard answers, such as Function Calling and NL2SQL.
- Rule-based evaluation - text similarity: Uses algorithms to compute the similarity between the model output and the reference text (BLEU/ROUGE/cosine, etc.). Suitable for quantifying the similarity of open-ended answers, such as translation, summarization, and rewriting.
Create a rule-based evaluation dimension
Log on to the Model Studio console, select Model Evaluation in the left navigation pane, switch to the Dimension tab, and click Create Evaluation Dimension to open the selection dialog: In the preset templates list, you can filter by type and tag (text matching, text similarity; 28 in total, see the list below) and click Use template on a template card to apply it in one click; or click + Create custom evaluation dimension to go to the custom configuration page.
After filling in the common fields (dimension name up to 20 characters, description up to 100 characters, and the type cannot be changed after creation), complete the configuration as follows:
- String matching
- Text similarity
- Configure the Evaluation Input (left side): Enter the reference text. You can use variables to reference evaluation data.
- Select a comparison operator: Equal (passes when the output is exactly the same as the reference), Not Equal (passes when they are inconsistent), or Include (passes when the output contains the reference text).
- Configure the Model Output (right side): Enter the text to match. You can use variables. At least one of the evaluation input and model output must contain a variable.
- Click Save.
Rule-based evaluation preset templates
Rule-based evaluation provides 28 preset templates, divided by tag into two categories: text similarity (14) and text matching (14). In the Create Evaluation Dimension dialog, filter by tag and click Use template to apply one. The list is dynamically fetched from the system configuration.
Text similarity preset templates (14):
- ROUGE-1/2/3/4/5 algorithm: Computes similarity based on 1~5 gram (n-gram) overlap.
- ROUGE-L algorithm: Based on the longest common subsequence (LCS); commonly used for text summarization evaluation.
- BLEU algorithm: Based on n-gram precision and brevity penalty; commonly used for machine translation evaluation.
- Sentence BLEU algorithm: Sentence-level BLEU, optimized for single-sentence evaluation.
- GLEU algorithm: An improved version of BLEU, more stable for sentence-level evaluation.
- Cosine algorithm: Computes cosine similarity based on TF-IDF vectorization.
- Jaccard algorithm: Based on the ratio of the intersection to the union of word sets.
- F1 algorithm: Token-level precision and recall; supports mixed Chinese-English text.
- Levenshtein algorithm: Based on the Levenshtein distance; suitable for spelling correction and approximate string matching.
- Edit distance algorithm: Returns a similarity score after normalizing the edit distance.
- Exact match: The text to evaluate is exactly the same as the reference text.
- Substring match: The text to evaluate contains the reference text as a substring.
- Prefix match/Suffix match: The text to evaluate starts/ends with the reference text.
- Contains all substrings/Contains any substring: The text to evaluate contains all/any of the specified substrings.
- Regex match: Matches by regular expression pattern.
- Word overlap rate/Character overlap rate: Word-level/character-level overlap rate.
- Numeric accuracy: Checks whether the numbers in the response are accurate within a tolerance range.
- JSON format validation/JSON content match: Validates the legality of the JSON format/deeply compares JSON key-value content.
- Reasoning format validation/Reasoning tool format validation: Validates the format compliance of the reasoning process and tool-call JSON.
Similarity algorithm selection
Select an appropriate similarity algorithm based on the evaluation task type:
- Translation tasks: BLEU (measures n-gram exact match).
- Summarization tasks: ROUGE-L (measures the longest common subsequence).
- Semantic relevance: cosine similarity (measures semantic vector distance).
- Classification tasks: Accuracy (measures the exact match rate).
- OCR and speech recognition: fuzzy match (Fuzzy Match).
FAQ
Issue: The scores of the rule-based evaluation dimension are inaccurate.
Issue: The scores of the rule-based evaluation dimension are inaccurate.
Rule-based evaluation compares literally or by algorithm and cannot understand semantically equivalent expressions. If the model output is semantically consistent with the reference answer but differs in wording, causing a misjudgment, we recommend switching to a text similarity algorithm to accommodate wording differences, or using LLM evaluation to have a judge model evaluate at the semantic level.