Bird
0
0

Which of the following is the correct syntax to define a custom evaluation metric class in Langchain?

easy📝 Syntax Q3 of 15
LangChain - Evaluation and Testing
Which of the following is the correct syntax to define a custom evaluation metric class in Langchain?
Aclass MyMetric():\n def train(self):\n pass
Bclass MyMetric(BaseEvalMetric):\n def evaluate(self, predictions, references):\n return score
Cdef MyMetric():\n return score
Ddef evaluate_metric(predictions, references):\n return score
Step-by-Step Solution
Solution:
  1. Step 1: Recognize class-based metric definition

    Custom metrics in Langchain are classes inheriting from a base metric class.
  2. Step 2: Check for evaluate method with correct parameters

    The evaluate method must accept predictions and references and return a score.
  3. Final Answer:

    class MyMetric(BaseEvalMetric):\n def evaluate(self, predictions, references):\n return score -> Option B
  4. Quick Check:

    Correct syntax = Class with evaluate method [OK]
Quick Trick: Define class with evaluate(predictions, references) method [OK]
Common Mistakes:
MISTAKES
  • Using functions instead of classes
  • Missing evaluate method
  • Defining unrelated methods like train

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LangChain Quizzes