MCPcopy Create free account
hub / github.com/FLC777/GLAT / SamplingMethod

Class SamplingMethod

fairseq/data/multilingual/sampling_method.py:36–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34
35
36class SamplingMethod:
37 @staticmethod
38 def add_arguments(parser):
39 parser.add_argument(
40 "--sampling-method",
41 choices=[
42 "uniform",
43 "temperature",
44 "concat",
45 "RoundRobin",
46 ],
47 type=str,
48 default="concat",
49 help="The method to sample data per language pairs",
50 )
51 parser.add_argument(
52 "--sampling-temperature",
53 default=1.5,
54 type=float,
55 help="only work with --sampling-method temperature",
56 )
57
58 @staticmethod
59 def build_sampler(args, task):
60 return SamplingMethod(args, task)
61
62 def __init__(self, args, task):
63 self.args = args
64 self.task = task
65
66 def is_adaptive(self):
67 return False
68
69 def sampling_method_selector(self):
70 args = self.args
71 logger.info(f"selected sampler: {args.sampling_method}")
72 if args.sampling_method == "uniform":
73 return uniform
74 elif args.sampling_method == "temperature" or self.is_adaptive():
75 return make_temperature_sampling(float(args.sampling_temperature))
76 else:
77 # default to concating all data set together
78 return None

Callers 1

build_samplerMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected