# Tutorials

> **📝 Note**
>
> An LLM-optimized bundle of this entire section is available at [`section.md`](https://www.union.ai/docs/v2/union/tutorials/section.md).
> This single file contains all pages in this section, optimized for AI coding agent context.

This section contains tutorials that showcase relevant use cases and provide step-by-step instructions on how to implement various features using Flyte and Union.

### [Automatic prompt engineering](https://www.union.ai/docs/v2/union/tutorials/auto_prompt_engineering/page.md)

Easily run prompt optimization with real-time observability, traceability, and automatic recovery.

### [GPU-accelerated climate modeling](https://www.union.ai/docs/v2/union/tutorials/climate-modeling/page.md)

Run ensemble atmospheric simulations on H200 GPUs with multi-source data ingestion and real-time extreme event detection.

### [Run LLM-generated code](https://www.union.ai/docs/v2/union/tutorials/code-agent/page.md)

Securely execute and iterate on LLM-generated code using a code agent with error reflection and retry logic.

### [Deep research](https://www.union.ai/docs/v2/union/tutorials/deep-research/page.md)

Build an agentic workflow for deep research with multi-step reasoning and evaluation.

### [Distributed LLM pretraining](https://www.union.ai/docs/v2/union/tutorials/distributed-pretraining/page.md)

Pretrain large language models at scale with PyTorch Lightning, FSDP, and H200 GPUs, featuring streaming data and real-time metrics.

### [Fine-tuning a VLM with a frozen backbone](https://www.union.ai/docs/v2/union/tutorials/qwen-vl-finetuning/page.md)

Adapt Qwen2.5-VL to occluded image classification by training a 10K-parameter adapter with multi-node DeepSpeed, automatic recovery, and live training dashboards.

### [Hyperparameter optimization](https://www.union.ai/docs/v2/union/tutorials/hpo/page.md)

Run large-scale HPO experiments with zero manual tracking, deterministic results, and automatic recovery.

### [Multi-agent trading simulation](https://www.union.ai/docs/v2/union/tutorials/trading-agents/page.md)

A multi-agent trading simulation, modeling how agents within a firm might interact, strategize, and make trades collaboratively.

### [Text-to-SQL](https://www.union.ai/docs/v2/union/tutorials/text_to_sql/page.md)

Learn how to turn natural language questions into SQL queries with Flyte and LlamaIndex, and explore prompt optimization in practice.

## Subpages

- [Distributed LLM pretraining](https://www.union.ai/docs/v2/union/tutorials/distributed-pretraining/page.md)
  - Overview
  - Implementation
  - Setting up the environment
  - Declaring resource requirements
  - Model configurations
  - Building the GPT model
  - The Lightning training module
  - Checkpointing for fault tolerance
  - Real-time metrics with Flyte Reports
  - Streaming data at scale
  - Distributed training with FSDP
  - Tying it together
  - Running the pipeline
  - Going further
- [Fine-tuning a vision-language model with a frozen backbone](https://www.union.ai/docs/v2/union/tutorials/qwen-vl-finetuning/page.md)
  - Overview
  - Implementation
  - Setting up the environment
  - Preparing the dataset
  - The adapter
  - Multi-node training with DeepSpeed
  - Fault tolerance and recovery
  - Live observability
  - Evaluation
  - Putting it all together
  - Running the tutorial
  - Going further
- [GPU-accelerated climate modeling](https://www.union.ai/docs/v2/union/tutorials/climate-modeling/page.md)
  - Overview
  - Implementation
  - Dependencies and container image
  - Simulation parameters and data structures
  - Task environments
  - Data ingestion: multiple sources in parallel
  - Preprocessing with Dask
  - GPU-accelerated atmospheric simulation
  - Distributing across multiple GPUs
  - The main workflow
  - Running the pipeline
  - Key concepts
  - Ensemble forecasting
  - Adaptive mesh refinement
  - Real-time event detection
  - Where to go next
- [Multi-agent trading simulation](https://www.union.ai/docs/v2/union/tutorials/trading-agents/page.md)
  - TL;DR
  - What is an agent, anyway?
  - What's different here?
  - How it works: step-by-step walkthrough
  - Entry point
  - Analyst agents
  - Research agents
  - Trading agent
  - Risk agents
  - Retaining agent memory with S3 vectors
  - Running the simulation
  - Why Flyte? _(A quick note before you go)_
- [Run LLM-generated code](https://www.union.ai/docs/v2/union/tutorials/code-agent/page.md)
  - What this example demonstrates
  - Setting up the agent environment
  - Retrieve docs
  - Code generation
  - Running the code agent
- [Text-to-SQL](https://www.union.ai/docs/v2/union/tutorials/text_to_sql/page.md)
  - Ingesting data
  - From question to SQL
  - Vector indexing
  - Table retrieval and context building
  - SQL generation and response synthesis
  - Building the QA dataset
  - Schema extraction and chunking
  - Question and SQL generation
  - Validation and quality control
  - Optimizing prompts
  - Evaluation pipeline
  - Iterative optimization
  - Run it
  - What we observed
  - The bigger lesson
- [Automatic prompt engineering](https://www.union.ai/docs/v2/union/tutorials/auto_prompt_engineering/page.md)
  - Set up the environment
  - Prepare the evaluation dataset
  - Define models
  - Evaluate prompts
  - Optimize prompts
  - Build the full pipeline
  - Run it
  - Why this matters
  - Next steps
- [Batching strategies](https://www.union.ai/docs/v2/union/tutorials/micro-batching/page.md)
  - Use Case
  - Goals
  - Solution Architecture
  - 1. Failure transparency with @flyte.trace
  - 2. Reusable Containers for Efficiency
  - Key Benefits:
  - Architecture Flow:
  - Architecture Diagram
  - Implementation
  - Step 0: Set up the runtime
  - Step 1: Initialize Flyte Configuration
  - Step 2: Define Container Image
  - Step 3: Define Task Environments
  - Step 4: Define External Service Interactions
  - Step 5: Implement the Batch Processing Task
  - Step 6: Implement the Orchestrator Workflow
  - Step 7: Execute the Workflow
  - Batch Size Selection
  - Summary
- [Deep research](https://www.union.ai/docs/v2/union/tutorials/deep-research/page.md)
  - Setting up the environment
  - Generate research queries
  - Search and summarize
  - Evaluate research completeness
  - Filter results
  - Generate the final answer
  - Orchestration
  - Run the deep research agent
  - Evaluate with Weights & Biases Weave
- [Hyperparameter optimization](https://www.union.ai/docs/v2/union/tutorials/hpo/page.md)
  - A better way to run HPO
  - Declare dependencies
  - Define the task environment
  - Define the optimizer
  - Define the objective function
  - Define the main optimization loop
  - Run the experiment

---
**Source**: https://github.com/unionai/unionai-docs/blob/main/content/tutorials/_index.md
**HTML**: https://www.union.ai/docs/v2/union/tutorials/
