Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Hugging Face 4 min read Research hardMaster

DiScoFormer: One transformer for density and score, across distributions

DiScoFormer is a transformer that takes a set of sample points and, in one forward pass, estimates both the density and the score (gradient of log-density) of the underlying distribution without per-distribution retraining. It uses cross-attention to query arbitrary points and a shared backbone with density and score heads, whose mismatch serves as a label-free consistency loss for test-time adaptation to out-of-distribution inputs. Attention provably generalizes kernel density estimation, since a single head approximates a Gaussian kernel, and the model is trained on freshly sampled Gaussian mixtures with closed-form targets. In 100 dimensions it cuts score error about 6.5x and density error over 37x versus the best tuned KDE and generalizes to Laplace and Student-t distributions, though KDE remains faster on small datasets.

Assumes: transformer attentionkernel density estimationscore matchingGaussian mixture models

Related posts

  • Towards demystifying the creativity of diffusion models

    Google Research hardMaster

    Diffusion models generalize beyond their training data because neural networks learn a smoothed version of the score function rather than the exact empirical one, which would only reproduce training samples. Regularization, whether explicit weight decay or the implicit bias of gradient training, softens the sharp transitions between training points, creating an interpolation zone where denoised samples settle between known data. A 1-D experiment with two-layer ReLU networks trained by AdamW shows this directly. In higher dimensions the smoothing acts mainly along directions tangential to the data manifold, so samples still converge onto the manifold while spreading between training points, which balances quality and novelty. The work is from an ICLR 2026 paper, and code is released.

  • Finetune Stable Diffusion Models with DDPO via TRL

    Hugging Face hardMaster

    Denoising Diffusion Policy Optimization (DDPO) fine-tunes diffusion models with reinforcement learning by treating the full denoising process as a multistep MDP. Because each step's policy is an isotropic Gaussian, it can use exact per-step likelihoods, unlike reward-weighted regression, which stacks approximations, and it then applies PPO with customized trajectory collection. TRL's new DDPOTrainer lets you fine-tune Stable Diffusion against a CLIP-based aesthetic reward model, needs at least an A100, and ships recommended single-GPU hyperparameters. LoRA training is stable and generalizes across prompts even with a small prompt set; full fine-tuning can give more intricate images but needs a low learning rate (~1e-5) and careful tuning.

  • Nyströmformer: Approximating self-attention in linear time and memory via the Nyström method

    Hugging Face hardMaster

    Nyströmformer replaces quadratic softmax self-attention with an O(n) approximation built on the Nyström method, which reconstructs a matrix from a sampled subset of its rows and columns via a Moore-Penrose pseudoinverse. Sampling columns of the softmax matrix directly is impossible because each entry needs its full row for normalization. The model therefore builds landmarks from segment means of queries and keys and composes three small softmax kernels (n×m, m×m pseudoinverse, m×n), so QKᵀ is never computed. The paper reports 32–64 landmarks staying competitive at sequence lengths of 4096–8192. A walkthrough of the Hugging Face PyTorch implementation follows, along with masked-language-modeling usage of the released checkpoints.

  • Universal Image Segmentation with Mask2Former and OneFormer

    Hugging Face mediumAdept

    Instance, semantic and panoptic segmentation have converged on "universal" architectures that treat every task as binary mask classification rather than per-pixel classification, a line running from DETR through MaskFormer to Mask2Former. Mask2Former passes backbone features through a pixel decoder and uses a Transformer decoder to turn queries into mask and class predictions, but still needs separate training per task. OneFormer adds a text encoder conditioned on the task, so a single panoptic training run matches state of the art on all three tasks, at the cost of extra latency. Code shows panoptic inference and post-processing with Mask2Former in 🤗 transformers, plus the class changes needed to fine-tune from MaskFormer notebooks.

  • Multi-token Residual Prediction

    Modal hardMaster

    Multi-token Residual Prediction (MRP) adapts multi-token prediction to diffusion language models by training a small 3-layer transformer on a frozen backbone to predict the logit residual between adjacent denoising steps, not the full next-step distribution. The residual target is low-complexity, so accuracy holds across several steps: on SDAR-4B GSM8K it scores 57.2% at four steps, while naive full-distribution distillation falls to 1.9%. In the static regime MRP serves as a speculative drafter for lossless speedups of about 1.3–1.4× in SGLang, or commits tokens directly for up to about 1.9× at a small quality cost. In the dynamic regime it remasks over-eager low-threshold reveals and recovers up to roughly +22 accuracy points. The best module depth is 2–3 layers, and shallower modules suit speculative mode.

The quest for software engineering knowledge.

Look:
Layout: