transformers/docs/source/en/main_classes/text_generation.md
Joao Gante b0f0c61899
Add SynthID (watermerking by Google DeepMind) (#34350)
* Add SynthIDTextWatermarkLogitsProcessor

* esolving comments.

* Resolving comments.

* esolving commits,

* Improving SynthIDWatermark tests.

* switch to PT version

* detector as pretrained model + style

* update training + style

* rebase

* Update logits_process.py

* Improving SynthIDWatermark tests.

* Shift detector training to wikitext negatives and stabilize with lower learning rate.

* Clean up.

* in for 7B

* cleanup

* upport python 3.8.

* README and final cleanup.

* HF Hub upload and initiaze.

* Update requirements for synthid_text.

* Adding SynthIDTextWatermarkDetector.

* Detector testing.

* Documentation changes.

* Copyrights fix.

* Fix detector api.

* ironing out errors

* ironing out errors

* training checks

* make fixup and make fix-copies

* docstrings and add to docs

* copyright

* BC

* test docstrings

* move import

* protect type hints

* top level imports

* watermarking example

* direct imports

* tpr fpr meaning

* process_kwargs

* SynthIDTextWatermarkingConfig docstring

* assert -> exception

* example updates

* no immutable dict (cant be serialized)

* pack fn

* einsum equivalent

* import order

* fix test on gpu

* add detector example

---------

Co-authored-by: Sumedh Ghaisas <sumedhg@google.com>
Co-authored-by: Marc Sun <marc@huggingface.co>
Co-authored-by: sumedhghaisas2 <138781311+sumedhghaisas2@users.noreply.github.com>
Co-authored-by: raushan <raushan@huggingface.co>
2024-10-23 21:18:52 +01:00

2.2 KiB

Generation

Each framework has a generate method for text generation implemented in their respective GenerationMixin class:

  • PyTorch [~generation.GenerationMixin.generate] is implemented in [~generation.GenerationMixin].
  • TensorFlow [~generation.TFGenerationMixin.generate] is implemented in [~generation.TFGenerationMixin].
  • Flax/JAX [~generation.FlaxGenerationMixin.generate] is implemented in [~generation.FlaxGenerationMixin].

Regardless of your framework of choice, you can parameterize the generate method with a [~generation.GenerationConfig] class instance. Please refer to this class for the complete list of generation parameters, which control the behavior of the generation method.

To learn how to inspect a model's generation configuration, what are the defaults, how to change the parameters ad hoc, and how to create and save a customized generation configuration, refer to the text generation strategies guide. The guide also explains how to use related features, like token streaming.

GenerationConfig

autodoc generation.GenerationConfig - from_pretrained - from_model_config - save_pretrained - update - validate - get_generation_mode

GenerationMixin

autodoc GenerationMixin - generate - compute_transition_scores

TFGenerationMixin

autodoc TFGenerationMixin - generate - compute_transition_scores

FlaxGenerationMixin

autodoc FlaxGenerationMixin - generate