|
|
"""
|
|
|
Upload Nursing LLM Model to Hugging Face
|
|
|
Run this script from wherever your trained model is saved (Colab, local machine, etc.)
|
|
|
"""
|
|
|
|
|
|
from huggingface_hub import HfApi, login, create_repo
|
|
|
import os
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MODEL_NAME = "NurseCitizenDeveloper/nursing-llama-3-8b-fons"
|
|
|
LOCAL_MODEL_PATH = "./nursing-llama-3-8b-fons"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print("π Logging in to Hugging Face...")
|
|
|
login()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print(f"\nπ Checking for model files in: {LOCAL_MODEL_PATH}")
|
|
|
|
|
|
required_files = [
|
|
|
"config.json",
|
|
|
"tokenizer_config.json",
|
|
|
"tokenizer.json",
|
|
|
"special_tokens_map.json"
|
|
|
]
|
|
|
|
|
|
|
|
|
weight_files = [
|
|
|
"pytorch_model.bin",
|
|
|
"model.safetensors",
|
|
|
"adapter_model.safetensors",
|
|
|
"adapter_config.json"
|
|
|
]
|
|
|
|
|
|
missing_files = []
|
|
|
for file in required_files:
|
|
|
if not os.path.exists(os.path.join(LOCAL_MODEL_PATH, file)):
|
|
|
missing_files.append(file)
|
|
|
|
|
|
has_weights = any(os.path.exists(os.path.join(LOCAL_MODEL_PATH, f)) for f in weight_files)
|
|
|
|
|
|
if missing_files:
|
|
|
print(f"β οΈ Missing required files: {missing_files}")
|
|
|
if not has_weights:
|
|
|
print(f"β No model weight files found! Need one of: {weight_files}")
|
|
|
print("\nπ‘ If you trained with LoRA, make sure adapter files are present.")
|
|
|
exit(1)
|
|
|
|
|
|
print("β
Model files verified!")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print(f"\nπ Uploading model to {MODEL_NAME}...")
|
|
|
|
|
|
api = HfApi()
|
|
|
|
|
|
|
|
|
try:
|
|
|
create_repo(MODEL_NAME, exist_ok=True, repo_type="model")
|
|
|
print(f"β
Repository ready: https://huggingface.co/{MODEL_NAME}")
|
|
|
except Exception as e:
|
|
|
print(f"βΉοΈ Repository already exists or error: {e}")
|
|
|
|
|
|
|
|
|
print("\nπ€ Uploading files...")
|
|
|
api.upload_folder(
|
|
|
folder_path=LOCAL_MODEL_PATH,
|
|
|
repo_id=MODEL_NAME,
|
|
|
repo_type="model",
|
|
|
commit_message="Upload trained nursing LLM model"
|
|
|
)
|
|
|
|
|
|
print(f"\nβ
Upload complete!")
|
|
|
print(f"π Model URL: https://huggingface.co/{MODEL_NAME}")
|
|
|
print(f"π Space URL: https://huggingface.co/spaces/NurseCitizenDeveloper/relational-ai-nursing")
|
|
|
print("\nβ³ The Space should automatically restart and work now!")
|
|
|
|