Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dict chunking in StreamingDataSilo for LMFinetuning #284

Merged
merged 1 commit into from
Mar 19, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion farm/data_handler/data_silo.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from tqdm import tqdm

from farm.data_handler.dataloader import NamedDataLoader
from farm.data_handler.processor import Processor
from farm.data_handler.processor import Processor, BertStyleLMProcessor
from farm.data_handler.utils import grouper, stream_grouper
from farm.utils import MLFlowLogger as MlLogger
from farm.utils import log_ascii_workers, calc_chunksize
Expand Down Expand Up @@ -608,6 +608,8 @@ def __iter__(self):

batch = []
for datasets, tensor_names in results:
if not datasets:
continue
self.tensor_names = tensor_names
for ds in datasets:
batch.append(ds)
Expand All @@ -626,6 +628,10 @@ def _dataset_from_chunk(self, chunk):
:return: PyTorch Dataset
"""
dicts = [d[1] for d in chunk]
# need at least 2 documents to sample random sentences from
if len(dicts) < 2 and type(self.processor) == BertStyleLMProcessor:
logger.info("Skipping a dict chunk as it contains less than 2 documents ...")
return None, None
indices = [x[0] for x in chunk]
datasets, tensor_names = self.processor.dataset_from_dicts(dicts=dicts, indices=indices)
return datasets, tensor_names
Expand Down