Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,35 @@ def __init__(self):
super().__init__()

def answers_similar(self, a: str, b: str) -> bool:
# TODO
# @Alex: You can access the inference engine via:
# self.inference_engine
print("TODO: Embedding-based Answer similarity check not implemented")
return False
system_message = "You are an expert in determining if two answers are semantically similar."
user_prompt = f"""
Please compare the following two answers:
<answer_a>
{a}
</answer_a>
<answer_b>
{b}
</answer_b>
Are these two answers semantically similar?
IMPORTANT: Respond ONLY with "SIMILAR" or "DIFFERENT".
"""
try:
response = self.inference_engine.create(
output_format=system_message,
prompt=user_prompt,
)
# Extract the last line for the final decision
response_lines = response.strip().split('\n')
final_decision = response_lines[-1].strip().upper()


if "SIMILAR" in final_decision:
return True
elif "DIFFERENT" in final_decision:
return False
else:
print(f"LLM similarity check returned unexpected final decision: '{final_decision}' in response: '{response}'. Defaulting to False.")
return False
except Exception as e:
print(f"Error during LLM similarity check: {e}. Defaulting to False.")
return False
Loading