NodePiece¶
pykeen.nn.node_piece Package¶
NodePiece modules.
A NodePieceRepresentation
contains a collection of TokenizationRepresentation
.
A TokenizationRepresentation
is defined as Representation
module mapping token
indices to representations, also called the vocabulary in resemblance of token representations
known from NLP applications, and an assignment from entities to (multiple) tokens.
In order to obtain the vocabulary and assignment, multiple options are available, which often follow a two-step approach of first selecting a vocabulary, and afterwards assigning the entities to the set of tokens, usually using the graph structure of the KG.
One way of tokenization, is tokenization by AnchorTokenizer
, which selects some anchor
entities from the graph as vocabulary. The anchor selection process is controlled by an
AnchorSelection
instance. In order to obtain the assignment, some measure of graph
distance is used. To this end, a AnchorSearcher
instance calculates the closest
anchor entities from the vocabulary for each of the entities in the graph.
Since some tokenizations are expensive to compute, we offer a mechanism to use precomputed tokenizations via
PrecomputedPoolTokenizer
. To enable loading from different formats, a loader subclassing from
PrecomputedTokenizerLoader
can be selected accordingly. To precompute anchor-based tokenizations,
you can use the command
pykeen tokenize
Its usage is explained by passing the --help
flag.
Classes¶
A method for finding the closest anchors. |
|
|
Find closest anchors using |
|
Find closest anchors using |
Find closest anchors using |
|
Select closest anchors as the nodes with the largest personalized page rank. |
|
|
Anchor entity selection strategy. |
|
Single-step selection. |
|
Select entities according to their (undirected) degree. |
|
A weighted mixture of different anchor selection strategies. |
|
Select entities according to their page rank. |
|
Random node selection. |
A base class for tokenizers for NodePiece representations. |
|
Tokenize entities by representing them as a bag of relations. |
|
|
Tokenize entities by representing them as a bag of anchor entities. |
|
An anchor tokenizer, which first partitions the graph using METIS. |
|
A tokenizer using externally precomputed tokenization. |
A loader for precomputed tokenization. |
|
A loader for pickle files provided by Galkin et al. |
|
A loader via torch.load. |
|
|
A module holding the result of tokenization. |
|
Basic implementation of node piece decomposition [galkin2021]. |
|
A ratio information object. |
Class Inheritance Diagram¶
