{"data":{"slug":"sahil280114-codealpaca","name":"codealpaca","tagline":"An instruction-following LLaMA model for code generation.","github_url":"https://github.com/sahil280114/codealpaca","owner":"sahil280114","repo":"codealpaca","owner_avatar_url":"https://avatars.githubusercontent.com/u/22678055?v=4","primary_language":"Python","stars":1514,"forks":113,"topics":[],"archived":false,"github_pushed_at":"2023-05-12T17:41:28+00:00","maintenance_label":"Dormant","url":"https://www.graphcanon.com/tools/sahil280114-codealpaca","markdown_url":"https://www.graphcanon.com/tools/sahil280114-codealpaca.md","api_url":"https://www.graphcanon.com/api/graphcanon/tools/sahil280114-codealpaca","graph_url":"https://www.graphcanon.com/api/graphcanon/graph?tool=sahil280114-codealpaca","description":null,"homepage_url":null,"license":"Apache-2.0","open_issues":17,"watchers":19,"ai_summary":"This repository focuses on creating and sharing an instruction-following LLaMA model tailored for generating code, using 20K fine-tuning data inspired by the Self-Instruct paper. It includes dataset generation processes, training protocols, but excludes model weights due to licensing restrictions.","readme_excerpt":"# Code Alpaca: An Instruction-following LLaMA Model trained on code generation instructions \n \n \n \n\nThis is the repo for the Code Alpaca project, which aims to build and share an instruction-following LLaMA model for code generation. This repo is fully based on [Stanford Alpaca](https://github.com/tatsu-lab/stanford_alpaca) ,and only changes the data used for training. Training approach is the same.\n\nThe repo contains:\n- The [20K data](#data-release) used for fine-tuning the model\n- The code for [generating the data](#data-generation-process)\n- The code for [fine-tuning the model](#fine-tuning)\n\nDemo for the model can be found [https://code-alpaca-demo.vercel.app/](https://code-alpaca-demo.vercel.app/)\n\n## Overview\n\nThe Code Alpaca models are fine-tuned from a 7B and 13B LLaMA model on 20K instruction-following data generated by the techniques in the Self-Instruct [1] paper, with some modifications that we discuss in the next section.\nEvals are still a todo.\n\nThe model is not finetuned to be safe and harmless, so be cautious.\n\nCurrent release contains the data generation procedure, dataset, and training code. Model weights aren't part of the release for now, to respect OpenAI TOS and LLaMA license.\n\n[1]: Self-Instruct: Aligning Language Model with Self Generated Instructions. Yizhong Wang, Yeganeh Kordi, Swaroop Mishra, Alisa Liu, Noah A. Smith, Daniel Khashabi, Hannaneh Hajishirzi. https://arxiv.org/abs/2212.10560\n\n\n## Data Release\n[`data/code_alpaca_20k.json`](./data/code_alpaca_20k.json) contains 20K instruction-following data used for fine-tuning the Code Alpaca model.\nThis JSON file is a list of dictionaries, each dictionary contains the following fields:\n- `instruction`: `str`, describes the task the model should perform. Each of the 20K instructions is unique.\n- `input`: `str`, optional context or input for the task. For example, when the instruction is \"Amend the following SQL query to select distinct elements\", the input is the SQL query. Around 40% of the examples have an input.\n- `output`: `str`, the answer to the instruction as generated by `text-davinci-003`.\n\nWe used the following prompts for fine-tuning the model:\n- for examples with a non-empty input field:\n ```\n Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.\n \n ### Instruction:\n {instruction}\n \n ### Input:\n {input}\n \n ### Response:\n ```\n- for examples with an empty input field:\n ```\n Below is an instruction that describes a task. Write a response that appropriately completes the request.\n \n ### Instruction:\n {instruction}\n \n ### Response:\n ```\n \n During inference (eg for the web demo), we use the user instruction with an empty input field (second option).\n\n## Data Generation Process\n\n<details>\n<summary> <strong> Running the code </strong> </summary>\n\n1. Set environment variables `OPENAI_API_KEY` to your OpenAI API key.\n2. Install the dependencies with `pip install -r requirements.txt`.\n3. Run `python -m generate_instruction generate_instruction_following_data` to generate the data.\n\n</details>\nData generation pipeline had minor changes from [Stanford Alpaca](https://github.com/tatsu-lab/stanford_alpaca)\n- Modified prompt to focus on code generation/editing/optimization tasks instead of general tasks.\n- Modified seed tasks to only be related to code generation.\n\nThis produced an instruction-following dataset with 20K examples obtained at a much lower cost (less than $200). Also including a smaller 2k samples dataset which was used to derisk the approach and quality of the model.\n\n## Fine-tuning\nFinetuned the models using standard Hugging Face training code and deepspeed with the following hyperparameters:\n\n| Hyperparameter | Value |\n|----------------|-------|\n| Learning rate  | 2e-5  |\n| Epochs         | 3     |\n| Max length     | 512   |\n| Weight decay   | 0     |\n\nGiven Hugging Face hasn't officially supported the LLaMA models, we fine-tuned LLaMA wi","github_created_at":"2023-03-22T11:28:54+00:00","created_at":"2026-07-11T23:44:21.138613+00:00","updated_at":"2026-08-05T12:02:10.182417+00:00","categories":[{"slug":"llm-frameworks","name":"LLM Frameworks","url":"https://www.graphcanon.com/categories/llm-frameworks","markdown_url":"https://www.graphcanon.com/categories/llm-frameworks.md","api_url":"https://www.graphcanon.com/api/graphcanon/categories/llm-frameworks"},{"slug":"model-training","name":"Model Training","url":"https://www.graphcanon.com/categories/model-training","markdown_url":"https://www.graphcanon.com/categories/model-training.md","api_url":"https://www.graphcanon.com/api/graphcanon/categories/model-training"}],"tags":[{"slug":"code-generation","name":"code generation"},{"slug":"fine-tuning","name":"fine-tuning"},{"slug":"instruction-following","name":"instruction-following"},{"slug":"python","name":"python"}],"trust":{"provenance":{"is_fork":false,"github_id":617429416,"owner_type":"User","methodology":"github_public_v1","parent_repo":null,"near_duplicate_slugs":[]},"computed_at":"2026-08-05T12:02:09.382Z","maintenance":{"label":"Dormant","score":18,"methodology":"github_public_v1","releases_90d":0,"days_since_push":1180,"last_release_at":null},"security_summary":{"status":"findings","scanner":"osv@v1","low_count":46,"high_count":0,"last_scan_at":"2026-07-11T23:44:28.530Z","medium_count":0,"scan_profile":"deps","critical_count":0}},"capability_facts":{"scan":{"source":"repo_scan","observed_at":"2026-08-05T12:02:09.878Z"},"languages":{"value":["python"],"source":"github.language","observed_at":"2026-08-05T12:02:09.878Z"},"license_spdx":{"value":"Apache-2.0","source":"github.license","observed_at":"2026-08-05T12:02:09.878Z"}},"decision_facts":{"hosting":null,"pricing":null,"requirements":{"notes":["Model weights are not available in this repository due to licensing restrictions."],"min_ram_gb":null,"requires_docker":false},"constraints":{"min_ram_gb":null,"requires_docker":false},"when_to_use":["When you need instruction-following capabilities tailored specifically for code generation tasks.","If your requirements align with a code-focused model that was trained using prompts emphasizing coding activities, such as code editing and optimization."],"when_not_to_use":["Avoid if you require models fine-tuned on datasets that cover a broader spectrum of non-code-related instructions beyond code editing and generation.","Do not use this tool when you must adhere to strict compliance or safety standards for model output, as the Code Alpaca model is noted to be unsafe and not fine-tuned for harmlessness."],"source":"enrich:decision_facts","observed_at":"2026-07-17T00:09:09.745Z"},"constraint_facets":{"min_ram_gb":null,"requires_docker":false},"decision_summary":[{"label":"Requirements","value":"Model weights are not available in this repository due to licensing restrictions."},{"label":"Adopt for","value":"A specialized LLaMA model for generating code from instructions, leveraging 20K fine-tuning data inspired by the Self-Instruct paper."},{"label":"License detail","value":"The project uses Apache-2.0 license, allowing users to utilize the source code and documentation freely."}]}}