# Grover
(aka, code for [Defending Against Neural Fake News](https://arxiv.org/abs/1905.12616))
Grover is a model for Neural Fake News -- both generation and detection. However, it probably can also be used for other generation tasks.
Visit our project page at [rowanzellers.com/grover](https://rowanzellers.com/grover), [the AI2 online demo](https://grover.allenai.org), or read the full paper at [arxiv.org/abs/1905.12616](https://arxiv.org/abs/1905.12616).
![teaser](https://i.imgur.com/VAGFpBe.png "teaser")
## What's in this repo?
We are releasing the following:
* Code for the Grover generator (in [lm/](lm/)). This involves training the model as a language model across fields.
* Code for the Grover discriminator in [discrimination/](discrimination/). Without much changing, you can run Grover as a discriminator to detect Neural Fake News.
* Code for generating from a Grover model, in [sample/](sample/).
* Code for making your own RealNews dataset in [realnews/](realnews/).
* Model checkpoints freely available online for the Grover-Base and Grover-Large models. For Grover-Mega or the RealNews dataset, please [submit this form](https://docs.google.com/forms/d/1LMAUeUtHNPXO9koyAIlDpvyKsLSYlrBj3rYhC30a7Ak) and we will get back to you as soon as possible.
Scroll down ���� for some easy-to-use instructions for setting up Grover to generate news articles.
## Setting up your environment
*NOTE*: If you just care about making your own RealNews dataset, you will need to set up your environment separately just for that, using an AWS machine (see [realnews/](realnews/).)
There are a few ways you can run Grover:
* **Generation mode (inference)**. This requires a GPU because I wasn't able to get top-p sampling, or caching of transformer hidden states, to work on a TPU.
* **LM Validation mode (perplexity)**. This could be run on a GPU or a TPU, but I've only tested this with TPU inference.
* **LM Training mode**. This requires a large TPU pod.
* **Discrimination mode (training)**. This requires a TPU pod.
* **Discrimination mode (inference)**. This could be run on a GPU or a TPU, but I've only tested this with TPU inference.
I used Python3.6 for everything. Usually I set it up using the following commands:
```
curl -o ~/miniconda.sh -O https://repo.continuum.io/miniconda/Miniconda3-4.5.4-Linux-x86_64.sh && \
chmod +x ~/miniconda.sh && \
~/miniconda.sh -b -p ~/conda && \
rm ~/miniconda.sh && \
~/conda/bin/conda install -y python=3.6
```
Then `pip install -r requirements-gpu.txt` if you're installing on a GPU, or `pip install requirements-tpu.txt` for TPU.
Misc notes/tips:
* If you have a lot of projects on your machine, you might want to use an anaconda environment to handle them all. Use `conda create -n grover python=3.6` to create an environment named `grover`. To enter the environment use `source activate grover`. To leave use `source deactivate`.
* I'm using tensorflow `1.13.1` which requires Cuda `10.0`. You'll need to install that from the nvidia website. I usually install it into `/usr/local/cuda-10.0/`, so you will need to run `export LD_LIBRARY_PATH=/usr/local/cuda-10.0/lib64` so tensorflow knows where to find it.
* I always have my pythonpath as the root directory. While in the `grover` directory, run `export PYTHONPATH=$(pwd)` to set it.
## Quickstart: setting up Grover for generation!
1. Set up your environment. Here's the easy way, assuming anaconda is installed: `conda create -y -n grover python=3.6 && source activate grover && pip install -r requirements-gpu.txt`
2. Download the model using `python download_model.py base`
3. Now generate: `PYTHONPATH=$(pwd) python sample/contextual_generate.py -model_config_fn lm/configs/base.json -model_ckpt models/base/model.ckpt -metadata_fn sample/april2019_set_mini.jsonl -out_fn april2019_set_mini_out.jsonl`
Congrats! You can view the generations, conditioned on the domain/headline/date/authors, in `april2019_set_mini_out.jsonl`.
### Bibtex
```
@inproceedings{zellers2019grover,
title={Defending Against Neural Fake News},
author={Zellers, Rowan and Holtzman, Ari and Rashkin, Hannah and Bisk, Yonatan and Farhadi, Ali and Roesner, Franziska and Choi, Yejin},
journal={arXiv preprint arXiv:1905.12616},
year={2019}
}
```
没有合适的资源?快使用搜索试试~ 我知道了~
Python-Grover神经网络假新闻生成与检测
共40个文件
py:16个
md:6个
json:5个
需积分: 27 12 下载量 161 浏览量
2019-08-11
04:14:20
上传
评论 1
收藏 669KB ZIP 举报
温馨提示
Grover:神经网络假新闻生成与检测
资源推荐
资源详情
资源评论
收起资源包目录
Python-Grover神经网络假新闻生成与检测.zip (40个子文件)
grover-master
Dockerfile 1KB
.gitignore 1KB
README.md 4KB
download_model.py 923B
lm
README.md 598B
validate.py 8KB
configs
base.json 289B
mega.json 303B
large.json 322B
train.py 5KB
train_tpu_adafactor.sh 1KB
utils.py 8KB
optimization_adafactor.py 9KB
__init__.py 0B
validate.sh 630B
modeling.py 43KB
dataloader.py 7KB
requirements-tpu.txt 155B
LICENSE 12KB
generation_examples
README.md 1KB
compute_accuracy_script.py 2KB
discrimination
README.md 165B
run_discrimination.py 14KB
sample
README.md 176B
april2019_set_mini.jsonl 34KB
vocab.bpe 446KB
encoder.py 14KB
__init__.py 0B
contextual_generate.py 6KB
encoder.json 1018KB
requirements-gpu.txt 130B
realnews
prepare_lm_data.py 10KB
README.md 1KB
domain_to_allowed_subdomains.json 138KB
prepare_lm_data.sh 409B
process_ccrawl.py 10KB
process_ccrawl.sh 282B
realnews_tiny.jsonl 18KB
dedupe_crawl.py 11KB
cc_files.txt 2KB
共 40 条
- 1
资源评论
weixin_39841856
- 粉丝: 487
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功