Skip to content

Commit

Permalink
cr feedback to use itertools to flatten
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosgjs committed Dec 12, 2023
1 parent 5e4db23 commit 5231456
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/autora/doc/pipelines/main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import itertools
import logging
from timeit import default_timer as timer
from typing import List
Expand Down Expand Up @@ -64,7 +65,7 @@ def eval(
mlflow.log_text(predictions[i][j], f"prediction_{i}_{j}.txt")

# flatten predictions for counting tokens
predictions_flat = [pred for pred_list in predictions for pred in pred_list]
predictions_flat = list(itertools.chain.from_iterable(predictions))
tokens = pred.tokenize(predictions_flat)["input_ids"]
total_tokens = sum([len(token) for token in tokens])
mlflow.log_metric("total_tokens", total_tokens)
Expand Down

0 comments on commit 5231456

Please sign in to comment.