detecting-fake-text:基于大语言模型的文本检测项目

Giant Language Model Test Room

分支22Tags0

GLTR:大型语言模型测试室

检测由大型语言模型(如GPT-2)生成的文本。

网页版:http://gltr.io
在线演示:http://gltr.io/dist/index.html
论文:https://arxiv.org/abs/1906.04043

项目由Hendrik Strobelt、Sebastian Gehrmann和Alexander M. Rush共同完成。

MIT-IBM沃森人工智能实验室与哈佛NLP的合作项目。

快速开始

在Python 3.6以上版本安装依赖:

pip install -r requirements.txt

运行gpt-2-small服务器:

python server.py

现在演示实例可在http://localhost:5001/client/index.html访问。

运行BERT服务器

启动BERT服务器:

python server.py --model BERT

实例现在运行在http://localhost:5001/client/index.html?nodemo。提示:我们仅提供gpt2-small的示例文本。

server.py 参数

使用方法: server.py [-h] [--model MODEL] [--nodebug NODEBUG] [--address ADDRESS]
                   [--port PORT] [--nocache NOCACHE] [--dir DIR] [--no_cors]

可选参数:
  -h, --help            显示此帮助消息并退出
  --model MODEL       选择 'gpt-2-small'(默认)、'BERT' 或自定义模型
  --nodebug NODEBUG    以非调试模式运行服务器
  --port PORT         启动UI和API的端口(默认:5001)
  --no_cors           不启用CORS支持(默认: 关闭)

扩展后端

后端定义了一系列模型API,可以通过--model NAME参数启动服务器调用。要添加自定义模型,您需要在backend/api.py中编写自己的API,并添加装饰器@register_api(name=NAME)。

每个API都需要是一个继承自AbstractLanguageChecker的类,该类定义了两个函数check_probabilities和postprocess。在实现类和函数时,请遵循api.py中的文档。

扩展前端

前端源代码位于client/src。

修改前需安装Node依赖项:

cd client/src; npm install; cd ../..

重新编译前端:

> rm -rf client/dist;cd client/src/; npm run build; cd ../..

许可证

Apache 2

(c) 2019年由Hendrik Strobelt、Sebastian Gehrmann和Alexander M. Rush所有。

项目介绍

Giant Language Model Test Room

定制我的领域