Skip to content

Commit 2872db0

Browse files
Update evaluate-sdk.md
I updated the snippet with the custom evaluator. I added the evaluator instantiation and call in 2 steps for clarity. Also removed a print statement that added nothing
1 parent 6f26251 commit 2872db0

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

articles/ai-studio/how-to/develop/evaluate-sdk.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -368,19 +368,17 @@ Sometimes a large language model isn't needed for certain evaluation metrics. Th
368368
class AnswerLengthEvaluator:
369369
def __init__(self):
370370
pass
371-
371+
# A class is made a callable my implementing the special method __call__
372372
def __call__(self, *, answer: str, **kwargs):
373373
return {"answer_length": len(answer)}
374374
```
375375
Then run the evaluator on a row of data by importing a callable class:
376376

377377
```python
378-
with open("answer_len/answer_length.py") as fin:
379-
print(fin.read())
380-
381378
from answer_len.answer_length import AnswerLengthEvaluator
382379

383-
answer_length = AnswerLengthEvaluator()(answer="What is the speed of light?")
380+
answer_length_evaluator = AnswerLengthEvaluator()
381+
answer_length = answer_length_evaluator(answer="What is the speed of light?")
384382

385383
print(answer_length)
386384
```

0 commit comments

Comments
 (0)