Skip to content

The best ChatGPT that $100 can buy.

Python

fix: open JSONL and results CSV with UTF-8 encoding for portability

Dipesh Babu226953b841f3
diff --git a/scripts/base_eval.py b/scripts/base_eval.py
index 21f7bac..a987049 100644
--- a/scripts/base_eval.py
+++ b/scripts/base_eval.py
@@ -88,7 +88,7 @@ def evaluate_model(model, tokenizer, device, max_per_task=-1):
# Load data for this task
data_path = os.path.join(data_base_path, task_meta['dataset_uri'])
- with open(data_path, 'r') as f:
+ with open(data_path, 'r', encoding='utf-8') as f:
data = [json.loads(line.strip()) for line in f]
# shuffle the data because in many cases it appears ordered but we want
@@ -184,7 +184,7 @@ def main():
results = out["results"]
centered_results = out["centered_results"]
core_metric = out["core_metric"]
- with open(output_csv_path, 'w') as f:
+ with open(output_csv_path, 'w', encoding='utf-8', newline='') as f:
f.write(f"{'Task':<35}, {'Accuracy':<10}, {'Centered':<10}\n")
for label in results:
f.write(f"{label:<35}, {results[label]:<10.6f}, {centered_results[label]:<10.6f}\n")