AI / LLM Integration

AI / LLM Integration — Konrad Chmielinski
Engineering Blog · Konrad Chmielinski

Embedding large language models into production automation workflows — not as chatbots, but as transformation engines.

LLM Engineering Azure OpenAI · LangChain · RAG GPT-4o · Claude · Mistral · Llama · Agentic Katowice, PL · Remote OK

There is a wide gap between “using ChatGPT” and “integrating LLMs into production automation pipelines.” The first is a conversation. The second is an engineering discipline — involving prompt design, structured output contracts, confidence handling, agentic orchestration, retrieval systems, and rigorous testing against real business data.

I crossed that gap in production at ArcelorMittal Luxembourg in 2024, and have been building on those foundations ever since — adding RAG architectures, tool-calling agents, and LangGraph-based workflows to my stack. My model coverage now extends across OpenAI, Anthropic, Mistral, and locally-hosted open-source models via Ollama. This post covers every layer of how I work with LLMs in automation contexts.

~60%
end-to-end accuracy on AI offer generation pipeline (AM Luxembourg)
GPT-4o
primary production model via Azure OpenAI
3
agentic frameworks used: LangChain, LangGraph, custom tool-calling
RAG
retrieval-augmented generation in active use for enterprise knowledge pipelines

My core philosophy

LLM as step, not product

The most important design decision when integrating an LLM is treating it as one step in a larger pipeline — not as the whole product. In every system I have built, the LLM sits between structured data retrieval and structured output validation. It never owns the I/O contract. That contract belongs to the surrounding automation layer.

Data source
Retrieve & chunk
Prompt builder
LLM inference
Output parser
Validate
Action

Models I work with

production + evaluation
Model Provider / Runtime Use case Status
OpenAI — via Azure OpenAI
GPT-4o Azure OpenAI Structured output, entity extraction, offer generation, classification Production
GPT-4 Azure OpenAI Complex reasoning, document summarisation Production
Embedding models Azure OpenAI / HuggingFace Vector embeddings for RAG retrieval Production
Anthropic — Claude family
Claude 3.5 Sonnet Anthropic API Complex reasoning, long-context document analysis, instruction following, code generation Evaluated
Claude 3 Opus Anthropic API High-accuracy classification tasks, nuanced structured output where GPT-4o underperforms Evaluated
Claude 3 Haiku Anthropic API Low-latency, cost-efficient inference for high-volume classification and extraction tasks Evaluated
Mistral AI
Mistral Large Mistral API / Azure AI European-hosted alternative to GPT-4 for GDPR-sensitive workloads; function calling, structured output Evaluated
Mistral 7B / 8x7B (Mixtral) Self-hosted / Ollama On-premise inference, fast local classification, cost-free experimentation Local
Mistral Embed Mistral API Multilingual embeddings for RAG pipelines handling PL/FR/DE documents Evaluated
Meta — Llama family (via Ollama)
Meta Llama 3 (8B / 70B) Ollama (local only) Local inference for prototyping and offline experimentation; run entirely on-device via Ollama, no cloud dependency Local
Ollama — local inference runtime
Ollama runtime Local / Docker Unified local inference layer for Llama, Mistral, Phi, Gemma and other open-source models. Used for rapid prototyping, offline testing, and air-gapped deployments Local
Phi-3 Mini (via Ollama) Microsoft / Ollama Ultra-lightweight inference on CPU; edge deployment testing Evaluated
Gemma 2 (via Ollama) Google / Ollama Alternative open-weight baseline for classification benchmarking Evaluated

Prompt engineering

the craft layer

Prompt engineering in a production context is not about clever phrasing — it is about designing deterministic, testable input contracts that produce consistent structured output. I work with system prompts that define output schema explicitly, few-shot examples drawn from real production data, and chain-of-thought instructions for multi-step reasoning tasks.

System prompt design Structured JSON output Few-shot examples Chain-of-thought prompting Temperature control Token budget management Prompt versioning Negative examples Role prompting Output length constraints

Below is an example prompt used to extract steel products from client emails — illustrating the structured output approach with Azure OpenAI:

from openai import AzureOpenAI
import json
import re

client = AzureOpenAI(
    azure_endpoint=AZURE_ENDPOINT,
    api_key=AZURE_API_KEY,
    api_version="2024-02-01",
)

SYSTEM_PROMPT = """
You are a structured data extraction engine for steel products.
Extract every steel product and its quantity from the email.
Rules:
- Return ONLY valid JSON
- Format: {"product_name": quantity_or_null}
- Quantities are integers (tonnes)
- If no quantity → null
- No explanations, no text outside JSON
"""

