{"id":13437527,"url":"https://github.com/yizhongw/self-instruct","last_synced_at":"2025-04-13T18:34:16.305Z","repository":{"id":65940462,"uuid":"580312797","full_name":"yizhongw/self-instruct","owner":"yizhongw","description":"Aligning pretrained language models with instruction data generated by themselves.","archived":false,"fork":false,"pushed_at":"2023-03-27T18:18:51.000Z","size":61421,"stargazers_count":4334,"open_issues_count":12,"forks_count":505,"subscribers_count":57,"default_branch":"main","last_synced_at":"2025-04-06T15:07:14.791Z","etag":null,"topics":["general-purpose-model","instruction-tuning","language-model"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yizhongw.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2022-12-20T08:52:51.000Z","updated_at":"2025-04-06T08:12:40.000Z","dependencies_parsed_at":"2024-01-13T20:15:34.135Z","dependency_job_id":null,"html_url":"https://github.com/yizhongw/self-instruct","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yizhongw%2Fself-instruct","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yizhongw%2Fself-instruct/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yizhongw%2Fself-instruct/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yizhongw%2Fself-instruct/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yizhongw","download_url":"https://codeload.github.com/yizhongw/self-instruct/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248760859,"owners_count":21157444,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["general-purpose-model","instruction-tuning","language-model"],"created_at":"2024-07-31T03:00:58.025Z","updated_at":"2025-04-13T18:34:16.284Z","avatar_url":"https://github.com/yizhongw.png","language":"Python","funding_links":[],"categories":["Open-source Instruction Data","Python","NLP","Instruct/Prompt Tuning Data","A01_文本生成_文本对话","动手实现ChatGPT/RLHF","[Self-Instruct](https://github.com/yizhongw/self-instruct)","Language Models for NLP"],"sub_categories":["大语言对话模型及数据","调用外部工具","Instruction Tuning and Preference Optimization"],"readme":"# Self-Instruct: Aligning LM with Self Generated Instructions\n\nThis repository contains code and data for the [Self-Instruct paper](https://arxiv.org/abs/2212.10560), a method for aligning pretrained language models with instructions.\n\n## Introduction\n\nSelf-Instruct is a framework that helps language models improve their ability to follow natural language instructions. It does this by using the model's own generations to create a large collection of instructional data. With Self-Instruct, it is possible to improve the instruction-following capabilities of language models without relying on extensive manual annotation.\n\n### Background\n\nIn recent years, there has been a growing interest in building models that can follow natural language instructions to perform a wide range of tasks. These models, known as \"instruction-tuned\" language models, have demonstrated the ability to generalize to new tasks. However, their performance is heavily dependent on the quality and quantity of the human-written instruction data used to train them, which can be limited in diversity and creativity. To overcome these limitations, it is important to develop alternative approaches for supervising instruction-tuned models and improving their instruction-following capabilities.\n\n### How Self-Instruct works?\n\nThe Self-Instruct process is an iterative bootstrapping algorithm that starts with a seed set of manually-written instructions and uses them to prompt the language model to generate new instructions and corresponding input-output instances. These generations are then filtered to remove low-quality or similar ones, and the resulting data is added back to the task pool. This process can be repeated multiple times, resulting in a large collection of instructional data that can be used to fine-tune the language model to follow instructions more effectively.\n\nHere is an overview of Self-Instruct:\n\n![The pipeline for generating instruction data from a language model itself.](docs/pipeline.JPG)\n\n## Usage\n\n\\* **This work is still in progress. We may update the code and data as we make progress. Please be cautious about the version control.**\n\n### Instruction-tuning using our Self-Instruct data\n\nWe release a dataset that contains 52k instructions, paired with 82K instance inputs and outputs. This instruction data can be used to conduct instruction-tuning for language models and make the language model follow instruction better. The entire model-generated data can be accessed in `data/gpt3-generations/batch_221203/all_instances_82K.jsonl`. This data (+ the 175 seed tasks) reformatted in clean GPT3-finetuning format (prompt + completion) is put in `data/finetuning/self_instruct_221203`. You can use the script in [`./scripts/finetune_gpt3.sh`](./scripts/finetune_gpt3.sh) to finetune GPT3 on this data.\n\n**Note**: This data is generated by a language model (GPT3) and inevitably contains some errors or biases. We analyzed the data quality on 200 random instructions in our paper, and found that 46% of the data points may have problems. We encourage users to use this data with caution and propose new methods to filter or improve the imperfections.\n\n### Evaluating instruction-following capabilities\n\nWe also release a new set of 252 expert-written tasks and their instructions motivated by user-oriented applications (rather than well-studied NLP tasks). This data is used in the human evaluation section of [the self-instruct paper](https://arxiv.org/abs/2212.10560). Please refer to [the human evaluation README](human_eval/README.md) for more details.\n\n### Generating Self-Instruct data from scratch\n\nTo generate Self-Instruct data using your own seed tasks or other models, we open-source our scripts for the entire pipeline here. Our current code is only tested on the GPT3 model accessible via the [OpenAI API](https://beta.openai.com/docs/models/gpt-3).\n\nHere are the scripts for generating the data:\n\n```bash\n# 1. Generate instructions from the seed tasks\n./scripts/generate_instructions.sh\n\n# 2. Identify whether the instruction represents a classification task or not\n./scripts/is_clf_or_not.sh\n\n# 3. Generate instances for each instruction\n./scripts/generate_instances.sh\n\n# 4. Filtering, processing, and reformatting\n./scripts/prepare_for_finetuning.sh\n```\n\n## Citation\n\nIf you use the Self-Instruct framework or data, feel free to cite us.\n\n```bibtex\n@misc{selfinstruct,\n  title={Self-Instruct: Aligning Language Model with Self Generated Instructions},\n  author={Wang, Yizhong and Kordi, Yeganeh and Mishra, Swaroop and Liu, Alisa and Smith, Noah A. and Khashabi, Daniel and Hajishirzi, Hannaneh},\n  journal={arXiv preprint arXiv:2212.10560},\n  year={2022}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyizhongw%2Fself-instruct","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyizhongw%2Fself-instruct","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyizhongw%2Fself-instruct/lists"}