Building Production-Scale Code Completion Tools with Continuous Evaluation and Prompt Engineering

gitlab · Tech · 2023 · source Agentic: no · promotional bias: low · source-backed · extracted with prompt 0.5.5 (schema v2)

Generated from extraction.json — do not edit by hand. Every claim cites verbatim source evidence; stated means the quote directly asserts the claim, implied means it supports it indirectly.

Problem

Domain: Production code-completion evaluation and prompt engineering

GitLab needed to build code completion tooling that helps developers write useful code while continuously evaluating multiple LLMs, prompt templates, and fine-tuning options at production scale rather than relying on manual prompt spreadsheets.

Constraints:

Architecture

GitLab's Model Ops architecture for GitLab Suggestions combines a multi-model completion gateway with a continuous evaluation loop. Historical code and completion data are tokenized, compared against developer commit patterns, and used to define agreeable developer outputs. A prompt engine with a prompt library/DB processes code and prompt templates; a gateway routes requests to third-party or internally tuned models; prompt validators and rate limiters score outputs; CI/CD-connected microservices run evaluation continuously; and low-quality outputs can trigger prompt tuning or fine-tuning of open-source models through a version-controlled loop.

Diagram confidence: reconstructed (reconstructed from prose).

flowchart LR
  developer[Developer] --> gitlab-suggestions[GitLab Suggestions]
  gitlab-suggestions --> gateway[Gateway]
  gateway --> prompt-engine[Prompt engine]
  prompt-engine --> prompt-library[Prompt library]
  prompt-engine --> tokenizer[Tokenizer]
  tokenizer --> historical-code-database[Historical code database]
  historical-code-database --> scoring-engine[Scoring engine]
  prompt-engine --> scoring-engine
  scoring-engine --> evaluation-microservices[Evaluation microservices]
  evaluation-microservices --> ci-cd[CI/CD]
  ci-cd --> prompt-library
  gateway --> prompt-validator[Prompt validator]
  prompt-validator --> rate-limiter[Rate limiter]
  prompt-validator --> fine-tuning-loop[Fine-tuning loop]
  gateway --> model-pool[Model pool]
  model-pool --> training-and-tuning-environment[Training and tuning environment]
  training-and-tuning-environment --> checkpoint-layers[Checkpoint layers]
  fine-tuning-loop --> training-and-tuning-environment
  completion-data-stream[Completion data stream] --> historical-code-database
  completion-data-stream --> evaluation-microservices
  completion-data-stream --> fine-tuning-loop
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

Components

Component Role Interacts with
Developer Coder receiving AI-assisted code completion suggestions. GitLab Suggestions
GitLab Suggestions Code completion product that recommends code to help developers write faster and more usable features. Developer, Gateway
Gateway Serving layer that post-processes prompts, validates outputs, and routes calls to model choices based on user input. GitLab Suggestions, Prompt engine, Prompt validator, Model pool
Prompt engine Engine that deconstructs code into tokens, uses prompt templates, and participates in scoring and ranking outputs. Gateway, Prompt library, Tokenizer, Scoring engine
Prompt library Prompt DB containing version-controlled templates used for code-completion prompts. Prompt engine, Prompt validator
Tokenizer Processing layer that breaks code and prompt inputs into tokens for evaluation and model input. Prompt engine, Historical code database
Historical code database Repository of prior code commits and completion patterns used to infer agreeable developer outputs. Tokenizer, Scoring engine, Evaluation microservices
Scoring engine Similarity and ranking layer that compares LLM outputs with agreeable developer outputs. Prompt engine, Historical code database, Evaluation microservices
Evaluation microservices Continuously running services that evaluate prompts and outputs in background loops. Historical code database, Scoring engine, CI/CD
Model pool Set of open-source, tuned, and third-party LLMs available for code completion. Gateway, Training and tuning environment
Training and tuning environment Pipeline for downloading, preprocessing, tokenizing, training, and tuning open-source models. Model pool, Checkpoint layers, Fine-tuning loop
Checkpoint layers Model training checkpoints used during tuning and serving iteration. Training and tuning environment
Prompt validator Serving-time validator that rates outputs and determines whether prompt tuning is sufficient. Gateway, Prompt library, Fine-tuning loop, Rate limiter
Rate limiter Serving control that manages throughput and user experience. Prompt validator, Gateway
Fine-tuning loop Fallback improvement path when prompt validation cannot reach desired output quality. Prompt validator, Training and tuning environment
CI/CD Version-controlled deployment and evaluation workflow connecting microservices and prompt/model changes. Evaluation microservices, Prompt library
Completion data stream Continuously generated code-completion and coding data used for evaluation, ranking, prompt inference, and training. Historical code database, Evaluation microservices, Fine-tuning loop

