File size: 728 Bytes
5d8396d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from transformers import GPT2LMHeadModel, GPT2Tokenizer
from huggingface_hub import HfApi, login

# Log in programmatically (Optional: If you didn’t use `huggingface-cli login`)
login(token="token")  # Replace with your actual token

# Load your fine-tuned model and tokenizer
model_path = "./gpt2_finetuned"
model = GPT2LMHeadModel.from_pretrained(model_path)
tokenizer = GPT2Tokenizer.from_pretrained(model_path)

# Define your Hugging Face model repository name
repo_id = "taiy0/Rae"  # Replace with your actual repo name

# Push model and tokenizer to Hugging Face
model.push_to_hub(repo_id)
tokenizer.push_to_hub(repo_id)

print(f"✅ Model uploaded to Hugging Face: https://huggingface.co/{repo_id}")