Fix random seed usage and handle empty descriptions
This commit is contained in:
parent
1c16a1744c
commit
9fec8fd322
2 changed files with 15 additions and 3 deletions
|
|
@ -16,7 +16,6 @@ import json
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
random.seed(42)
|
|
||||||
|
|
||||||
|
|
||||||
async def answer_qa_instance(instance, context_provider, contexts_filename):
|
async def answer_qa_instance(instance, context_provider, contexts_filename):
|
||||||
|
|
@ -110,6 +109,7 @@ async def eval_on_QA_dataset(
|
||||||
dataset = load_qa_dataset(dataset_name_or_filename)
|
dataset = load_qa_dataset(dataset_name_or_filename)
|
||||||
context_provider = qa_context_providers[context_provider_name]
|
context_provider = qa_context_providers[context_provider_name]
|
||||||
eval_metrics = get_metrics(metric_name_list)
|
eval_metrics = get_metrics(metric_name_list)
|
||||||
|
random.seed(42)
|
||||||
instances = dataset if not num_samples else random.sample(dataset, num_samples)
|
instances = dataset if not num_samples else random.sample(dataset, num_samples)
|
||||||
|
|
||||||
contexts_filename = Path(out_path) / Path(
|
contexts_filename = Path(out_path) / Path(
|
||||||
|
|
|
||||||
|
|
@ -39,10 +39,22 @@ def _insight_to_string(triplet: tuple) -> str:
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
node1_name = node1["name"] if "name" in node1 else "N/A"
|
node1_name = node1["name"] if "name" in node1 else "N/A"
|
||||||
node1_description = node1["description"] if "description" in node1 else node1["text"]
|
node1_description = (
|
||||||
|
node1["description"]
|
||||||
|
if "description" in node1
|
||||||
|
else node1["text"]
|
||||||
|
if "text" in node1
|
||||||
|
else "N/A"
|
||||||
|
)
|
||||||
node1_string = f"name: {node1_name}, description: {node1_description}"
|
node1_string = f"name: {node1_name}, description: {node1_description}"
|
||||||
node2_name = node2["name"] if "name" in node2 else "N/A"
|
node2_name = node2["name"] if "name" in node2 else "N/A"
|
||||||
node2_description = node2["description"] if "description" in node2 else node2["text"]
|
node2_description = (
|
||||||
|
node2["description"]
|
||||||
|
if "description" in node2
|
||||||
|
else node2["text"]
|
||||||
|
if "text" in node2
|
||||||
|
else "N/A"
|
||||||
|
)
|
||||||
node2_string = f"name: {node2_name}, description: {node2_description}"
|
node2_string = f"name: {node2_name}, description: {node2_description}"
|
||||||
|
|
||||||
edge_string = edge.get("relationship_name", "")
|
edge_string = edge.get("relationship_name", "")
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue