Skip to main content

A toolkit for distributional control of generative models

Project description

The 🕺🏽 disco toolkit allows to control the properties of the generations by language models and other generative systems to match human preferences while avoiding catastrophic forgetting.

To achieve this in disco, we first represent in what ways we want to update original model as a target distribution and then, generate samples from this new distribution through a combination of learning or monte-carlo methods, as follows.

Step 1: We express how the target distribution should be

To have a handle on the generative model, we define some feature over the generated samples. It can be anything we can compute. For example, on a language model it can be as simple as whether the generated text contains a certain word or as complex as the compilability of some generated piece of code. Importantly, there is no need for the feature to be differentiable.
Then, we can express our preferences on the target distribution by defining the target moments of this feature. For example, we might want to ask that a certain word appears 50% of the time when sampling from the model; or that 100% of the generated code is compilable. The resulting target distribution is expressed as an energy-based model or EBM, which is an unnormalized probability distribution that respects the desired moments while avoiding catastrophic forgetting, as a result of having minimal KL divergence to the original model.
This representation of the target distribution can score samples, but cannot directly be used to generate them.

Step 2: We generate samples from the target distribution

To generate samples from the target distribution, if not perfectly, we can tune a model to approximate it. The resulting model can generate samples directly from a close approximation of the target distribution. Furthermore, it can be used jointly with Quasi-Rejection Sampling (QRS), a Monte Carlo sampling technique that allows the generation of samples that are even more representative of the target distribution.
Alternatively, it is then possible to use decoding methods such as nucleus sampling, top-k sampling, or beam search, which would return samples from a further updated target distribution.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

disco-generation-1.1.1.tar.gz (30.3 kB view details)

Uploaded Source

File details

Details for the file disco-generation-1.1.1.tar.gz.

File metadata

  • Download URL: disco-generation-1.1.1.tar.gz
  • Upload date:
  • Size: 30.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.13

File hashes

Hashes for disco-generation-1.1.1.tar.gz
Algorithm Hash digest
SHA256 f6e9d8e8cd2f3d189b92a7897c9f5269b2d6119c89381fe6900b106a0cc6d74b
MD5 1223e12bd1e94628e42ff8b5d13f7c0c
BLAKE2b-256 609172a3ef55538678a939f6e4318de1ec7b1b1ed9750d1eeb3455db0289e63d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page