BlogsModalFine-tuning Generative Models

Fine-tuning Generative Models

Fine-tuning Generative Models

7
posts
2023–2024

Modal now supports fine-tuning generative models on custom datasets, enabling users to prepare datasets, set up containerized environments with necessary dependencies, utilize cloud storage for model weights, and configure training hyperparameters. The process includes training scripts, hyperparameter configuration, and serving the fine-tuned model via a web UI. Ramp has utilized Modal to accelerate the development of their text-to-structured-JSON model for receipt management, driving down receipt processing costs. This post details the process of fine-tuning LLMs, including cost benefits, common use cases, and steps for preparing datasets and training models, with a focus on using Modal for infrastructure.

2024

What is LLM fine-tuning?

12/10/2024

This post provides a comprehensive overview of LLM fine-tuning, explaining its benefits (cost, performance, customization) and common use cases. It details the steps involved, from choosing a base model and preparing datasets (including prompt engineering and special tokens) to the training process itself. The post highlights Modal as a configurable platform for running fine-tuning code, emphasizing its ability to provide on-demand GPUs and simplify infrastructure management. It also mentions Modal's existing tutorial for LLM fine-tuning.

Create an infinite icon library by fine-tuning Stable Diffusion

5/21/2024

This post details the technical process of fine-tuning a Stable Diffusion model on a custom dataset (Heroicons) to generate new icons. It covers dataset preparation (SVG to PNG conversion, captioning, CSV creation, HuggingFace upload), setting up a Modal environment with Diffusers dependencies, using Modal Volumes for persistent storage of model weights, and configuring training hyperparameters. It also outlines the steps for serving the fine-tuned model and wrapping it in a Gradio UI.

Why Substack moved their AI and ML pipelines to Modal

5/20/2024

This post details Substack's migration of their AI and ML pipelines from AWS SageMaker to Modal. It highlights the challenges faced with SageMaker, such as convoluted developer experience, difficulties in code collaboration, and slow container startup times. The post then describes how Substack leveraged Modal's features, including its natural iteration flow, autoscaling capabilities, and native storage primitives (network volumes and key-value stores), to build a faster and more flexible ML workflow. This includes a full fine-tune -> validation -> deployment process, enabling rapid development and deployment of recommendation models and other ML applications.

Beating proprietary models with a quick fine-tune

4/26/2024

This post details the process of fine-tuning embedding models to achieve better accuracy and lower cost than proprietary alternatives. It covers the 'why' of fine-tuning, including the data flywheel concept and the benefits of open-source models. It then delves into the 'how,' discussing dataset selection (using the Quora duplicates dataset as an example), choosing a base model, and acquiring training infrastructure. A key contribution is the description of running a grid search over hyperparameters (base model, dataset size, embedding dimensions) to optimize the fine-tuning process, leveraging Modal's autoscaling GPU capabilities for efficient experimentation.

How Ramp automated receipt processing with fine-tuned LLMs

3/26/2024

This post details how Ramp used Modal to fine-tune LLMs for receipt processing. They implemented a custom experimentation framework by setting up Modal functions to train multiple models in parallel, persist weights to Modal volumes, and serve inference endpoints. This approach allowed them to evaluate different model designs efficiently and achieve a 34% reduction in manual receipt intervention. The post also highlights the use of Modal for accelerating LLM batch processing, demonstrating a significant speedup and cost reduction for a PII stripping task.

Embedding English Wikipedia in under 15 minutes

1/23/2024

This post details the implementation of a distributed GPU job on Modal to generate text embeddings for the entire English Wikipedia corpus. It covers setting up a Modal app with custom images for Hugging Face's Text Embedding Inference server, utilizing Modal Volumes for dataset persistence, and managing container lifecycles with Modal classes. The solution leverages concurrent requests to the inference server and dynamic batching to achieve efficient embedding generation, reducing the time from hours to under 15 minutes and costing under $15.

2023

How to fine-tune an LLM on Modal

12/20/2023

This post provides a step-by-step tutorial on fine-tuning a Large Language Model (LLM) on Modal. It details the process of preparing a dataset, setting up the Modal environment with necessary dependencies (e.g., PyTorch, Transformers), writing a training script that utilizes Modal's distributed compute capabilities, and configuring hyperparameters. The post also covers how to upload model weights to cloud storage and deploy the fine-tuned model as a Modal Function for inference. It highlights the use of Modal's GPU support and efficient resource management for LLM training.