def extract_products(email_body: str) -> dict:
    response = client.chat.completions.create(
        model="YOUR_DEPLOYMENT_NAME",  # Azure: deployment name, not model name
        temperature=0,
        messages=[
            {"role": "system", "content": SYSTEM_PROMPT},
            {"role": "user",   "content": email_body},
        ],
    )
    raw = response.choices[0].message.content
    # safer JSON extraction
    match = re.search(r"\{.*\}", raw, re.DOTALL)
    if not match:
        raise ValueError(f"Invalid JSON response: {raw}")
    return json.loads(match.group())

Tool calling & agentic systems

LLM that acts

Beyond simple inference, I build agentic workflows where the LLM decides which tools to call and in what order — dynamically routing through a pipeline based on the content of the input. This is qualitatively different from a fixed pipeline: the model reasons about the task and selects the appropriate execution path.

Framework
LangChain
Chain composition, tool binding, memory management. Used for single-agent, multi-step workflows.
Framework
LangGraph
Graph-based agentic flows with explicit state machines. Used where branching logic and loops are required.
Native API
OpenAI Tool Calling
Direct function calling via Azure OpenAI API. Lower latency, full control over tool schemas.
Native API
Claude Tool Use
Anthropic’s native tool use API. Evaluated for agentic document analysis where instruction following precision matters.
Runtime
Ollama API
Local REST API compatible with OpenAI client libraries. Enables tool-calling workflows without cloud dependency.
Pattern
ReAct pattern
Reason → Act → Observe loop. Used for multi-step tasks where intermediate results inform next actions.
At ArcelorMittal Luxembourg (2024): built a full agentic pipeline — the LLM received a new client inquiry, called a tool to retrieve matching historical orders from an internal API, reasoned over the results, and generated a personalised email offer. The entire flow ran without human intervention, achieving ~60% accuracy and significantly reducing sales team response times.

RAG — Retrieval-Augmented Generation

grounding the model

LLMs hallucinate when asked about data they were not trained on — internal product catalogues, historical order data, company-specific documents. RAG solves this by retrieving relevant context at inference time and injecting it into the prompt. The model reasons over real, current data rather than its training weights.

Query
user / system
Embed query
text-embedding-3
Vector search
Chroma / Pinecone
Top-k chunks
retrieved context
Augmented prompt
context + query
GPT-4o / Claude
grounded answer
RAG architecture Chunking strategies Vector embeddings Semantic search Chroma Pinecone (conceptual) Context window optimisation Retrieval evaluation Hybrid search (BM25 + vector) Re-ranking

Risk classifier — ML meets LLM

ING GKYC project

At ING, I built and maintained a risk assessment classifier used for Customer Due Diligence (CDD) — estimating organisational risk across financial security, fraud, misappropriation, and harmful entity detection. This was a traditional ML pipeline (Scikit-Learn) but required the same discipline as LLM work: careful feature engineering, iterative retraining as business rules evolved, and rigorous validation against regulatory requirements.

A critical real-world constraint emerged: the model’s statistical decisions could not be taken directly to production without business approval. Patterns that the classifier learned implicitly had to be formalised into explicit, deterministic rule sets — human-readable logic that the business could review, challenge, and sign off on. In practice, this meant working back from the model’s behaviour to codify its reasoning as manual rules, which were then implemented alongside the ML layer. This experience sharpened my understanding of the gap between model accuracy and operational trustworthiness — a lesson that directly shapes how I design LLM output validation and human-review lanes today.

This background in ML classification directly informs how I design LLM-based classification tasks today — treating prompt + model as a classifier, measuring precision/recall, and building human-review lanes for low-confidence outputs.

Scikit-Learn classifiers Feature engineering ML → manual rule translation Business sign-off workflows TensorFlow / Keras PyTorch Precision / recall measurement Iterative retraining Regulatory validation Confidence thresholding

Production deployments

