Tokenizer

class Tokenizer[source]

Bases: object

A base class for tokenizers for NodePiece representations.

Methods Summary

__call__(mapped_triples, num_tokens, ...)

Tokenize the entities contained given the triples.

Methods Documentation

abstract __call__(mapped_triples: Tensor, num_tokens: int, num_entities: int, num_relations: int) tuple[int, Tensor][source]

Tokenize the entities contained given the triples.

Parameters:
  • mapped_triples (Tensor) – shape: (n, 3) the ID-based triples

  • num_tokens (int) – the number of tokens to select for each entity

  • num_entities (int) – the number of entities

  • num_relations (int) – the number of relations

Returns:

shape: (num_entities, num_tokens), -1 <= res < vocabulary_size the selected relation IDs for each entity. -1 is used as a padding token.

Return type:

tuple[int, Tensor]