Close Menu
    Trending
    • Musk’s X appoints ‘king of virality’ in bid to boost growth
    • Why Entrepreneurs Should Stop Obsessing Over Growth
    • Implementing IBCS rules in Power BI
    • What comes next for AI copyright lawsuits?
    • Why PDF Extraction Still Feels LikeHack
    • GenAI Will Fuel People’s Jobs, Not Replace Them. Here’s Why
    • Millions of websites to get ‘game-changing’ AI bot blocker
    • I Worked Through Labor, My Wedding and Burnout — For What?
    AIBS News
    • Home
    • Artificial Intelligence
    • Machine Learning
    • AI Technology
    • Data Science
    • More
      • Technology
      • Business
    AIBS News
    Home»Artificial Intelligence»Automate Models Training: An MLOps Pipeline with Tekton and Buildpacks
    Artificial Intelligence

    Automate Models Training: An MLOps Pipeline with Tekton and Buildpacks

    Team_AIBS NewsBy Team_AIBS NewsJune 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 now not sufficient; strong, automated, and reproducible coaching pipelines are quick turning into customary necessities in MLOps. Many groups battle to combine machine studying experimentation with production-grade CI/CD practices, typically turning into entangled in guide processes or advanced container configurations. What if you happen to may 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 lets you outline pipelines as Kubernetes assets, enabling cloud-native construct, take a look at, and deploy workflows. In a Tekton pipeline, every step runs in a container, making it a perfect match for ML workflows that require isolation and reproducibility.

    Buildpacks: skipping Dockerfiles

    Bear in mind the final time you wrestled with a posh Dockerfile, attempting to get all dependencies and configurations good? Paketo Buildpacks (an implementation of Cloud Native Buildpacks) provide a refreshing various. They automate the creation of container pictures immediately out of your supply code. Buildpacks analyze your mission, detect the language and dependencies, after which construct an optimized, safe container picture for you. This not solely saves time but additionally incorporates finest practices into your image-building course of, typically leading to safer and environment friendly pictures than these created manually with Dockerfiles.

    GPT-2: light-weight mannequin

    We’ll be utilizing GPT-2 as our instance mannequin. It’s a widely known transformer mannequin, and crucially, it’s light-weight sufficient for us to tune shortly on a small, customized dataset. This makes it good for demonstrating the mechanics of our coaching pipeline with out requiring large compute assets 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 attain groundbreaking NLP outcomes with GPT-2. As a substitute, 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 Venture: Code, Information, and Pipeline Construction

    I’ve arrange an instance repository on GitHub that comprises the whole lot you’ll have to observe alongside. Let’s take a fast tour of the important thing parts:

    • 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, we’ve got our code, knowledge, and pipeline definitions prepared. Now, let’s study 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 would execute two main Duties, one after the opposite: first, to construct and containerize our coaching code, and second, to run the coaching course of utilizing that recent container picture.

    Let’s go over every intimately.

    Construct The Picture: Containerize the Coaching Code

    This activity makes use of Paketo Buildpacks to create a Docker picture that comprises our coaching code and all its dependencies. Importantly, no Dockerfile is required: the Buildpacks builder will routinely detect the Python app and set up PyTorch, Transformers, and different dependencies as specified within the necessities.txt file. Within the pipeline, this activity is known as build-image. It runs the Paketo Buildpacks builder (paketobuildpacks/builder:full) with the supply code workspace mounted. Underneath 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 simply’ll have to substitute together with your registry. I exploit 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 activity, run-training, is dependent upon the primary. This activity 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 many others. 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 phases, the construct stage and coaching stage require a shared place to alternate recordsdata or knowledge. Our build-image activity wants entry to our native supply code to containerize it. Later, the run-training activity wants entry to the coaching knowledge. Lastly, when the coaching activity efficiently generates a fine-tuned mannequin, we’d like a approach to save and retrieve that worthwhile 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 might have in training_process/ in your machine are mounted into the Tekton activity 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 information and writes outputs there as properly. 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 the whole coaching pipeline appears to be like 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 via setting it up and operating it.

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

    Able to see it in motion? Observe these steps to arrange your surroundings, deploy the Tekton assets, and set off the coaching pipeline. This assumes you might have a Kubernetes cluster (for native testing, you need to use Kind with the offered config) and kubectl entry to it. When you wouldn’t have such a setup, here is a tough record 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 just isn’t 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, Activity, PipelineRun, and many others.) 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 assets:

    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 Type 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 operating 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 activity will push the constructed picture to a container registry. For this, it’s essential 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= 
    
        --docker-password= 
    
        --docker-server= 
    
        --namespace default

    This secret will retailer your auth data. 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 the whole lot in place, you can begin the pipeline, run:

    tkn pipeline begin model-training-pipeline 
    
    --workspace identify=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. It is best to 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 shall be saved within the training_process/output-model listing (due to the PVC workspace, it persists in your native filesystem through the Type 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 appropriately reply the query.

    After the Coaching Course of

    Now let’s see GPT-2 tuned on our Q&An information. 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 easy 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 provides a sublime answer for machine studying CI/CD workflows. Each Tekton and Buildpacks are cloud-native, open-source options that combine properly with the remainder of your Kubernetes ecosystem. 

    By automating mannequin coaching on this means, ML engineers and DevOps groups can collaborate extra successfully. The ML code is handled equally to utility code in CI/CD – each change can set off a pipeline that reliably builds and trains the mannequin. Tekton supplies the pipeline glue with Kubernetes scalability, and Paketo Buildpacks take the trouble out of containerizing ML workloads. The tip result’s quicker 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, observe 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 ArticleWhy Smart Australian Businesses Are Hiring Dedicated AI Developers — And You Should Too | by Ethanmitchell | Jun, 2025
    Next Article Citigroup Gives Employees Two Weeks of Remote Work in August
    Team_AIBS News
    • Website

    Related Posts

    Artificial Intelligence

    Implementing IBCS rules in Power BI

    July 1, 2025
    Artificial Intelligence

    Become a Better Data Scientist with These Prompt Engineering Tips and Tricks

    July 1, 2025
    Artificial Intelligence

    Lessons Learned After 6.5 Years Of Machine Learning

    July 1, 2025
    Add A Comment
    Leave A Reply Cancel Reply

    Top Posts

    Musk’s X appoints ‘king of virality’ in bid to boost growth

    July 1, 2025

    I Tried Buying a Car Through Amazon: Here Are the Pros, Cons

    December 10, 2024

    Amazon and eBay to pay ‘fair share’ for e-waste recycling

    December 10, 2024

    Artificial Intelligence Concerns & Predictions For 2025

    December 10, 2024

    Barbara Corcoran: Entrepreneurs Must ‘Embrace Change’

    December 10, 2024
    Categories
    • AI Technology
    • Artificial Intelligence
    • Business
    • Data Science
    • Machine Learning
    • Technology
    Most Popular

    He Was Afraid to Share Bad News With His Business Partners — Until One Insight Changed Everything

    June 12, 2025

    Track Computer Vision Experiments with MLflow | by Yağmur Çiğdem Aktaş | Dec, 2024

    December 26, 2024

    Deloitte Reports on Nuclear Power and the AI Data Center Energy Gap

    April 18, 2025
    Our Picks

    Musk’s X appoints ‘king of virality’ in bid to boost growth

    July 1, 2025

    Why Entrepreneurs Should Stop Obsessing Over Growth

    July 1, 2025

    Implementing IBCS rules in Power BI

    July 1, 2025
    Categories
    • AI Technology
    • Artificial Intelligence
    • Business
    • Data Science
    • Machine Learning
    • Technology
    • Privacy Policy
    • Disclaimer
    • Terms and Conditions
    • About us
    • Contact us
    Copyright © 2024 Aibsnews.comAll Rights Reserved.

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