Skip to content

aws-samples/sample-slm-agentic-workshop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Building a Multi-Agent System with Fine-Tuned SLMs on Amazon SageMaker and Strands

A hands-on workshop demonstrating how to fine-tune Ministral 8B for specialized tasks, deploy models efficiently using LoRA adapters on Amazon SageMaker, and build intelligent multi-agent systems with Strands for automated data analysis and visualization.

Workshop Overview

This workshop guides you through the end-to-end lifecycle of AI systems from model fine-tuning to deployment and orchestration. You'll work with product sales data to create a multi-agent system that can understand natural language queries, generate SQL, and produce visualizations automatically.

Duration: 2-3 hours

Platform: Workshop Studio (all resources provided)

What You'll Build

  • Fine-tuned SLM Models: Two specialized Ministral 8B models using LoRA (Low-Rank Adaptation)
    • Text-to-SQL model for database querying
    • Text-to-Python model for Matplotlib visualization generation
  • Efficient Deployment: Single base model endpoint with 2 LoRA adapters on Amazon SageMaker
  • Multi-Agent System: Strands-powered orchestration that converts natural language to insights

Architecture

Architecture Diagram

Prerequisites

All resources are provisioned through Workshop Studio, including:

  • AWS Account with appropriate permissions
  • Amazon SageMaker Studio environment
  • Pre-configured IAM roles
  • Product sales dataset with schema

Key Technologies

  • Ministral 8B: Base small language model
  • LoRA (Low-Rank Adaptation): Efficient fine-tuning technique
  • Amazon SageMaker: Model training and deployment platform
  • Strands: Multi-agent orchestration framework
  • SQL & Python/Matplotlib: Target output formats

Workshop Labs

Lab 1: Fine-Tuning Ministral 8B with LoRA

Fine-tune two LoRA adapters for specialized tasks:

  • 1-NL2SQL.ipynb — Fine-tune for Text-to-SQL generation
  • 2-NL2Py.ipynb — Fine-tune for Text-to-Python/Matplotlib generation

Lab 2: Deploying and Benchmarking Models

Deploy both adapters on a single SageMaker endpoint and evaluate performance:

  • 1-deploy-and-benchmark.ipynb — Deploy with vLLM, attach LoRA adapters, benchmark against Bedrock LLMs

Lab 3: Building Multi-Agent Systems with Strands

Create an intelligent orchestration layer that combines your models:

  • 1-multi-agent-setup.ipynb — Build and test the complete multi-agent system

Key Concepts Covered:

  • Strands @tool decorator for creating agent tools
  • Agents-as-tools pattern: Wrapping specialized agents as tools for a supervisor
  • Multi-agent orchestration with Claude Haiku 4.5 as the reasoning layer
  • SageMaker inference components for serving multiple LoRA adapters

Architecture:

Agent Model Role
Supervisor Claude Haiku 4.5 (Bedrock) Orchestrates workflow, executes SQL, manages data flow
SQL Agent NL2SQL (fine-tuned SLM) Converts natural language → SQL queries
Python Agent NL2Py (fine-tuned SLM) Generates Matplotlib visualization code

Repository Structure

slm-agentic-workshop/
├── lab1/                              # Fine-tuning LoRA adapters
│   ├── 1-NL2SQL.ipynb
│   ├── 2-NL2Py.ipynb
│   └── scripts/
│       ├── train.py
│       └── requirements.txt
├── lab2/                              # Deployment + benchmarking
│   └── 1-deploy-and-benchmark.ipynb
├── lab3/                              # Multi-agent system
│   └── 1-multi-agent-setup.ipynb
├── assets/                            # Datasets and diagrams
│   ├── cosmetics_sales_synthetic_data.csv
│   ├── training_samples_120.csv
│   ├── training_dataset_matplotlib_30_v2.csv
│   ├── benchmark_samples.csv
│   ├── sample_product_sales.csv
│   └── agent-slm.png
├── requirements.txt                   # Shared dependencies
└── README.md

Important

This is sample code, for non-production usage. You should work with your security and legal teams to meet your organizational security, regulatory and compliance requirements before deployment.

Security

See CONTRIBUTING for more information.

License

This library is licensed under the MIT-0 License. See the LICENSE file.

About

A hands-on workshop demonstrating how to fine-tune Ministral 8B for specialized tasks, deploy models efficiently using LoRA adapters on Amazon SageMaker, and build intelligent multi-agent systems with Strands for automated data analysis and visualization.

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors