flambe
flambe copied to clipboard
Separate embedder and encoder in flambe.nn.embedder
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.
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?
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.
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?