tropt-emb-optbench / README.md
MatanBT's picture
Add trigger_loss: the recipe's loss of each best_trigger_str, scored from the string
a12eff7 verified
|
Raw History Blame Contribute Delete
7.81 kB
---
license: mit
task_categories:
- text-retrieval
tags:
- adversarial
- corpus-poisoning
- optimizers
pretty_name: TROPT EmbOptBench
size_categories:
- 10K<n<100K
configs:
- config_name: triggers
default: true
data_files:
- split: triggers
path: triggers.parquet
- config_name: eval_triggered_messages
data_files:
- split: eval_triggered_messages
path: eval_triggered_messages/*.parquet
---
# TROPT EmbOptBench
Adversarial triggers found by 15 discrete optimizers from
[TROPT](https://github.com/matanbt/tropt) against four embedding models, in
GASLITE's concept-specific corpus-poisoning setting
([Ben-Tov & Sharif, 2025](https://arxiv.org/abs/2412.20953)): each trigger ends
a passage carrying a malicious statement, so that the passage ranks high for one
concept's MSMARCO queries. Each passage comes with its retrieval evaluation on
the concept's held-in and held-out queries.
## Contents
| File | Rows | One row is |
| --- | --- | --- |
| `triggers.parquet` | 28,800 | one optimization run's best trigger at one FLOP checkpoint |
| `eval_triggered_messages/<model_short>.parquet` | 28,800 | one trigger's retrieval evaluation on its concept's held-in and held-out queries |
- **Models (4):** `sentence-transformers/all-MiniLM-L6-v2` (`minilm`),
`intfloat/e5-base-v2` (`e5`), `Qwen/Qwen3-Embedding-0.6B` (`qwen3emb`),
`Qwen/Qwen3-Embedding-8B` (`qwen3emb8b`)
- **Optimizers (15):** `adv_decoding`, `arca`, `autoprompt`, `beast`, `gaslite`,
`gbda`, `gcg`, `gcq`, `hotflip`, `mac`, `mcpal`, `pal`, `pez`, `ral`,
`random_search`. `mcpal` is PAL's search configuration (128 candidates,
top-256 sampling, single-token replacement) with MAC's gradient momentum
(μ = 0.6).
- **Loss:** `Similarity` (minus the cosine similarity to the target) in every
run.
- **Concepts (8):** `boston`, `flower`, `golf`, `iphone`, `mortgage`, `potter`,
`sandwich`, `vaccine`. Each passage is optimized on half of its concept's
queries and evaluated on both halves.
- **Trigger lengths (2):** 30 and 100 tokens.
- **Seeds (3):** 42, 123, 777.
## Loading
```python
from datasets import load_dataset
R = "MatanBT/tropt-emb-optbench"
triggers = load_dataset(R, "triggers", split="triggers")
evals = load_dataset(R, "eval_triggered_messages",
split="eval_triggered_messages")
```
## Concepts
`concept` names a split of
[`MatanBT/msmarco-concepts`](https://huggingface.co/datasets/MatanBT/msmarco-concepts):
its `queries` config holds the concept's MSMARCO queries, and its `corpus`
config the `n_corpus` passages they are ranked against. Each run splits the
concept's queries in half by its seed (`random.Random(seed).shuffle` of the
queries in dataset order): the first half is held-in (`heldin_queries`) and sets
the target, the second is held-out and is only evaluated on.
## `triggers`
Each model has one FLOP budget per run, counting any auxiliary model the
optimizer runs (`google/gemma-2-2b-it`, for `beast` and `adv_decoding`):
| `model_short` | Budget (FLOPs) |
| --- | --- |
| `minilm` | `2.16e14` |
| `e5` | `7.8e15` |
| `qwen3emb` | `7.8e15` |
| `qwen3emb8b` | `1.26e17` |
Every run is capped at 167% of its budget; `hotflip` and `pez` can stop earlier
at 1,500 and 60,000 steps, and `beast` and `adv_decoding` after one step per
trigger token. Its best trigger so far (lowest `best_loss`) is recorded at ten
checkpoints, labeled by their share of the budget: `2pct`, `3pct`, `8pct`,
`17pct`, `33pct`, `50pct`, `70pct`, `100pct`, `133pct`, `167pct`. A checkpoint
excludes the step that crosses it, so `trigger_flops` never exceeds
`budget_flops`; a checkpoint past a run's end holds the run's best trigger.
*Identity*
- `uid` — `{model_short}|{optimizer_name}|{concept}|s{seed}|t{trigger_len}|{budget_label}`,
e.g. `qwen3emb|gcg|potter|s42|t30|100pct`. Referenced by
`eval_triggered_messages.trigger_uid`.
- `model_name`, `model_short` — the target encoder.
- `optimizer_name` — the optimization method.
- `loss_name` — the training loss (`Similarity`).
- `concept` — the concept attacked.
- `seed` — the run's random seed; it also splits the queries.
- `trigger_len` — the trigger's length in tokens (30 or 100).
- `run_id`, `run_name` — wandb run identifiers, for provenance only.
- `tropt_version` — the TROPT the run was optimized with: `gitcommit:<sha>` or
`pypi:<version>`.
*Budget*
- `budget_label`, `budget_fraction`, `budget_flops` — the checkpoint: its label,
its share of the model's budget, and its FLOPs.
*Trigger & result*
- `best_trigger_str` — the optimized trigger.
- `best_loss` — its training loss (lower is better).
- `trigger_loss` — the loss of `best_trigger_str` itself: the string encoded and
scored under the recipe (lower is better).
- `best_cos_sim` — `-best_loss`: the passage's cosine similarity to the target.
- `trigger_flops` — cumulative FLOPs at the step that found this trigger.
- `n_steps_within_budget` — optimizer steps counted toward this checkpoint.
- `run_total_flops`, `run_total_steps` — the full run's totals.
*Inputs*
- `optimized_instruction` — the passage template optimized:
`passage_prefix` + `mal_info` + `{{OPTIMIZED_TRIGGER}}`, the placeholder the
trigger replaces.
- `adv_passage` — the template with `best_trigger_str` in place: the
adversarial passage.
- `mal_info` — the concept's malicious statement, verbatim from GASLITE.
- `passage_prefix`, `query_prefix` — the encoder's input prefixes: `passage: `
and `query: ` for `e5`, an instruction before each query for the Qwen3
models, none for `minilm`.
- `initial_trigger` — the trigger the run started from.
- `target_kind`, `heldin_queries`, `n_held_in`, `n_held_out` — the target
(`heldin_query_centroid`): the normalized mean embedding of the `n_held_in`
held-in queries, each with `query_prefix`; `n_held_out` counts the held-out
ones.
## `eval_triggered_messages`
One file per model, with one row per `triggers` row (every checkpoint). The
trigger's own encoder embeds `adv_passage`, the concept's queries (with
`query_prefix`) and its corpus passages (with `passage_prefix`); for each query,
the passage is ranked against the concept's corpus.
*Trigger identity (copied from `triggers`)*
- `trigger_uid` — `triggers.uid`.
- `model_name`, `model_short`, `optimizer_name`, `loss_name`, `concept`,
`seed`, `trigger_len`, `budget_label`, `best_cos_sim` — as in `triggers`.
*Retrieval* (`{split}` is `heldin` or `heldout`)
- `{split}_cos_sim` — the passage's cosine similarity to the centroid of the
split's queries; `heldin_cos_sim` is the training objective, recomputed from
`adv_passage`.
- `{split}_mean_cos_sim` — the passage's mean cosine similarity to the split's
queries.
- `{split}_appeared@10` — the share of the split's queries whose top 10 results
include the passage.
- `{split}_ranks` — the passage's rank against the concept's corpus, per query
(1 is first; 101 means below the top 100); `heldin_ranks` is aligned with
`triggers.heldin_queries`.
- `n_{split}_eval` — the number of queries in the split.
- `n_corpus` — the number of passages in the concept's corpus.
For example, the mean held-out appeared@10 per optimizer and model, for 30-token
triggers at the budget (`100pct`):
```python
df = evals.to_pandas()
heldout = (df[(df.trigger_len == 30) & (df.budget_label == "100pct")]
.groupby(["model_short", "optimizer_name"])["heldout_appeared@10"]
.mean().unstack(0))
```
## License and citation
MIT. If you use this dataset, please cite the TROPT toolbox
(<https://github.com/matanbt/tropt>).