Home/LLM Frameworks/codealpaca
codealpaca logo

codealpaca

sahil280114/codealpaca

An instruction-following LLaMA model for code generation.

GraphCanon updated 2w · GitHub synced 2w

1.5k stars113 forksLast push 3y Python Apache-2.0

Decision brief

A specialized LLaMA model for generating code from instructions, leveraging 20K fine-tuning data inspired by the Self-Instruct paper.

Good fit when

  • 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.

Avoid when

  • 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.
Requirements:
Model weights are not available in this repository due to licensing restrictions.

Observed Jul 17, 2026 · Source: enrich:decision_facts

Verify the decision

Maintenance and security

Full trust report
Maintenance
Dormant (1180d since push)
As of 2w
Provenance
Not a fork · Personal account
As of 2w
Security (OSV)
46 low (46 low)
As of 1mo

Public GitHub metadata and optional OSV scans. Signals, not a guarantee. Trust methodology.

Install

pip install codealpaca
PyPI

Similar tools

Same-category neighbours. No typed graph edges are catalogued for this tool yet.

Evidence and technical details

Sourced facts, taxonomy, compatibility claims, README excerpt, and machine-readable endpoints.

Overview

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.

Capability facts

Languages
python

Source: github.language · Aug 5, 2026

Categories

Compatibility

Sourced claims from the README excerpt - not unsourced marketing copy.

OpenAI APIOpenAI API

Source: README excerpt (regex_v1, Aug 5, 2026)

1. Set environment variables `OPENAI_API_KEY` to your OpenAI API key.
Source link
Python runtimePython

Source: README excerpt (regex_v1, Aug 5, 2026)

3. Run `python -m generate_instruction generate_instruction_following_data` to generate the da
Source link

Tags

README

Code Alpaca: An Instruction-following LLaMA Model trained on code generation instructions

This 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 ,and only changes the data used for training. Training approach is the same.

The repo contains:

  • The 20K data used for fine-tuning the model
  • The code for generating the data
  • The code for fine-tuning the model

Demo for the model can be found https://code-alpaca-demo.vercel.app/

Overview

The 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. Evals are still a todo.

The model is not finetuned to be safe and harmless, so be cautious.

Current 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.

[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

Data Release

data/code_alpaca_20k.json contains 20K instruction-following data used for fine-tuning the Code Alpaca model. This JSON file is a list of dictionaries, each dictionary contains the following fields:

  • instruction: str, describes the task the model should perform. Each of the 20K instructions is unique.
  • 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.
  • output: str, the answer to the instruction as generated by text-davinci-003.

We used the following prompts for fine-tuning the model:

  • for examples with a non-empty input field:
Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.

### Instruction:
{instruction}

### Input:
{input}

### Response:
  • for examples with an empty input field:
Below is an instruction that describes a task. Write a response that appropriately completes the request.

### Instruction:
{instruction}

### Response:

During inference (eg for the web demo), we use the user instruction with an empty input field (second option).

Data Generation Process

Running the code
  1. Set environment variables OPENAI_API_KEY to your OpenAI API key.
  2. Install the dependencies with pip install -r requirements.txt.
  3. Run python -m generate_instruction generate_instruction_following_data to generate the data.
Data generation pipeline had minor changes from [Stanford Alpaca](https://github.com/tatsu-lab/stanford_alpaca) - Modified prompt to focus on code generation/editing/optimization tasks instead of general tasks. - Modified seed tasks to only be related to code generation.

This 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.

Fine-tuning

Finetuned the models using standard Hugging Face training code and deepspeed with the following hyperparameters:

HyperparameterValue
Learning rate2e-5
Epochs3
Max length512
Weight decay0

Given Hugging Face hasn't officially supported the LLaMA models, we fine-tuned LLaMA wi

For agents

This page has a .md twin and JSON over the API.

Was this helpful?

Anonymous feedback helps us improve pages and translations.