Skip to content

Commit

Permalink
Update ctranslate2 options in release_model (#1742)
Browse files Browse the repository at this point in the history
  • Loading branch information
francoishernandez committed Mar 6, 2020
1 parent 995bf03 commit e442f3f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion onmt/bin/release_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ def get_ctranslate2_model_spec(opt):
return None
import ctranslate2
num_heads = getattr(opt, "heads", 8)
if opt.enc_layers == opt.dec_layers:
opt.layers = opt.enc_layers
return ctranslate2.specs.TransformerSpec(
opt.layers,
num_heads,
Expand All @@ -34,6 +36,10 @@ def main():
choices=["pytorch", "ctranslate2"],
default="pytorch",
help="The format of the released model")
parser.add_argument("--quantization", "-q",
choices=["int8", "int16"],
default=None,
help="Quantization type for CT2 model.")
opt = parser.parse_args()

model = torch.load(opt.model)
Expand All @@ -48,7 +54,8 @@ def main():
"more information on supported models.")
import ctranslate2
converter = ctranslate2.converters.OpenNMTPyConverter(opt.model)
converter.convert(opt.output, model_spec, force=True)
converter.convert(opt.output, model_spec, force=True,
quantization=opt.quantization)


if __name__ == "__main__":
Expand Down

0 comments on commit e442f3f

Please sign in to comment.