Import and Fine-Tune Private HuggingFace Models
Import and Fine-Tune Private HuggingFace Models
Use this tutorial to learn how to import a private HuggingFace model into NeMo Customizer, fine-tune it with LoRA, and deploy it for inference.
Prerequisites
New to using NeMo Platform?
All platform resources—models, datasets, and more—must belong to a workspace. Workspaces provide organizational and authorization boundaries for your work. Within a workspace, you can optionally use projects to group related resources.
If you’re new to the platform, start with the Setup guide to learn how to deploy and evaluate models, and optimize agents using the platform end-to-end.
If you’re already familiar with workspaces and how to upload datasets to the platform, you can proceed directly with this tutorial.
For more information, see Workspaces and Projects.
Tutorial-Specific Prerequisites
- Completed the Quickstart to install and deploy NeMo Platform locally.
- Installed the Python SDK and any tutorial packages you need in your environment.
- A HuggingFace token with access to the private or gated model repository.
- A HuggingFace model with a compatible architecture. This tutorial uses
google/gemma-2-2b-itas an example, but success depends on architectural compatibility. - Sufficient GPU memory for the model and LoRA training job.
This tutorial uses the current NeMo Platform SDK resources: client.files.filesets, client.models, client.customization.automodel.jobs, and client.inference.gateway.
Known Issues
Conv1D Model Architecture Limitation: Models that use Conv1D layers are not compatible with NeMo Customizer AutoModel LoRA.
Error signature: AttributeError: 'Conv1D' object has no attribute 'config'
Affected models include:
microsoft/DialoGPT-*seriesopenai-gptmodels- Some older
gpt2variants - Other models with Conv1D-based architectures
Root cause: These models use Conv1D layers that lack the linear layers expected by NeMo’s LoRA transformation utilities.
Solution: Use modern transformer architectures instead:
- Llama models (3.1, 3.2, 3.3 series)
- Nemotron models
- Phi models
- Gemma models (used in this tutorial)
For a complete list of tested models, see the Model Catalog.
Quick Start
1. Initialize the SDK
The SDK needs your NeMo Platform server URL. By default, this tutorial uses http://localhost:8080.
2. Store the HuggingFace Token
Private and gated HuggingFace repositories require a token. Store it as a NeMo Platform secret and reference that secret from the HuggingFace fileset.
3. Create a Model FileSet and Model Entity
Create a HuggingFace-backed fileset for the private model, then register a Model Entity that points to that fileset. Model files are downloaded by the platform when training or deployment needs them.
4. Prepare and Upload Training Data
Create chat-format JSONL files and upload them to a fileset. The file service, not a dataset-specific SDK resource, is the current entry point for training data.
5. Start a LoRA Customization Job
Submit a LoRA job to the Automodel backend. Reference the model and dataset filesets using workspace/name.
6. Track Training Progress
Poll job status until training reaches a terminal state.
7. Deploy the Base Model With LoRA Enabled
Create a deployment for the base model with LoRA support enabled. The LoRA adapter from training is served by the same deployment.
8. Test the Deployed Model
Call the inference gateway through the SDK. Use the base model name to test the original model and the output adapter name to test the LoRA-adapted model.
Python SDK
cURL
Next Steps
Learn how to check customization job metrics to monitor training progress and performance for your fine-tuned model.