uma-pi1 / kge

LibKGE - A knowledge graph embedding library for reproducible research
MIT License
776 stars 124 forks source link

Possibility to not take in s_emb, but the actual indices to the scores #231

Closed Filco306 closed 3 years ago

Filco306 commented 3 years ago

Hello,

I was wondering; is there any setting that would allow taking in the actual entity (and relation) indices to the scoring function, and use the lookup embeddings directly in the scorer instead?

Thanks :)

AdrianKs commented 3 years ago

There is no setting to directly achieve this. But, the function kge_model.score_spo() takes vectors of indices as input. If you would like to have a model with a specific scorer that only takes those indices as input you could overwrite this function inside your model and just directly call the score function with the indices instead of the embeddings.

https://github.com/uma-pi1/kge/blob/308cebd21e58119d05b1c8613c195cdafe0a112b/kge/model/kge_model.py#L663

You would need to do this for all score functions of kge_model, I think.

@rgemulla should we extend the signature of the scoring functions to take the indices as well or maybe allow for further keyword arguments?

rgemulla commented 3 years ago

The goal of the scorer is to abstract away indexes and solely work with embeddings. To score based on indexes, a scorer is not needed: simply extend KgeModel and override the score_* functions (which do obtain indexes) in your subclass.

Filco306 commented 3 years ago

Thank you for this! I love the great support for this package! :D