Data flow

A developer requests a completion through GitLab Suggestions. The gateway invokes the prompt engine, which uses the prompt library and tokenization over current and historical code. Historical commits and similarity algorithms define an agreeable developer output. Candidate outputs from open-source, tuned, or third-party LLMs are compared against that benchmark by evaluation microservices. Prompt validators, rate limiters, CI/CD, and version control feed improvements back into prompt templates or fine-tuning loops, while new completion data continuously refreshes the evaluation and training corpus.

4 supporting quotes
“the prompt engine almost where you're instantly with every code a person has written you're going through the same layer of what we call a prompt library or prompt DB”transcript, stated
“library or prompt DB of then looking into how do you deconstruct that code into tokens uh understand what was then finally committed uh and then get a better sense of a scoring mechanism of ranking is this a good average good developer understanding and”transcript, stated
“we've rung this algorithm based on the code commit and similarity and agreed on what is an actual agreeable developer output”transcript, stated
“calling the models based on the input the user is doing whether it's through the third party or or actually to a through your pre-trained model”transcript, stated

Why this architecture

GitLab's architecture exists because model quality cannot be assessed by intuition or one-off prompt inspection. Multiple raw models, opaque training data, latency/cost constraints, and developer-specific code patterns require a continuous benchmark loop that compares LLM output to historical developer behavior, version-controls prompt and model changes, and escalates from prompt tuning to fine-tuning when needed.

4 supporting quotes
“you're not just choosing one you're choosing many based on the factors we discussed before and let's say you have an open source pre-trained llam that you can also feed in further data to tune it and then you also have certain third-party um llms as well and”transcript, stated
“are this flexible what kind of tuning uh Frameworks can we do uh or even for third party um cost is obviously another thing and latency I see a lot of posts where we say we want to also assess quality but I do think that this is a really Hardline on how you”transcript, stated
“where we say we want to also assess quality but I do think that this is a really Hardline on how you can actually assist quality Without Really evaluating an N scale and and and how do you actually then use these efforts of work on prompt engineering at scale and to almost like continuous”transcript, stated
“Version Control it scale it do it continuously have a CI CD continuous training continuous feedback to consistently keep on dialing up the accuracy for your use case um now to do that those orange boxes on the left is a way we would probably have a mechanism”transcript, stated

Models used: Open-source pre-trained LLMs · Third-party LLMs · Tuned LLMs · ChatGPT · XGBoost

Scale

Alternatives considered (roads not taken)

Pick a single LLM

Rejected because: The presenter argues production code completion involves choosing many models based on objective, training data, benchmarks, weights, cost, and latency.

“first look into what an llm architecture from a perspective can look like where you basically in this world of llms you're not just choosing one you're choosing many based on the factors we discussed before and let's say you have an open source pre-trained llam that you can also feed in”transcript, stated
“are this flexible what kind of tuning uh Frameworks can we do uh or even for third party um cost is obviously another thing and latency I see a lot of posts where we say we want to also assess quality but I do think that this is a really Hardline on how you”transcript, stated

Manual spreadsheet prompt evaluation

Rejected because: Spreadsheets cannot continuously evaluate outputs at scale or feed an instant improvement loop.

“I see people having manual spreadsheets to looking into prompts and how to evaluate it but imagine this having this in scale as engines and that's the beauty of having this sort of a microservice engines added to your layer of full architecture where you can”transcript, stated
“I see people having manual spreadsheets to looking into prompts and how to evaluate it but imagine this having this in scale as engines and that's the beauty of having this sort of a microservice engines added to your layer of full architecture where you can”transcript, stated

Prompt tuning only

Rejected because: When a prompt validator cannot reach output quality, the system should route to model fine-tuning.

“if that can't be done stranded to a fine tuning of the yellow labs again continuous loop having it version based control based each of these can be microservice connected through uh CI and uh having that prompt validator rate limiter becomes a key to really”transcript, stated

Trust user-facing model output without historical comparison

Rejected because: The system needs an agreeable developer output baseline derived from commits and similarity.

“then what we've done is we've rung this algorithm based on the code commit and similarity and agreed on what is an actual agreeable developer output um that then is then evaluated with how the llms open source third party tuned uh is outputting through a technique where”transcript, stated
“developer output should look like to understand how to map that to a quality and then we know how each of these elements are giving uh outputting it and matching that and then sending the right output uh to to the right uh to the to the user now this makes probably sense in just one line”transcript, stated