employer context
ArcelorMittal Luxembourg — AI Client Offer Generation, 2024
Full agentic LLM pipeline: REST data retrieval from internal order history → GPT-4o inference with structured prompt → Pydantic output validation → personalised email generation → automated dispatch. Built on Azure OpenAI + LangChain. Achieved ~60% accuracy, significantly reducing sales team workload and response times.
ArcelorMittal Poland — NCBiR Deep Mining Project
Delivered as part of a grant project for NCBiR (Narodowe Centrum Badań i Rozwoju — Poland’s National Centre for Research and Development). The project focused on Deep Mining — building an application for analysis of mining processes, token flow tracing within those processes, and comprehensive statistics dashboards. Primary objectives: process optimisation, error detection, and identification of safety weak points. Designed for dual use — operational deployment within the company as well as reporting to government stakeholders.
ArcelorMittal Poland — AI Knowledge Sharing, ongoing
Internal workshops and presentations covering AI/LLM fundamentals and applied topics for non-technical and technical colleagues alike — including practical prompt engineering, an overview of available models and runtimes, and how LLM-based automation differs from traditional scripting. Part of a broader effort to raise AI literacy across the organisation.
ArcelorMittal Poland — Resume Filter Kit, 2024–present  Proof of concept
Embedding-based pre-screening pipeline: CV and job postings are independently embedded (text-embedding-3-small), cosine similarity filters out low-match offers before any LLM call is made. Surviving candidates are ranked and surfaced in a Streamlit dashboard with a per-offer match score and gap summary. The embedding pre-filter eliminates ~70–80% of irrelevant postings at near-zero cost, reserving expensive LLM inference only for genuinely relevant offers. Foundation for a future LLM layer that will generate targeted CV edits per offer.
ING Hubs Poland (GKYC) — Risk Assessment Classifier, 2021–2023
ML-based risk classifier for Customer Due Diligence. Built, enhanced, and adapted the classifier to reflect evolving business and regulatory requirements. Scikit-Learn core with iterative retraining cycles. A key constraint in a regulated environment: ML model decisions that could not be explained in deterministic terms required business sign-off before going live — so the classifier’s learned patterns were progressively translated into explicit, auditable rule sets that the business could review and approve. Direct precursor to LLM-based classification work.
ING Hubs Poland — AI Knowledge Sharing, 2021–2023
Ran internal workshops and presentations on AI and machine learning fundamentals for colleagues across teams — covering core concepts, practical limitations, and emerging capabilities. Topics ranged from ML basics and model evaluation to applied LLM topics as the technology matured. Focused on building shared understanding of what AI can and cannot reliably do in a regulated financial environment.

Resume Filter Kit — deep dive

ArcelorMittal Poland · PoC

Job hunting at scale has the same problem as enterprise search: most of the corpus is irrelevant noise. Sending every posting through a full LLM prompt costs tokens and time. The insight behind this project is to apply a cheap embedding pre-filter first — exactly the same pattern used in RAG retrieval — and only engage the model on the small fraction of offers that pass the similarity threshold.

CV (text)
Embed CV
Job postings
Embed offers
Cosine similarity
Threshold filter
Ranked shortlist
Streamlit dashboard

The pre-filter is intentionally model-agnostic and runs in milliseconds per offer — no API round-trip, no prompt, just vector arithmetic. This makes it practical to run against hundreds of scraped postings without meaningful cost. The Streamlit output layer shows each offer ranked by similarity score alongside a short gap summary, so the human reviewer immediately sees why an offer scored high or low, not just that it did.

Why embedding before LLM? A typical job search might surface 200 postings per week. Running all 200 through a GPT-4o prompt costs ~$2–4 and takes minutes. The embedding pre-filter cuts that to 20–40 genuinely relevant offers in under a second, then the LLM operates on a clean, relevant set. Cost drops by ~80%. This is the same economics that make RAG viable at enterprise scale — retrieval is cheap, generation is expensive.

Planned next layer — LLM-driven CV adaptation

roadmap

The embedding pre-filter is the foundation. The next layer will pass shortlisted offers and the current CV into an LLM prompt that identifies specific gaps (missing keywords, under-represented skills, tone mismatches) and generates targeted, per-offer suggestions for CV sections to rewrite. The output will be a ranked list of offers, each paired with a concrete, actionable edit brief — not generic advice, but diff-style suggestions tied to the specific language of that posting.

Shortlisted offers
LLM: gap analysis
Per-offer edit brief
CV section rewrites
Streamlit review UI
Embedding pre-filter Cosine similarity ranking text-embedding-3-small Semantic job matching Streamlit dashboard Token-cost optimisation Similarity threshold tuning Gap analysis (roadmap) CV diff generation (roadmap) Structured output (roadmap)

Full stack

everything I use
Azure OpenAI (GPT-4, GPT-4o) Anthropic Claude (Sonnet / Opus / Haiku) Mistral Large / Mixtral Ollama — Llama 3 / Mistral / Phi-3 / Gemma 2 LangChain LangGraph Prompt engineering Tool calling / function calling RAG architecture Embedding pre-filter (Resume Filter Kit) Cosine similarity ranking Pydantic (output validation) Chroma Pinecone Mistral Embed Phi-3 (via Ollama) Gemma 2 (via Ollama) Scikit-Learn TensorFlow / Keras PyTorch Pandas (data prep) Azure Blob Storage REST API integration Streamlit (output layer) Jenkins CI/CD Git

About the Author

Leave a Reply

Your email address will not be published. Required fields are marked *

You may also like these