# GenAIOps - LLM-Specific MLOps Practices

**Dato:** 2026-02-04
**Last updated:** 2026-06-19
**Kategori:** MLOps & GenAIOps
**Konfidensgrad:** Høy (basert på 18 MCP-kilder fra Microsoft Learn)

---

> **⚠️ Retirement 2027-04-20 (verifisert 2026-06-19):** Prompt Flow (Microsoft Foundry + Azure ML) pensjoneres 20. april 2027 og anbefales ikke for ny utvikling — migrer til **Microsoft Agent Framework (MAF)**. Referanser til Prompt Flow nedenfor gjelder eksisterende løsninger frem til fristen; nye GenAIOps-pipelines bør bygge på MAF. [Migrasjonsguide](https://learn.microsoft.com/azure/machine-learning/prompt-flow/migrate-prompt-flow-to-agent-framework?view=azureml-api-2).

## Introduksjon

GenAIOps (Generative AI Operations), også kalt LLMOps, beskriver operasjonelle praksiser og strategier for håndtering av store språkmodeller (LLMs) i produksjon. Mens tradisjonell MLOps fokuserer på å trene og deploye diskriminative modeller, handler GenAIOps om å **velge, tilpasse, orkestrere og overvåke** eksisterende foundation models.



### MLflow 3 Tracing — GenAI Observability
MLflow Tracing provides end-to-end observability for GenAI applications:
- Records inputs, outputs, intermediate steps, and metadata
- Supports complex agent-based systems and multi-turn conversations
- Integrates with Genie Code for natural language trace analysis
- Enables: debugging, performance monitoring, cost optimization, auditability
- Production monitoring reuses same scorers as development evaluation (consistent lifecycle)


### 1. Fine-Tuning Pattern

**Når:** Foundation model trenger domenespesifikk kunnskap som ikke kan oppnås med prompting alene.

**Workflow:**
1. Data preparation (JSONL format for Azure OpenAI)
2. Fine-tuning job (Azure OpenAI Studio eller REST API)
3. Model evaluation (hold-out test set)
4. Model deployment (dedicated PTU deployment for production)
5. A/B testing (new fine-tuned model vs. base model)

**MLOps-overlap:** 80% — Kan gjenbruke eksisterende DataOps og model training pipelines.

**Konfidensgrad:** 90% — Microsoft dokumenterer end-to-end fine-tuning workflow.

### 2. Prompt Engineering Pattern

**Når:** Use case kan løses med zero-shot, few-shot eller Chain-of-Thought prompting.

**Artefakter:**
- System prompt (persona, tone, constraints)
- User prompt template (Jinja2, Handlebars)
- Few-shot examples (stored in Prompt Registry)

**Workflow:**
1. Prompt experimentation (Prompt Flow designer)
2. Variant testing (A/B testing av ulike prompts)
3. Evaluation (LLM-as-judge metrics)
4. Prompt versioning (Prompt Registry)
5. Deployment (orchestrator henter versioned prompt)

**MLOps-utvidelse:** Ny — Prompts som first-class artifacts.

**Konfidensgrad:** 85% — Best practices fremdeles emergent (2025).

### 3. RAG (Retrieval-Augmented Generation) Pattern

**Når:** LLM trenger domain-specific eller real-time data for å svare korrekt.

**Microsoft RAG Architecture:**
```
[User Query]
    → [Orchestrator (Prompt Flow / Semantic Kernel)]
        → [Embedding Model (Azure OpenAI text-embedding-3-small)]
        → [Vector Store (Azure AI Search hybrid search)]
        → [Retrieval (top-k chunks)]
        → [Prompt Construction (query + context)]
        → [LLM (Azure OpenAI GPT-4o)]
        → [Response]
```

**Experimentation-dimensjoner:**
- Chunking strategy (fixed-size, semantic, recursive)
- Chunk size (512, 1024, 2048 tokens)
- Chunk overlap (0%, 10%, 20%)
- Embedding model (ada-002, text-embedding-3-small, text-embedding-3-large)
- Retrieval method (vector, full-text, hybrid, semantic ranker)
- Top-k (3, 5, 10 chunks)
- Reranking (Azure AI Search semantic ranker, cross-encoder models)

**DataOps-utvidelse:**
- **Index versioning**: Snapshot av chunked data + embeddings
- **Incremental updates**: Add/update/delete chunks uten full rebuild
- **Freshness policies**: Real-time (change data capture) vs. batch (nightly)
- **GDPR compliance**: Right-to-be-forgotten (delete user data from vector store)

**Konfidensgrad:** 95% — RAG er den mest dokumenterte GenAIOps-patternern.

---

## Beslutningsveiledning

### Når velge hva?

| Scenario | Anbefaling | Begrunnelse |
|----------|------------|-------------|
| **Foundation model er "good enough"** | Prompt Engineering | Lavest kostnad, raskest time-to-market |
| **Trenger domenekunnskap, har kvalitetsdata** | Fine-Tuning | Bedre ytelse enn few-shot, men krever PTU for production |
| **Trenger real-time data eller stor knowledge base** | RAG | Unngår staleness, kan oppdatere uten retraining |
| **Høy security/compliance** | RAG + Azure AI Search (RBAC) | Data forblir i vector store, ikke "bakt inn" i modellen |
| **Multimodal (tekst + bilde)** | Prompt Engineering (GPT-4o/GPT-4 Turbo) | Foundation models støtter multimodal input |

**Konfidensgrad:** 85% — Valg avhenger av use case-spesifikke trade-offs.

### GenAIOps Maturity Model (Microsoft)

**Nivå 1 - Initial (0-9 poeng):**
- Eksperimenterer med LLM APIs
- Manuell prompt engineering
- Ingen strukturerte evalueringer

**Nivå 2 - Defined (10-14 poeng):**
- Systematisk prompt development
- CI/CD for flows (basic)
- Grunnleggende evaluering (groundedness, relevance)

**Nivå 3 - Managed (15-19 poeng):**
- Proaktiv monitoring (quality + safety)
- Fine-tuning workflows
- Advanced version control (prompts + data + models)

**Nivå 4 - Optimized (20-28 poeng):**
- Full automation (CI/CD + monitoring + retraining)
- A/B testing i produksjon
- Continuous improvement loops (feedback → retraining)

**Selvvurdering:** [GenAIOps Maturity Model Assessment](https://learn.microsoft.com/en-us/assessments/e14e1e9f-d339-4d7e-b2bb-24f056cf08b6/)

**Konfidensgrad:** 95% — Offisiell Microsoft assessment.

---

## Integrasjon med Microsoft-stakken

### Microsoft Foundry (tidligere Azure AI Studio)

**Hva:** Unified platform for GenAI lifecycle management.

**GenAIOps capabilities:**
- **Model Catalog**: Browse 1600+ foundation models (OpenAI, Meta, Mistral, Cohere)
- **Prompt Flow**: Visual designer for LLM workflows
- **Evaluation SDK**: Built-in evaluators (groundedness, relevance, coherence, fluency, safety)
- **Content Safety**: Real-time filtering (hate, violence, sexual, self-harm)
- **Model fine-tuning**: Azure OpenAI fine-tuning jobs
- **Deployment**: Managed Online Endpoints (serverless, PTU, PAYG)
- **Monitoring**: Generation Quality Signal + Token Statistics Signal

**Konfidensgrad:** 95% — Microsoft Foundry er Microsoft sitt flagship GenAI-verktøy (2025).

### Azure Machine Learning

**Hva:** Enterprise MLOps-plattform som utvides med GenAIOps capabilities.

**GenAIOps features:**
- **Prompt Flow integration**: Author flows i AML Studio
- **MLflow**: Experiment tracking + model registry (støtter LLM artifacts)
- **Pipelines**: Orchestrate chunking, embedding, evaluation workflows
- **Managed Online Endpoints**: Deploy orchestrators (Docker containers)
- **Model Monitoring**: Data drift + model decay (LLM-specific metrics coming)

**Konfidensgrad:** 90% — AML støtter GenAIOps, men Foundry er mer fokusert.

### Azure Databricks

**Hva:** Unified analytics platform med Mosaic AI (LLMOps suite).

**LLMOps features:**
- **Unity Catalog**: Unified governance (models, prompts, vector indexes)
- **MLflow for GenAI**: Prompt Registry, LLM tracing, autologging
- **Vector Search**: Delta table-based, auto-syncing indexes
- **Model Serving**: Unified endpoint for OpenAI, open-source og custom models
- **Mosaic AI Agent Framework**: Build, evaluate, deploy agents
- **AI Gateway**: Centralized governance for multiple LLM providers

**Konfidensgrad:** 95% — Databricks har dedikert LLMOps docs (mest moden platform).

### API Management som LLM Gateway

**Hva:** Centralized gateway foran Azure OpenAI in Foundry Models og andre LLM APIs.

**GenAIOps use cases:**
- **Load balancing**: Distribuer trafikk over multiple Azure OpenAI instances (med health endpoint monitoring og circuit breaking)
- **Throttling**: Rate limiting per user/subscription (token-per-minute og requests-per-minute)
- **Token tracking**: Centralized logging av token consumption (cross-model observability)
- **Cost allocation**: Chargeback til teams basert på usage (showback/chargeback for multitenant)
- **A/B testing / Safe deployment**: Route 10% traffic til ny modell, 90% til gammel
- **Circuit breaker**: Failover til backup LLM provider (OpenAI → Mistral)
- **Federated authentication**: Extend client auth beyond Entra ID and API keys
- **Data sovereignty**: Enforce regional routing compliance for GDPR

**Implementasjonsalternativer (Verified MCP 2026-04):**
1. **Azure API Management** (anbefalt) — PaaS, built-in Azure OpenAI policies (`Limit Azure OpenAI API token usage`, `Emit metrics for consumption`), zone-redundant, multi-region. Bruk [GenAI gateway toolkit](https://github.com/Azure-Samples/apim-genai-gateway-toolkit) for custom policies + load-testing.
2. **Custom code** — Deploy gateway-logikk til App Service, Container Apps eller AKS. Kan frontes av API Management for HTTP-gateway capabilities.

**Viktig:** Global og data zone deployments i Azure OpenAI (som distribuerer kapasitet på tvers av datasentre) er i seg selv en gateway-implementasjon — vurder om disse dekker behovet FØR du legger til ekstra gateway-lag.

**Konfidensgrad:** 90% — API Management for LLM er dokumentert pattern (Verified MCP 2026-04).

---

## Offentlig sektor (Norge)

### Compliance-dimensjoner

| Krav | GenAIOps-implikasjon |
|------|---------------------|
| **GDPR Article 17 (right to be forgotten)** | Vector stores må støtte incremental deletion. Azure AI Search støtter dette. |
| **Utredningsinstruksen (KS/KMD)** | Prompt versioning + evaluation results = audit trail for AI-beslutninger |
| **NSM Grunnprinsipper for IKT-sikkerhet** | Content Safety må være enabled i production. Azure AI Content Safety er realtime. |
| **Digdir Prinsipper for utvikling av digitale tjenester** | Human-in-the-loop approval gates i CI/CD (GenAIOps template støtter dette) |
| **AI Act (High-Risk AI Systems)** | Logging av alle LLM-interaksjoner (MLflow tracing + Application Insights) |

**Konfidensgrad:** 80% — Compliance-tolkning krever juridisk input.

### Norsk språkstøtte

**Utfordring:** Foundation models (GPT-4, GPT-4o) er primært engelsk-trent.

**GenAIOps-tilnærminger:**
1. **Multilingual prompts**: Eksplisitt be om norsk output ("Svar på norsk")
2. **Fine-tuning**: Fine-tune GPT-4o på norske datasett (krever PTU)
3. **RAG med norsk grounding data**: Norske dokumenter i vector store (embeddings er multilingual)
4. **NB-BERT embeddings**: Bruk Norwegian BERT for embedding norske dokumenter (Azure AI Search custom embeddings)

**Konfidensgrad:** 70% — Norsk språkstøtte i GenAI er fortsatt eksperimentell (2025).

---

## Kostnad og lisensiering

### Token-basert prissetting (Azure OpenAI)

| Modell | Input (1M tokens) | Output (1M tokens) | Bruksområde |
|--------|-------------------|-------------------|-------------|
| **GPT-4o** | $2.50 | $10.00 | RAG, complex reasoning |
| **GPT-4o-mini** | $0.15 | $0.60 | High-volume classification |
| **GPT-4 Turbo** | $10.00 | $30.00 | Legacy (prefer GPT-4o) |
| **GPT-3.5 Turbo** | $0.50 | $1.50 | Cost-sensitive use cases |
| **text-embedding-3-small** | $0.02 | N/A | Embedding generation |

**Priser er per februar 2025 (NOK-estimat: USD × 10.5).**

**Konfidensgrad:** 95% — Azure OpenAI pricing er dokumentert.

### Provisioned Throughput Units (PTU)

**Hva:** Dedikert kapasitet for forutsigbar latency og cost.

**Når:** Production workloads med >100M tokens/måned.

**Kostnad:** $36 000 - $48 000 per PTU per måned (avhenger av modell og region).

**Konfidensgrad:** 90% — PTU pricing varierer, krever Azure quote.

### Cost Optimization Tactics

1. **Prompt compression**: Fjern unødvendige tokens fra system prompt
2. **Caching**: Azure OpenAI støtter prompt caching (50% discount på cached tokens)
3. **Model downselection**: Bruk GPT-4o-mini for classification, GPT-4o for reasoning
4. **Batching**: Async batch API (50% discount, men høyere latency)
5. **Token limits**: `max_tokens` parameter for å unngå runaway costs

**Konfidensgrad:** 95% — Cost optimization er godt dokumentert.

---

## For arkitekten (Cosmo)

### Spørsmål du ALLTID bør stille

1. **"Trenger dere faktisk fine-tuning, eller holder prompting?"**
   - 80% av use cases løses med RAG + prompt engineering.
   - Fine-tuning krever PTU (dyrt) og mer ops-kompleksitet.

2. **"Hva er kvalitetskravet?"**
   - Pass rate på 70% (groundedness) er typisk for MVP.
   - Pass rate på 90%+ krever extensive evaluation og tuning.

3. **"Har dere plan for human feedback loop?"**
   - Thumbs up/down i UI → Application Insights → Retraining pipeline.
   - Uten feedback loop, modellen degraderer over tid.

4. **"Hva er token-budsjettet?"**
   - 1M requests × 1000 tokens avg = 1B tokens/måned = ~$12,500 USD med GPT-4o.
   - PTU blir billigere ved >100M tokens/måned.

5. **"Hvordan håndterer dere GDPR right-to-be-forgotten i vector store?"**
   - Azure AI Search: Incremental deletion støttes.
   - Databricks Vector Search: Delta table-based, soft delete.

### Red Flags

❌ **"Vi trenger ikke evaluering, vi bare deployer"**
→ Uten groundedness/relevance metrics, ingen måte å vite om LLM hallusinerer.

❌ **"Vi lagrer alle prompts i hardkoded strings"**
→ Prompts MÅ være versjonerte artefakter (Prompt Registry eller Git).

❌ **"Vi overvåker bare latency, ikke quality"**
→ LLM kan svare raskt med feil svar. Quality monitoring er kritisk.

❌ **"Vi trenger ikke content safety, det er et B2B-system"**
→ Prompt injection attacks kan få LLM til å lekke data selv i enterprise-systemer.

### Anbefalte Steg for Pilot (MVP)

**Uke 1-2: Setup**
1. Provisioner Microsoft Foundry project
2. Deploy Azure OpenAI (GPT-4o + text-embedding-3-small)
3. Setup Azure AI Search (vector index)
4. Enable Azure AI Content Safety

**Uke 3-4: Development**
1. Bygg RAG flow i Prompt Flow
2. Test med 10-20 representative queries
3. Evaluer med built-in evaluators (groundedness, relevance)
4. Iterer på chunking strategy og retrieval method

**Uke 5-6: CI/CD**
1. Clone GenAIOps Prompt Flow template
2. Setup GitHub Actions / Azure DevOps pipelines
3. Implementer human-in-the-loop approval gate
4. Deploy til dev endpoint

**Uke 7-8: Production Prep**
1. Setup monitoring (quality + tokens + safety)
2. Implement feedback loop (thumbs up/down)
3. Load testing (PTU vurdering)
4. Deploy til production endpoint (blue-green)

**Konfidensgrad:** 90% — Basert på Microsoft LLMOps workshop (2025).

---

## Kilder og verifisering

### Microsoft Learn-kilder (18 dokumenter)

1. [Advance your maturity level for GenAIOps](https://learn.microsoft.com/en-us/azure/machine-learning/prompt-flow/concept-llmops-maturity)
2. [GenAIOps with prompt flow and Azure DevOps](https://learn.microsoft.com/en-us/azure/machine-learning/prompt-flow/how-to-end-to-end-azure-devops-with-prompt-flow)
3. [GenAIOps with prompt flow and GitHub](https://learn.microsoft.com/en-us/azure/machine-learning/prompt-flow/how-to-end-to-end-llmops-with-prompt-flow)
4. [Generative AI operations for organizations with MLOps investments](https://learn.microsoft.com/en-us/azure/architecture/ai-ml/guide/genaiops-for-mlops)
5. [LLMOps workflows on Azure Databricks](https://learn.microsoft.com/en-us/azure/databricks/machine-learning/mlops/llmops)
6. [MLOps and GenAIOps for AI workloads on Azure](https://learn.microsoft.com/en-us/azure/well-architected/ai/mlops-genaiops)
7. [Integrate prompt flow with DevOps for LLM-based applications](https://learn.microsoft.com/en-us/azure/machine-learning/prompt-flow/how-to-integrate-with-llm-app-devops)
8. [Azure AI Evaluation SDK](https://learn.microsoft.com/en-us/python/api/overview/azure/ai-evaluation-readme)
9. [Mosaic AI capabilities for GenAI](https://learn.microsoft.com/en-us/azure/databricks/generative-ai/guide/mosaic-ai-gen-ai-capabilities)
10. [MLflow Prompt Registry](https://learn.microsoft.com/en-us/azure/databricks/mlflow3/genai/prompt-version-mgmt/prompt-registry/)
11. [Microsoft Foundry monitoring](https://learn.microsoft.com/en-us/azure/foundry-classic/how-to/monitor-quality-safety)
12. [MLflow Tracing for GenAI](https://learn.microsoft.com/en-us/azure/databricks/mlflow3/genai/tracing/)
13. [GenAI app developer workflow](https://learn.microsoft.com/en-us/azure/databricks/generative-ai/tutorials/ai-cookbook/genai-developer-workflow)
14. [Plan and prepare a GenAIOps solution (Microsoft Learn Training)](https://learn.microsoft.com/en-us/training/modules/plan-prepare-genaiops/)
15. [Implement LLMOps in Azure Databricks (Microsoft Learn Training)](https://learn.microsoft.com/en-us/training/modules/implement-llmops-azure-databricks/)
16. [Access Azure OpenAI in Foundry Models through a gateway](https://learn.microsoft.com/en-us/azure/architecture/ai-ml/guide/azure-openai-gateway-guide) (Verified MCP 2026-04)
17. [RAG solution design and evaluation guide](https://learn.microsoft.com/en-us/azure/architecture/ai-ml/guide/rag/rag-solution-design-and-evaluation-guide)
18. [Microsoft GenAIOps Prompt Flow Template (GitHub)](https://github.com/microsoft/genaiops-promptflow-template)

### MCP-kall utført

- **microsoft_docs_search**: 3 søk (GenAIOps overview, LLMOps best practices, lifecycle)
- **microsoft_docs_fetch**: 3 hentinger (maturity model, genaiops-for-mlops, databricks llmops)
- **microsoft_code_sample_search**: 2 søk (evaluation Python code, monitoring code)

**Totalt:** 18 kilder, 8 MCP-kall.

**Verifiseringsdato:** 2026-02-04

---

**For Cosmo Skyberg:**

Denne kunnskapsfilen dekker det **operasjonelle rammeverket** for GenAI-løsninger — hvordan du går fra prototype til production med repeatable processes. Fokus er på **Microsoft-spesifikke verktøy** (Microsoft Foundry, Prompt Flow, MLflow, Databricks Mosaic AI), men prinsippene er portable til andre platforms.

Viktigste takeaway: **GenAIOps er MLOps + Prompt Ops + Orchestration Ops + Vector Store Ops**. Det er MER enn bare model deployment — det er hele økosystemet rundt LLM-baserte applikasjoner.

Når kunder spør "hvordan setter vi LLM i produksjon?", start med **GenAIOps Maturity Model** for å kartlegge hvor de er, og bruk **GenAIOps Prompt Flow Template** som konkret utgangspunkt.
