Skip to content

Commit bd30b56

Browse files
author
shixiaowen03
committed
Deep Knowledge-aware network
1 parent 63b37c5 commit bd30b56

File tree

2 files changed

+70
-24
lines changed

2 files changed

+70
-24
lines changed

.idea/workspace.xml

Lines changed: 5 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# DKN
2+
3+
This repository is the implementation of [DKN](https://dl.acm.org/citation.cfm?id=3186175) ([arXiv](https://arxiv.org/abs/1801.08284)):
4+
> DKN: Deep Knowledge-Aware Network for News Recommendation
5+
Hongwei Wang, Fuzheng Zhang, Xing Xie, Minyi Guo
6+
The Web Conference 2018 (WWW 2018)
7+
8+
![](https://github.com/hwwang55/DKN/blob/master/framework.jpg)
9+
10+
DKN is a deep knowledge-aware network that takes advantage of knowledge graph representation in news recommendation.
11+
The main components in DKN is a KCNN module and an attention module:
12+
- The KCNN module is to learn from semantic-level and knowledge-level representations of news jointly.
13+
The multiple channels and alignment of words and entities enable KCNN to combine information from heterogeneous sources.
14+
- The attention module is to model the different impacts of a user’s diverse historical interests on current candidate news.
15+
16+
17+
### Files in the folder
18+
19+
- `data/`
20+
- `kg/`
21+
- `Fast-TransX`: an efficient implementation of TransE and its extended models for Knowledge Graph Embedding (from https://github.com/thunlp/Fast-TransX);
22+
- `kg.txt`: knowledge graph file;
23+
- `kg_preprocess.py`: pre-process the knowledge graph and output knowledge embedding files for DKN;
24+
- `prepare_data_for_transx.py`: generate the required input files for Fast-TransX;
25+
- `news/`
26+
- `news_preprocess.py`: pre-process the news dataset;
27+
- `raw_test.txt`: raw test data file;
28+
- `raw_train.txt`: raw train data file;
29+
- `src/`: implementations of DKN.
30+
31+
> Note: Due to the pricacy policies of Bing News and file size limits on Github, the released raw dataset and the knowledge graph in this repository is only a small sample of the original ones reported in the paper.
32+
33+
34+
### Format of input files
35+
- **raw_train.txt** and **raw_test.txt**:
36+
`user_id[TAB]news_title[TAB]label[TAB]entity_info`
37+
for each line, where `news_title` is a list of words `w1 w2 ... wn`, and `entity_info` is a list of pairs of entity id and entity name: `entity_id_1:entity_name;entity_id_2:entity_name...`
38+
- **kg.txt**:
39+
`head[TAB]relation[TAB]tail`
40+
for each line, where `head` and `tail` are entity ids and `relation` is the relation id.
41+
42+
43+
### Required packages
44+
The code has been tested running under Python 3.6.5, with the following packages installed (along with their dependencies):
45+
- tensorflow-gpu == 1.4.0
46+
- numpy == 1.14.5
47+
- sklearn == 0.19.1
48+
- pandas == 0.23.0
49+
- gensim == 3.5.0
50+
51+
52+
### Running the code
53+
```
54+
$ cd data/news
55+
$ python news_preprocess.py
56+
$ cd ../kg
57+
$ python prepare_data_for_transx.py
58+
$ cd Fast-TransX/transE/ (note: you can also choose other KGE methods)
59+
$ g++ transE.cpp -o transE -pthread -O3 -march=native
60+
$ ./transE
61+
$ cd ../..
62+
$ python kg_preprocess.py
63+
$ cd ../../src
64+
$ python main.py (note: use -h to check optional arguments)
65+
```

0 commit comments

Comments
 (0)