I have been working with the datasets and feature_columns in tensorflow(https://developers.googleblog.com/2017/11/introducing-tensorflow-feature-columns.html). I see they have categorical features and a way to create embedding features from categorical features. But when working on nlp tasks, how do we create a single embedding lookup?
For eg: Consider text classification task. Every data point would have a lot of textual columns but they would not be separate categories. How do we create and use a single embedding lookup for all these columns?
Below is an example of how I am currently using the embedding features. I am building a categorical feature for each column and using that for creating embedding. The problem would be that the embeddings for same word could be different for different columns.
def create_embedding_features(key, vocab_list=None, embedding_size=20):
cat_feature = \
tf.feature_column.categorical_column_with_vocabulary_list(
key=key,
vocabulary_list = vocab_list
)
embedding_feature = tf.feature_column.embedding_column(
categorical_column = cat_feature,
dimension = embedding_size
)
return embedding_feature
le_features_embd = [create_embedding_features(f, vocab_list=vocab_list)
for f in feature_keys]