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

Detection Phase #21

Open
kirudang opened this issue Feb 17, 2025 · 1 comment
Open

Detection Phase #21

kirudang opened this issue Feb 17, 2025 · 1 comment

Comments

@kirudang
Copy link

Hello,

I already generated watermarked data with the below code sample:

from transformers import (
    AutoModelForCausalLM,
    AutoTokenizer,
    SynthIDTextWatermarkingConfig,
)

# Standard model and tokenizer initialization
tokenizer = AutoTokenizer.from_pretrained('repo/id')
model = AutoModelForCausalLM.from_pretrained('repo/id')

# SynthID Text configuration
watermarking_config = SynthIDTextWatermarkingConfig(
    keys=[654, 400, 836, 123, 340, 443, 597, 160, 57, ...],
    ngram_len=5,
)

# Generation with watermarking
tokenized_prompts = tokenizer(["your prompts here"])
output_sequences = model.generate(
    **tokenized_prompts,
    watermarking_config=watermarking_config,
    do_sample=True,
)
watermarked_text = tokenizer.batch_decode(output_sequences)

Could you help me with:
How to train the detector and how to detect the watermark?
My length of output text is maximum 200 tokens, can you suggest the threshold for detection?

@sdathath
Copy link
Collaborator

Hello,

Have you tried following along with the colab here: https://github.com/google-deepmind/synthid-text/blob/main/notebooks/synthid_text_huggingface_integration.ipynb?

There a few detectors that do not need training, you could get started with them and see if you see that the scores for watermarked text and unwatermarked text follow different distributions. Following that, there's also a section of the colab that shows you how to train a detector if the performance of the detectors that aren't trained does not suffice.

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