Papers › Revisiting Character-level Adversarial Attacks for Language Models

Revisiting Character-level Adversarial Attacks for Language Models

7 May 2024arXiv:2405.04346archive 2025-07-28

Elias Abad Rocamora, Yongtao Wu, Fanghui Liu, Grigorios G. Chrysos, Volkan Cevher

Adversarial attacks in Natural Language Processing apply perturbations in the character or token levels. Token-level attacks, gaining prominence for their use of gradient-based methods, are susceptible to altering sentence semantics, leading to invalid adversarial examples. While character-level attacks easily maintain semantics, they have received less attention as they cannot easily adopt popular gradient-based methods, and are thought to be easy to defend. Challenging these beliefs, we introduce Charmer, an efficient query-based adversarial attack capable of achieving high attack success rate (ASR) while generating highly similar adversarial examples. Our method successfully targets both small (BERT) and large (Llama 2) models. Specifically, on BERT with SST-2, Charmer improves the ASR in 4.84% points and the USE similarity in 8% points with respect to the previous art. Our implementation is available in https://github.com/LIONS-EPFL/Charmer.

PaperPDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2405.04346")

Code

Syntology Ran 23 of 31 code samples harvested from 1 repository linked to this paper; 8 have no recorded run. Of those that ran: 9 ran · our draft was wrong; 1 ran · fixture could not drive it; 13 ran with no contract checked.

By repository: official repository: 31 samples from 1 repository, 23 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

lions-epfl/charmer officialmentioned in paperpytorchMIT report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

31 samples harvested; 23 ran; 0 honoured the contract we drafted; 8 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

9ran · our draft was wrong
1ran · fixture could not drive it
13ran
8unverified

Licence: 0 of the 31 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from lions-epfl/charmer. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

CrossEntropyLoss_negative lions-epfl/charmer/charmer.py official repository ran MIT (permissive) · 6a768c7d89fa45a6 · report
all_strings_within_edit1 lions-epfl/charmer/charmer.py official repository ran · our draft was wrong MIT (permissive) · b87dfb2a13227d05 · report
all_strings_within_editx lions-epfl/charmer/charmer.py official repository ran · our draft was wrong MIT (permissive) · 232efbd63c8df619 · report
backtrace lions-epfl/charmer/charmer.py official repository ran · fixture could not drive it MIT (permissive) · 96a7b58d20a2005f · report
compute_centroid_distances LIONS-EPFL/Charmer/baseline/roben/agglom_clusters.py official repository ran fingerprinted MIT (permissive) · 92dfc8c506947d1c · report
concat_prompt_question_label lions-epfl/charmer/charmer.py official repository ran · our draft was wrong MIT (permissive) · 7a4e3ab49ac3c159 · report
ctx_noparamgrad lions-epfl/charmer/charmer.py official repository ran MIT (permissive) · 4e36262a542c16fb · report
generate_all_sentences lions-epfl/charmer/charmer.py official repository ran · our draft was wrong fingerprinted MIT (permissive) · 7b06bf5b0955fdac · report
generate_all_sentences_at_z lions-epfl/charmer/charmer.py official repository ran · our draft was wrong MIT (permissive) · b82a34d25dd75308 · report
generate_sentence lions-epfl/charmer/charmer.py official repository ran · our draft was wrong MIT (permissive) · 7f56e8436fe9b621 · report
get_class_num LIONS-EPFL/Charmer/dataloader.py official repository ran fingerprinted MIT (permissive) · 904d63da437332d4 · report
get_goals_and_targets LIONS-EPFL/Charmer/utils_jailbreak.py official repository ran MIT (permissive) · 55554ebb64125749 · report
get_module_training_state LIONS-EPFL/Charmer/context.py official repository ran MIT (permissive) · 28413f6ed2f091a9 · report
get_param_grad_state lions-epfl/charmer/charmer.py official repository ran · our draft was wrong MIT (permissive) · 41eb44fa1a771cd1 · report
get_task_type LIONS-EPFL/Charmer/dataloader.py official repository ran MIT (permissive) · 75df2d0c0186e517 · report
get_vocabulary LIONS-EPFL/Charmer/utils.py official repository ran MIT (permissive) · 593614c84d8b37c2 · report
llm_input_processor lions-epfl/charmer/charmer.py official repository ran MIT (permissive) · 456e7d855a79eb1e · report
margin_loss_llm lions-epfl/charmer/charmer.py official repository ran MIT (permissive) · 28879c448358c558 · report
margin_loss_lm lions-epfl/charmer/charmer.py official repository ran · our draft was wrong fingerprinted MIT (permissive) · 7eae0eca72c38f98 · report
margin_loss_lm_batched lions-epfl/charmer/charmer.py official repository ran MIT (permissive) · f38056701ce7c0b6 · report
target_loss LIONS-EPFL/Charmer/utils_jailbreak.py official repository ran MIT (permissive) · 11a3348eb0e4ba60 · report
update_mu LIONS-EPFL/Charmer/baseline/roben/agglom_clusters.py official repository ran fingerprinted MIT (permissive) · 12efa3ddd30cf7c2 · report
word_edit_distance lions-epfl/charmer/charmer.py official repository ran · our draft was wrong fingerprinted MIT (permissive) · f0c1289fd2565267 · report
Charmer lions-epfl/charmer/charmer.py official repository unverified MIT (permissive) · 59ab5813bed83cb2 · report
combined_emb_input LIONS-EPFL/Charmer/utils.py official repository unverified MIT (permissive) · a299d58465c7bf59 · report
get_llm_embeddings lions-epfl/charmer/charmer.py official repository unverified MIT (permissive) · 8ae9f9ad369707a9 · report
get_llm_encoder lions-epfl/charmer/charmer.py official repository unverified MIT (permissive) · 6297161e122df004 · report
load_attack_dataset LIONS-EPFL/Charmer/dataloader.py official repository unverified MIT (permissive) · 7f504481b40a6171 · report
resize_embeddings lions-epfl/charmer/charmer.py official repository unverified MIT (permissive) · cb53a78f621babdb · report
set_param_grad_off lions-epfl/charmer/charmer.py official repository unverified MIT (permissive) · e75d10fb3cfbb60c · report
set_param_grad_state lions-epfl/charmer/charmer.py official repository unverified MIT (permissive) · ea9f4cd8cc668205 · report

Tasks

Adversarial AttackSentence

1 archive task tag without a task page not shown.

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Methods

AdamAttentionAttention DropoutBERTDense ConnectionsDropoutLayer NormalizationLinear LayerLinear Warmup With Linear DecayMulti-Head AttentionResidual ConnectionSoftmaxUSEWeight DecayWordPiece

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections