flair icon indicating copy to clipboard operation
flair copied to clipboard

[Question]: How the StackedEmbeddings function actually works?

Open ijazul-haq opened this issue 1 year ago • 3 comments

Question

How the StackedEmbeddings function actually works? Is it concatinating the two word embeddings, i.e. using torch.cat([emb1, emb2]).

I want to concatinate BytePairEmbeddings with TransformerWordEmbeddings, so i'm doing like this:

bert_emb = TransformerWordEmbeddings( model='xlm-roberta-base', layers="-1", subtoken_pooling="mean", fine_tune=True, use_context=True, )

bpe_emb = BytePairEmbeddings('en') stacked_embeddings = StackedEmbeddings([bert_emb , bpe_emb])

So the resultant word embeddings (stacked_embeddings) will be a concatenation of the two embeddings, or is it element-wise mean embedding, or anything else?

Thank you

ijazul-haq avatar Sep 08 '23 02:09 ijazul-haq

Hi @ijazul-haq

StackedEmbeddings use the stacking/concatination operator as their name implies. Note that element-wise pooling would not be possible, as the embeddings usually don't have the same embedding length.

helpmefindaname avatar Sep 11 '23 07:09 helpmefindaname

Does it mean that StackedEmbeddings can not be used for sequence tagging, it's only for sequence classification? right?

ijazul-haq avatar Sep 16 '23 00:09 ijazul-haq

Sorry, I cannot follow how you come to that conclusion, but I can asure you that the StackedEmbeddings work for both, TokenEmbeddings and DocumentEmbeddings.

helpmefindaname avatar Sep 18 '23 08:09 helpmefindaname