I am using the Transformer model from Hugging face for machine translation. However, my input data has relational information as shown below:
I want to craft a graph like the like the following:
________
| |
| \|/
He ended his meeting on Tuesday night.
/|\ | | /|\
| | | |
|__| |___________|
Essentially each token in the sentence is a node and there could be an edge embedded between the tokens.
In a normal transformer, the tokens are processed into token embeddings, also there is an encoding of each position which resulted into positional embeddings.
How could I do something similar with the edge information?
Theoretically I could take the edge type and the positional encoding of a node and output an embedding. The embeddings of all the edges can be added to the positional embeddings for the corresponding nodes.
Ideally, I would like to implement this with the hugging face transformer.
I am struggling to understand how could I update the positional embedding here:
self.position_embeddings = nn.Embedding(
config.max_position_embeddings, config.hidden_size, padding_idx=self.padding_idx
)
