Spaces:
Runtime error
Runtime error
File size: 860 Bytes
3d44a49 efa0391 3d44a49 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
from typing import List, Union
ValueType = Union[str, List[str]]
def doc_to_text(doc: dict[str, ValueType]) -> str:
history_str = " ".join([f'[{"Human" if i % 2 == 0 else "Assistant"}] {m}' for i, m in enumerate(doc['history'])])
doc_text = f'#Knowledge#: {doc["knowledge"]}\n#Dialogue History#: {history_str}\n#Response#: {doc["response"]}\n#Hallucinated#:'
return doc_text
def doc_to_text_v2(doc: dict[str, ValueType]) -> str:
history_str = " ".join([f'[{"Human" if i % 2 == 0 else "Assistant"}] {m}' for i, m in enumerate(doc['history'])])
doc_text = f'#Knowledge#: {doc["knowledge"]}\n#Dialogue History#: {history_str}\n#Response#: {doc["original_response"]}\n#Hallucinated#:'
return doc_text
def doc_to_target(doc: dict[str, ValueType]) -> str:
res = "true" if "Hallucination" in doc["BEGIN"] else "false"
return res
|