Giter Site home page Giter Site logo

markchenyutian / t5-sentinel-public Goto Github PK

View Code? Open in Web Editor NEW
17.0 1.0 1.0 260 KB

Release repo for our work "Token Prediction as Implicit Classification to Identify LLM-Generated Text"

License: MIT License

Python 18.18% Jupyter Notebook 81.82%
emnlp2023

t5-sentinel-public's Introduction

image

Release repo for our work "Token Prediction as Implicit Classification to Identify LLM-Generated Text"

Abstract

This paper introduces a novel approach for identifying the possible large language models (LLMs) involved in text generation. Instead of adding an additional classification layer to a base LM, we reframe the classification task as a next-token prediction task and directly fine-tune the base LM to perform it. We utilize the Text-to-Text Transfer Transformer (T5) model as the backbone for our experiments. We compared our approach to the more direct approach of utilizing hidden states for classification. Evaluation shows the exceptional performance of our method in the text classification task, highlighting its simplicity and efficiency. Furthermore, interpretability studies on the features extracted by our model reveal its ability to differentiate distinctive writing styles among various LLMs even in the absence of an explicit classifier. We also collected a dataset named OpenLLMText, containing approximately 340k text samples from human and LLMs, including GPT3.5, PaLM, LLaMA, and GPT2.

Evaluation Result Overview

image

Requirement

Run pip install -r requirements.txt to install dependencies.

Note that the baseline model proposed by Solaiman et al. requires a legacy version of library transformers, the detailed environment requirements for baseline model is placed in here

Evaluate

  1. Run ./data/download.py to automatically download dataset & model checkpoints
  2. Run the following files in need
    1. ./evaluator/calc/calc_accuracy.py to calculate the accuracy under different settings for each module
    2. ./evaluator/interpret/integrated_gradient.ipynb to calculate the integrated gradient for samples
    3. ./evaluator/interpret/sample_pca.py to calculate the PCA analysis for hidden layers of the test subset
    4. ./evaluator/plot/*.py to generate plots of related metrics (confusion matrix, roc, det, etc.)

Note that python files are in module, so to use ./evaluator/calc/calc_accuracy.py, you need to run python3 -m evaluator.calc.calc_accuracy.

Train

  1. Use the ./detector/t5/arbitrary/__main__.py to train the T5-Sentinel Model

    (The detailed hyperparameter setup we used for training the T5-Sentinel model in paper is presented in settings_0613_full.yaml)

  2. Use the ./detector/t5/arbitrary_hidden/__main__.py to train the T5-Hidden Model

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.