tech-srl / code2seq

Code for the model presented in the paper: "code2seq: Generating Sequences from Structured Representations of Code"
http://code2seq.org
MIT License
548 stars 165 forks source link

How extract code vectors? #81

Closed celsofranssa closed 3 years ago

celsofranssa commented 3 years ago

Is possible to use code2seq to output the code vector?

urialon commented 3 years ago

Hi @Ceceu , It will require a little coding, but yes. In general, code2seq computes a new "code vector" for every target subtoken. So if the model predicts "save bitmap to file", a different "code vector" is computed for each of the outputs [save, bitmap, to, file].

If you need a single vector, you can use this contexts_average vector: https://github.com/tech-srl/code2seq/blob/master/model.py#L414

Best, Uri

urialon commented 3 years ago

Closing due to inactivity, but feel free to re-open if you have additional questions.