Discrete Autoregressive Transformer for Generative Mechanism Synthesis

arXiv cs.LG Papers

Summary

This paper presents a discrete autoregressive transformer that generates planar mechanisms from target coupler curves, using variational autoencoder latents and tokenized joint coordinates to achieve diverse, accurate designs across multiple topologies.

arXiv:2606.17409v1 Announce Type: new Abstract: Planar path synthesis requires mechanisms whose coupler curves match a prescribed trajectory; the mapping from curve to linkage is inherently one-to-many across four-, six-, and eight-bar topologies. We address this design problem with simulation-grounded evaluation on a curated corpus of over one million mechanisms, reporting Chamfer distance and dynamic time warping after forward kinematics and geometric alignment. We formulate synthesis as conditional autoregressive sequence modeling: joint coordinates are uniformly quantized to tokens and generated by a decoder-only transformer with a variational-autoencoder (VAE) latent of the target curve and an explicit mechanism-type token. Training combines token cross-entropy with a Gaussian-smoothed bin auxiliary loss that respects ordinal structure among bins. At inference, a bounded latent-noise schedule decodes all mechanism types at each noise level; we retain the top five candidates by geometric error, yielding diverse accurate families without dataset lookup. On held-out tests, aggregate mean Chamfer distance is $0.0132$ and mean dynamic time warping is $0.153$; a latent $k$-nearest-neighbor baseline that conditions on training-set neighbor latents in VAE space achieves matched-topology mean Chamfer distance $0.0071$ and mean dynamic time warping $0.117$ using the same decoder.
Original Article
View Cached Full Text

Cached at: 06/17/26, 05:37 AM

