Coder Social home page Coder Social logo

chanliang / watme Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 8.56 MB

The implementation for ACL 2024 paper ”WatME: Towards Lossless Watermarking Through Lexical Redundancy“

Home Page: https://arxiv.org/pdf/2311.09832

Python 90.25% Cython 0.12% JavaScript 0.97% Shell 8.66%
large-language-models text-watermark aigc-detection lossless-watermark

watme's Introduction

WatME: Towards Lossless Watermarking Through Lexical Redundancy

Welcome to the repository for our ACL 2024 paper, "WatME: Towards Lossless Watermarking Through Lexical Redundancy" In this work, we introduce WatME (Watermarking with Mutual Exclusion), a novel approach leveraging linguistic prior knowledge of inherent lexical redundancy in LLMs' vocabularies to seamlessly integrate watermarks.

WatME Method

This illustration highlights the advantages of the WatME (Watermarking with Mutual Exclusion) Method for lossless watermarking. The left panel displays a Vanilla large language model (LLM) that utilizes all available tokens during generation. The middle panel reveals a flaw in traditional KGW-watermarking approaches, which may indiscriminately assign all suitable tokens (e.g., 'ocean' and 'sea') to a red list, thus diminishing the expressiveness of the LLM. The right panel demonstrates how WatME addresses this issue by harnessing lexical redundancy. It applies a mutual exclusion rule to redundant tokens, ensuring that at least one appropriate token remains available (on the green list) during the watermarking process, thereby preserving the expressive power of LLMs.

image

Getting Started

1. Set Up the Environment

Begin by setting up your Conda environment with the provided env.txt file, which will install all necessary packages and dependencies.

cd watermark
pip install -r env.txt

If you run into any missing packages or dependencies, please install them as needed.

2. Explore the Redundancy in Lexical Space

Code for building and processing synonym clusters is located in the synonym directory, with the processed clusters saved in the output directory.

  • Buinding Clusters:

    (a) Use LLMs, e.g. llama to infer synonyms.

    python3 build_cluster_llama.py

    (b) Use an external dictionary (e.g. youdao) to obtain synonyms.

    python3 get_synonmy_by_youdao.py
    python3 build_clusters.py
  • Post-processing:

    python3 filter_cluster.py

3. Exploit the Lexical Redundancy During Watermarking

The process is divided into two main parts: running experiments and parsing results. Ensure that the experimental data is downloaded into the data folder and the processed synonym clusters are placed in the output folder before proceeding.

  • Run experiments with WatME. Execute the following script to run experiments, replacing ${task} with the appropriate task name (e.g., truthfulqa).
bash scripts/${task}_llama2_run.sh 
  • Parse result. After running the experiments, parse the results by executing the script corresponding to the task.
bash scripts/parse_${task}.sh 

Interactive Demo Visualization

You may try our demo, which is implemented using Gradio. For details, please refer to the demo folder.

Citing Our Work

If you find our work helpful in your research, please cite our paper:

@misc{chen2024watme,
      title={WatME: Towards Lossless Watermarking Through Lexical Redundancy}, 
      author={Liang Chen and Yatao Bian and Yang Deng and Deng Cai and Shuaiyi Li and Peilin Zhao and Kam-fai Wong},
      year={2024},
      eprint={2311.09832},
      archivePrefix={arXiv},
      primaryClass={cs.CL}
}

watme's People

Contributors

chanliang avatar

Stargazers

 avatar  avatar  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.