--- license: apache-2.0 language: - en datasets: - instruction-pretrain/ft-instruction-synthesizer-collection --- # Instruction Pre-Training: Language Models are Supervised Multitask Learners This repo contains the **context-based instruction synthesizer** used in our paper **Instruction Pre-Training: Language Models are Supervised Multitask Learners**. We explore supervised multitask pre-training by proposing ***Instruction Pre-Training***, a framework that scalably augments massive raw corpora with instruction-response pairs to pre-train language models. The instruction-response pairs are generated by an efficient instruction synthesizer built on open-source models. In our experiments, we synthesize 200M instruction-response pairs covering 40+ task categories to verify the effectiveness of *Instruction Pre-Training*. ***Instruction Pre-Training* outperforms *Vanilla Pre-training* in both general pre-training from scratch and domain-adaptive continual pre-training.** In pre-training from scratch, *Instruction Pre-Training* not only improves pre-trained base models but also benefits more from further instruction tuning. In continual pre-training, *Instruction Pre-Training* enables Llama3-8B to be comparable to or even outperform Llama3-70B.
## Resources **🤗 We share our data and models with example usages, feel free to open any issues or discussions! 🤗** - Context-Based Instruction Synthesizer: [instruction-synthesizer](https://huggingface.co/instruction-pretrain/instruction-synthesizer) - Fine-Tuning Data for the Synthesizer: [ft-instruction-synthesizer-collection](https://huggingface.co/datasets/instruction-pretrain/ft-instruction-synthesizer-collection) - General Models Pre-Trained from Scratch: - [InstructLM-500M](https://huggingface.co/instruction-pretrain/InstructLM-500M) - [InstructLLM-1.3B](https://huggingface.co/instruction-pretrain/InstructLLM-1.3B) - Domain-Specific Models Pre-Trained from Llama3-8B: - [Finance-Llama3-8B](https://huggingface.co/instruction-pretrain/finance-Llama3-8B) - [Biomedicine-Llama3-8B](https://huggingface.co/instruction-pretrain/medicine-Llama3-8B) ## Synthesize Instruction-Response Pairs based on Any Raw text We conduct multitask fine-tuning on a language model to develop an instruction synthesizer capable of generating instruction-response pairs from any raw text. The fine-tuning data are available at [ft-instruction-synthesizer-collection](https://huggingface.co/datasets/instruction-pretrain/ft-instruction-synthesizer-collection)
For example, to prompt the synthesizer to generate instruction-response pairs based on a given raw text: ```python from transformers import AutoModelForCausalLM, AutoTokenizer model = AutoModelForCausalLM.from_pretrained("instruction-pretrain/instruction-synthesizer") tokenizer = AutoTokenizer.from_pretrained("instruction-pretrain/instruction-synthesizer") # Put your raw text here: context = '''Free Fishing Weekend in NYS Slated This weekend (June 28th-29th) New Yorkers may fish for free without a license in any of the state's 7,500 lakes and ponds or 50,000 miles of rivers and streams. In addition, there are a number of free events and fishing clinics taking place across the state to encourage New Yorkers to enjoy the great outdoors. For more information, visit''' def parse_pred(pred): """Extract the list of instruction-response pairs from the prediction""" QA_str_list = pred.split('') if not pred.endswith(''): QA_str_list = QA_str_list[:-1] QA_list = [] raw_questions = [] for QA_str in QA_str_list: try: assert len(QA_str.split('