Magpie: Alignment Data Synthesis from Scratch by Prompting Aligned LLMs with Nothing

Paper · arXiv 2406.08464 · Published June 12, 2024
LLM AlignmentSynthetic Dialogue GenerationSelf-Refinement and Self-Consistency

Is it possible to synthesize high-quality instruction data at scale by extracting it directly from an aligned LLM? We present a self-synthesis method for generating large-scale alignment data named MAGPIE. Our key observation is that aligned LLMs like Llama-3-Instruct can generate a user query when we input only the pre-query templates up to the position reserved for user messages, thanks to their auto-regressive nature. We use this method to prompt Llama-3-Instruct and generate 4 million instructions along with their corresponding responses. We further introduce extensions of MAGPIE for filtering, generating multi-turn, preference optimization, domain-specific and multilingual datasets.

Is it possible to synthesize high-quality instructions at scale by directly extracting data from advanced aligned LLMs? A typical input to an aligned LLM contains three key components: the pre-query template, the query, and the post-query template. For instance, an input to Llama-2-chat could be “[INST] Hi! [/INST]”, where [INST] is the pre-query template and [/INST] is the post-query template. These templates are predefined by the creators of the aligned LLMs to ensure the correct prompting of the models. We observe that when we only input the pre-query template to aligned LLMs such as Llama-3-Instruct, they self-synthesize a user query due to their auto-regressive nature. Our experiments indicate that these random user queries are of high quality and great diversity, suggesting that the abilities learned during the alignment process are effectively utilized.

Based on these findings, we developed a self-synthesis method to construct high-quality instruction datasets at scale, named MAGPIE (as illustrated in Figure 1). Unlike existing methods, our approach does not rely on prompt engineering or seed questions. Instead, it directly constructs instruction data by prompting aligned LLMs with a pre-query template for sampling instructions.

An instance of instruction data consists of at least one or multiple instruction-response pairs. Each pair specifies the roles of instruction provider (e.g., user) and follower (e.g., assistant), along with their instruction and response. As shown in Figure 1, MAGPIE consists of two steps: (1) instruction generation, and (2) response generation. The MAGPIE pipeline can be fully automated without any human intervention, and can be readily adapted for the generation of multi-turn, preference, and domain-specific datasets, as detailed in Section 2.2. We describe each step in the following. <|begin_of_text|><|start_header_id|>system<|end_header_id|>

You are a helpful Al assistant. The user will engage in a multi−round conversation with you, asking initial questions and following up with additional related questions. Your goal is to provide thorough, relevant and insightful responses to help the user with their queries.<|eot_id|><|start_header_id|>user<|end_header_id|> {instruction}<|eot_id|><|start_header_id|>assistant<|end_header_id|> {response}<|eot_id|><|start_header_id|>user<|end_header_id|>

Instruction

Please label the task tags for the user query.

User Query

‘‘‘{input}‘‘‘

Tagging the user input

Please label the task tags for the user query. You will need to analyze the user query and select the most relevant task tag from the list below. all_task_tags = [ "Information seeking", # Users ask for specific information or facts about various topics. "Reasoning", # Queries require logical thinking, problem−solving, or processing of complex ideas. "Planning", # Users need assistance in creating plans or strategies for activities and projects. "Editing", # Involves editing, rephrasing, proofreading, or other tasks related to the composition of general written content. "Coding & Debugging", # Users seek help with writing, reviewing, or fixing code in programming. "Math", # Queries related to mathematical concepts, problems, and calculations. "Role playing", # Users engage in scenarios requiring ChatGPT to adopt a character or persona. "Data analysis", # Requests involve interpreting data, statistics, or performing analytical tasks. "Creative writing", # Users seek assistance with crafting stories, poems, or other creative texts. "Advice seeking", # Users ask for recommendations or guidance on various personal or professional issues. "Brainstorming", # Involves generating ideas, creative thinking, or exploring possibilities. "Others" # Any queries that do not fit into the above categories or are of a miscellaneous nature. ]

Output Format:

Note that you can only select a single primary tag. Other applicable tags can be added to the list of other tags. Now, please output your tags below in a json format by filling in the placeholders in <...>: ‘‘‘ {{ "primary_tag": "<--primary tag-->", "other_tags": ["<--tag 1-->", "<-- tag 2 -->", ... ] }} You need to rate the quality of the user query based on its clarity, specificity, and coherence. The rating scale is as follows: − very poor: The query is unclear, vague, or incoherent. It lacks essential information and context. − poor: The query is somewhat unclear or lacks important details. It requires significant clarification. − average: The query is moderately clear and specific. It may require some additional information for a complete understanding. − good: The query is clear, specific, and mostly well−formed. It provides sufficient context for understanding the user’s intent. − excellent: The query is very clear, specific, and well−articulated. It contains all the necessary information and context for providing a comprehensive response.

Output Format

Given the user query, you first need to give an assessment, highlighting the strengths and/or weaknesses of the user query. Then, you need to output a rating from very poor to excellent by filling in the placeholders in [...]: "explanation": "[...]", "input_quality": "[very poor/poor/average/good/excellent]" ’’’ You first need to identify the given user intent and then label the difficulty level of the user query based on the content of the user query. Given the user query, in your output, you first need to identify the user intent and the knowledge needed to solve the task in the user query. Then, rate the difficulty level of the user query as ‘very easy‘, ‘easy‘, ‘medium‘, ‘hard‘, or ‘very hard‘. Now, please output the user intent and difficulty level below in a json format by filling in the placeholders in [...]: "intent": "The user wants to [....]", "knowledge": "To solve this problem, the models need to know [....]", "difficulty": "[very easy/easy/medium/hard/very hard]" Role Playing In this game, you will be the host, and I will be the contestant. You will ask me a series of questions, and I will try to answer them correctly. The questions will be multiple choice, and I will have a 25% chance of getting the correct answer if I just randomly guess. However, I am a clever contestant, and I will try to use logic and reasoning to increase my chances of getting the correct answer. C FILTER SETUPS In this section, we explore potential filter configurations for selecting high-quality instructional data for fine-tuning purposes. We provide the following metrics to enable users to customize their filtered MAGPIE dataset:

  1. Input Length: The total number of characters in the instructions.
  2. Output Length: The total number of characters in the responses.
  3. Task Category: The specific category of the instructions. See Appendix D.1 for details.
  4. Input Quality: The clarity, specificity, and coherence of the instructions, rated as ‘very poor’, ‘poor’, ‘average’, ‘good’, and ‘excellent’.
  5. Input Difficulty: The level of knowledge required to address the task described in the instruction, rated as ‘very easy’, ‘easy’, ‘medium’, ‘hard’, or ‘very hard’.
  6. Minimum Neighbor Distance: The embedding distance to the nearest neighbor. Can be used for filtering out repetitive or similar instances.
  7. Reward: Denoted as r∗. See Section 3 for details. This metric can be used to filter out low-quality responses, such as repetitions or refusals.
  8. Reward Difference: Denoted as r∗ − rbase. See Section 3 for details. We provide several off-the-shelf configurations, as demonstrated in Table 5. We defer the detailed performance analysis of each filter configuration for MAGPIE-Pro to Appendix F.4.