Git Product home page Git Product logo

ntmgraph's Introduction

NTMGraph

The data and code of paper Topic Aware Graph.

1. Preprocess the data Gossipcop

The format of dataset of the model NTM we used is in ntm/data/gossipcop_lines.txt, which you can find that each line in the txt file is one doc of your datas.

So first to preprocess to get the txt file:

$ python preprocess.py

And in the preprocess.py you can change the data path.

The dataset gossipcop_v3_keep_data_in_proper_length.json we offered here has 15,729 news.

Just clik the link gossipcop_v3_keep_data_in_proper_length.json to download it.

The 0-3,784 are fake news, and the other 3785-1,5729 are real news. Detailes can be seen in CossipCop-LLM.

2. Run the NTM model

$ cd ntm
$ python GSM_run.py --taskname gossipcop

Then you will find the model ckpt in ckpt/, and change the ckpt path in the next code embedding.py.

$ python embedding.py

After that you could get the docs embedding under topic in results/gossipcop_embed.py, whose size is (n, 16).(The n_topic we set is 16).

The docs of different topic is stored in results/gossipcop_topic_{i}.txt, where i is from 0 to 15.

3. Construct Topic Aware Graph

$ cd ..
$ python graph_construct.py

Then you can get different 16 graphs of 16 topics in data/sparse_matrix_topic_{j}.npz, where j is from 0 to 15.

4. Training

$ python main.py

After that you will see the scores print on the terminal, and you can see the epoch-accuracy graph on the tensorboard.

More optional arguments can also be seen in main.py.

Reference

This work has received assistance from the following. Consider citing their works if you find this repo useful.

@misc{ZLL2020,
  author = {Leilan Zhang},
  title = {Neural Topic Models},
  year = {2020},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished = {\url{https://github.com/zll17/Neural_Topic_Models}},
  commit = {f02e8f876449fc3ebffc66f7635a59281b08c1eb}
}
https://github.com/SZULLM/GossipCop-LLM

ntmgraph's People

Contributors

greg0987 avatar

Watchers

 avatar

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.