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
444
444
class AnswerLengthEvaluator:
445
445
def __init__ (self ):
446
446
pass
447
-
447
+ # A class is made a callable my implementing the special method __call__
448
448
def __call__ (self , * , answer: str , ** kwargs):
449
449
return {" answer_length" : len (answer)}
450
450
```
451
451
452
452
Then run the evaluator on a row of data by importing a callable class :
453
453
454
454
```python
455
- with open (" answer_len/answer_length.py" ) as fin:
456
- print (fin.read())
457
-
458
455
from answer_len.answer_length import AnswerLengthEvaluator
459
456
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?" )
461
459
462
460
print (answer_length)
463
461
```
You can’t perform that action at this time.
0 commit comments