Skip to content

Cannot provide custom entity_representations_kwargs or relation_representations_kwargs via model_kwargs to pipeline #1441

@mberr

Description

@mberr

Describe the bug

When providing custom entity_representations_kwargs (or relation_representations_kwargs) via model_kwargs to pykeen.pipeline.pipeline, a TypeError occurs

Traceback (most recent call last):
  File "/home/max/code/pykeen/scratch/tmp.py", line 4, in <module>
    result = pipeline(
  File "/home/max/code/pykeen/src/pykeen/pipeline/api.py", line 1503, in pipeline
    model_instance = _handle_model(
  File "/home/max/code/pykeen/src/pykeen/pipeline/api.py", line 970, in _handle_model
    model_instance, model_kwargs = _build_model_helper(
  File "/home/max/code/pykeen/src/pykeen/pipeline/api.py", line 837, in _build_model_helper
    model_resolver.make(
  File "/home/max/code/pykeen/venv/lib/python3.10/site-packages/class_resolver/api.py", line 210, in make
    raise e
  File "/home/max/code/pykeen/venv/lib/python3.10/site-packages/class_resolver/api.py", line 204, in make
    return cls(**(pos_kwargs or {}), **kwargs)  # type: ignore
  File "/home/max/code/pykeen/src/pykeen/models/unimodal/trans_e.py", line 87, in __init__
    super().__init__(
TypeError: pykeen.models.nbase.ERModel.__init__() got multiple values for keyword argument 'entity_representations_kwargs'

How to reproduce

from pykeen.pipeline import pipeline

result = pipeline(
    dataset="nations",
    model="TransE",
    model_kwargs=dict(entity_representations_kwargs=dict()),
)

Environment

Key Value
OS posix
Platform Linux
Release 5.15.153.1-microsoft-standard-WSL2
Time Sat Sep 7 13:43:19 2024
Python 3.10.6
PyKEEN 1.10.3-dev
PyKEEN Hash 3f4c870
PyKEEN Branch master
PyTorch 2.3.1+cu121
CUDA Available? true
CUDA Version 12.1
cuDNN Version 8902

Additional information

The reason is that some models (e.g., TransE) add their own entity_representations_kwargs.

While I would generally advocate using the new style interaction + entity_representations (+...) whenever you want to have custom representations, many users may not be aware of this and face problems when trying to use it.

Issue Template Checks

  • This is not a feature request (use a different issue template if it is)
  • This is not a question (use the discussions forum instead)
  • I've read the text explaining why including environment information is important and understand if I omit this information that my issue will be dismissed

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions