Language model with adversarial loss
Explorations into adversarial losses on top of autoregressive loss for language modeling
I have tried this in the past, when GANs were still dominant. But at the time I was either too inexperienced or the research not there. Either way could not get it working. Will give it another shot in the next few weeks, mainly to see if an adversarial system could benefit world modeling
Usage
import torch
from transformer_lm_gan import (
LanguageModelGenerator,
Discriminator,
GAN,
)
gan = GAN(
strategy = 'gumbel_one_hot', # or 'rotate' for rotation trick, may try combination of two if both fails in experiments
generator = dict(
num_tokens = 256,
dim = 512,
depth = 6,
dim_head = 64,
heads = 8,
max_seq_len = 1024
),
discriminator = dict(
num_tokens = 256,
dim = 512,
depth = 2,
dim_head = 64,
heads = 9,
max_seq_len = 1024
)
).cuda()
seq = torch.randint(0, 256, (2, 1024)).cuda()
discr_loss = gan.discriminate_forward(seq)
discr_loss.backward()
gen_loss = gan.generate_forward(seq)
gen_loss.backward()
Citations
@inproceedings{Huang2025TheGI,
title = {The GAN is dead; long live the GAN! A Modern GAN Baseline},
author = {Yiwen Huang and Aaron Gokaslan and Volodymyr Kuleshov and James Tompkin},
year = {2025},
url = {https://api.semanticscholar.org/CorpusID:275405495}
}
Metadata
Release files for transformer-lm-gan 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| transformer_lm_gan-0.0.5.tar.gz | 5.9 kB | Without provenance | Details for transformer_lm_gan-0.0.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| transformer_lm_gan-0.0.5-py3-none-any.whl | Python 3 | none | any | Details for transformer_lm_gan-0.0.5-py3-none-any.whl |
Total release size: 11.6 kB
Release files / transformer_lm_gan-0.0.5.tar.gz
| Download URL | transformer_lm_gan-0.0.5.tar.gz |
|---|---|
| Size | 5.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d62126cfdb809a4094dbe921ef555458cad96c88b01ec88fde18ef710bda079f
|
|
BLAKE2b-256 checksum How to use checksums |
c28c25e88e659663d591a4ced9092d27983fcdd6f03752d52c4265a05be8dfcb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.13
|
Release files / transformer_lm_gan-0.0.5-py3-none-any.whl
| Download URL | transformer_lm_gan-0.0.5-py3-none-any.whl |
|---|---|
| Size | 5.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
36190f7d44f218b937c84549b2479027a449f164cb549d94232626d760bf3247
|
|
BLAKE2b-256 checksum How to use checksums |
d660115d57b7d4b1e138faee91b2ef521036fb2959506c4bd8663811a570a0e8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.13
|
Security for transformer-lm-gan 0.0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.