OpenCompass/opencompass/datasets/calm/utils/load_items.py
Peng Bo 07c96ac659
Calm dataset (#1385)
* Add CALM Dataset
2024-08-01 10:03:21 +08:00

19 lines
463 B
Python

import json
from pathlib import Path
def load_query_instances(path):
"""Loads query instances from a JSON file.
Args:
path (str or Path): The path to the JSON file.
Returns:
list: A list of query instances loaded from the JSON file.
"""
if isinstance(path, str):
path = Path(path)
with path.open('r', encoding='utf-8') as f:
item_list = [json.loads(line) for line in f.readlines()]
return item_list