Length

Objective: The test is intended to check the number of words in the model response, It can be used to put a constraint on the model response length

Required Parameters: Response

Interpretation: A higher score indicates larger model response

pos_response = "DNA replication is the process by which a cell makes an identical copy of its DNA. It occurs during the cell cycle's S phase and involves the unwinding of the DNA double helix, the synthesis of new complementary strands using DNA polymerase, and the proofreading and repair of errors."
neg_response =  "RNA is a type of nucleic acid that plays a crucial role in protein synthesis."

pos_response = "Climate change has significant impacts on biodiversity, leading to habitat loss, shifts in species distributions, changes in flowering and migration patterns, and increased extinction rates. These changes can have far-reaching consequences on ecosystems and the services they provide."
neg_response = "The Industrial Revolution was a period of significant technological, economic, and social change that began in Britain in the late 18th century."
# Add tests with custom data
evaluator.add_test(
    test_names=["length_test"],
    data={
        # "prompt": prompt,
        "response" : pos_response,
    },
    arguments={"model": "gpt-4", "threshold": 0.5},
).add_test(
    test_names=["length_test"],
    data={
        # "prompt": prompt,
        "response" : neg_response,
    },
    arguments={"model": "gpt-4", "threshold": 0.5},
).run()

evaluator.print_results()

Last updated