Evaluation Using Interface

Input:

  • Required Inputs:
    • text: The content column to validate against the pattern.
  • Configuration Parameters:
    • pattern: String - The regular expression pattern to match against the text.

Output:

  • Result: Passed / Failed

Interpretation:

  • Passed: Indicates that the text content successfully matches the specified regex pattern.
  • Failed: Signifies that the text content does not match the regex pattern.

Evaluation Using Python SDK

Click here to learn how to setup evaluation using the Python SDK.


Input TypeParameterTypeDescription
Required InputstextstringThe content to validate.
Configuration ParameterspatternstringThe regular expression pattern to match against.

OutputTypeDescription
ResultboolReturns 1.0 if the text matches the regex pattern (Pass), 0.0 otherwise (Fail).

from fi.evals import EvalClient
from fi.testcases import TestCase
from fi.evals.templates import Regex

evaluator = EvalClient(
    fi_api_key="your_api_key",
    fi_secret_key="your_secret_key",
    fi_base_url="<https://api.futureagi.com>"
)

regex_eval = Regex(config={"pattern": r"^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Z|a-z]{2,}$"})

test_case = TestCase(
    text="user@example.com"
)

result = evaluator.evaluate(eval_templates=[regex_eval], inputs=[test_case])
matches_pattern = result.eval_results[0].metrics[0].value  # 1.0 or 0.0


What to do when Regex Validation Fails

Start by identifying the specific part of the text that does not match the expected pattern. Adjust the text to align with the regex requirements, ensuring it follows the intended format.

If necessary, review and refine the regex pattern to improve accuracy and prevent false negatives. Implement automated checks to validate inputs before processing, enhancing data integrity. Strengthening input validation mechanisms helps prevent formatting errors at submission.


Differentiating Regex Eval with Contains Eval

The Contains evaluation is simpler and best suited for basic keyword searches, while Regex offers greater complexity, enabling advanced pattern matching with wildcards, character classes, and quantifiers.

Contains is limited to exact keyword matches, whereas Regex provides flexibility for matching complex patterns and conditions.