---
title: "Building LLMs for Code Repair"
description: "Replit finetuned a 7B code model (DeepSeek-Coder-Instruct-v1.5) to repair Python errors flagged by LSP diagnostics."
url: "https://swe.quest/articles/building-llms-for-code-repair-56ef089519b9fe77"
canonical: "https://replit.com/blog/code-repair"
source: "Replit"
published: "2024-04-02"
difficulty: "hard"
kind: "Case study"
reading_minutes: 14
tags: ["model-training","ai-coding","llms","evals","data-pipelines"]
---

# Building LLMs for Code Repair

A post on [Replit](https://swe.quest/sources/replit.md), published 2024-04-02, 14 min read, Case study. Original: [https://replit.com/blog/code-repair](https://replit.com/blog/code-repair)

## Summary

Replit finetuned a 7B code model (DeepSeek-Coder-Instruct-v1.5) to repair Python errors flagged by LSP diagnostics. Only 10% of these diagnostics come with deterministic fixes, while hundreds of millions are logged daily. Training data comes from replaying Operational Transformation histories to reconstruct the project state at each diagnostic. LLM-synthesized numbered line diffs are then generated with DSPy, verified, and distilled. Sentinel-token schemas replace natural-language instructions, and training ran on 8xH100 with LLM Foundry, FSDP and 4 epochs. Evaluation uses a new Replit repair benchmark plus a contamination-resistant Leetcode set built from DebugBench and recent LiveCodeBench-style problems.

Written by swe.quest, not by the author.

**Difficulty:** Hard: written for specialists in the field

## Topics

- [Model training](https://swe.quest/tags/model-training.md) (AI & ML)
- [AI for coding](https://swe.quest/tags/ai-coding.md) (AI & ML)
- [LLMs](https://swe.quest/tags/llms.md) (AI & ML)
- [Evaluation](https://swe.quest/tags/evals.md) (AI & ML)
- [Data pipelines](https://swe.quest/tags/data-pipelines.md) (Data & databases)

## Prerequisites

- LLM finetuning ([easy posts on LLMs](https://swe.quest/tags/llms.md?difficulty=easy))
- Language Server Protocol
- distributed training basics ([easy posts on Model training](https://swe.quest/tags/model-training.md?difficulty=easy))

## Keywords

DeepSeek-Coder, Language Server Protocol, LLM Foundry, DSPy, DebugBench, LiveCodeBench, Pyright, Ruff

## Related posts

- [Code Llama: Llama 2 learns to code](https://swe.quest/articles/code-llama-llama-2-learns-to-code-bbc6e9367fb26138.md): Hugging Face · 2023-08-25 · Medium · 12 min read · LLMs, AI for coding, Inference & serving, Python, Evaluation
  Code Llama is a family of 7B, 13B and 34B Llama 2 derivatives trained on 500B tokens of code.
- [StarCoder2-Instruct: Fully Transparent and Permissive Self-Alignment for Code Generation](https://swe.quest/articles/starcoder2-instruct-fully-transparent-and-permissive-self-alignment-for-code-7d548d6a3e65fc89.md): Hugging Face · 2024-04-29 · Hard · 6 min read · Model training, LLMs, AI for coding, Evaluation
  StarCoder2-15B-Instruct is instruction-tuned entirely on data generated by its own base model, with no human annotations or distillation from proprietary LLMs.
- [Replit’s new AI Model now available on Hugging Face](https://swe.quest/articles/replit-s-new-ai-model-now-available-on-hugging-face-3b96faee1bd121e8.md): Replit · 2023-10-10 · Easy · 2 min read · LLMs, AI for coding, Model training, Open source
  Replit Code V1.5 3B is an open code-completion model released on Hugging Face under a license that allows commercial use.
- [StarCoder: A State-of-the-Art LLM for Code](https://swe.quest/articles/starcoder-a-state-of-the-art-llm-for-code-ae224d2374e67db4.md): Hugging Face · 2023-05-04 · Easy · 5 min read · LLMs, AI for coding, Evaluation, Open source
  StarCoder and StarCoderBase are ~15B-parameter code LLMs trained on 1 trillion tokens of permissively licensed GitHub data from The Stack 1.2, covering 80+ languages, commits, issues and notebooks, with StarCoder further fine-tuned on 35B Python tokens.
- [Introducing the LiveCodeBench Leaderboard - Holistic and Contamination-Free Evaluation of Code LLMs](https://swe.quest/articles/introducing-the-livecodebench-leaderboard-holistic-and-contamination-free-cd05ed71356a1cca.md): Hugging Face · 2024-04-16 · Easy · 4 min read · Evaluation, LLMs, AI for coding
  LiveCodeBench is a code-LLM benchmark built from LeetCode, AtCoder and CodeForces contest problems annotated with release dates, so models can be scored only on problems published after their training cutoff to avoid contamination.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
