liveBook · Manning

Chapter 10: Creating a coding copilot project: Integrating an LLM service into VS Code with RAG

What you will learn in chapter 10 of LLMs in Production

The chapter introduces a project to build a Python-focused coding copilot in VS Code using a pretrained coding model, an LLM service, and local retrieval-augmented generation.

After this chapter you will be able to

What it builds on

Section by section

Introduction

The chapter introduces a project to build a Python-focused coding copilot in VS Code using a pretrained coding model, an LLM service, and local retrieval-augmented generation.

Key terms: coding model, API, VectorDB, retrieval-augmented generation, VS Code extension, LLM service, open source model, coding problems, RAG, finetuning

10.1 Our model

The section chooses DeciCoder for a Python coding copilot, examines its limitations for RAG, and serves it through a local API that the VS Code extension can call.

Key terms: DeciCoder, Stack dataset, 1B parameters, RAG, context window, 2,048 tokens, instruction tuned, HumanEval, FastAPI, DeciCoder model and tokenizer

10.2 Data is king

The section explains why RAG can adapt a coding model to an organization’s code and previews the data and API work needed to do it.

Key terms: RAG, context, finetune, code base, VectorDB, Python coding dataset, API

10.2.1 Our VectorDB

This section chooses a local Milvus vector database for the coding copilot and explains how to start it before loading the dataset.

Key terms: Milvus, VectorDB, Faiss, USearch, similarity search, Milvus standalone, Docker, startup script, Stop command, delete command

10.2.2 Our dataset

The section builds and tests a Milvus collection of Python coding examples so the copilot can retrieve relevant context for its prompts.

Key terms: Alpaca dataset, Python coding challenges, synthetic data, PythonCodeIngestion, Milvus, collection, schema, metadata, CodeSearchNet, IVF_FLAT

10.2.3 Using RAG

This section adds retrieval-augmented generation to the coding copilot API by retrieving code examples, fitting them into the prompt, and testing the updated service.

Key terms: Milvus service, embedding model, FastAPI lifecycle, collection, generate endpoint, nearest neighbors, few-shot prompt example dataset, instruction prompt, limit, token counter

10.3 Build the VS Code extension

This section builds a VS Code coding copilot extension that sends selected code to an existing LLM service and displays the response as an inline suggestion.

Key terms: Node, npm, VS Code extension generator, package.json, extension.js, activationEvents, onCommand:editor.action.inlineSuggest.trigger, contributes, keybindings, Alt+S

10.4 Lessons learned and next steps

The section diagnoses why RAG worsened the coding copilot’s output and proposes ways to improve or simplify the project.

Key terms: RAG, DeciCoder, linked list, few-shot examples, HumanEval, instruction tuned, prompt tuning, example code, finetune, instruction datasets

10.5 Summary

The chapter summary recaps the coding copilot’s model, vector database, and editor extension, then emphasizes dataset preparation and prompts suited to the model.

Concepts explained in this chapter

← Chapter 9: Creating an LLM project: Reimplementing Llama 3 Chapter 11: Deploying an LLM on a Raspberry Pi: How low can you go? →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.