def convert_example_to_cands(rec):
  """Generate candidate completions for each example."""
  cand_size = 25
  example_list = []
  text = rec["passage"]["text"]
  text_clean = text.replace("@highlight", " ")
  ent_set = set()
  for ent in rec["passage"]["entities"]:
    ent_str = text[ent["start"]:ent["end"] + 1]
    ent_set.add(ent_str.lower())
  for qa in rec["qas"]:
    question = qa["query"]
    answers = set([q["text"].lower() for q in qa["answers"]])

    # incorrect ents
    neg_ents = [ent for ent in ent_set if ent not in answers]
    completions = []
    completions.append(create_completion(question, list(answers)[0]))
    completions.extend([
        create_completion(question, neg_ent)
        for neg_ent in neg_ents[:cand_size - 1]
    ])
    example_list.append(Example(text_clean, completions))
  return example_list
Generate candidate completions for each example.
language/conpono/evals/model_builder.py