versae commited on
Commit
3d69f5d
1 Parent(s): 28c2a71

Fix defaults for sampling methods

Browse files
Files changed (1) hide show
  1. mc4-sampling.py +4 -4
mc4-sampling.py CHANGED
@@ -324,8 +324,9 @@ class Mc4Sampling(datasets.GeneratorBasedBuilder):
324
  doc_length += length
325
  return 10.0 ** (-doc_log_score / doc_length)
326
 
327
- def _should_keep_doc_step(self, doc, factor=1.5e5, boundaries=None, **kwargs):
328
  perplexity = self.get_perplexity(doc)
 
329
  if boundaries is None:
330
  boundaries = [536394.99320948, 662247.50212365, 919250.87225178]
331
  if perplexity <= boundaries[0]:
@@ -339,9 +340,10 @@ class Mc4Sampling(datasets.GeneratorBasedBuilder):
339
  probability = factor / quartile_range
340
  return self.rng.uniform() < probability
341
 
342
- def _should_keep_doc_gaussian(self, doc, factor=0.78, boundaries=None, **kwargs):
343
  width = kwargs.get("width", 9 / 2) # width (spread) of the exponential curve
344
  perplexity = self.get_perplexity(doc)
 
345
  if boundaries is not None:
346
  m = boundaries[1]
347
  else:
@@ -423,8 +425,6 @@ class Mc4Sampling(datasets.GeneratorBasedBuilder):
423
  example = json.loads(line)
424
  if self.should_keep_doc(
425
  example["text"],
426
- factor=self.sampling_factor,
427
- boundaries=self.boundaries,
428
  **self.kwargs):
429
  yield id_, example
430
  id_ += 1
 
324
  doc_length += length
325
  return 10.0 ** (-doc_log_score / doc_length)
326
 
327
+ def _should_keep_doc_step(self, doc, factor=None, boundaries=None, **kwargs):
328
  perplexity = self.get_perplexity(doc)
329
+ factor = 1.5e5 if factor is None else factor
330
  if boundaries is None:
331
  boundaries = [536394.99320948, 662247.50212365, 919250.87225178]
332
  if perplexity <= boundaries[0]:
 
340
  probability = factor / quartile_range
341
  return self.rng.uniform() < probability
342
 
343
+ def _should_keep_doc_gaussian(self, doc, factor=None, boundaries=None, **kwargs):
344
  width = kwargs.get("width", 9 / 2) # width (spread) of the exponential curve
345
  perplexity = self.get_perplexity(doc)
346
+ factor = 0.78 if factor is None else factor
347
  if boundaries is not None:
348
  m = boundaries[1]
349
  else:
 
425
  example = json.loads(line)
426
  if self.should_keep_doc(
427
  example["text"],
 
 
428
  **self.kwargs):
429
  yield id_, example
430
  id_ += 1