Sarghaby Araghatta
Home / Knowledge Base / CI/CD for AI apps
LLMOps · AI Engineering

CI/CD for AI apps

Continuous integration/deployment adapted for LLM apps: every change to prompts, RAG config, or model version runs an eval suite, and promotion is gated on quality, cost, and safety thresholds.

Pull Request(PR)Run Eval Suiteon Curated DatasetScore withDeterministic ChecksModel-GradedRubrics (LLM)Compare Resultsto Baseline
CI/CD Pipeline for AI Apps

How it works

When a pull request (PR) is made, the CI/CD pipeline kicks off by executing the application against a carefully curated evaluation dataset. This involves a combination of deterministic checks, such as schema validation and regex matching, alongside model-graded assessments where the LLM itself acts as a judge. These checks score the changes based on various metrics, including latency, token usage, and cost. The results from this evaluation are then compared to a predefined baseline. If any regressions are detected, the merge is automatically blocked, ensuring that only high-quality changes make it into the main branch.

To implement this system effectively, tools like Promptfoo for prompt evaluation, LangSmith or Langfuse for tracking model performance, and DeepEval or Braintrust for comprehensive evaluations are integrated into the CI/CD pipeline. These tools work together to provide a thorough assessment of the changes, ensuring that every aspect of the application is scrutinized before it goes live. The integration with GitHub Actions allows for smooth automation, triggering the evaluation process with each PR to maintain consistent quality control.

Consider a scenario where a developer modifies a prompt to improve user engagement. The CI/CD pipeline runs the modified prompt against the eval dataset, scoring it on various metrics. If the new prompt leads to a significant increase in engagement but also raises latency beyond acceptable levels, the regression check will prevent the merge. This mechanism ensures that modifications are not just made in isolation but are evaluated in the context of overall application performance and user experience.

  • Trigger eval suite on PR
  • Use deterministic checks for structure
  • Employ LLM for quality grading
  • Compare scores to baseline
  • Block merge on regressions

The software-engineering analogue

This concept parallels traditional software engineering CI/CD practices, where a test stage is included to validate code changes. In standard CI/CD, tests are typically deterministic, meaning they pass or fail based on clear criteria. However, in the context of AI applications, the tests become probabilistic and are graded on a scale, which introduces a layer of complexity. Instead of a simple pass/fail, the gates for merging changes are based on whether the score meets or exceeds a threshold across multiple cases, requiring a versioned evaluation set to serve as the ground truth for comparison.

Why not the obvious alternative

A common initial approach might be to manually review a few prompts before deploying changes. However, this method quickly becomes unmanageable as the number of prompts grows. It often leads to missed regressions, where a fix for one prompt inadvertently breaks others. Without an automated evaluation gate, developers lack visibility into whether a change results in an overall improvement or degradation in quality, creating a risk of silently shipping flawed updates.

This manual process fails to scale because it relies heavily on human judgment, which can be inconsistent and subjective. Automated evaluation provides a systematic way to assess changes, ensuring that every modification is quantitatively analyzed against established benchmarks. This approach minimizes the risk of regressions and ensures that the application maintains a high standard of quality as it evolves.

When to use which

In practice, deterministic assertions should be employed for structural checks and critical must-not-fail cases, as they provide a clear pass/fail outcome. For more subjective quality assessments, using LLM-as-judge becomes essential, as it can evaluate open-ended responses against human labels. It is advisable to run inexpensive checks on every PR to catch obvious issues early, while reserving more comprehensive evaluations for nightly builds or just before a release, balancing speed and thoroughness effectively.

Automated Checks are Critical Relying solely on manual reviews can lead to unnoticed regressions; automate evaluations to ensure quality.

In production: when it breaks

The scenario A recent deployment caused a 25% increase in latency for model responses.
Latency Increase DetectedCheck Prompt EfficiencyCheck RAG ConfigurationCheck Model VersionOptimize PromptsAdjust RAG SettingsRollback Model Version
Debugging CI/CD latency issues

Why it happens. The increase in error rates may stem from insufficient testing of the new model version against the eval suite, leading to the deployment of a model that doesn't generalize well to real user queries. Changes in prompt configurations or retrieval settings could have introduced biases or misalignments with user expectations, which were not caught during the CI/CD process.

  • Check the eval suite results for the new model version against previous benchmarks.
  • Log the specific queries that are failing and analyze their characteristics.
  • A/B test the new model against the previous stable version to compare performance metrics.
The call To fix this, revert to the previous stable model version while addressing the issues identified in the eval suite. The tradeoff is a temporary loss of new features or improvements from the new model. Monitor the error rates and user satisfaction scores closely after redeployment to ensure stability and user experience.

What it delivers

This CI/CD approach for AI applications delivers the confidence needed to rapidly implement changes to prompts and models without the fear of unintentionally degrading quality. By establishing a rigorous evaluation process, teams can ensure that their updates are beneficial and maintain the integrity of the application.