Code Monkey home page Code Monkey logo

anchorkg's Introduction

Reinforced Anchor Knowledge Graph Generation for News Recommendation Reasoning

This repository contains the source code of the paper: Reinforced Anchor Knowledge Graph Generation for News Recommendation Reasoning

framework

Dataset:

The original data we used is from the public news dataset : MIND. We build an item2item dataset based on the method in the paper.

Files in data folder:

  • ./data/
    • kg/wikidata-graph/
      • wikidata-graph.tsv knowledge graph triples from Wikidata
      • entity2id.txt entity label to index
      • relation2id.txt relation label to index
      • entity2vecd100.vec entity embedding from TransE
      • relation2vecd100.vec relation embedding from TransE
    • mind/
      • behaviors.tsv the impression logs and users' news click hostories
      • news.tsv the detailed information of news articles involved in the behaviors.tsv file
    • item2item/
      • all_news.tsv all news used for training, validating, testing
      • doc_feature_embedding.tsv document embedding from sentence-bert
      • doc_feature_entity.tsv entities mentioned in documents
      • pos_train.tsv positive item pairs in train data
      • pos_valid.tsv positive item pairs in valid data
      • pos_test.tsv positive item pairs in test data
      • random_neg_sample_train.tsv item2item train data
      • random_neg_sample_valid.tsv item2item valid data
    • kprn/
      • train_data.json train data for KPRN
      • valid_data.json valid data for KPRN
      • predict_train.json warm up train data for anchorKG
      • predict_valid.json warm up valid data for anchorKG

Requirements:

python == 3.9.13
torch == 1.12.0
sklearn == 1.1.2
numpy == 1.23.4
hnswlib == 0.4.0
networkx == 2.8.7
nni == 2.8
sentence_transformers == 2.2.2
tqdm == 4.64.1

How to run the code:

  1. Dataset download and process

    $ python data_process.py

    The config file is ./config/data_config.json

    If the download speed is too slow, you can refer to followng links for dataset download and put it under the corresponding folder before running the code.

  2. Kprn training

    $ python KPRN_train.py

    The config file is ./config/KPRN_config.json

  3. Warmup training + AnchorKG training

    $ python main.py

    The config file is ./config/anchorkg_config.json

Automatic hyper-parameter tuning

We integrates with NNI module for tuning the hyper-parameters automatically. You can tune the KPRN training stage, warmpup training stage, anchorKG training stage respectively. For easy usage, you can run the following code:

$ nnictl create --config ./nni_config.yaml --port 9074

You can configure the nni_config.yaml for your own usage. For more details about NNI, please refer to NNI Documentation

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.