flambe icon indicating copy to clipboard operation
flambe copied to clipboard

Separate embedder and encoder in flambe.nn.embedder

Open cle-ros opened this issue 5 years ago • 3 comments

The current implementation where the encoder is part of the embedder prevents "one embedder, two encoder" implementations. As the embedder is oftentimes the largest single matrix in an NLP model, this can lead to an unnecessary increase in memory usage.

cle-ros avatar Dec 17 '19 16:12 cle-ros

I don't know if this use case legitimizes changing the interface.. You could just create a new Embedder-style object for you use case. Could you provide an example or two so we can better understand the motivation?

jeremyasapp avatar Dec 28 '19 00:12 jeremyasapp

NLP models that do sequence comparison (the NLI groups comes to mind) are oftentimes implemented with a different encoder object for each compared part. In these cases, the standard flambe implementation will instantiate not only two encoders, but also two embedders - which, again, can result in a waste of GPU memory as embedding matrices can be huge.

cle-ros avatar Dec 29 '19 22:12 cle-ros

Ok this use case makes sense, but I don't understand the change you are requesting. Embedding and encoder are already separated. Embedder links both of them, so you could very easily create a different embedder with two encoders?

jeremyasapp avatar Dec 29 '19 23:12 jeremyasapp