Skip to content

Commit 9876d03

Browse files
committed
example script is done
1 parent f094d92 commit 9876d03

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

named-entity-recognition/run_ner.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,10 @@ def compute_metrics(p: EvalPrediction) -> Dict:
246246
trainer.save_model()
247247
# For convenience, we also re-save the tokenizer to the same directory,
248248
# so that you can share your model easily on huggingface.co/models =)
249-
if trainer.is_world_master():
249+
250+
# error log: Replace "is_world_master" with "is_world_process_zero"
251+
252+
if trainer.is_world_process_zero():
250253
tokenizer.save_pretrained(training_args.output_dir)
251254

252255
# Evaluation
@@ -257,7 +260,9 @@ def compute_metrics(p: EvalPrediction) -> Dict:
257260
result = trainer.evaluate()
258261

259262
output_eval_file = os.path.join(training_args.output_dir, "eval_results.txt")
260-
if trainer.is_world_master():
263+
264+
# error log: Replace "is_world_master" with "is_world_process_zero"
265+
if trainer.is_world_process_zero():
261266
with open(output_eval_file, "w") as writer:
262267
logger.info("***** Eval results *****")
263268
for key, value in result.items():
@@ -284,7 +289,9 @@ def compute_metrics(p: EvalPrediction) -> Dict:
284289

285290
# Save predictions
286291
output_test_results_file = os.path.join(training_args.output_dir, "test_results.txt")
287-
if trainer.is_world_master():
292+
293+
# error log: Replace "is_world_master" with "is_world_process_zero"
294+
if trainer.is_world_process_zero():
288295
with open(output_test_results_file, "w") as writer:
289296
logger.info("***** Test results *****")
290297
for key, value in metrics.items():
@@ -293,7 +300,9 @@ def compute_metrics(p: EvalPrediction) -> Dict:
293300

294301

295302
output_test_predictions_file = os.path.join(training_args.output_dir, "test_predictions.txt")
296-
if trainer.is_world_master():
303+
304+
# error log: Replace "is_world_master" with "is_world_process_zero"
305+
if trainer.is_world_process_zero():
297306
with open(output_test_predictions_file, "w") as writer:
298307
with open(os.path.join(data_args.data_dir, "test.txt"), "r") as f:
299308
example_id = 0

named-entity-recognition/test.py

Whitespace-only changes.

0 commit comments

Comments
 (0)