Close Menu
    Trending
    • Why Should We Bother with Quantum Computing in ML?
    • Federated Learning and Custom Aggregation Schemes
    • How To Choose The Perfect AI Tool In 2025 » Ofemwire
    • Implementing DRIFT Search with Neo4j and LlamaIndex
    • Agentic AI in Finance: Opportunities and Challenges for Indonesia
    • Dispatch: Partying at one of Africa’s largest AI gatherings
    • Topp 10 AI-filmer genom tiderna
    • OpenAIs nya webbläsare ChatGPT Atlas
    ProfitlyAI
    • Home
    • Latest News
    • AI Technology
    • Latest AI Innovations
    • AI Tools & Technologies
    • Artificial Intelligence
    ProfitlyAI
    Home » Automate Models Training: An MLOps Pipeline with Tekton and Buildpacks
    Artificial Intelligence

    Automate Models Training: An MLOps Pipeline with Tekton and Buildpacks

    ProfitlyAIBy ProfitlyAIJune 11, 2025No Comments11 Mins Read
    Share Facebook Twitter Pinterest LinkedIn Tumblr Reddit Telegram Email
    Share
    Facebook Twitter LinkedIn Pinterest Email


    machine studying successfully signifies that merely coaching a mannequin is not sufficient; sturdy, automated, and reproducible coaching pipelines are quick turning into normal necessities in MLOps. Many groups wrestle to combine machine studying experimentation with production-grade CI/CD practices, usually turning into entangled in handbook processes or advanced container configurations. What in the event you might streamline the containerization of your coaching workflows and orchestrate them with out ever needing to write down a Dockerfile?

    On this tutorial, I’ll present the way to automate coaching a GPT-2 mannequin utilizing open-source Tekton pipelines and Buildpacks. We’ll containerize a coaching workflow with out writing a Dockerfile, and use Tekton to orchestrate the construct and coaching steps. 

    I’ll exhibit this with a light-weight GPT-2 tuning instance, exhibiting the mannequin’s output earlier than versus after coaching, and supply step-by-step directions to recreate the pipeline.

    Overview of the toolkit: Tekton, Buildpacks, and GPT-2

    Tekton Pipelines: Cloud-Native CI/CD for ML

    Tekton Pipelines is an open-source CI/CD framework that runs natively on Kubernetes. It permits you to outline pipelines as Kubernetes sources, enabling cloud-native construct, check, and deploy workflows. In a Tekton pipeline, every step runs in a container, making it a great match for ML workflows that require isolation and reproducibility.

    Buildpacks: skipping Dockerfiles

    Keep in mind the final time you wrestled with a posh Dockerfile, making an attempt to get all dependencies and configurations good? Paketo Buildpacks (an implementation of Cloud Native Buildpacks) supply a refreshing various. They automate the creation of container photos straight out of your supply code. Buildpacks analyze your undertaking, detect the language and dependencies, after which construct an optimized, safe container picture for you. This not solely saves time but in addition incorporates greatest practices into your image-building course of, usually leading to safer and environment friendly photos than these created manually with Dockerfiles.

    GPT-2: light-weight mannequin

    We’ll be utilizing GPT-2 as our instance mannequin. It’s a well known transformer mannequin, and crucially, it’s light-weight sufficient for us to tune rapidly on a small, customized dataset. This makes it excellent for demonstrating the mechanics of our coaching pipeline with out requiring huge compute sources or hours of ready. We’ll tune it on a tiny set of question-answer pairs, permitting us to see a transparent distinction in its outputs after our pipeline works its magic.

    The purpose right here isn’t to realize groundbreaking NLP outcomes with GPT-2. As an alternative, we’re focusing squarely on showcasing an environment friendly and automatic CI/CD pipeline for mannequin coaching. The mannequin is our payload.

    Peeking Contained in the Challenge: Code, Knowledge, and Pipeline Construction

    I’ve arrange an instance repository on GitHub that incorporates all the things you’ll have to comply with alongside. Let’s take a fast tour of the important thing elements:

    • training_process/practice.py – the mannequin coaching script. It makes use of HuggingFace Transformers with PyTorch to fine-tune GPT-2 on a customized Q&A dataset. It reads a small textual content file of question-answer pairs (see beneath), fine-tunes GPT-2 on this knowledge, and saves the educated mannequin to an output listing.
    • training_process/necessities.txt – Python dependencies wanted for coaching. Buildpacks will auto-install these into the picture.
    • training_process/practice.txt – A small dataset of Q&A pairs. Be happy to customise it 🙂
    • untrained_model.py – A helper script to check GPT-2 earlier than fine-tuning.

    Tekton Pipeline Information:

    • model-training-pipeline.yaml – defines the Tekton pipeline with two duties (defined within the subsequent part).
    • source-pv-pvc.yaml – defines a PersistentVolume and PersistentVolumeClaim for sharing the supply code and knowledge with the Tekton duties (used as a workspace). 
    • kind-config.yaml – a Kind cluster configuration to mount the native training_process/ listing into the Kubernetes cluster. 
    • sa.yml – a ServiceAccount and secret configuration for pushing the constructed picture to a container registry (Docker Hub on this case).

    With these items, now we have our code, knowledge, and pipeline definitions prepared. Now, let’s look at the construction of the Tekton pipeline.

    Anatomy of Our Tekton Pipeline: Constructing and Coaching

    At its core, a Tekton Pipeline useful resource is what orchestrates your CI/CD workflow by defining a sequence of Duties. You may consider these Duties as reusable constructing blocks, every composed of a number of Steps the place your precise instructions and scripts execute — all neatly packaged inside containers.  

    For our particular MLOps purpose of automating the GPT-2 mannequin coaching, the Pipeline (outlined in model-training-pipeline.yaml) is designed with a transparent, sequential construction. It is going to execute two major Duties, one after the opposite: first, to construct and containerize our coaching code, and second, to run the coaching course of utilizing that contemporary container picture.

    Let’s go over every intimately.

    Construct The Picture: Containerize the Coaching Code

    This process makes use of Paketo Buildpacks to create a Docker picture that incorporates our coaching code and all its dependencies. Importantly, no Dockerfile is required: the Buildpacks builder will robotically detect the Python app and set up PyTorch, Transformers, and different dependencies as specified within the necessities.txt file. Within the pipeline, this process is known as build-image. It runs the Paketo Buildpacks builder (paketobuildpacks/builder:full) with the supply code workspace mounted. Below the hood, it invokes the Cloud Native Buildpacks lifecycle creator:

    /cnb/lifecycle/creator -skip-restore -app "$(workspaces.supply.path)" "$(params.APP_IMAGE)"

    This command tells Buildpacks to create a container picture from the app supply within the workspace and tag it as $(params.APP_IMAGE). By default, APP_IMAGE is ready to a Docker Hub repository (e.g., sylvainkalache/automate-pytorch-model-training-with-tekton-and-buildpacks:newest). 

    Notice that you just’ll have to substitute together with your registry. I take advantage of Docker Hub on this instance. After this step, our coaching code is packaged right into a container picture and pushed to the registry.

    Prepare the Mannequin

    The second process, run-training, is determined by the primary. This process pulls and runs the picture produced by the construct step to execute the mannequin coaching. Basically, it begins a container from the picture (which has Python, GPT-2 code, and so forth. put in) and runs the practice.py script inside that container.

    The Shared Workspace: Connecting the Dots

    Let’s go over why we’d like a shared workspace in our Tekton pipeline. On this automated workflow composed of a number of levels, the construct stage and coaching stage require a shared place to trade recordsdata or knowledge. Our build-image process wants entry to our native supply code to containerize it. Later, the run-training process wants entry to the coaching knowledge. Lastly, when the coaching process efficiently generates a fine-tuned mannequin, we’d like a technique to save and retrieve that precious output.

    ​​Each duties share a Tekton Workspace named “supply”. This workspace is backed by a PersistentVolumeClaim (source-pvc), which is ready as much as mount our native code. That is how the pipeline accesses the coaching script and knowledge: the identical recordsdata you’ve in training_process/ in your machine are mounted into the Tekton process pods at /workspace/supply. 

    Diagram showing how the code is connected to the Kind cluster where the Tekton pipeline will run

    The Buildpacks builder reads the code from there to construct the picture, and the coaching container later reads the info and writes outputs there as nicely. Utilizing a shared workspace ensures that the mannequin saved throughout coaching persists after the duty completes (so we will retrieve it) and that each duties function on the identical code base. Notice that this setup is appropriate for this tutorial, however it’s unlikely to be one thing you’d need for manufacturing.

    Now, merging the 2 sections, that is what all the coaching pipeline seems to be like.

    A diagram of the entire process, showing how the code and passed to Kind and the Tekton pipeline in its entirety

    Now that we perceive the pipeline, let’s stroll by means of setting it up and working it.

    Step-by-Step: Working the Tekton Pipeline for GPT-2 Coaching

    Able to see it in motion? Comply with these steps to arrange your atmosphere, deploy the Tekton sources, and set off the coaching pipeline. This assumes you’ve a Kubernetes cluster (for native testing, you should use Kind with the offered config) and kubectl entry to it. In the event you should not have such a setup, here is a tough listing of instructions you’ll have to get the required instruments. This tutorial was examined on Ubuntu 22.04.

    Clone the Instance Repository

    Get the code and pipeline manifests in your machine:

    git clone https://github.com/sylvainkalache/Automate-PyTorch-Mannequin-Coaching-with-Tekton-and-Buildpacks.git
    cd Automate-PyTorch-Mannequin-Coaching-with-Tekton-and-Buildpacks

    Set up Tekton Pipelines 

    If Tekton shouldn’t be already put in in your cluster, set up it by making use of the official launch YAML:
    kubectl apply -f https://storage.googleapis.com/tekton-releases/pipeline/newest/launch.yaml

    This command will create the Tekton CRDs (Pipeline, Process, PipelineRun, and so forth.) in your cluster. You solely want to do that as soon as.

    Apply the Pipeline and Quantity Manifests

    Deploy the Tekton pipeline definition and supporting Kubernetes sources:

    kubectl apply -f model-training-pipeline.yaml
    
    kubectl apply -f source-pv-pvc.yaml
    
    kubectl apply -f sa.yaml

    Let’s go over the main points of every command:

    • The primary command creates the Tekton Pipeline object model-training-pipeline within the cluster.
    • The second creates a PersistentVolume and Declare. The offered source-pv-pvc.yaml assumes you’re utilizing Form and mounts the native training_process/ listing into the cluster. It defines a hostPath quantity at /mnt/training_process on the node, and ties it to a PVC named source-pvc.
    • The third applies a ServiceAccount for Tekton to make use of when working the pipeline. This sa.yml ought to reference the Docker registry secret created within the subsequent step, permitting Tekton’s construct step to push the picture.

    Create Docker Registry Secret

    Tekton’s Buildpacks process will push the constructed picture to a container registry. For this, you want to present your registry credentials (e.g., Docker Hub login). Create a Kubernetes secret together with your registry auth particulars:

    kubectl create secret docker-registry docker-hub-secret 
    
        --docker-username=<USERNAME> 
    
        --docker-password=<PASSWORD> 
    
        --docker-server=<REGISTRY_URL> 
    
        --namespace default

    This secret will retailer your auth information. Make sure the ServiceAccount from step 3 is configured to make use of this secret for picture pull and push.

    Run the Tekton Pipeline

    With all the things in place, you can begin the pipeline, run:

    tkn pipeline begin model-training-pipeline 
    
    --workspace title=supply,claimName=source-pvc 
    
     -s tekton-pipeline-sa

    Right here we cross the PVC because the supply workspace. Additionally specify the service account (-s) that has the registry secret. It will begin the pipeline. Use tkn pipelinerun logs -f to look at the progress. You must see output from the Buildpacks creator (detecting a Python app, putting in necessities) after which from the coaching script (printing coaching epochs and completion).

    After the pipeline finishes efficiently, the fine-tuned mannequin will probably be saved within the training_process/output-model listing (because of the PVC workspace, it persists in your native filesystem by way of the Form mount). We are able to now examine the GPT-2 mannequin’s output earlier than and after fine-tuning.

    The Proof is within the Pudding: GPT-2 Output Earlier than vs. After Coaching

    Did our automated pipeline enhance the mannequin? Let’s discover out.

    Earlier than The Coaching

    What does the off-the-shelf GPT-2 mannequin say? Run untrained_model.py with a query. For instance:

    Terminal screenshot showing that the off the shelf model did not correctly answer the question “How far is the sun?”

    We are able to see that GPT-2 gave a rambling response that didn’t accurately reply the query.

    After the Coaching Course of

    Now let’s see GPT-2 tuned on our Q&A knowledge. We are able to load the mannequin saved by our pipeline and generate a solution. The script training_process/serve.py does this. For instance:

    Terminal screenshot showing that the trained model correctly answer the question “How far is the sun?”

    As a result of we educated on a QA format, the fine-tuned GPT-2 will produce a solution after the | separator. Certainly, after coaching, the mannequin’s reply to “How far is the solar?” was: “150 million kilometers away.” — exactly the reply from our coaching knowledge.

    This straightforward comparability demonstrates that our CI/CD pipeline efficiently took our supply code, constructed it, educated the mannequin, and produced an improved model. Whereas this was a minimal dataset for illustrative functions, think about plugging in your bigger, domain-specific datasets. The pipeline construction stays unchanged, offering a strong and automatic path for mannequin updates.

    Tekton + Buildpacks: A Profitable Combo for Less complicated ML CI/CD

    Utilizing Tekton pipelines with Buildpacks presents a sublime answer for machine studying CI/CD workflows. Each Tekton and Buildpacks are cloud-native, open-source options that combine nicely with the remainder of your Kubernetes ecosystem. 

    By automating mannequin coaching on this manner, ML engineers and DevOps groups can collaborate extra successfully. The ML code is handled equally to software code in CI/CD – each change can set off a pipeline that reliably builds and trains the mannequin. Tekton offers the pipeline glue with Kubernetes scalability, and Paketo Buildpacks take the effort out of containerizing ML workloads. The top result’s sooner experimentation and deployment for ML fashions, achieved with a declarative, easy-to-maintain pipeline. I hope you prefer it!

    Thanks For Studying

    I’m Sylvain Kalache, main Rootly AI Labs: a fellow-driven neighborhood constructing AI-centric prototypes, open-source instruments, and analysis to redefine reliability engineering. Sponsored by Anthropic, Google Cloud, and Google DeepMind, all our work is freely obtainable on GitHub. For extra of my tales, comply with me on LinkedIn or discover my writing in my portfolio.

    Sylvain Kalache

    Sylvain Kalache, the creator, created all the pictures and diagrams on this article.



    Source link

    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Previous ArticleAudio Spectrogram Transformers Beyond the Lab
    Next Article 10,000x Faster Bayesian Inference: Multi-GPU SVI vs. Traditional MCMC
    ProfitlyAI
    • Website

    Related Posts

    Artificial Intelligence

    Why Should We Bother with Quantum Computing in ML?

    October 22, 2025
    Artificial Intelligence

    Federated Learning and Custom Aggregation Schemes

    October 22, 2025
    Artificial Intelligence

    Implementing DRIFT Search with Neo4j and LlamaIndex

    October 22, 2025
    Add A Comment
    Leave A Reply Cancel Reply

    Top Posts

    How to build AI scaling laws for efficient LLM training and budget maximization | MIT News

    September 16, 2025

    Implementing the Caesar Cipher in Python

    September 2, 2025

    What are NLP, NLU, and NLG, and Why should you know about them and their differences?

    April 6, 2025

    Shaip Expands Availability of High-Quality Healthcare Data throughPartnership with Protege

    April 4, 2025

    The Complete Guide to De-identifying Unstructured Healthcare Data

    April 6, 2025
    Categories
    • AI Technology
    • AI Tools & Technologies
    • Artificial Intelligence
    • Latest AI Innovations
    • Latest News
    Most Popular

    MIT Learn offers “a whole new front door to the Institute” | MIT News

    July 21, 2025

    7 ChatGPT Prompts For Business In 2025 » Ofemwire

    April 4, 2025

    How to Overlay a Heatmap on a Real Map with Python

    July 16, 2025
    Our Picks

    Why Should We Bother with Quantum Computing in ML?

    October 22, 2025

    Federated Learning and Custom Aggregation Schemes

    October 22, 2025

    How To Choose The Perfect AI Tool In 2025 » Ofemwire

    October 22, 2025
    Categories
    • AI Technology
    • AI Tools & Technologies
    • Artificial Intelligence
    • Latest AI Innovations
    • Latest News
    • Privacy Policy
    • Disclaimer
    • Terms and Conditions
    • About us
    • Contact us
    Copyright © 2025 ProfitlyAI All Rights Reserved.

    Type above and press Enter to search. Press Esc to cancel.