ConceptFrameMet / HUGGINGFACE_UPLOAD_GUIDE.md
nixie1981's picture
Upload folder using huggingface_hub
1b12abd verified

Hugging Face Upload Guide for ConceptFrameMet

This guide will help you upload your ConceptFrameMet model to the Hugging Face Hub.

Prerequisites

  1. Hugging Face Account: Create an account at huggingface.co
  2. Install Hugging Face CLI:
    pip install huggingface_hub
    

Step 1: Login to Hugging Face

huggingface-cli login

Enter your Hugging Face token when prompted. You can create a token at: https://huggingface.co/settings/tokens

Step 2: Create a New Model Repository

Option A: Via Web Interface (Recommended)

  1. Go to https://huggingface.co/new
  2. Choose a repository name: ConceptFrameMet
  3. Select visibility (Public or Private)
  4. Click "Create model"

Option B: Via CLI

huggingface-cli repo create ConceptFrameMet --type model

Step 3: Prepare Your Model Files

Your ConceptFrameMet directory should contain:

ConceptFrameMet/
β”œβ”€β”€ pytorch_model.bin          # Main model weights (1.5GB)
β”œβ”€β”€ config.json                # Model configuration
β”œβ”€β”€ vocab.json                 # Tokenizer vocabulary
β”œβ”€β”€ merges.txt                 # BPE merges
β”œβ”€β”€ README.md                  # Model card
β”œβ”€β”€ requirements.txt           # Dependencies
β”œβ”€β”€ modeling_conceptframemet.py # Custom model class
β”œβ”€β”€ inference.py               # Inference script
└── HUGGINGFACE_UPLOAD_GUIDE.md # This file

Step 4: Upload Files to Hugging Face

Method 1: Using Git LFS (Recommended for Large Files)

cd /data/gpfs/projects/punim0478/otmakhovay/ConceptFrameMet

# Clone your model repository
git clone https://huggingface.co/YOUR_USERNAME/ConceptFrameMet
cd ConceptFrameMet

# Install Git LFS if not already installed
git lfs install

# Track large files
git lfs track "*.bin"
git lfs track "pytorch_model.bin"

# Copy all files
cp ../pytorch_model.bin .
cp ../config.json .
cp ../vocab.json .
cp ../merges.txt .
cp ../README.md .
cp ../requirements.txt .
cp ../modeling_conceptframemet.py .
cp ../inference.py .

# Add, commit, and push
git add .
git commit -m "Upload ConceptFrameMet model with frame and source prediction"
git push

Method 2: Using Hugging Face Hub Python API

from huggingface_hub import HfApi, create_repo

# Initialize API
api = HfApi()

# Create repository (if not done via web)
create_repo("ConceptFrameMet", exist_ok=True)

# Upload files
api.upload_folder(
    folder_path="/data/gpfs/projects/punim0478/otmakhovay/ConceptFrameMet",
    repo_id="YOUR_USERNAME/ConceptFrameMet",
    repo_type="model",
)

Method 3: Manual Upload via Web Interface

  1. Go to your model page: https://huggingface.co/YOUR_USERNAME/ConceptFrameMet
  2. Click "Files" tab
  3. Click "Add file" β†’ "Upload files"
  4. Drag and drop or select files
  5. Click "Commit changes"

Note: For large files (>100MB), use Git LFS or the Python API.

Step 5: Create Model Card (README.md)

The README.md is already created with model information. You can enhance it with:

  • Training metrics
  • Example outputs
  • Your contact information
  • License information

Step 6: Test Your Model

After uploading, test that others can use your model:

from transformers import AutoTokenizer, AutoModel

# Load model
model_name = "YOUR_USERNAME/ConceptFrameMet"
tokenizer = AutoTokenizer.from_pretrained(model_name)

print(f"βœ“ Model successfully loaded from Hugging Face Hub!")

Step 7: Add Model Tags and Metadata

Edit your model card to include:

---
language:
- en
tags:
- metaphor-detection
- semantic-frames
- source-domains
- nlp
- text-classification
license: mit  # or your license
datasets:
- vua
metrics:
- f1
- accuracy
widget:
- text: "The company is navigating through troubled waters"
  example_title: "Metaphor Example"
---

Troubleshooting

Large File Issues

If pytorch_model.bin is too large:

# Make sure Git LFS is tracking it
git lfs track "pytorch_model.bin"
git add .gitattributes
git add pytorch_model.bin
git commit -m "Add model weights with LFS"
git push

Authentication Issues

# Re-login
huggingface-cli logout
huggingface-cli login

Upload Timeout

For very large files, use the Python API with chunks:

from huggingface_hub import HfApi

api = HfApi()
api.upload_file(
    path_or_fileobj="/path/to/pytorch_model.bin",
    path_in_repo="pytorch_model.bin",
    repo_id="YOUR_USERNAME/ConceptFrameMet",
    repo_type="model",
)

Model Usage After Upload

Users can then use your model like this:

from transformers import RobertaTokenizer

model_name = "YOUR_USERNAME/ConceptFrameMet"
tokenizer = RobertaTokenizer.from_pretrained(model_name)

# Your inference code here

Additional Features

Add Model to a Collection

Create collections on Hugging Face to organize related models.

Enable Spaces Demo

Create a Gradio or Streamlit demo in Hugging Face Spaces to showcase your model.

Add DOI

Get a DOI for your model through Hugging Face for academic citations.

Resources

Next Steps

  1. Upload your model following the steps above
  2. Test that it loads correctly
  3. Share your model with the community!
  4. Consider creating a Space demo for interactive use

Your Model: ConceptFrameMet
Model Type: Metaphor Detection with Frame & Source Prediction
Base Model: RoBERTa-base
Size: ~1.5GB