Patterns

eval-driven-development (evaluation)

GitLab's architecture continuously evaluates code-completion outputs against historical developer behavior and feeds the results into prompt/model improvement.

“how do you actually have a continuous evaluation and inference as part of this architecture”transcript, stated
“continuous feedback to consistently keep on dialing up the accuracy for your use case”transcript, stated

prompt-versioning (prompt-operations)

The prompt library/DB, prompt validator, version-based control, and CI/CD path make prompt templates tracked deployable artifacts.

“where you're instantly with every code a person has written you're going through the same layer of what we call a prompt library or prompt DB of then looking into how do you deconstruct that code into tokens uh understand what was then finally committed uh and then get a better sense of a scoring”transcript, stated
“continuous loop having it version based control based each of these can be microservice connected through uh CI”transcript, stated

model-routing (model-operations)

The gateway can call different third-party or pre-trained models depending on user input and quality needs.

“calling the models based on the input the user is doing whether it's through the third party or or actually to a through your pre-trained model”transcript, stated
“look into what an llm architecture from a perspective can look like where you basically in this world of llms you're not just choosing one you're choosing many based on the factors we discussed before and let's say you have an open source pre-trained llam that you can also feed in further data to”transcript, stated

fine-tuning-adaptation (model-customization)

Open-source model weights can be tuned with additional data and fine-tuned when prompt validation is not enough.

“you have an open source pre-trained llam that you can also feed in further data to tune it”transcript, stated
“if that can't be done stranded to a fine tuning of the yellow labs again continuous loop”transcript, stated

data-quality-loop (data-engineering)

Continuous completion data and historical commit data become the baseline for ranking outputs and improving prompts/training.

“with code completion you will always have code there will always be a coder writing code”transcript, stated
“you can continuously add this and keep on adding to this data for evaluation for prompt inference for ranking”transcript, stated

cost-aware-routing (production-optimization)

Model choice explicitly includes cost and latency alongside objective, training data, benchmarks, and weights.

“the model weights are this flexible what kind of tuning uh Frameworks can we do uh or even for third party um cost is obviously another thing and latency I see a lot of posts where we say we want to also assess quality but I do think that this is a really Hardline on how you can actually”transcript, stated
“what kind of evaluation benchmarks already there with the alarms that you've chosen”transcript, stated

Tradeoffs

Use many model options

Chose Open-source, tuned, and third-party LLMs behind a routing gateway over A single fixed completion model.

Rationale: Different models offer different weights, tuning options, costs, latency, and benchmark behavior for code-completion use cases.

“look into what an llm architecture from a perspective can look like where you basically in this world of llms you're not just choosing one you're choosing many based on the factors we discussed before and let's say you have an open source pre-trained llam that you can also feed in further data to”transcript, stated
“if it is open source we want to understand the model weights are this flexible what kind of tuning uh Frameworks can we do”transcript, stated

Evaluate against agreeable developer output

Chose Historical commit and similarity-derived benchmarks over Pure generic benchmark or manual reviewer judgment.

Rationale: The system needs a GitLab-specific proxy for what helpful developer code should look like.

“based on the code commit and similarity and agreed on what is an actual agreeable developer output”transcript, stated
“how each of these elements are giving uh outputting it and matching that”transcript, stated

Automate prompt evaluation

Chose Microservice engines running in continuous loops over Manual spreadsheet review.

Rationale: Continuous service-based evaluation can run at scale and keep improving completion usefulness without manual bottlenecks.

“and a lot of times I see people having manual spreadsheets to looking into prompts and how to evaluate it but imagine this having this in scale as engines and that's the beauty of having this sort of a microservice engines added to your layer of full architecture where you can do this in an”transcript, stated
“infinite loop on an instant basis to keep on dialing let's say your code completion uh usefulness”transcript, stated

Escalate from prompt tuning to fine-tuning

Chose Prompt templates first, fine-tuning when validation cannot meet quality over Only retraining models or only editing prompts.

Rationale: Prompt changes are fast, but the architecture keeps a deeper model-adaptation path for failures that need it.

“prompt templates of prompt tunings that we can do on an instantaneous basis”transcript, stated
“prompt templates of prompt tunings that we can do on an instantaneous basis have a prompt validator rate output if that can't be done stranded to a fine tuning of the yellow labs again continuous loop having it version based control based each of these can be microservice connected through uh CI”transcript, stated

Gotchas (what bit them)

Quality is hard to assess without scaled evaluation.

