Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unbiased Watermark #24

Open
kirudang opened this issue Oct 11, 2024 · 4 comments
Open

Unbiased Watermark #24

kirudang opened this issue Oct 11, 2024 · 4 comments

Comments

@kirudang
Copy link

Hello,

Could you help me with a sample code of Invoking watermarking algorithms for Unbias Watermark?
I know from the original paper that we can either choose delta-reweight or gamma-reweight, but from your code, I dont know how to apply to my use case.
Thank you

@panly2003
Copy link
Contributor

Thank you for your issue. We currently only support Gamma reweight, as delta-reweight significantly impacts text quality. We appreciate your suggestion and plan to add delta-reweight implementation in a future update. Thanks for helping us improve. 😊

@kirudang
Copy link
Author

Hello there,
Thank you for your prompt return and I really appreciate your effort to make the code run.

If you are able to run the delta-reweight, may you share the file with me? Sorry If I am asking too much.
I think it is okay to take a look at the watermarked output of delta-reweight as delta-rewieght is more logit-based watermark than gamma (in term of logic and intuition), I believe.
Actually, I am able to run the code from the original paper (link: https://github.com/xiaoniu-578fa6bff964d005/UnbiasedWatermark ) but for some reasons, it always stops at 499th data point due to the below error:

Processing input 498 of 2000
Traceback (most recent call last):
  File "/network/rit/lab/Lai_ReSecureAI/kiel/Unbiased_WM/Gen_llama2.py", line 84, in <module>
    outputs = model.generate(
              ^^^^^^^^^^^^^^^
  File "/network/rit/lab/Lai_ReSecureAI/kiel/Unbiased_WM/unbiased_watermark/monkeypatch.py", line 20, in generate
    return original_generate(*args, **kargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/network/rit/lab/Lai_ReSecureAI/kiel/Unbiased_WM/unbiased_watermark/monkeypatch.py", line 20, in generate
    return original_generate(*args, **kargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/network/rit/lab/Lai_ReSecureAI/kiel/Unbiased_WM/unbiased_watermark/monkeypatch.py", line 20, in generate
    return original_generate(*args, **kargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  [Previous line repeated 495 more times]
  File "/network/rit/lab/Lai_ReSecureAI/kiel/anaconda3/envs/unbias_wm/lib/python3.12/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/network/rit/lab/Lai_ReSecureAI/kiel/anaconda3/envs/unbias_wm/lib/python3.12/site-packages/transformers/generation/utils.py", line 1945, in generate
    prepared_logits_processor = self._get_logits_processor(
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/network/rit/lab/Lai_ReSecureAI/kiel/Unbiased_WM/unbiased_watermark/monkeypatch.py", line 23, in _get_logits_processor
    processors = original__get_logits_processor(*args, **kargs)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/network/rit/lab/Lai_ReSecureAI/kiel/Unbiased_WM/unbiased_watermark/monkeypatch.py", line 23, in _get_logits_processor
    processors = original__get_logits_processor(*args, **kargs)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/network/rit/lab/Lai_ReSecureAI/kiel/Unbiased_WM/unbiased_watermark/monkeypatch.py", line 23, in _get_logits_processor
    processors = original__get_logits_processor(*args, **kargs)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  [Previous line repeated 495 more times]
  File "/network/rit/lab/Lai_ReSecureAI/kiel/anaconda3/envs/unbias_wm/lib/python3.12/site-packages/transformers/generation/utils.py", line 873, in _get_logits_processor
    processors = self._merge_criteria_processor_list(processors, logits_processor)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RecursionError: maximum recursion depth exceeded

Or if you can share monkeypatch.py, I would be really grateful for it.
Thank you.

@panly2003
Copy link
Contributor

Thanks for your questions. We will release the implementation of delta-reweight as soon as possible. Then you can use our code to run your experiment. 😊

@kirudang
Copy link
Author

Thank you Panly
Please let me know when you've released the code by commenting here.
Thank you and have a great weekend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants