DALLE-pytorch icon indicating copy to clipboard operation
DALLE-pytorch copied to clipboard

Pretrained text encoder

Open ethancohen123 opened this issue 2 years ago • 2 comments

Is it possible to use and train dalle with an external ( frozen) text encoder ( as those available in hugging face) ?

ethancohen123 avatar Sep 13 '22 21:09 ethancohen123

Anyone has an idea about this ? @lucidrains

ethancohen123 avatar Oct 03 '22 18:10 ethancohen123

Hi. If you want to use pretrained language model, you are actually using the text embedding of that model.

  1. At first, you can load and save the text embedding layer weight of pretrained models like CLIP and BERT.
  2. Then, you need to replace the text_emb in DALLE __init__ function. Now, instead of using nn.Embedding to create new text embedding, you can use torch.load to load pretrained weight saved in step 1.

Example: link

kingnobro avatar Dec 20 '22 07:12 kingnobro