versae commited on
Commit
28c2a71
1 Parent(s): 741a33a

Fix defaults for init

Browse files
Files changed (1) hide show
  1. mc4-sampling.py +10 -3
mc4-sampling.py CHANGED
@@ -300,13 +300,20 @@ class Mc4Sampling(datasets.GeneratorBasedBuilder):
300
  else:
301
  # Loading 5-gram model
302
  # http://dl.fbaipublicfiles.com/cc_net/lm/es.arpa.bin
303
- logger.info("loading model = %s", self.perplexity_model)
304
- self.pp_model = kenlm.Model(self.perplexity_model)
 
 
 
305
  if self.sampling_method == "gaussian":
306
  self.should_keep_doc = self._should_keep_doc_gaussian
307
  else:
308
  self.should_keep_doc = self._should_keep_doc_step
309
- super().__init__(*args, writer_batch_size=writer_batch_size, **kwargs)
 
 
 
 
310
 
311
  def get_perplexity(self, doc):
312
  doc_log_score, doc_length = 0, 0
 
300
  else:
301
  # Loading 5-gram model
302
  # http://dl.fbaipublicfiles.com/cc_net/lm/es.arpa.bin
303
+ logger.info("loading model = %s", str(self.perplexity_model))
304
+ if isinstance(self.perplexity_model, str):
305
+ self.pp_model = kenlm.Model(self.perplexity_model)
306
+ else:
307
+ self.pp_model = self.perplexity_model
308
  if self.sampling_method == "gaussian":
309
  self.should_keep_doc = self._should_keep_doc_gaussian
310
  else:
311
  self.should_keep_doc = self._should_keep_doc_step
312
+ init_kwargs = {
313
+ prop: kwargs.get(prop)
314
+ for prop in ("name", "version", "data_dir", "data_files", "description")
315
+ }
316
+ super().__init__(*args, writer_batch_size=writer_batch_size, **init_kwargs)
317
 
318
  def get_perplexity(self, doc):
319
  doc_log_score, doc_length = 0, 0