File tree Expand file tree Collapse file tree 1 file changed +3
-5
lines changed
articles/ai-studio/how-to/develop Expand file tree Collapse file tree 1 file changed +3
-5
lines changed Original file line number Diff line number Diff line change @@ -444,20 +444,18 @@ Sometimes a large language model isn't needed for certain evaluation metrics. Th
444444class AnswerLengthEvaluator:
445445 def __init__ (self ):
446446 pass
447-
447+ # A class is made a callable my implementing the special method __call__
448448 def __call__ (self , * , answer: str , ** kwargs):
449449 return {" answer_length" : len (answer)}
450450```
451451
452452Then run the evaluator on a row of data by importing a callable class :
453453
454454```python
455- with open (" answer_len/answer_length.py" ) as fin:
456- print (fin.read())
457-
458455from answer_len.answer_length import AnswerLengthEvaluator
459456
460- answer_length = AnswerLengthEvaluator()(answer = " What is the speed of light?" )
457+ answer_length_evaluator = AnswerLengthEvaluator()
458+ answer_length = answer_length_evaluator(answer = " What is the speed of light?" )
461459
462460print (answer_length)
463461```
You can’t perform that action at this time.
0 commit comments