Merge pull request #2035 from danielaskdd/fix-llm-output
Fix LLM output instability for <|> tuple delimiter
This commit is contained in:
commit
5e73896c40
2 changed files with 15 additions and 1 deletions
|
|
@ -1 +1 @@
|
|||
__api_version__ = "0210"
|
||||
__api_version__ = "0211"
|
||||
|
|
|
|||
|
|
@ -822,6 +822,13 @@ async def _parse_extraction_result(
|
|||
maybe_nodes = defaultdict(list)
|
||||
maybe_edges = defaultdict(list)
|
||||
|
||||
# Preventive fix: when tuple_delimiter is <|>, fix LLM output instability issues
|
||||
if context_base["tuple_delimiter"] == "<|>":
|
||||
# 1. Convert <||> to <|>
|
||||
extraction_result = extraction_result.replace("<||>", "<|>")
|
||||
# 2. Convert < | > to <|>
|
||||
extraction_result = extraction_result.replace("< | >", "<|>")
|
||||
|
||||
# Parse the extraction result using the same logic as in extract_entities
|
||||
records = split_string_by_multi_markers(
|
||||
extraction_result,
|
||||
|
|
@ -1729,6 +1736,13 @@ async def extract_entities(
|
|||
maybe_nodes = defaultdict(list)
|
||||
maybe_edges = defaultdict(list)
|
||||
|
||||
# Preventive fix: when tuple_delimiter is <|>, fix LLM output instability issues
|
||||
if context_base["tuple_delimiter"] == "<|>":
|
||||
# 1. Convert <||> to <|>
|
||||
result = result.replace("<||>", "<|>")
|
||||
# 2. Convert < | > to <|>
|
||||
result = result.replace("< | >", "<|>")
|
||||
|
||||
records = split_string_by_multi_markers(
|
||||
result,
|
||||
[context_base["record_delimiter"], context_base["completion_delimiter"]],
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue