RUCAIBox / RecSysDatasets

This is a repository of public data sources for Recommender Systems (RS).
https://recbole.io/
844 stars 132 forks source link

你好,如何获得.ent_feature和.rel_feature #117

Open zhaijianyang opened 1 year ago

zhaijianyang commented 1 year ago

你好,如何获得.ent_feature和.rel_feature呢,GRU4RecKG需要这些文件,文件内容是什么格式呢?如何获取?

Sherry-XLL commented 1 year ago

@zhaijianyang 您好,.ent_feature.rel_feature 是存储预训练知识图谱向量的文件,一般会采用 TransE 等方法得到知识图谱每个实体 entity 的向量表征 entity_embedding 以及关系 relation 的向量表征 relation_embedding,然后将每个实体/关系对应的表征导出并存储。

对于知识图谱特征文件的获取方式,可以根据自身需求并参考知识图谱表示的论文编写代码,通过训练得到对应的特征表示;也可以借用 graphviteLibKGEAmpliGraph 等开源库来生成结果。

对于这种额外的原子文件,可以通过文档中的 Additional Atomic Files 相关提示来导入:

Firstly, prepare your additional atomic file (e.g. ml-1m.ent).

ent_id:token ent_emb:float_seq
m.0gs6m -115.08 13.60 113.69
m.01b195 -130.97 263.05 -129.88

Secondly, update the args as:

.. code:: yaml

additional_feat_suffix: [ent]
load_col:
    # inter/user/item/...: As usual
    ent: [ent_id, ent_emb]

Then, this additional atomic file will be loaded into the :class:Dataset object. These new features can be used as following.

.. code:: python

dataset = create_dataset(config)
print(dataset.ent_feat)