You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -96,15 +96,15 @@ result = optimizer.optimize_trigger(
96
96
```
97
97
98
98
You can replace any component in this recipe code with another compatible one; e.g., swap the loss or optimizer with a more sophisticated one to enhance the jailbreak.
99
-
For more examples see [quickstart.ipynb](quickstart.ipynb) notebook, and the detailed guide on [adding a recipe](docs/guides/adding_a_recipe.md).
99
+
For more examples see [quickstart.ipynb](quickstart.ipynb) notebook, and the detailed guide on [adding a recipe](https://tropt.dev/guides/adding_a_recipe.html).
100
100
101
101
### Build New Optimizers & Losses 🔬
102
102
103
103
TROPT is designed as a **factory for new optimizers and losses**. Each is a self-contained module behind a compact, standardized interface. This makes optimizer and loss modules more transparent and easy to read, and easily extensible: creating a new optimizer largely amounts to defining its search algorithm, and a new loss to defining its core computation.
104
104
TROPT internally handles the repeated logic required to operate these modules, including input--trigger management, batching, tokenization blocking, trigger gradient computation, etc.
105
105
Your new optimizer or loss then composes automatically with every existing model and counterpart component.
106
106
107
-
Quick examples for a custom optimizer and loss are in [quickstart.ipynb](quickstart.ipynb); the docs have more detailed guides on building [optimizers](docs/guides/adding_an_optimizer.md) and [losses](docs/guides/adding_a_loss.md).
107
+
Quick examples for a custom optimizer and loss are in [quickstart.ipynb](quickstart.ipynb); the docs have more detailed guides on building [optimizers](https://tropt.dev/guides/adding_an_optimizer.html) and [losses](https://tropt.dev/guides/adding_a_loss.html).
You do **not** implement `compute_loss_from_tokens`, `compute_grad_from_tokens`, or `compute_grad_from_embeds` — those come from `HuggingFaceBackendModel`.
421
+
You do **not**need to implement `compute_loss_from_tokens`, `compute_grad_from_tokens`, or `compute_grad_from_embeds` — those come from `HuggingFaceBackendModel`.
422
422
423
-
---
424
-
425
-
## Checklist
426
-
427
-
1.**Verify optimizer compatibility** — Instantiate an optimizer that requires your model's mixins and confirm `model_requirements` validation passes.
428
-
2.**Usage stats** — Confirm `invoke_from_tokens` calls `_update_invoke_stats` with `n_tokens`, `n_samples`, and `count_backward`. Gradient methods should pass `count_backward=True` to `invoke_from_tokens`. For HuggingFace models this is already handled by `HuggingFaceBackendModel`. This takes care of usage tracking and FLOPs.
429
-
3.**Test** — Write tests covering initialization, the inference method, and each mixin method. Test both single and multi-template cases. See `tests/models/` for examples.
430
-
431
-
> Want to contribute your model backend back to the TROPT package? See [CONTRIBUTING.md](https://github.com/matanbt/TROPT/blob/main/CONTRIBUTING.md) for the file placement, export, and testing steps.
0 commit comments