At SAP TechEd 2025, I demonstrated how to operationalize Hugging Face Transformer models in SAP AI Foundation using the Bring Your Own Model (BYOM) approach.
The goal was to show how I can move beyond consuming pre-hosted APIs and instead own the full model lifecycle – from training to serving inside SAP BTP.
My showcase focused on blocked invoice classification in SAP S/4HANA, a common process bottleneck.
Using BYOM, I trained and deployed a custom NLP model that predicts why an invoice was blocked, helping finance teams accelerate processing and reduce manual work.
BYOM enables organizations and developers to:
This approach contrasts with SAP’s Generative AI Hub, where models are pre-hosted by SAP or partners and accessed via API only.
With BYOM, I define the model architecture, container image, and YAML-based orchestration.
SAP AI Core executes these workflows securely, while AI Launchpad provides lifecycle management, logging, and governance.
Invoices in SAP S/4HANA can be blocked for reasons such as mismatched quantities, missing purchase orders, or pricing errors.
To automate this review, I fine-tuned a DeBERTa-v3-base model from Hugging Face on labeled invoice text.
Label map:
Label Category
| 0 | Price Variance |
| 1 | Quantity Mismatch |
| 2 | Missing PO Reference |
| 3 | Three-Way Match Failure |
| 4 | Supplier Issues |
The BYOM setup in SAP AI Core uses modular components that I can fully customize and version-control.
This architecture allows me to deploy, retrain, and scale models independently while maintaining full ownership of data and artifacts.
Below is a visual representation of the Bring Your Own Model workflow that connects all components:
This diagram illustrates how:
training-template.yaml, serving-template.yaml) and runtime configurations that sync with AI Core.Before deploying the model, I performed several key setup steps to prepare SAP AI Core and AI Launchpad for BYOM:
docker-registry-secret).
This one-time configuration ensures a seamless transition between local development and enterprise-grade orchestration in AI Core.
I created a training template (training-template.yaml) that runs my PyTorch script inside AI Core:
apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
name: invoice-classifier-training
spec:
arguments:
parameters:
- name: trainImage
value: "docker.io/itsmarlo/invoice-train:latest"
- name: baseModel
value: "microsoft/deberta-v3-base"
- name: numLabels
value: "5"
The workflow fine-tunes the model, evaluates it, and stores the trained weights as an artifact.
All training logic, hyperparameters, and dependencies are defined by me, illustrating the “bring your own” principle in action.
Training dependencies (requirements-train.txt)
torch==2.3.1
transformers>=4.42.0
datasets>=2.20.0
scikit-learn>=1.4.2
pandas>=2.2.2
The serving template (serving-template.yaml) deploys the model as a REST API using a lightweight FastAPI application:
apiVersion: ai.sap.com/v1alpha1
kind: ServingTemplate
metadata:
name: invoice-classifier-serving
spec:
parameters:
- name: image
default: "docker.io/itsmarlo/invoice-serve:latest"
- name: port
default: 8080
Serving stack (requirements-serve.txt)
fastapi>=0.111.0
uvicorn[standard]>=0.30.0
torch==2.3.1
transformers>=4.42.0
pydantic>=2.7.0
AI Core hosts this container as a KServe inference service that scales automatically and can be consumed securely by any SAP application.
I validated the deployed endpoint directly from AI Launchpad and Postman:
curl -X POST "https://<aicore-endpoint>/v1/invocations" \\
-H "Content-Type: application/json" \\
-d '{"text":"Invoice blocked due to mismatch between PO and invoice quantity"}'
Response:
{
"predicted_label": "Quantity Mismatch",
"confidence": 0.94
}
I integrated the inference endpoint with:
This completes the BYOM loop – training in AI Core, serving through KServe, and consuming predictions in SAP S/4HANA.
linux/amd64.Each step underlines the strength of BYOM: complete visibility and control of the AI lifecycle.
Metric Value
| Base model | DeBERTa-v3-base |
| Training time | ≈ 10 min (3 epochs, batch 16) |
| Model size | ≈ 250 MB |
| Validation accuracy | ≈ 90 % |
| Inference latency | < 200 ms (CPU) |
I plan to enhance the BYOM pipeline by:
You can explore the full setup, including all YAML templates, Dockerfiles, and sample datasets, in my public GitHub repository:
👉GitHub – teched25-BYOM-classifier
Clone the repo, adjust the dataset paths, and deploy your own BYOM workflow on SAP AI Core.
The repository includes:
This example is a starting point for deploying your own Hugging Face models in SAP AI Foundation with full lifecycle control.
Challenge Resolution
| Image pull failures due to architecture mismatch (ARM vs. x86) | Rebuilt Docker images specifically for linux/amd64, ensuring compatibility with AI Core runtimes. |
| Path mismatches and missing dependencies | Validated Docker builds locally before pushing to Docker Hub; used absolute paths for mounted datasets in YAML templates. |
| Dataset access issues (S3 permissions) | Adjusted IAM policy and verified bucket configuration early in the setup. |
| Versioning conflicts between Docker images and YAML definitions | Implemented strict version tagging across all artifacts to maintain reproducibility. |
| Debugging failed executions | Used AI Launchpad logs extensively and added print statements in Python scripts to trace errors. |
Each challenge reinforced the value of BYOM having full transparency and ownership made it easier to troubleshoot, iterate, and optimize the overall AI lifecycle.
This project demonstrates how Bring Your Own Model (BYOM) empowers developers to run open-source models like Hugging Face Transformers within SAP AI Foundation under full enterprise governance.
By defining my own Docker images, YAML pipelines, and inference logic, I combined open innovation with SAP’s orchestration and compliance framework.
The result is an end-to-end, production-ready AI service for SAP S/4HANA that remains explainable, auditable, and reusable across use cases.
Follow me on SAP Community for more insights on BYOM, Hugging Face integration, and AI Core automation.🤗
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 9 | |
| 6 | |
| 6 | |
| 5 | |
| 5 | |
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 3 |