new-dim / UPLOAD_GUIDE.md
splendidcomputer's picture
Upload folder using huggingface_hub
fa9878d verified

Hugging Face Upload Guide

Prerequisites

  1. Hugging Face Account: Create an account at https://huggingface.co
  2. Git LFS: Install Git Large File Storage for handling large model files
    git lfs install
    
  3. Hugging Face CLI: Install the Hugging Face CLI
    pip install huggingface_hub[cli]
    

Step 1: Create a New Model Repository

  1. Go to https://huggingface.co/new
  2. Choose "Model" as the repository type
  3. Name your repository (e.g., llama3-dementia-care)
  4. Set it to Public or Private as desired
  5. 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)

  1. Run the export script:

    ./export_model.sh
    
  2. Use a conversion tool like ollama-export or similar to convert your Ollama model to PyTorch format

  3. Common 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

  1. Download the base Llama 3 8B model from Hugging Face
  2. Add your fine-tuning weights/adapters
  3. Upload the complete model

Option C: Re-create the Model

  1. Start with the official Llama 3 8B model
  2. Fine-tune it using your dementia care dataset
  3. 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

  1. Go to your model page on Hugging Face
  2. Edit the README.md if needed
  3. Add any additional information about training data, evaluation metrics, etc.
  4. 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.bin or model.safetensors (converted model weights)
  • ⚠️ tokenizer.model or tokenizer.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:

  1. Large file errors: Make sure Git LFS is properly configured
  2. Token errors: Use huggingface-cli login to authenticate
  3. Model loading errors: Ensure all config files are correct
  4. Inference issues: Test the model locally before uploading

Getting Help:

Important Notes

  1. License Compliance: Ensure your model respects the Llama 3 Community License
  2. Attribution: Always include "Built with Meta Llama 3" as required
  3. Medical Disclaimers: Include appropriate disclaimers for medical/health content
  4. 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! 🚀