RADAR Vicuna 7B

提供商TrustSafeAI
分类text-classification
许可证Apache-2.0
下载量934.5K
星标0

简介

RADAR Vicuna 7B 是一款基于 Vicuna 架构并由 TrustSafeAI 优化的小参数量文本分类模型。它将通用大模型的理解能力聚焦于分类任务,旨在为开发者提供一个轻量级且高效的文本打标方案。相比于调用闭源 API,该模型支持私有化部署,能有效降低推理成本并提升数据隐私性。对于习惯使用 Hugging Face 或 vLLM 的开发者来说,其上手难度极低,非常适合作为自动化工作流中的预处理模块,用于快速筛选或对海量文本进行类别标注。

核心亮点

  • 专注文本分类,实现高效的自动化打标
  • 轻量级 7B 参数,支持低成本私有化部署
  • 采用 Apache-2.0 协议,商业使用无压力
  • 适配主流推理框架,开发者快速集成

使用方法

安装依赖
# 安装 Hugging Face transformers
pip install transformers torch
SDK 使用
# 使用 transformers 加载模型
from transformers import AutoModel, AutoTokenizer

model = AutoModel.from_pretrained("TrustSafeAI/RADAR-Vicuna-7B")
tokenizer = AutoTokenizer.from_pretrained("TrustSafeAI/RADAR-Vicuna-7B")

Hugging Face 下载

我们推荐使用命令行或者 Hugging Face Hub SDK 来进行模型的下载。

操作指引:在下载前,请先通过如下命令安装 huggingface_hub:

操作指引
pip install -U huggingface_hub

命令行下载

下载完整模型库

下载完整模型库
huggingface-cli download TrustSafeAI/RADAR-Vicuna-7B

下载单个文件到指定本地文件夹(以下载 config.json 到当前路径下 ./dir 目录为例)

下载单个文件到指定本地文件夹(以下载 config.json 到当前路径下 ./dir 目录为例)
huggingface-cli download TrustSafeAI/RADAR-Vicuna-7B config.json --local-dir ./dir

更多命令行下载选项,可参见官方文档

SDK 下载

SDK 下载
# 模型下载
from huggingface_hub import snapshot_download
model_dir = snapshot_download('TrustSafeAI/RADAR-Vicuna-7B')

Git 下载

请确保 lfs 已经被正确安装

Git 下载
git lfs install
git clone https://huggingface.co/TrustSafeAI/RADAR-Vicuna-7B

如果您希望跳过 lfs 大文件下载,可以使用如下命令

跳过 LFS
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/TrustSafeAI/RADAR-Vicuna-7B

模型文件托管在 Hugging Face Hub,使用 HF CLI / SDK / Git 直接下载,不经过本站。

PyTorch / Transformers 使用

安装 Transformers

安装 Transformers
pip install -U transformers torch

模型加载和推理

模型加载和推理
from transformers import AutoModelForCausalLM, AutoTokenizer

model = AutoModelForCausalLM.from_pretrained('TrustSafeAI/RADAR-Vicuna-7B')
tokenizer = AutoTokenizer.from_pretrained('TrustSafeAI/RADAR-Vicuna-7B')

完整文档

来源: HuggingFace

---
pipeline_tag: text-classification
---

<br>

RADAR Model Card

Model Details

RADAR-Vicuna-7B is an AI-text detector trained via adversarial learning between the detector and a paraphraser on human-text corpus (OpenWebText) and AI-text corpus generated
based on OpenWebText.

  • Model type: An encoder-only language model based on the transformer architecture (RoBERTa).

Model Sources

  • Project Page: https://radar.vizhub.ai/
  • Paper: https://arxiv.org/abs/2307.03838
  • IBM Blog Post: https://research.ibm.com/blog/AI-forensics-attribution

Uses

Users could use this detector to assist them in detecting text generated by large language models. Please note that this detector is trained on AI-text generated by Vicuna-7B-v1.1. As the model only supports non-commercial use, the intended users are not allowed to involve this detector into commercial activities.

Get Started with the Model

Please refer to the following guidelines to see how to locally run the downloaded model or use our API service hosted on Huggingface Space.
  • Google Colab Demo: https://colab.research.google.com/drive/1r7mLEfVynChUUgIfw1r4WZyh9b0QBQdo?usp=sharing
  • Huggingface API Documentation: https://trustsafeai-radar-ai-text-detector.hf.space/?view=api

Training Pipeline

We propose adversarial learning between a paraphraser and our detector. The paraphraser's goal is to make the AI-generated text more like human-writen and the detector's goal is to
promote it's ability to identify the AI-text.

  • (Step 1) Training Data preparation: Before training, we use Vicuna-7B to generate AI-text by performing text completion based on the prefix span of human-text in OpenWebText.
  • (Step 2) Update the paraphraser During training, the paraphraser will do paraphrasing on the AI-text generated in Step 1. And then collect the reward returned by the detector to update the paraphraser using Proxy Proximal Optimization loss.
  • (Step 3) Update the detector The detector is optimized using the logistic loss on the human-text, AI-text and paraphrased AI-text.

See more details in Sections 3 and 4 of this paper.

Ethical Considerations

We suggest users use our tool to assist with identifying AI-written content at scale and with discretion. If the detection result is to be used as evidence, further validation steps are necessary as RADAR cannot always make correct predictions.