char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
5a6bc6b1a
char/aliceai-t5-moe
1#!/usr/bin/env python3 2 3from huggingface_hub import HfApi 4import argparse 5 6# This script requires that the environment variable HF_TOKEN is set with your 7# Hugging Face API token. 8api = HfApi () 9 10def load_template_and_substitute (template_path ,** kwargs ): 11try : 12with open (template_path ,'r' ,encoding = 'utf-8' )as f : 13template_content = f .read () 14 15return template_content .format (** kwargs ) 16except FileNotFoundError : 17f"Template file ' { template_path } ' not found!" ) 18return None 19except KeyError as e : 20f"Missing template variable: { e } " ) 21return None 22 23parser = argparse .ArgumentParser (description = 'Create a new Hugging Face model repository' ) 24parser .add_argument ('--model-name' ,'-m' ,help = 'Name for the model' ,required = True ) 25parser .add_argument ('--namespace' ,'-ns' ,help = 'Namespace to add the model to' ,required = True ) 26parser .add_argument ('--org-base-model' ,'-b' ,help = 'Original Base model name' ,default = "" ) 27parser .add_argument ('--no-card' ,action = 'store_true' ,help = 'Skip creating model card' ) 28parser .add_argument ('--private' ,'-p' ,action = 'store_true' ,help = 'Create private model' ) 29parser .add_argument ('--embedding' ,'-e' ,action = 'store_true' ,help = 'Use embedding model card template' ) 30parser .add_argument ('--dry-run' ,'-d' ,action = 'store_true' ,help = 'Print repository info and template without creating repository' ) 31 32args = parser .parse_args () 33 34repo_id = f" { args . namespace } / { args . model_name } -GGUF" 35"Repository ID: " ,repo_id ) 36 37repo_url = None 38if not args .dry_run : 39repo_url = api .create_repo ( 40repo_id = repo_id , 41repo_type = "model" , 42private = args .private , 43exist_ok = False 44 ) 45 46if not args .no_card : 47if args .embedding : 48template_path = "scripts/embedding/modelcard.template" 49else : 50template_path = "scripts/causal/modelcard.template" 51 52"Template path: " ,template_path ) 53 54model_card_content = load_template_and_substitute ( 55template_path , 56model_name = args .model_name , 57namespace = args .namespace , 58base_model = args .org_base_model , 59 ) 60 61if args .dry_run : 62"\nTemplate Content:\n" ) 63model_card_content ) 64else : 65if model_card_content : 66api .upload_file ( 67path_or_fileobj = model_card_content .encode ('utf-8' ), 68path_in_repo = "README.md" , 69repo_id = repo_id 70 ) 71"Model card created successfully." ) 72else : 73"Failed to create model card." ) 74 75if not args .dry_run and repo_url : 76f"Repository created: { repo_url } " ) 77 78