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

Function main

python/ctranslate2/converters/transformers.py:3613–3668  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3611
3612
3613def main():
3614 parser = argparse.ArgumentParser(
3615 formatter_class=argparse.ArgumentDefaultsHelpFormatter
3616 )
3617 parser.add_argument(
3618 "--model",
3619 required=True,
3620 help=(
3621 "Name of the pretrained model to download, "
3622 "or path to a directory containing the pretrained model."
3623 ),
3624 )
3625 parser.add_argument(
3626 "--activation_scales",
3627 help=(
3628 "Path to the pre-computed activation scales. Models may "
3629 "use them to rescale some weights to smooth the intermediate activations "
3630 "and improve the quantization accuracy. See "
3631 "https://github.com/mit-han-lab/smoothquant."
3632 ),
3633 )
3634 parser.add_argument(
3635 "--copy_files",
3636 nargs="+",
3637 help=(
3638 "List of filenames to copy from the Hugging Face model to the converted "
3639 "model directory."
3640 ),
3641 )
3642 parser.add_argument(
3643 "--revision",
3644 help="Revision of the model to download from the Hugging Face Hub.",
3645 )
3646 parser.add_argument(
3647 "--low_cpu_mem_usage",
3648 action="store_true",
3649 help="Enable the flag low_cpu_mem_usage when loading the model with from_pretrained.",
3650 )
3651 parser.add_argument(
3652 "--trust_remote_code",
3653 action="store_true",
3654 help="Allow converting models using custom code.",
3655 )
3656
3657 Converter.declare_arguments(parser)
3658 args = parser.parse_args()
3659 converter = TransformersConverter(
3660 args.model,
3661 activation_scales=args.activation_scales,
3662 copy_files=args.copy_files,
3663 load_as_float16=args.quantization in ("float16", "int8_float16"),
3664 revision=args.revision,
3665 low_cpu_mem_usage=args.low_cpu_mem_usage,
3666 trust_remote_code=args.trust_remote_code,
3667 )
3668 converter.convert_from_args(args)
3669
3670

Callers 1

transformers.pyFile · 0.70

Calls 3

declare_argumentsMethod · 0.80
convert_from_argsMethod · 0.80

Tested by

no test coverage detected