Performance: LangSmith evaluators
LangSmith evaluators impact the speed and responsiveness of language model evaluation processes, affecting how quickly results are available after input.
Jump into concepts and practice - no test required
import asyncio async def evaluate_output_async(output): # Run evaluation asynchronously result = await async_complex_metric(output) return result # Called with async handling score = await evaluate_output_async(user_response)
def evaluate_output(output): # Heavy synchronous evaluation result = complex_metric_calculation(output) return result # Called directly during user interaction score = evaluate_output(user_response)
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Synchronous evaluation on main thread | Minimal | 0 | Blocks paint during evaluation | [X] Bad |
| Asynchronous evaluation with async/await | Minimal | 0 | Non-blocking paint, smooth UI | [OK] Good |
evaluator = SomeEvaluator() prediction = "The sky is blue." reference = "The sky is clear and blue." result = evaluator.evaluate(prediction, reference) print(result)
print(result)?evaluator = SomeEvaluator() result = evaluator.evaluate(reference, prediction) print(result)
evaluate expects (prediction, reference) order.