When Machines Speak: A Unified Generative Framework for Integrating Machine-Native Symbols into Pretrained Large Language Models
A framework that lets pretrained LLMs generate machine-only codes -- like recommendation item IDs or legal citation markers -- right alongside plain text
Pretrained LLMs can only natively handle natural-language tokens, so systems that represent information as discrete machine codes (recommendation item IDs, graph structures, etc.) have had to either translate everything into text or rely on separate task-specific models. This paper introduces UniLang, which adds these machine codes as new vocabulary tokens to a pretrained LLM, aligns their meaning to the LLM's embedding space via contrastive learning, and then generates text and machine codes together under one autoregressive objective. Tested on two very different problems -- predicting a user's next movie/product and predicting which legal precedent sentence gets quoted -- UniLang beat strong specialized baselines on both.
METAL MEDIA explanatory visual
A framework that lets pretrained LLMs generate machine-only codes -- like recommendation item IDs or legal citation markers -- right alongside plain text
- 01The problem: information like recommendation item codes or graph relations is represented as discrete machine-native symbols rather than natural language, so it sits outside a pretrained LLM's normal token vocabulary and is hard for the LLM to generate directly.
- 02Building the codes: item descriptions (e.g., a movie's title and genre) are embedded with a text encoder and then compressed by an RQ-VAE (Residual Quantized VAE) into a short sequence of discrete codes, called a Semantic ID (SID), representing each item.
- 03Grounding into the LLM: 1,024 new tokens for these SIDs are added to the LLM's vocabulary, and their embeddings are pre-trained with an InfoNCE contrastive loss so a code's embedding lines up with the embedding of its matching text description -- giving the raw codes real meaning inside the LLM's space.
- 04Joint fine-tuning: the aligned code tokens and the LLM's original text tokens are merged into one vocabulary, and a Llama-3.2-1B-Instruct model is fine-tuned with LoRA to autoregressively generate mixed text-and-code sequences for each task.
- 05Results: on movie/product next-item recommendation, UniLang improved NDCG@5 by up to 151.7% over the strongest baseline (MovieLens-20M); on legal precedent prediction it improved Recall@1 by up to 49.4% over the strongest baseline (10k dataset); ablations showed training fails entirely without the contrastive pre-alignment step.
What they did
- The problem: information like recommendation item codes or graph relations is represented as discrete machine-native symbols rather than natural language, so it sits outside a pretrained LLM's normal token vocabulary and is hard for the LLM to generate directly.
- Building the codes: item descriptions (e.g., a movie's title and genre) are embedded with a text encoder and then compressed by an RQ-VAE (Residual Quantized VAE) into a short sequence of discrete codes, called a Semantic ID (SID), representing each item.
- Grounding into the LLM: 1,024 new tokens for these SIDs are added to the LLM's vocabulary, and their embeddings are pre-trained with an InfoNCE contrastive loss so a code's embedding lines up with the embedding of its matching text description -- giving the raw codes real meaning inside the LLM's space.
- Joint fine-tuning: the aligned code tokens and the LLM's original text tokens are merged into one vocabulary, and a Llama-3.2-1B-Instruct model is fine-tuned with LoRA to autoregressively generate mixed text-and-code sequences for each task.
- Results: on movie/product next-item recommendation, UniLang improved NDCG@5 by up to 151.7% over the strongest baseline (MovieLens-20M); on legal precedent prediction it improved Recall@1 by up to 49.4% over the strongest baseline (10k dataset); ablations showed training fails entirely without the contrastive pre-alignment step.


| metric | mean ± standard error |
|---|---|
| Recall@5 | 0.1908 ± 0.00016 |
| NDCG@5 | 0.1378 ± 0.00017 |
| Recall@10 | 0.2596 ± 0.00014 |
| NDCG@10 | 0.1600 ± 0.00014 |


| Dataset | #users | #items | #actions | Avg. length | Density |
|---|---|---|---|---|---|
| Beauty | 40,226 | 54,542 | 0.35m | 8.8 | 0.02% |
| ML-1m | 6,040 | 3,416 | 1m | 163.5 | 4.79% |
| ML-20m | 138,493 | 26,744 | 20m | 144.4 | 0.54% |


| Feature | Mean | Std | Min | Max |
|---|---|---|---|---|
| Length of cited text (chars) | 306 | 225 | 24 | 18,342 |
| Length of citing context (chars) | 562 | 216 | 5 | 14,062 |


| Dataset | Validation size | Sample size |
|---|---|---|
| Beauty | 40,226 | 5,000 |
| MovieLens-1m | 6,040 | 1,000 |
| MovieLens-20m | 138,493 | 1,000 |
| 10k | 103,812 | 1,000 |
| 20k | 134,737 | 1,000 |
| 50k | 190,051 | 1,000 |


| ML-1M | LePaRD |
|---|---|
| Hyperparameter | Beauty |
| ML-20M | 10k / 20k / 50k |


| ML-1M | LePaRD |
|---|---|
| Dataset | Beauty |
| ML-20M | 10k / 20k / 50k |
| ML-1M | LePaRD |
|---|---|
| Dataset | Beauty |
| ML-20M | 10k / 20k / 50k |
Why it matters
It offers a practical path for real systems -- recommenders, medical coding, graph-structured data -- that store information as machine codes to directly tap into a pretrained LLM's language and world knowledge, instead of clumsily converting everything to text or building a separate model per task. One framework handling two structurally unrelated prediction problems suggests broader reuse potential across other symbolic domains.
Terms in this paper
- RQ-VAE (Residual Quantized VAE) · An autoencoder that compresses continuous vectors into a short sequence of discrete codes through multiple quantization stages
- Semantic ID (SID) · A machine-native identifier representing one item as a short sequence of discrete codes
- InfoNCE contrastive loss · A training objective that pulls matching representations together and pushes non-matching ones apart to align two embedding spaces
- LoRA (Low-Rank Adaptation) · A lightweight fine-tuning method that trains a small set of added parameters instead of the whole model
- autoregressive generation · Generating a sequence one token at a time, each based on the tokens produced so far
Original abstract (English)
Many real-world AI systems represent entities, behaviors, and structured information using discrete machine-native symbols rather than natural language. While these representations are compact and preserve task-relevant structure, they lie outside the linguistic token space of pretrained large language models (LLMs), creating a fundamental divide between language modeling and structured prediction. We introduce UniLang, a unified generative framework that bridges this divide by extending pretrained LLMs to treat machine-native symbols as first-class generative units alongside natural-language tokens. UniLang expands the LLM's vocabulary and embedding space with grounded machine-native representations, enabling textual and symbolic tokens to be jointly modeled and generated under a single autoregressive objective. This unified interface allows pretrained LLMs to directly operate on machine-native representations without requiring them to be verbalized as natural language or relying on task-specific architectures. We evaluate UniLang on two structurally distinct tasks, sequential recommendation and legal precedent prediction, spanning different domains and types of structured prediction. Across both tasks, UniLang consistently outperforms strong baselines, demonstrating a path toward extending pretrained LLMs beyond language and using them as a common generative modeling backbone for heterogeneous machine-native representations.
Read on arXivLatest papers
- SWE-bench Science: Can Coding Agents Resolve Engineering Tasks in Science?AI coding agents were tested on fixing real scientific software, and even the best one failed more than half the time
- FlashPrefill V2: Block-Sparse Prefill Attention for Long-Context LLM ServingMaking sparse attention fast enough and accurate enough for real LLM serving, not just papers
- PolicyGuide: From Guarding One Action to Guiding the Whole Workflow for Policy-Compliant LLM AgentsMaking customer-service AI agents follow the whole procedure, not just avoid one bad action
- EXIMO: VLM Guided Exploration of VLA PoliciesTeaching a robot new chores without human teleoperation, by letting a chatty AI supervise it
- EnvHarness: Awakening Static Worlds for Agent LearningInstead of building new training worlds from scratch, this work adds a plug-in layer that reshapes existing ones around each agent's actual weaknesses
- Bounded Sovereignty and the Control Tax: Pricing AI Oversight When the Deployer Does Not Own the ModelCompanies that rent AI instead of owning it can only do half of AI safety oversight
- PersonalBench: Measuring the Authorship Gap in LLM PersonalizationAI can be prompted to write 'like someone,' but its own voice never fully disappears
- Automated Summarization of Financial News Using Large Language Models and Retrieval-Augmented Generation: An Early Empirical Study (Fall 2023)Testing AI summaries of stock news, the simple approach beat the trendy retrieval-based one
Latest from METAL MEDIA
Figures: Su Yan et al., arXiv:2608.19529, CC BY 4.0