bjascob / amrlib

A python library that makes AMR parsing, generation and visualization simple.
MIT License
216 stars 33 forks source link

How to speed up my parsing? #51

Closed SHADOWX-frank closed 1 year ago

SHADOWX-frank commented 2 years ago

hello, I use the pretrained parse_xfm_bart_base for parsing, but the speed of parsing is limited to one sentence per seconds instead of 31 sentences per seconds. how to speed up it?

bjascob commented 2 years ago

Don't call parse_sents for each sent. Call it with a long list of sents so the code can batch process them on the GPU. Make sure the GPU is being used. My testing used a 3090. You can also instantiate the model with num_beams=1. The default is 4 which is much slower that using 1. You can also instantiate the model with batch_size=X. The default is 12 which is fine but you might be able to push this up higher if your sentences are short and you have plenty of VRAM.