# SWaRL: Safeguard Code Watermarking via Reinforcement Learning

Source: [SWaRL: Safeguard Code Watermarking via Reinforcement Learning](<https://www.sota2.com/research/paper/695de87653fdd5c361743c1f>)

Collection index: [llms.txt](<https://www.sota2.com/research/llms.txt>)

Data updated: 2026-05-12T05:00:04.826Z

Authors: Neusha Javidnia, Ruisi Zhang, Ashish Kundu, Farinaz Koushanfar

Published: 2026-01-05T23:35:39.000Z

## Abstract

We present SWaRL, a robust and fidelity-preserving watermarking framework designed to protect the intellectual property of code LLMs by embedding unique and verifiable signatures in the generated program. Existing watermarking approaches either rely on handcrafted code transformations or manipulate token generation probabilities at inference time, making them vulnerable to removal attacks or prone to breaking functional correctness. To address these challenges, SWaRL employs a reinforcement learning-based co-training framework that uses compiler feedback for functional correctness and a jointly trained confidential verifier as a reward signal to maintain watermark detectability. Furthermore, SWaRL employs low-rank adaptation (LoRA) during fine-tuning, enabling efficient integration of watermarking behavior and transferability across model updates. Extensive experiments show that SWaRL achieves strong watermark detection accuracy compared to prior methods while fully maintaining watermarked code functionality. Moreover, SWaRL exhibits strong resilience against refactoring and adversarial transformation attacks, which maintains reliable attribution without substantial computational overhead.

## Recorded benchmark results

A research result applies to its stated dataset, split, metric and evaluation configuration. Compare like-for-like settings, preserve the metric's unit and direction, and distinguish paper-reported results from independent reproduction. The best result recorded here is not a claim of exhaustive, current global coverage.

- [Watermark Detection on HumanEval+](<https://www.sota2.com/research/sota/watermark-detection-on-humaneval-plus.md>): Watermark Detection; HumanEval+; AUROC: 0.705.

- [Watermark Detection on MBPP+](<https://www.sota2.com/research/sota/watermark-detection-on-mbpp-plus.md>): Watermark Detection; MBPP+; AUROC: 77.2.

- [Code Generation on MBPP+ (pass@1)](<https://www.sota2.com/research/sota/code-generation-on-mbpp-plus-pass-at-1.md>): Code Generation; MBPP+; Pass@1: 66.2.

- [Code Generation on HumanEval+](<https://www.sota2.com/research/sota/code-generation-on-humaneval-plus.md>): Code Generation; HumanEval+; Pass@1: 52.36.

- [Code Generation on HumanEval](<https://www.sota2.com/research/sota/code-generation-on-humaneval.md>): Code Generation; HumanEval; Pass@1: 58.22.

- [Watermark Detection on MBPP](<https://www.sota2.com/research/sota/watermark-detection-on-mbpp.md>): Watermark Detection; MBPP; TPR @ 1% FPR: not recorded.

- [Watermark Detection on HumanEval](<https://www.sota2.com/research/sota/watermark-detection-on-humaneval.md>): Watermark Detection; HumanEval; F1 Score: not recorded.

## Original sources and implementation

[Original paper](<https://arxiv.org/abs/2601.02602>)

[PDF](<https://arxiv.org/pdf/2601.02602.pdf>)
