← Back
AWS ML Blog

Deploy decision models with llama.cpp on Amazon SageMaker AI

•11 min read•
#llm#amazon
Level:Intermediate
For:AI Engineers
✦TL;DR

** This article shows how to serve quantized decision models with llama.cpp on Amazon SageMaker AI using the AWS Deep Learning Container (DLC). The standard path exposes an OpenAI‑compatible /v1/chat/completions endpoint, while a custom child image swaps in the SemIf adapter to return option‑level probabilities instead of generated text. Engineers can package a .gguf model as model.tar.gz in S3, launch the DLC (CPU or GPU), and optionally build the SemIf image with CodeBuild and push it to ECR for low‑latency structured‑decision inference. **KeyTakeaways:** - The DLC maps POST /invocations to llama‑server at /v1/chat/completions and reads SM_LLAMA_CPP_* environment variables for llama.cpp arguments. - The SemIf child image replaces the default entry point with a SageMaker‑compatible adapter that returns option_ids, probabilities, and raw option_logits.

⚡ Key Takeaways

  • The DLC maps POST /invocations to llama‑server at /v1/chat/completions and reads SM_LLAMA_CPP_* environment variables for llama.cpp arguments.
  • The SemIf child image replaces the default entry point with a SageMaker‑compatible adapter that returns option_ids, probabilities, and raw option_logits.
  • Structured‑decision inference avoids prose parsing, enabling thresholding and policy checks directly on stable option IDs.
  • Build the child image with AWS CodeBuild and store it in Amazon ECR to keep the compiled CPU or CUDA libraries while swapping the server binary.
  • The endpoint accepts two schemas: the OpenAI Chat Completions JSON for text generation and a custom decision JSON (id, state, question, options) for probability scoring.
💡 Why It Matters

** By leveraging the llama.cpp DLC and a lightweight SemIf adapter, teams can deploy CPU‑ or GPU‑accelerated decision models at scale on SageMaker with minimal latency and without building a full inference stack, accelerating production of rule‑based routing or policy‑selection services. **TechnicalLevel:** Advanced **TargetAudience:** ML Engineers, AI Ops **PracticalSteps:** - Package your…

✅ Practical Steps

  1. Package your quantized .gguf model as model.tar.gz in Amazon S3 and reference the published AWS DLC for llama.cpp image when creating the SageMaker model.
  2. Set the required SM_LLAMA_CPP_* environment variables in the SageMaker endpoint configuration to pass arguments to llama.cpp.
  3. Use AWS CodeBuild to build a SemIf child image that replaces the DLC entry point, push the image to Amazon ECR, and deploy it as a SageMaker endpoint for structured‑decision inference.

Want the full story? Read the original article.

Read on AWS ML Blog ↗

More like this

After 10 Heads in a Row, Small LLMs Bet Up to 82% on an 11th

Towards Data Science•#llm

Serving Scikit-LLM Pipelines as REST APIs with FastAPI

Machine Learning Mastery•#deployment

Hugging Face and OpenRouter join forces to make open-weight models easy to run

Hugging Face Blog•#inference

Understanding Positional Embeddings in Modern LLMs

Ahead of AI•#llm

EXPLORE AI NEWS

Daily hand-picked stories on LLMs, RAG, agents and production AI — curated for engineers who ship.

BROWSE NEWS

GET THE WEEKLY DIGEST

Join engineers getting the Monday signal-over-noise AI breakdown. No spam, unsubscribe anytime.

LEARN AI ENGINEERING

Curated courses, research papers, repos and tutorials built for engineers leveling up in AI.

START LEARNING