# Discrete Autoregressive Transformer for Generative Mechanism Synthesis
Source: [https://arxiv.org/html/2606.17409](https://arxiv.org/html/2606.17409)
Anurag PurwarComputer\-Aided Design and Innovation Lab, Department of Mechanical Engineering, Stony Brook University, Stony Brook, NY 11794\-2300, USA

###### Abstract

Engineering application\.Planar path synthesis requires mechanisms whose coupler curves match a prescribed trajectory; the mapping from curve to linkage is inherently one\-to\-many across four\-, six\-, and eight\-bar topologies\. We address this design problem with simulation\-grounded evaluation on a curated corpus of over one million mechanisms, reporting Chamfer distance and dynamic time warping after forward kinematics and geometric alignment\.

Artificial intelligence contribution\.We formulate synthesis as conditional autoregressive sequence modeling: joint coordinates are uniformly quantized to tokens and generated by a decoder\-only transformer with a variational\-autoencoder \(VAE\) latent of the target curve and an explicit mechanism\-type token\. Training combines token cross\-entropy with a Gaussian\-smoothed bin auxiliary loss that respects ordinal structure among bins\. At inference, a bounded latent\-noise schedule decodes all mechanism types at each noise level; we retain the top five candidates by geometric error, yielding diverse accurate families without dataset lookup\. On held\-out tests, aggregate mean Chamfer distance is0\.01320\.0132and mean dynamic time warping is0\.1530\.153; a latentkk\-nearest\-neighbor baseline that conditions on training\-set neighbor latents in VAE space achieves matched\-topology mean Chamfer distance0\.00710\.0071and mean dynamic time warping0\.1170\.117using the same decoder\.

###### keywords:

Mechanism synthesis , Autoregressive transformer , Coupler curves , Variational autoencoder , Generative design , Kinematic simulation

††journal:Engineering Applications of Artificial Intelligence## 1Introduction

Mechanism synthesis for path, function, and motion generation has been a central topic in mechanical engineering for decades\. In path synthesis, the objective is to design a mechanism whose coupler traces a prescribed trajectory, commonly referred to as a coupler curve\. Figure[1](https://arxiv.org/html/2606.17409#S1.F1)shows an example path generation problem where given a coupler curve for walking motion, goal is to synthesize a variety of legged walking mechanisms for integration in robotic systemsTang2026\. Classical formulations discretize the desired path into a finite set of precision points, either directly specified or sampled from a continuous path\. For example, analytical synthesis methods can yield exact solutions for up to nine precision points for planar four\-bar linkage mechanismsWampler1992\. In general, the problem is overdetermined and approximate solutions based on numerical optimization are requirednocedal2006numerical\.

![Refer to caption](https://arxiv.org/html/2606.17409v1/figures/leg-mechanisms.png)Figure 1:Four different types of legged walking mechanismsWhile optimization\-based approaches have been widely adopted, they suffer from several fundamental limitationsNurizada2025cBetaVAE\. These methods are often sensitive to initial conditions, computationally expensive, and provide no guarantees of convergence to high\-quality solutions\. Moreover, they typically ensure interpolation only at discrete precision points, failing to capture the global shape of the desired coupler curve\. Objective functions such as the Structural Error, which simultaneously optimize curve shape, scale, orientation, and positionErdman2001MechanismDesign, frequently mischaracterize the synthesis problem and lead to impractical solutions\. Perhaps most critically, optimization\-based methods generally yield a single mechanism per design task, despite the inherently one\-to\-many nature of path synthesis\. In conceptual mechanism design, however, engineers often seek a diverse set of feasible solutions to accommodate additional constraints such as joint placement, link length ratios, workspace limitations, or manufacturability\.

To address some of these challenges, alternative formulations have been proposed that synthesize mechanisms capable of tracing continuous paths rather than interpolating finite point sets\. Such approaches explicitly confront the overdetermined nature of coupler\-curve synthesis, where the coefficients of the curve equation exceed the available design parametersBai2015\. Although more complex linkages, such as six\- and eight\-bar mechanisms, offer increased expressive power and can realize intricate motions, their synthesis remains challenging due to the expanded design space and increased computational complexity\. Advanced optimization strategies have been applied in this context, yet scalability and robustness remain open problems\.

In recent years, approaches grounded in machine learning \(ML\) have emerged as a promising paradigm for mechanism synthesis\. Early work leveraged artificial neural networks \(ANNs\)Hoskins1993;vasiliu2001;Xie2007;galan2009;khan2015;Ahmadi2016;Li2017;Mo2019;Yim2021;Kapsalyamov2023;Yim2023to learn inverse mappings between coupler curve representations and mechanism parameters, enabling near\-instantaneous synthesis once trained\. These studies explored a variety of curve representations, including Cartesian coordinates, Fourier descriptorskhan2015;Li2017, waveletsgalan2009, and image\-based encodingsNurizada2024InvariantCoupler\. However, most ANN\-based methods treat synthesis as a deterministic regression problem and produce only a single mechanism of a fixed type for a given input curve\. Nurizada and PurwarNurizada2024InvariantCouplersystematically demonstrated that different coupler curve representations do not yield meaningful performance differences across learning\-based models, highlighting that representation choice alone does not resolve the fundamental limitations of one\-to\-one prediction\.

Subsequent work has increasingly adopted generative formulations to address the one\-to\-many structure of path synthesis\. A comprehensive review by Nurizada and PurwarNurizada2025cBetaVAEsurveyed over three decades of learning\-based approaches, including regression models, reinforcement learningVermeer2018;Fogelson2023, latent\-variable generative modelskingma2014autoencoding, and hybrid optimization pipelinesnocedal2006numerical\. Representative recent systems include CLIP\-style joint embedding of mechanisms and curves with optimization\-based refinementnobari2024linklearningjointrepresentations;radford2021learningand transformer\-based sequence modeling over discretized joint coordinatesBolanos2025\. Progress in these directions has been enabled by large\-scale datasets\. The corpus of Nurizada et al\.Nurizada2025Datasetcontains on the order of three million planar mechanisms across four\-, six\-, and eight\-bar families \(including prismatic variants\); the LINKS dataset of Nobari et al\.Nobari2022LINKSDatasetemphasizes richer topological diversity at the cost of many samples being structurally impractical for manufacture\. Together, such resources make it realistic to train conditional models that span multiple linkage classes, but they also raise the question of how to evaluate and diversify synthesis under a single, simulation\-grounded contract\.

Despite this progress, practical gaps remain\. Many learning pipelines still emphasize a single predicted mechanism per query, depend on multi\-stage architectures, or offer limited control over topology at generation time\. Reinforcement\-learning approachesVermeer2018;Fogelson2023can explore large spaces but are often costly per sample, which is awkward for interactive or high\-throughput design\. There is also a need for inference\-time procedures that surface*several*accurate, distinct mechanism families for the same target coupler curve while keeping scores comparable across published methods\.

Motivated by these gaps, we present a single discrete autoregressive transformer on a curated multi\-topology subset ofNurizada2025Dataset\. The model conditions on a VAE latent of the target coupler curve and on an explicit mechanism\-type token, generates quantized joint coordinates with a LLaMA\-style causal decodertouvron2023llama, and is trained with token cross\-entropy plus a geometry\-aware smoothed\-bin auxiliary lossszegedy2016rethinking\. Figure[2](https://arxiv.org/html/2606.17409#S1.F2)sketches the pipeline; Section[2](https://arxiv.org/html/2606.17409#S2)fixes notation and data representation, Section[3](https://arxiv.org/html/2606.17409#S3)the architecture and training objective, and Section[4](https://arxiv.org/html/2606.17409#S4)the simulation\-grounded evaluation and inference\-time procedures \(greedy decodingsutskever2014sequence, latent\-noise sweeps with cross\-topology top\-KKselection, and a latent KNN baseline that reuses the same decoder\)\.

![Refer to caption](https://arxiv.org/html/2606.17409v1/figures/discrete_model.png)Figure 2:Overview of the discrete transformer architecturevaswani2017attention;touvron2023llama\. Continuous joint coordinates are discretized into bins and represented as integer tokensBolanos2025;oord2017neural\. A latent geometric token \(from the VAEkingma2014autoencodingembedding of the input coupler curve\) and a mechanism\-type token are prepended to the sequence\. A LLaMA\-style decoder processes these tokens with causal maskingvaswani2017attentionand predicts discretized coordinate tokens\. Together with the selected mechanism type, the decoded sequence defines a linkage configuration\.Prior learning pipelines differ in how they score coupler agreement: the dataset paperNurizada2025Datasetillustrates accuracy with bidirectional Chamfer distance from*unsquared*Euclidean nearest\-neighbor terms after independent per\-curve normalization and a VAE–kk\-NN*retrieval*stage that returns stored candidates, whereas conditionalβ\\beta\-VAE synthesisNurizada2025cBetaVAEand transformer\-based mechanism generationBolanos2025report dynamic time warping under other normalizations and software conventions\. Published scalars are therefore not literal drop\-in comparisons to ours\. In this work, all reported mechanisms are produced by autoregressive decoding; we do not output dataset mechanism parameters by lookup\. The primary protocol conditions on the target curve’s VAE latent and on noised variants thereof \- points in latent space that need not coincide with any training codevector\. A complementary KNN protocol uses the same decoder but conditions on latents taken from training examples near the query in VAE space, so those conditioning vectors were heavily exposed during optimization\. We adopt a stringent simulation\-grounded protocol \- arc\-length resampling, centering, a discrete rotation–reflection search that minimizes squared symmetric Chamfer, and banded DTWSakoeChiba1978DTW;BerndtClifford1994DTW\- and report state\-of\-the\-art CD/DTW on this multi\-topology benchmark relative to these in\-protocol evaluations\.

The main contributions of this work are:

- •Multi\-topology conditional synthesis:A single autoregressive decodervaswani2017attention;radford2019languagetrained on a curated 33\-type subset ofNurizada2025Dataset\(over1\.2​M1\.2Mmechanisms\), with explicit mechanism\-type conditioning for four\-, six\-, and eight\-bar families\.
- •Dual conditioning and architecture:Coupler\-curve geometry is injected as a VAEkingma2014autoencodinglatent projected to one prefix tokenNurizada2025Dataset, together with a learned mechanism\-type embedding, feeding a LLaMA\-style causal transformertouvron2023llama\. Joint coordinates are discretized and generated followingBolanos2025;oord2017neural, as sketched in Fig\.[2](https://arxiv.org/html/2606.17409#S1.F2)\.
- •Hybrid discrete training objective:Cross\-entropy plus a Gaussian\-smoothed bin lossszegedy2016rethinkingto respect ordinal structure among quantized coordinates\.
- •Simulation\-grounded benchmark:Greedy\-decoding evaluationsutskever2014sequencewith alignment search prior to CDBarrow1977Chamferand DTWSakoeChiba1978DTW, together with a latent\-space noise sweephiggins2017betathat decodes every mechanism type at multiple perturbed latents and keeps the top five candidates per noise level by \(CD, DTW\)\. This procedure delivers the best CD/DTW we report and yields a diverse set of mechanism types among high\-scoring solutions for the same target trajectory\.
- •Complementary KNN baseline:The same decoder is evaluated when conditioning on VAE latents of training nearest neighborscover1967nearestversus the target or noised query latent, highlighting how much error drops when the conditioning point coincides with codes seen repeatedly during training, without any dataset mechanism lookup\.

The remainder of this paper is organized as follows\. Section[2](https://arxiv.org/html/2606.17409#S2)formulates the synthesis problem and describes the dataset and representations used\. Section[3](https://arxiv.org/html/2606.17409#S3)details the transformer architecture and training methodology\. Section[4](https://arxiv.org/html/2606.17409#S4)presents experimental results and discussion\. Section[5](https://arxiv.org/html/2606.17409#S5)concludes\.

## 2Discrete Dataset Representation

The mechanisms used in this work are drawn from a large\-scale dataset of planar single\-degree\-of\-freedom linkage mechanisms introduced in prior workNurizada2025Dataset\. The full dataset contains approximately three million four\-, six\-, and eight\-bar mechanisms with both open and closed coupler curves, represented using continuous joint coordinates and simulated within a unified kinematic framework\. A detailed description of the dataset generation process, normalization procedures, topology encoding, and simulation methodology is provided inNurizada2025Dataset\.

In the present work, a curated subset of this dataset is employed\. Specifically, mechanism types with fewer than 20,000 samples are excluded in order to reduce class imbalance and avoid over\-representation of dominant topologies during training\. After this filtering, the resulting dataset comprises 33 distinct mechanism types, including four four\-bar mechanism families \(with both revolute and prismatic joint variants\), sixteen six\-bar mechanisms, and thirteen eight\-bar mechanisms\. This selection preserves substantial topological diversity while yielding a more balanced distribution across mechanism families, facilitating effective conditional generative modeling\. There is a total of 1,260,121 mechanisms in the dataset\.

In addition to joint coordinates, each mechanism in the dataset is associated with its corresponding coupler curve representation\. In this work, coupler curves are represented as images and encoded using the same variational autoencoder \(VAE\)kingma2014autoencodingframework introduced alongside the dataset inNurizada2025Dataset\. Specifically, each normalized coupler curve image is mapped to a 50\-dimensional latent representation, which captures the global geometric structure of the desired trajectory\. This latent vector serves as the geometric conditioning signal for the generative model and is provided as input during both training and inference\. By decoupling coupler curve encoding from mechanism generation, this representation enables compact, invariant conditioning while preserving compatibility with the original dataset formulation\.

Each planar mechanism is represented using a unified, fixed\-length vector of joint and tracer\-point coordinates,

𝐉=\[\(x1,y1\),\(x2,y2\),…,\(xNmax,yNmax\)\],\\mathbf\{J\}=\\big\[\(x\_\{1\},y\_\{1\}\),\(x\_\{2\},y\_\{2\}\),\\dots,\(x\_\{N\_\{\\max\}\},y\_\{N\_\{\\max\}\}\)\\big\],\(1\)whereNmaxN\_\{\\max\}denotes the maximum number of joints/tracer points among all mechanism families included in the dataset\. Mechanisms with fewer points \(e\.g\., four\-bar or six\-bar linkages\) are padded to lengthNmax=12N\_\{\\max\}=12, using a consistent padding scheme, enabling a single model to operate over multiple topologies while preserving a uniform input/output dimensionality\. In addition to𝐉\\mathbf\{J\}, each mechanism is associated with a discrete mechanism\-type label specifying its kinematic topology\. This label is provided as an explicit conditioning token during training and generation, allowing the model to synthesize mechanisms across different linkage families while maintaining topology control\.

To enable autoregressive sequence modeling, continuous joint coordinates are discretized into a finite set of tokens\. Each coordinate dimension is quantized independently over the normalized coordinate range using uniform binning \(a choice proposed inBolanos2025\)\. Specifically, given a normalized coordinate valuex∈\[xmin,xmax\]x\\in\[x\_\{\\min\},x\_\{\\max\}\], it is mapped to a discrete bin index

q​\(x\)=⌊x−xminxmax−xmin⋅\(K−1\)⌋,q\(x\)=\\left\\lfloor\\frac\{x\-x\_\{\\min\}\}\{x\_\{\\max\}\-x\_\{\\min\}\}\\cdot\(K\-1\)\\right\\rfloor,\(2\)withK=201K\{=\}201discrete bins per coordinate dimension\.

This transformation converts each joint coordinate into an integer\-valued token and each mechanism into an ordered token sequence of fixed length\. The discretization resolution is selected to balance representational fidelity and vocabulary size, ensuring that quantization error remains small relative to the scale of the normalized mechanisms while maintaining tractable sequence modelingoord2017neural\.

Following discretization, each mechanism is represented as a fixed\-length token sequence suitable for autoregressive generationvaswani2017attention;radford2019language\. Conditioning information is provided separately and is not part of the predicted output sequence\. Specifically, the input to the model is defined as

𝒮in=\[zc,zt,SOS,q​\(x1\),q​\(y1\),…,q​\(xN\),q​\(yN\),…,PAD\],\\mathcal\{S\}\_\{\\text\{in\}\}=\[\\,z\_\{c\},\\;z\_\{t\},\\;\\texttt\{SOS\},\\;q\(x\_\{1\}\),q\(y\_\{1\}\),\\dots,q\(x\_\{N\}\),q\(y\_\{N\}\),\\;\\dots,\\texttt\{PAD\}\],\(3\)wherezcz\_\{c\}is a latent geometric token encoding the desired coupler curve andztz\_\{t\}is a discrete mechanism\-type token \(see Fig\.[2](https://arxiv.org/html/2606.17409#S1.F2)\)\. TheSOStoken marks the beginning of the autoregressive generation of joint coordinates\. The remaining tokens correspond to discretized joint locations, ordered consistently across all samples\. Mechanisms with fewer thanNmaxN\_\{\\max\}joints are padded withPADtokens to ensure a uniform sequence length\.

The training target \(label\) sequence is defined as

𝒮out=\[q​\(x1\),q​\(y1\),…,q​\(xN\),q​\(yN\),EOS,PAD,…,PAD\],\\mathcal\{S\}\_\{\\text\{out\}\}=\[\\,q\(x\_\{1\}\),q\(y\_\{1\}\),\\dots,q\(x\_\{N\}\),q\(y\_\{N\}\),\\;\\texttt\{EOS\},\\;\\texttt\{PAD\},\\dots,\\texttt\{PAD\}\\,\],\(4\)whereEOSdenotes the end\-of\-sequence token\. The model is trained to autoregressively predict the joint\-coordinate tokens and terminate generation upon emittingEOS, without predicting the conditioning tokenszcz\_\{c\}andztz\_\{t\}\.

This formulation cleanly separates conditioning information from the predicted sequence while allowing the transformervaswani2017attentionto model joint\-level and global geometric dependencies through autoregressive decodingsutskever2014sequence;radford2019language\.

## 3Discrete Autoregressive Transformer

This section describes the discrete autoregressive transformer used for generative mechanism synthesis\. Mechanism generation is formulated as a conditional sequence prediction problemsutskever2014sequencein which discretized joint coordinates are generated sequentially under geometric and topological constraints\.

A decoder\-only transformer architecture inspired by autoregressive language modelsradford2019language;vaswani2017attentionis employed\. The implementation uses a LLaMA\-style configurationtouvron2023llama\- RMSNormzhang2019root, SiLU\-based feed\-forward blocksramachandran2017searching, and multi\-head causal self\-attentionvaswani2017attention\- in a decoder\-only stack\. The network consists of token embeddings for discretized coordinate values, followed by decoder blocks and a linear output projection\. Residual connectionsHe2016ResNetand normalization are applied throughout\. Positional embeddings preserve token ordering, and causal maskingvaswani2017attentionis applied during both training and inference so that each prediction depends only on previously generated tokens\. The configuration used for the results reported here has a hidden size of 1,536, 32 attention heads, and 6 decoder layers, totaling 229,673,676 trainable parameters\. Training uses distributed data parallel optimizationpaszke2019pytorchon four NVIDIA A100 GPUs with batch size 512, the AdamW optimizerloshchilov2017adamw, and learning rate10−410^\{\-4\}\(as used for the reported checkpoint\)\. Figure[2](https://arxiv.org/html/2606.17409#S1.F2)summarizes the architecture\.

Let𝐱=\[x1,x2,…,xL\]\\mathbf\{x\}=\[x\_\{1\},x\_\{2\},\\dots,x\_\{L\}\]denote a sequence of discretized joint\-coordinate tokens\. Under autoregressive decoding, the conditional distribution modeled by the network is

p​\(𝐱∣zc,zt\)=∏i=1Lp​\(xi∣zc,zt,x1,…,xi−1\),p\(\\mathbf\{x\}\\mid z\_\{c\},z\_\{t\}\)=\\prod\_\{i=1\}^\{L\}p\(x\_\{i\}\\mid z\_\{c\},z\_\{t\},x\_\{1\},\\dots,x\_\{i\-1\}\),\(5\)wherezcz\_\{c\}is a latent geometric conditioning token encoding the desired coupler curve andztz\_\{t\}is a discrete mechanism\-type token specifying the kinematic topology\. Although conditioning tokens are provided as part of the decoder input, they are not included in the predicted output sequence and are excluded from the loss computation\.

The latent geometric tokenzcz\_\{c\}is obtained by projecting the 50\-dimensional VAE latent through a small multilayer perceptron, producing a single vector in the transformer’s embedding space that is treated as one prefix token\. The mechanism\-type tokenztz\_\{t\}is embedded using a dedicated lookup table\. These two tokens are prepended to the embedded coordinate sequence and serve as global context that conditions all subsequent predictions\. Joint\-coordinate generation begins only after a dedicated start\-of\-sequence \(SOS\) token, ensuring a clear separation between conditioning information and predicted tokens\.

We apply a geometry\-aware auxiliary loss only at coordinate\-token positionst∈𝒯coordt\\in\\mathcal\{T\}\_\{\\text\{coord\}\}\. Letkt⋆k^\{\\star\}\_\{t\}be the ground\-truth bin index attt, and letqtq\_\{t\}be the Gaussian\-smoothed target over binskk,

qt​\(k\)=exp⁡\(−\(k−kt⋆\)22​σ2\)∑k′exp⁡\(−\(k′−kt⋆\)22​σ2\),q\_\{t\}\(k\)\\;=\\;\\frac\{\\exp\\\!\\left\(\-\\dfrac\{\(k\-k^\{\\star\}\_\{t\}\)^\{2\}\}\{2\\sigma^\{2\}\}\\right\)\}\{\\displaystyle\\sum\_\{k^\{\\prime\}\}\\exp\\\!\\left\(\-\\dfrac\{\(k^\{\\prime\}\-k^\{\\star\}\_\{t\}\)^\{2\}\}\{2\\sigma^\{2\}\}\\right\)\},\(6\)whereσ\\sigmais a*smoothing width*\(kernel scale\) on the bin index; we useσ=2\.0\\sigma=2\.0in our experiments \(a soft\-target construction related to label smoothingszegedy2016rethinking\)\. To avoid confusion with softmax temperature used elsewhere, we do not refer toσ\\sigmaas a “temperature\.” The auxiliary term is cross\-entropy betweenqtq\_\{t\}and the predicted categorical distributionpθp\_\{\\theta\},

ℒgeom=−∑t∈𝒯coord∑kqt​\(k\)​log⁡pθ​\(xt=k∣zc,zt,x1,…,xt−1\)\.\\mathcal\{L\}\_\{\\text\{geom\}\}\\;=\\;\-\\sum\_\{t\\in\\mathcal\{T\}\_\{\\text\{coord\}\}\}\\sum\_\{k\}q\_\{t\}\(k\)\\,\\log p\_\{\\theta\}\\\!\\left\(x\_\{t\}=k\\mid z\_\{c\},z\_\{t\},x\_\{1\},\\dots,x\_\{t\-1\}\\right\)\.\(7\)Herepθ​\(xt∣zc,zt,x1,…,xt−1\)p\_\{\\theta\}\(x\_\{t\}\\mid z\_\{c\},z\_\{t\},x\_\{1\},\\dots,x\_\{t\-1\}\)is the same conditional as in \([5](https://arxiv.org/html/2606.17409#S3.E5)\) \(withSOSplaced after\(zc,zt\)\(z\_\{c\},z\_\{t\}\)and beforex1x\_\{1\}, as in𝒮in\\mathcal\{S\}\_\{\\text\{in\}\}\)\. The full objective is

ℒ=ℒCE\+ℒgeom,\\mathcal\{L\}=\\mathcal\{L\}\_\{\\text\{CE\}\}\+\\mathcal\{L\}\_\{\\text\{geom\}\},\(8\)with unit weight onℒgeom\\mathcal\{L\}\_\{\\text\{geom\}\}relative toℒCE\\mathcal\{L\}\_\{\\text\{CE\}\}\. Tokens such asSOSandEOScontribute only toℒCE\\mathcal\{L\}\_\{\\text\{CE\}\};PADpositions are masked and omitted from both sums\.

Training is performed using randomly shuffled mini\-batches\. During training, ground\-truth tokens are provided as input to predict subsequent tokens \(teacher forcingwilliams1989learning\)\. Padding tokens are masked out of the loss, allowing mechanisms of varying complexity to be trained within a unified fixed\-length representation\. Continuous monitoring metrics include token\-level accuracy, discrete bin error, and continuous coordinate error obtained by mapping predicted bins back to bin centers\.

At inference time, generation proceeds autoregressively by first providing the conditioning tokens followed by theSOStoken\. Joint\-coordinate tokens are then generated sequentially until an end\-of\-sequence \(EOS\) token is emitted or a maximum sequence length is reached, after which padding tokens are appended as needed\. The quantitative results in Section[4](https://arxiv.org/html/2606.17409#S4)use*greedy*decodingsutskever2014sequence: at each autoregressive step the highest\-probability coordinate token is chosen, so the trajectory is deterministic and no randomness is injected\. Temperature scaling and stochastic samplingradford2019language;touvron2023llamacan be used for exploratory design but were not used for the reported CD/DTW tables\.

This formulation enables efficient generation of multiple distinct mechanisms for a single target coupler curve while maintaining explicit control over mechanism topology, thereby capturing the inherently one\-to\-many structure of the mechanism synthesis problem\.

## 4Results

This section evaluates the discrete autoregressive transformer \(Fig\.[2](https://arxiv.org/html/2606.17409#S1.F2)\)\. We focus on two questions: whether the model can accurately reconstruct coupler curves under forward kinematic simulation, and whether it supports one\-to\-many generation across mechanism families for a fixed target trajectory\. All results are obtained through simulation\-based geometric evaluation; no metrics are computed directly in token space\.

Each test sample consists of a target coupler curve and its associated mechanism data from a held\-out subset of the dataset described in Section[2](https://arxiv.org/html/2606.17409#S2)\. The coupler curve is first encoded using the pretrained variational autoencoderkingma2014autoencodingintroduced inNurizada2025Dataset, yielding a 50\-dimensional latent representation\. This latent vector is treated as a fixed geometric descriptor of the desired trajectory and is used as conditioning input for all evaluations involving that curve\.

Mechanism generation for the main tables uses deterministic greedy autoregressive decodingsutskever2014sequence;vaswani2017attention\. Starting from theSOStoken, the model predicts one token at a time by selecting the maximum\-probability output at each step, terminating when theEOStoken is emitted or when a predefined maximum sequence length is reached\. No stochastic sampling, temperature scaling, top\-kktruncation, or noise injection is used during these evaluations\. This design choice ensures that reconstruction performance reflects the learned conditional mapping rather than variability introduced by random sampling\.

The generated token sequences are decoded into continuous joint coordinates using the bin centers defined during discretization\. These coordinates are then passed to a forward kinematic simulatorcraig2005introduction;Erdman2001MechanismDesign\. Only mechanisms that yield valid simulations with sufficiently long trajectories are retained\. From each simulation, the coupler curve corresponding to the appropriate tracer point is extracted for geometric evaluation\.

All geometric comparisons are performed after identical preprocessing of the ground\-truth and predicted coupler curves\. Curves are resampled uniformly by arc lengthdocarmo1976differentialto a fixed number of points and centered to remove translational effects\. While global normalization removes scale differences, angular normalization alone is not always reliable, as it can result in mirrored or rotated curve configurations that are geometrically equivalent but misaligned under direct comparison\.

To resolve this ambiguity, we explicitly search for the best geometric alignment between predicted and target curves\. For each predicted curve, a discrete set of in\-plane rotations and mirror reflections is evaluated, and the configuration that minimizes the Chamfer Distance \(CD\)Barrow1977Chamferwith respect to the ground\-truth curve is selected\. This procedure identifies the appropriate orientation of the predicted curve prior to further evaluation, ensuring that geometric similarity is assessed independently of arbitrary angular or mirroring discrepancies\. After the optimal alignment is determined using CD, Dynamic Time Warping \(DTW\)SakoeChiba1978DTW;BerndtClifford1994DTWis computed between the aligned predicted curve and the ground\-truth curve, and the minimum DTW value over forward and reversed traversal directions is reported\.

Earlier studies report Chamfer and DTW under different conventions \- for example, the dataset manuscriptNurizada2025Datasetuses*unsquared*mean nearest\-neighbor Chamfer after per\-curve normalization in a VAE–kk\-NN pipeline, while conditionalβ\\beta\-VAENurizada2025cBetaVAEand transformer DSL synthesisBolanos2025use other normalizations and DTW implementations \- so raw table values are not identical units to ours\. Our scores use squared symmetric ChamferBarrow1977Chamfer;Fan2017Pointafter jointO​\(2\)\\mathrm\{O\}\(2\)alignment and banded DTWSakoeChiba1978DTWas specified above\. Within this strict simulator\-evaluation contract, the aggregate mean CD0\.01320\.0132and mean DTW0\.1530\.153\(Table[2](https://arxiv.org/html/2606.17409#S4.T2)\) represent state\-of\-the\-art multi\-topology coupler fidelity among the protocols we instantiate, achieved by autoregressive decoding from the target latent and from noised latents along the schedule \- not by copying mechanism parameters from the dataset\.

Reconstruction accuracy is first evaluated under matched topology conditions\. For each test sample, the model is conditioned on the latent representation of the target coupler curve and the mechanism\-type token corresponding to the ground\-truth mechanism\. A single mechanism is generated via greedy decoding, simulated, and compared against the target trajectory\. Across the evaluated samples, the model consistently produces mechanisms whose simulated coupler curves closely match the desired geometry, yielding low Chamfer Distance and DTW values in the majority of cases\. Visual inspection confirms that the generated curves capture global geometric characteristics such as overall shape, symmetry, and curvature extrema, indicating that discretized autoregressive generation does not impede accurate geometric reconstruction\.

The*primary*generative study in this section goes beyond a single greedy decode at the nominal VAE latentkingma2014autoencoding;higgins2017beta\. We treat the 50\-dimensional latent𝝁\\boldsymbol\{\\mu\}encoding the target coupler curve as a point in a smooth space and construct a one\-parameter family of perturbed latents

𝒛~​\(α\)=𝝁\+α​σ​ϵ,\\tilde\{\\boldsymbol\{z\}\}\(\\alpha\)=\\boldsymbol\{\\mu\}\+\\alpha\\,\\sigma\\,\\boldsymbol\{\\epsilon\},\(9\)whereα\\alphavaries from0to11over a fixed number of steps,σ\\sigmasets the noise scale, andϵ\\boldsymbol\{\\epsilon\}is a single draw of standard normal noise per target curve \(fixed acrossα\\alpha\), so that increasingα\\alphamoves along one random direction away from𝝁\\boldsymbol\{\\mu\}\. In software, this schedule is implemented in*ray*mode: one pseudorandom direction per test curve \(deterministically seeded per sample index\) is reused for allα\\alpha\. An alternative*step*ablation draws a fresh isotropic Gaussian perturbation at each noise level; all reported latent\-noise tables use the ray formulation\. At*each*α\\alpha, we condition the decoder on𝒛~​\(α\)\\tilde\{\\boldsymbol\{z\}\}\(\\alpha\)and, in turn, on*every*mechanism\-type token in the label set\. Each pair\(𝒛~​\(α\),type\)\(\\tilde\{\\boldsymbol\{z\}\}\(\\alpha\),\\text\{type\}\)yields a greedy token sequence, a simulated coupler curve, and the usual CD and DTW after the alignment search described at the beginning of this section\. For that noise level we retain only the top five type–decode pairs ranked by CD, with DTW as tie\-breaker, discarding poorer candidates\. Aggregating over targets and noise levels produces a compact set of high\-fidelity mechanisms that differ in topology as well as joint geometry\.

This protocol directly targets two goals stressed throughout the paper: \(i\) minimize geometric error under simulation, and \(ii\) expose diversity in mechanism family among solutions that remain accurate for the same trajectory\. In practice the top\-KKsets exhibit broader coverage of mechanism indices than a single matched\-topology greedy decode, while the best CD/DTW values in each sweep meet or improve upon the single\-latent greedy baseline\. We summarize aggregate CD/DTW over retained predictions and report simple diversity diagnostics \- for example, the empirical distribution of mechanism types in the saved top\-KKsets \(entropyshannon1948mathematicalrelative to a uniform label prior highlights under\- or over\-represented families\)\. Together, these statistics support the claim that latent\-space exploration with cross\-topology decoding is an effective inference\-time strategy for high\-quality, multi\-family synthesis\.

Table[1](https://arxiv.org/html/2606.17409#S4.T1)reports mean CD and DTW among*matched\-topology*rows in the saved top\-KKlists \- that is, evaluations where the mechanism\-type token equals the ground\-truth type for the target curve \- at each noise levelα\\alphaon100100held\-out samples\. The columnnncounts how often the ground\-truth type appears in the top five at thatα\\alpha\(it need not appear for every curve once the latent is perturbed\)\. Table[2](https://arxiv.org/html/2606.17409#S4.T2)aggregates geometry over all5,0005\{,\}000saved predictions \(100100targets×\\times1010noise levels×\\timesK=5K\{=\}5ranks\) and lists diversity of mechanism labels in that pool\. Figures[3](https://arxiv.org/html/2606.17409#S4.F3)and[4](https://arxiv.org/html/2606.17409#S4.F4)visualize the same inference protocol for two representative targets using five evenly spaced noise levelsα∈\{0,0\.25,0\.5,0\.75,1\}\\alpha\\in\\\{0,0\.25,0\.5,0\.75,1\\\}; each row is a noise level and each column is a rank after sorting candidates by CD \(DTW tie\-break\)\. Each subplot overlays ground truth \(black solid line\) and prediction \(blue dotted line\) after alignment\.

Table 1:Latent\-noise sweep, ground\-truth mechanism only: mean CD/DTW over saved top\-KKrows whose evaluated type matches the target, for100100test curves perα\\alpha\.Table 2:Latent\-noise sweep withK=5K\{=\}5: aggregate geometry over all saved predictions and label diversity \(3333mechanism types\)\.![Refer to caption](https://arxiv.org/html/2606.17409v1/figures/latent_noise_grid_034_Watt1T2A1.png)Figure 3:Latent\-noise sweep for a target curve\. Rows:α∈\{0,0\.25,0\.5,0\.75,1\}\\alpha\\in\\\{0,0\.25,0\.5,0\.75,1\\\}\(top to bottom\) along a fixed random direction in VAE latent space\. Columns: top five mechanisms at thatα\\alphaafter cross\-topology greedy decoding, simulation, and ranking by Chamfer distance \(DTW tie\-break\)\. Solid black curve is the desired curve, whereas dotted blue curve is the predicted curve\.![Refer to caption](https://arxiv.org/html/2606.17409v1/figures/latent_noise_grid_079_Watt2T2A2.png)Figure 4:Latent\-noise sweep for a target curve; same layout and protocol as Fig\.[3](https://arxiv.org/html/2606.17409#S4.F3)\.For*additional*comparison, we evaluate a latent\-space nearest\-neighbor protocolcover1967nearestthat still uses autoregressive generationvaswani2017attention\- not dataset lookup of stored linkages\. For each neighbor, the same transformer is conditioned on that neighbor’s VAE latent \(a vector that appears in the training set\) and on a mechanism\-type token, and a mechanism is produced by greedy decoding from scratch\. The resulting simulated coupler curve is compared to the query target curve using the same CD/DTW and alignment protocol as elsewhere\. Intuitively, neighbor latents lie on the training manifold and were “seen” many times during optimization, whereas the primary protocol emphasizes the target latent and directions perturbed away from it \(similar to the training distribution but not identical to any stored code\)\. For each test case, the mean and minimum CD and DTW values across the nearest neighbors are recorded\.

Using this KNN approach, we report quantitative results under two settings\. In both cases, the same set of 100 target coupler curves is used\. For each target curve, we take its 30 nearest neighbors in the VAE latent spacekingma2014autoencoding\(training\-set codevectors\), yielding 3,000 neighbor latents per setting for conditioning the decoder\.

In the first setting,*matched\-topology KNN evaluation*, each neighbor latent is decoded using only the mechanism type associated with it\. This results in100×30100\\times 30total predictions\. Table[3](https://arxiv.org/html/2606.17409#S4.T3)summarizes the resulting Chamfer Distance \(CD\) and Dynamic Time Warping \(DTW\) statistics\. The low mean and median errors indicate that nearby latent codes consistently correspond to mechanisms whose coupler curves closely match the desired geometry\.

In the second setting,*cross\-topology KNN evaluation*, the same 30 neighbor latents for each target curve are decoded under all available mechanism\-type conditionings\. Specifically, for each neighbor latent, mechanisms are generated using all 33 mechanism families, resulting in100×30×33100\\times 30\\times 33total predictions\. This evaluation substantially expands the design space and reflects a more challenging one\-to\-many synthesis scenario\. Table[4](https://arxiv.org/html/2606.17409#S4.T4)reports the corresponding DTW statistics\. While the mean DTW increases due to the inclusion of less compatible mechanism families, the minimum DTW remains low, demonstrating that for most target curves there exists at least one mechanism type capable of producing a close geometric match\. These KNN tables complement the latent\-noise sweep: the latter perturbs the*query*latent and ranks*all*types at each level, whereas KNN varies the conditioning latent among training\-set neighbors while using the same decoder and simulator pipeline\. Figure[6](https://arxiv.org/html/2606.17409#S4.F6)illustrates five representative neighbor\-conditioning panels for one query curve\.

Figure[5](https://arxiv.org/html/2606.17409#S4.F5)compares, on the same axes, two empirical mechanism\-type distributions in percentage of their respective pools: \(i\) the*corpus*marginal from all1,260,1211\{,\}260\{,\}121training coupler\-curve images \(encoded labels in the released dataset\), and \(ii\) the mix of ground\-truth mechanism types among VAE\-spacekk\-nearest neighbors \(k=30k\{=\}30\) to1,0001\{,\}000randomly drawn training latents \(Euclidean distance, ball tree over the full corpus; no decoding or simulation\)\. The dashed vertical line marks a uniform1/331/33share for reference\. Neighbor\-type percentages track the corpus closely: Pearson correlation between the two3333\-vectors of percentages exceeds0\.990\.99, so frequent families in the dataset also appear proportionally more often among latent neighbors—as expected if neighborhoods sample the training manifold rather than a single class\. The scriptknn\_latent\_neighbor\_label\_histogram\.pyregenerates the figure in under one minute fromvae\_mu\.npyandencoded\_labels\.npy\.

![Refer to caption](https://arxiv.org/html/2606.17409v1/figures/knn_latent_neighbor_label_histogram.png)Figure 5:Mechanism\-type mix: corpus marginal \(all1,260,1211\{,\}260\{,\}121training images\) vs\. labels of3030VAE nearest neighbors for each of1,0001\{,\}000random queries \(30,00030\{,\}000neighbor slots\)\. Bar heights are percentages of each pool; dashed line is uniform1/331/33\. Pearsonr\>0\.99r\>0\.99between the two percentage profiles\. No transformer decoding or curve simulation\.![Refer to caption](https://arxiv.org/html/2606.17409v1/figures/knn_neighbor_panel_01.png)![Refer to caption](https://arxiv.org/html/2606.17409v1/figures/knn_neighbor_panel_02.png)![Refer to caption](https://arxiv.org/html/2606.17409v1/figures/knn_neighbor_panel_03.png)Figure 6:Latent KNN baseline: five training\-set neighbor latents for a single query coupler curve, each decoded with the same autoregressive transformer and simulated\. Each panel shows the generated mechanism layout and the resulting coupler trace relative to the query geometry\.Table 3:Latent\-space KNN evaluation under matched\-topology conditions\. Each of the 100 target coupler curves is evaluated using its 30 nearest neighbors in latent space, decoded with the same mechanism type as the target curve, resulting in 3,000 total predictions\.Table 4:Latent\-space KNN evaluation across all mechanism families\. For each of the 100 target coupler curves and its 30 nearest latent neighbors, mechanisms are generated using all 33 mechanism types, resulting in100×30×33100\\times 30\\times 33total predictions\.![Refer to caption](https://arxiv.org/html/2606.17409v1/figures/knn_results.png)Figure 7:Top\-10 predicted coupler curves for a single target trajectory\. The black curve shows the ground\-truth coupler curve, while colored dashed curves correspond to the ten best predicted mechanisms ranked by Chamfer Distance after geometric alignment\. Predictions are drawn from the latent\-noise and cross\-topology evaluation and from nearest\-neighbor latent decoding, illustrating one\-to\-many synthesis under forward kinematic simulation\.Figure[7](https://arxiv.org/html/2606.17409#S4.F7)compresses the one\-to\-many behavior already established above: ranked predictions combine the cross\-topology latent\-noise sweep \(including nearest\-neighbor latent conditioning in the same simulator metric\) and illustrate that multiple linkage layouts can approximate the same target coupler curve after alignment\.

In summary, Tables[1](https://arxiv.org/html/2606.17409#S4.T1)–[2](https://arxiv.org/html/2606.17409#S4.T2)quantify the latent\-noise protocol; Tables[3](https://arxiv.org/html/2606.17409#S4.T3)–[4](https://arxiv.org/html/2606.17409#S4.T4)isolate how conditioning on training\-set neighbor latents in VAE space shifts CD/DTW relative to query and noised latents under the*same*decoder and alignment codeBarrow1977Chamfer;SakoeChiba1978DTW\. The headline aggregate means in Table[2](https://arxiv.org/html/2606.17409#S4.T2)match the state\-of\-the\-art claim in the comparison paragraph above; all reported mechanisms are produced by autoregressive decodingradford2019language, not by reading parameters from dataset tables\.

## 5Conclusion

This paper presented a discrete autoregressive transformer for generative mechanism synthesis, framing the inverse mapping from coupler curves to linkage parameters as conditional sequence modeling on a large multi\-topology subset ofNurizada2025Dataset\. Dual conditioning combines a VAE\-derived curve latent with a mechanism\-type token \(Fig\.[2](https://arxiv.org/html/2606.17409#S1.F2)\); training adds a geometry\-aware bin loss to standard cross\-entropy\.

The experiments in Section[4](https://arxiv.org/html/2606.17409#S4)summarize greedy reconstruction, latent\-noise exploration with cross\-topology top\-KKretention, and KNN latent baselines under one simulator\-grounded CD/DTW pipeline\. Discretization, paired with the proposed conditioning and losses, does not prevent high geometric fidelity under forward simulation\.

Future work includes ablations of the hybrid loss and bin resolutionszegedy2016rethinking;oord2017neural, alternative noise schedules and candidate countsKK, reporting validity rates for simulated assembliescraig2005introduction, richer geometric or kinematic metrics, variable\-length decodersvaswani2017attention, explicit constraints during generation, and integration with optimization or human\-in\-the\-loop refinement\.

## Data availability

Mechanism and coupler\-curve data are described in prior work \(Nurizada2025Dataset\); evaluation scripts and model checkpoints will be released upon acceptance subject to licensing\.

## Declaration of generative AI and AI\-assisted technologies in the manuscript preparation process

During the preparation of this work the author\(s\) used ChatGPT \(OpenAI\) and Cursor \(AI\-assisted editing\) in order to proofread the manuscript, revise wording, and improve clarity and coherence of the prose\. After using these tools, the author\(s\) reviewed and edited the content as needed and take\(s\) full responsibility for the content of the published article\.

## References

Similar Articles

Scaling an Autoregressive Transformer for Single-Cell Generation

arXiv cs.LG

This paper studies a self-supervised task for generating single-cell gene expression vectors using an autoregressive transformer with a quantized VAE tokenizer. It reports scaling laws and a compute-optimal frontier for single-cell foundation models, with potential fine-tuning for perturbation prediction.