triples_str = "\n".join([f"({h}, {r}, {t})" for h, r, t in triples])
prompt = f"{icl_sys_prompt}\n\n" + \
"Example Input:\n" + icl_user_prompt + "\n" + \
"Example Output:\n" + icl_ass_prompt + "\n\n" + \
"Current Input:\n" + \
"Triplets:\n" + triples_str + "\n" + \
"Question: " + sample_info['question'] + "\n" + \
"Please provide your answer in the same format as the example.If you cannot get the answer from the provided triples, please answer based on your own knowledge."
prompts.append(prompt)
sample_ids.append(sample_id)
outputs = llm.generate(prompts, sampling_params)
all_natural_language_triples = []
for output in outputs:
text = output.outputs[0].text.strip()
answers = [line.strip() for line in text.split('\n') if line.strip().startswith('ans:')]
麻烦提供完整测试代码