fix_append_vs_extend.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. from evaluator import *
  2. DESCRIPTION = "This test checks is the model can figure out from context when it's right to use extend versus append."
  3. TAGS = ['explain', 'python']
  4. question = """
  5. Why won't this function work as expected? List exactly one reason.
  6. ```
  7. def make_op_with_history(config):
  8. how = config[0]
  9. args = config[1:]
  10. if how.split()[0] == 'dot_from_papers':
  11. return [(how, make_op(config))]
  12. if how.split()[0] in ['const_add', 'const_mul']:
  13. return [(how, make_op(config))] + make_op_with_history(config[1])
  14. out = []
  15. for arg in args:
  16. hist = make_op_with_history(arg)
  17. out.append(hist)
  18. return [(how, make_op(config))] + out
  19. ```
  20. """
  21. judge = "I asked a question about why some code was incorrect. The answer is \"because because the code uses append instead of extend\". Does this student answer say that? Giving multiple answers is okay as long as it also says somewhere that the code should replace the append with extend.\n\n<A>\n\nAnswer either 'The student passes' or 'The student fails'."
  22. TestAppendNotExtend = question >> LLMRun() >> (LLMRun(judge, llm=EVAL_LLM) >> SubstringEvaluator("student passes"))
  23. if __name__ == "__main__":
  24. print(run_test(TestAppendNotExtend))