TL;DR
This paper introduces EmbGen, a novel framework for generating synthetic training data (question-answer pairs) to improve the performance of small, instruction-tuned language models on specialized domains. EmbGen addresses the high cost of creating high-quality domain-specific data by reassembling existing corpus content based on semantic similarity, leading to more effective fine-tuning, especially in heterogeneous domains.
What Problem Does This Paper Address?
Adapting large language models (LLMs), particularly smaller ones, to specialized domains often requires supervised fine-tuning (SFT) on curated instruction-response examples. However, collecting such data at scale is expensive and time-consuming. While synthetic data generation using teacher LLMs offers a cost-effective alternative, existing methods often produce homogenized outputs, lack consistent capture of cross-document dependencies, and struggle to adapt to the diverse nature of information within a domain. This paper tackles the challenge of generating high-quality, domain-specific synthetic data that can effectively teach LLMs, especially when the domain's knowledge is varied and dispersed.
Methods
EmbGen employs a four-stage pipeline to generate synthetic question-answer (QA) pairs:
- Decomposition into Entity-Description (ED) Pairs: Documents from a domain corpus are first chunked. Then, a teacher LLM extracts ED pairs, where each pair consists of an entity and its contextualized description. These pairs are then normalized and consolidated to ensure a unique description per entity.
- Reassembly into Proximity Groups: The ED pair embeddings are generated and then projected into a lower-dimensional space. These embeddings are clustered (using K-Means or HDBSCAN), and within each cluster, an undirected proximity graph is built based on embedding similarity. Connected components in this graph form "proximity groups," which are semantically coherent collections of ED pairs.
- System Prompt Specialization: For each cluster, a cluster-specific system prompt is generated. This involves extracting "context patterns" from the proximity groups and consolidating them to create prompts that are tailored to the specific semantic neighborhood of the cluster, while retaining the general task definition.
- Sampling and QA Synthesis: QA pairs are generated using three sampling strategies:
- Proximity Sampling: Each proximity group is used once as a standalone context.
- Intra-cluster Sampling: Multiple proximity groups from the same cluster are sampled to generate QA pairs that leverage relationships within that cluster.
- Inter-cluster Sampling: Proximity groups from different clusters are sampled to generate QA pairs that synthesize information across diverse semantic areas.
The generated QA pairs are then paired with either a cluster-specific prompt or a general base prompt, forming the synthetic SFT dataset.
Datasets
The paper evaluates EmbGen on three datasets with varying degrees of heterogeneity:
- Pop-QA-Cities-20: A subset of Pop-QA focusing on 20 European cities, representing the lowest heterogeneity.
- SQUAD-20: A subset of SQUAD containing 20 documents chosen for intermediate heterogeneity, covering diverse topics related to the US.
- Wikitext-10: A subset of the Salesforce Wikitext dataset, designed to create a high-heterogeneity setting.
The authors also constructed evaluation sets using an LLM (distinct from the teacher LLM used for generation) to ensure questions require reasoning across multiple text segments.
Key Insights and Ideas
- Semantic Reassembly is Key: EmbGen's core innovation is reassembling corpus content based on semantic similarity (via embeddings and clustering) rather than relying solely on document locality or curated knowledge graphs. This allows it to capture dependencies across dispersed information.
- Heterogeneity Matters: EmbGen shows its strongest gains on datasets with higher knowledge heterogeneity, suggesting its approach is particularly effective when information is diverse and not neatly organized.
- Cluster-Specific Prompts Enhance Relevance: Tailoring system prompts to the semantic clusters of the generated data helps improve the quality and relevance of the synthetic QA pairs.
- Balancing Sampling Strategies is Crucial: The paper explores different combinations of proximity, intra-cluster, and inter-cluster sampling, finding that the optimal strategy is dataset-dependent.
- LLM-as-a-Judge is Essential for True Evaluation: Traditional NLP metrics (like BLEU, ROUGE) can be misleading. An LLM-based judge, focusing on factual accuracy and completeness, provides a more reliable assessment of the generated data's effectiveness for SFT.
Key Results
- Strong Performance on Heterogeneous Data: On Wikitext-10 (the most heterogeneous dataset), EmbGen achieved significant relative Binary Accuracy gains of 12.5% at 5M tokens and 88.9% at 20M tokens compared to the strongest baseline, demonstrating its ability to handle diverse knowledge.
- Competitive Across Datasets: EmbGen remained competitive on other datasets, showing improvements in Binary Accuracy, especially at the larger 20M token budget.
- Improved Factual Accuracy and Completeness: The LLM-as-a-judge results indicated that EmbGen often produced more complete answers, contributing to higher Binary Accuracy, even when other methods had comparable factual accuracy.
- Ablation Studies Highlight Nuances: Ablation studies revealed that the optimal configuration of EmbGen (e.g., sampling mix, prompt specialization) is dataset-dependent, suggesting that simplification of certain strategies can sometimes be beneficial.
Limitations and Future Work
- LLM Dependency: EmbGen relies on a teacher LLM for ED extraction and prompt generation, meaning errors from the LLM can propagate through the pipeline. The paper does not quantify this sensitivity.
- Fixed Embedding Model: The study used a single embedding model (all-mpnet-base-v2) throughout. Future work could explore the impact of different embedding models.
- LLM-Based Evaluation: While necessary, the reliance on LLMs for both generation and evaluation introduces potential biases. Human evaluation or multi-judge setups could strengthen validity.
- Future Directions: The authors suggest applying EmbGen's proximity grouping paradigm to other tasks beyond QA generation, such as retrieval-augmented generation, to improve context assembly for LLMs. Further research could also explore more sophisticated methods for combining sampling strategies and optimizing prompt specialization.
Summary updated