Root cause: Raw model benchmarks and training-data descriptions do not reveal whether completions help GitLab developers in context.

Resolution: Build scaled evaluation over historical code, prompt outputs, and similarity to agreeable developer outputs.

“how you can actually assist quality Without Really evaluating an N scale”transcript, stated
“engine so the prompt is here model xgb we then know what an actual agreeable developer output should look like to understand how to map that to a quality and then we know how each of these elements are giving uh outputting it and matching that and then sending the right output uh to to the right uh”transcript, stated

Opaque model training data complicates quality judgment.

Root cause: For many third-party or open-source LLMs, the team cannot constantly inspect or feed the training data used to judge quality.

Resolution: Evaluate outputs against GitLab-specific historical developer patterns instead of relying only on model provenance.

“we don't necessarily constantly feed them the training data off uh to judge the quality”transcript, stated
“third-party open source llamps make them write code that are much better than an average coder”transcript, stated

Manual prompt review does not scale.

Root cause: Spreadsheet-based prompt evaluation cannot run continuously or instantaneously across many prompt/model outputs.

Resolution: Implement microservice evaluation engines that loop continuously and feed CI/CD-controlled prompt and model changes.

“manual spreadsheets to looking into prompts and how to evaluate it”transcript, stated
“microservice engines added to your layer of full architecture where you can do this in an infinite loop”transcript, stated

Prompt improvements may not be enough.

Root cause: Some completion failures cannot be repaired by instantaneous prompt-template tuning.

Resolution: Route unresolved quality gaps into fine-tuning through the continuous loop.

“prompt templates of prompt tunings that we can do on an instantaneous basis”transcript, stated
“prompt templates of prompt tunings that we can do on an instantaneous basis have a prompt validator rate output if that can't be done stranded to a fine tuning of the yellow labs again continuous loop having it version based control based each of these can be microservice connected through uh CI”transcript, stated

The useful benchmark is developer intent, not only syntactic correctness.

Root cause: Code completion must be honest, harmless, and helpful, with helpfulness tied to the coder's actual goal.

Resolution: Frame evaluation around developer usefulness and compare suggestions to what developers actually committed.

“there's basically three areas um will this code that a AI assistant completion agent or recommendation be honest”transcript, stated
“is it actually helpful so accomplishing exactly the goal of the coder”transcript, stated

Evaluation

GitLab evaluates code-completion usefulness by processing prompt input, tokenizing code, comparing candidate outputs to historically committed developer code, scoring similarity to an agreeable developer output, and running this as continuous microservice engines connected to version control and CI/CD. The framework measures whether suggestions are honest, harmless, and helpful, with particular focus on helpfulness for developer goals.

Metrics: Honest/harmless/helpful dimensions · Developer acceptance rate · Similarity to agreeable developer output · Prompt validator rating · Historical commit similarity · Prompt output quality · Cost · Latency · Benchmark performance · Continuous CI/CD evaluation results

4 supporting quotes
“feature um so um that's sort of what a code completion tool and how we actually decide on llms and based on these outcomes of these three different metrics now I want to actually focus on the last part does it actually help um to get to the uh the goal of the quota um to do that I do want to”transcript, stated
“similarity and agreed on what is an actual agreeable developer output”transcript, stated
“you can use piercement or however based on the prompt as well as the code”transcript, stated
“want to know if there are prompt templates of prompt tunings that we can do on an instantaneous basis have a prompt validator rate output if that can't be done stranded to a fine tuning of the yellow labs again continuous loop having it version based control based each of these can be”transcript, stated

Outcomes

The transcript quantifies the build as roughly four/six/seven months, frames productivity as moving from 500 to 1,000 lines of usable feature code, describes evaluation at thousand-times continuous background scale, and mentions a raw LLM combination starting around a 10 acceptance rate for coders.

4 supporting quotes
“Ops and um we started this journey on building code completions through uh through two cockle suggestions uh pretty much around four or six seven months and and yeah we've learned a lot through it and um and just want to share through all the learnings together so um before we go into”transcript, stated
“to evaluate it but imagine this having this in scale as engines and that's the beauty of having this sort of a microservice engines added to your layer of full architecture where you can do this in an infinite loop on an instant basis to keep on dialing let's say your code completion uh”transcript, stated
“raw llms of a combination giving you a 10 acceptance rate for coders”transcript, stated
“have today um I do want to end by saying that it is uh of one of my lines that in this day in age of elements data is still the oil it is very difficult to imagine this that with sufficient data they will remain things that only humans can do so uh in the Journey of llms this is still the”transcript, stated