Hugging Face Upload Guide
Prerequisites
- Hugging Face Account: Create an account at https://huggingface.co
- Git LFS: Install Git Large File Storage for handling large model files
git lfs install - Hugging Face CLI: Install the Hugging Face CLI
pip install huggingface_hub[cli]
Step 1: Create a New Model Repository
- Go to https://huggingface.co/new
- Choose "Model" as the repository type
- Name your repository (e.g.,
llama3-dementia-care) - Set it to Public or Private as desired
- Click "Create Repository"
Step 2: Clone Your Repository
git clone https://huggingface.co/your-username/llama3-dementia-care
cd llama3-dementia-care
Step 3: Copy Repository Files
Copy all the files from this directory to your cloned Hugging Face repository:
# From your LLAMA3_DEMENTIA_SHARE directory
cp README.md /path/to/your-username/llama3-dementia-care/
cp config.json /path/to/your-username/llama3-dementia-care/
cp tokenizer_config.json /path/to/your-username/llama3-dementia-care/
cp special_tokens_map.json /path/to/your-username/llama3-dementia-care/
cp Modelfile /path/to/your-username/llama3-dementia-care/
cp model_info.json /path/to/your-username/llama3-dementia-care/
cp usage_example.py /path/to/your-username/llama3-dementia-care/
cp requirements.txt /path/to/your-username/llama3-dementia-care/
cp NOTICE /path/to/your-username/llama3-dementia-care/
cp .gitignore /path/to/your-username/llama3-dementia-care/
Step 4: Add Model Weights (Critical Step)
This is the most complex part. You have several options:
Option A: Convert Ollama Model (Recommended)
Run the export script:
./export_model.shUse a conversion tool like
ollama-exportor similar to convert your Ollama model to PyTorch formatCommon conversion commands:
# Example conversion (may vary based on tool) ollama export llama3-dementia-care:latest model.gguf # Then convert GGUF to PyTorch format using appropriate tools
Option B: Use Base Model + Fine-tuning Weights
- Download the base Llama 3 8B model from Hugging Face
- Add your fine-tuning weights/adapters
- Upload the complete model
Option C: Re-create the Model
- Start with the official Llama 3 8B model
- Fine-tune it using your dementia care dataset
- Upload the fine-tuned result
Step 5: Set up Git LFS for Large Files
cd your-username/llama3-dementia-care
git lfs track "*.bin"
git lfs track "*.safetensors"
git lfs track "*.gguf"
git add .gitattributes
Step 6: Commit and Push
git add .
git commit -m "Add Llama 3 Dementia Care Assistant model"
git push
Step 7: Update Model Card
- Go to your model page on Hugging Face
- Edit the README.md if needed
- Add any additional information about training data, evaluation metrics, etc.
- Test the inference widget with sample prompts
Sample Model Files You Need
For a complete Hugging Face model, you typically need:
- ✅
README.md(with YAML frontmatter) - ✅
config.json - ✅
tokenizer_config.json - ✅
special_tokens_map.json - ⚠️
pytorch_model.binormodel.safetensors(converted model weights) - ⚠️
tokenizer.modelortokenizer.json(if needed) - ✅ Optional:
generation_config.json,training_args.bin
Testing Your Model
After upload, test your model:
from transformers import AutoTokenizer, AutoModelForCausalLM
model_name = "your-username/llama3-dementia-care"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name)
# Test with a dementia care question
prompt = "What are some strategies for managing sundown syndrome?"
# ... rest of inference code
Troubleshooting
Common Issues:
- Large file errors: Make sure Git LFS is properly configured
- Token errors: Use
huggingface-cli loginto authenticate - Model loading errors: Ensure all config files are correct
- Inference issues: Test the model locally before uploading
Getting Help:
- Hugging Face Documentation: https://huggingface.co/docs
- Community Forum: https://discuss.huggingface.co
- Discord: https://discord.gg/huggingface
Important Notes
- License Compliance: Ensure your model respects the Llama 3 Community License
- Attribution: Always include "Built with Meta Llama 3" as required
- Medical Disclaimers: Include appropriate disclaimers for medical/health content
- Model Safety: Test thoroughly before public release
Final Checklist
- Repository created on Hugging Face
- All configuration files uploaded
- Model weights converted and uploaded
- README.md is complete and accurate
- License information is included
- Model card is comprehensive
- Inference widget works
- Example usage is provided
- Appropriate disclaimers are included
Good luck with your model upload! 🚀