Distributed Training: Train BART/T5 for Summarization using 🤗 Transformers and Amazon SageMaker
BART-large-CNN can be fine-tuned for dialogue summarization on the SAMSum dataset with distributed data-parallel training on Amazon SageMaker, using the Hugging Face estimator and the Transformers Deep Learning Containers. Enabling smdistributed data parallelism takes one `distribution` parameter, and the job reuses the stock run_summarization.py example script pulled from Git. On 2 ml.p3dn.24xlarge instances (16 GPUs, total batch size 64), three epochs take about 24 minutes and cost roughly $28, reaching validation ROUGE-1 of about 42.6. The walkthrough ends by downloading the model from S3, generating a model card with metrics, and pushing it to the Hugging Face Hub for hosted inference.
Related posts
- The Partnership: Amazon SageMaker and Hugging Face
Hugging Face mediumAdeptHugging Face and AWS partner, making AWS Hugging Face's preferred cloud and introducing Hugging Face Deep Learning Containers plus a HuggingFace Estimator in the SageMaker Python SDK for training Transformers models. An end-to-end walkthrough fine-tunes DistilBERT on IMDB binary sentiment classification: setting up a SageMaker session and IAM role, writing a Trainer-based train.py that reads SageMaker environment variables, tokenizing and uploading datasets to S3, and launching a training job with estimator.fit(). The containers also support SageMaker's data-parallel and model-parallel distributed training libraries through a distribution parameter, along with automatic hyperparameter tuning.
- Deploy Hugging Face models easily with Amazon SageMaker
Hugging Face mediumAdeptHugging Face Inference Deep Learning Containers and the SageMaker Hugging Face Inference Toolkit let Transformers models be deployed as SageMaker endpoints with a few lines of Python, using transformers pipelines for zero-code pre- and post-processing. Models can be deployed straight after a SageMaker training job via the Estimator, from a model.tar.gz in S3 via HuggingFaceModel's model_data, or directly from the Model Hub by setting the HF_MODEL_ID and HF_TASK environment variables. Requests use an `inputs` key plus optional pipeline `parameters`, and custom inference code can override the defaults when needed.
- Introducing the Hugging Face LLM Inference Container for Amazon SageMaker
Hugging Face mediumAdeptHugging Face's LLM Inference Deep Learning Container for Amazon SageMaker is built on Text Generation Inference (TGI), which provides tensor parallelism, continuous batching, flash-attention, bitsandbytes quantization, safetensors loading and SSE token streaming. The walkthrough deploys the 12B Pythia Open Assistant model on an ml.g5.12xlarge instance (4 A10G GPUs) using the sagemaker Python SDK, with environment variables for GPU count and token limits. It then covers TGI generation parameters such as temperature, top_p, stop sequences and repetition penalty, and builds a Gradio chatbot on top of the endpoint. For a cheaper setup, a g5.2xlarge with int8 quantization is suggested.
- How to deploy and fine-tune DeepSeek models on AWS
Hugging Face mediumAdeptDeepSeek-R1's distilled Llama and Qwen models can be deployed on AWS through Hugging Face Inference Endpoints, Bedrock Marketplace, SageMaker with Hugging Face LLM DLCs (TGI v3) on GPUs or Neuron, and EC2 Inferentia via the Hugging Face Neuron AMI. The guide includes SageMaker Python SDK code and a recommended instance table (e.g. ml.g6.48xlarge with 8 GPUs for the 70B distill), plus Neuron settings such as 24 cores, bf16, batch size 4 and 4096 total tokens using pre-compiled models. The full R1 runs on Inference Endpoints as an Unsloth GGUF quantization for about $8.3/hour, while full-R1 SageMaker deployment and all fine-tuning paths are still marked as coming soon.
- Productizing Large Language Models
Replit mediumAdeptReplit runs transformer models from ~100M parameters (search, spam) through 1-10B (GhostWriter code autocomplete) to 100B+ in production, and shares lessons on making them usable. Nonsense and repetition loops are handled with temperature and frequency penalty tuning, cycle detection, multi-temperature sampling, reranking with a second model, and fine-tuning on user feedback. Quality is tracked with HumanEval, loop and nonsense rates, and A/B tests. Inference cost is cut with FasterTransformer, distillation and quantization, and GPUs are run at 70-80% utilization on Kubernetes so request queues stay bounded while autoscaling has headroom.