MCPcopy Create free account
hub / github.com/OpenNMT/CTranslate2 / main

Function main

python/ctranslate2/converters/fairseq.py:304–358  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

302
303
304def main():
305 parser = argparse.ArgumentParser(
306 formatter_class=argparse.ArgumentDefaultsHelpFormatter
307 )
308 parser.add_argument("--model_path", required=True, help="Model path.")
309 parser.add_argument(
310 "--data_dir",
311 required=True,
312 help="Data directory containing the source and target vocabularies.",
313 )
314 parser.add_argument(
315 "--user_dir",
316 help="Directory containing custom extensions.",
317 )
318 parser.add_argument(
319 "--fixed_dictionary",
320 help="Fixed dictionary for multilingual models.",
321 )
322 parser.add_argument(
323 "--source_lang",
324 help="Source language. This argument is used to find dictionary file from `data_dir`.",
325 )
326 parser.add_argument(
327 "--target_lang",
328 help="Target language. This argument is used to find dictionary file from `data_dir`.",
329 )
330 parser.add_argument(
331 "--no_default_special_tokens",
332 action="store_true",
333 help=(
334 "Require all special tokens to be provided by the user during inference, "
335 "including the decoder start token."
336 ),
337 )
338 parser.add_argument(
339 "--unsafe_deserialization",
340 action="store_true",
341 help=(
342 "Allow loading legacy checkpoints with unsafe pickle deserialization. "
343 "Only enable this option for trusted checkpoints."
344 ),
345 )
346 Converter.declare_arguments(parser)
347 args = parser.parse_args()
348 converter = FairseqConverter(
349 args.model_path,
350 args.data_dir,
351 source_lang=args.source_lang,
352 target_lang=args.target_lang,
353 fixed_dictionary=args.fixed_dictionary,
354 no_default_special_tokens=args.no_default_special_tokens,
355 user_dir=args.user_dir,
356 unsafe_deserialization=args.unsafe_deserialization,
357 )
358 converter.convert_from_args(args)
359
360
361if __name__ == "__main__":

Callers 1

fairseq.pyFile · 0.70

Calls 3

FairseqConverterClass · 0.85
declare_argumentsMethod · 0.80
convert_from_argsMethod · 0.80

Tested by

no test coverage detected