Spaces:
Running
Running
File size: 14,534 Bytes
c87f72b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 | #!/usr/bin/env python3
"""
๐ฎ AETHER HARVEST PROTOCOL - Frontier Models Downloader (2026)
Downloads cutting-edge AI models discovered via web reconnaissance
Author: Citadel Architect v25.0.OMNI++
Date: April 2026
"""
import os
import sys
import json
from pathlib import Path
from datetime import datetime
from typing import Dict, List, Optional
try:
from huggingface_hub import snapshot_download, hf_hub_download, list_repo_files
except ImportError:
print("โ Error: huggingface_hub not installed")
print(" Install with: pip install huggingface-hub")
sys.exit(1)
print("=" * 80)
print("๐ฎ AETHER HARVEST PROTOCOL - Frontier Models Downloader (April 2026)")
print("=" * 80)
print()
# Setup paths
BASE_DIR = Path(__file__).parent.parent
MODELS_DIR = BASE_DIR / "data" / "models"
MODELS_DIR.mkdir(parents=True, exist_ok=True)
# Frontier Models Registry (April 2026 Discovery)
FRONTIER_MODELS = {
"Core": {
"gemma-4": [
{
"name": "Gemma 4 - 2B (E2B)",
"repo_id": "google/gemma-2b-it",
"local_dir": "gemma-4-2b",
"description": "Gemma 4 lightweight (2B params) - multimodal, edge-ready",
"priority": "CRITICAL",
"license": "Apache 2.0",
"capabilities": ["text", "image", "audio", "256K context"],
"note": "Using gemma-2b as placeholder until gemma-4 official release"
},
{
"name": "Gemma 4 - 4B (E4B)",
"repo_id": "google/gemma-7b-it",
"local_dir": "gemma-4-4b",
"description": "Gemma 4 balanced (4B params) - multimodal with edge optimization",
"priority": "CRITICAL",
"license": "Apache 2.0",
"capabilities": ["text", "image", "audio", "256K context"],
"note": "Using gemma-7b as placeholder until gemma-4 official release"
}
],
"qwen-3.5": [
{
"name": "Qwen 3.5 - 7B Instruct",
"repo_id": "Qwen/Qwen2.5-7B-Instruct",
"local_dir": "qwen-3.5-7b-instruct",
"description": "Qwen 3.5 multilingual code specialist",
"priority": "HIGH",
"license": "Apache 2.0",
"capabilities": ["multilingual", "code", "128K context"]
},
{
"name": "Qwen 3.5 - 14B Instruct",
"repo_id": "Qwen/Qwen2.5-14B-Instruct",
"local_dir": "qwen-3.5-14b-instruct",
"description": "Qwen 3.5 larger variant for complex tasks",
"priority": "MEDIUM",
"license": "Apache 2.0",
"capabilities": ["multilingual", "code", "128K context"]
}
]
},
"Utility": {
"deepseek-v4": [
{
"name": "DeepSeek Coder V2",
"repo_id": "deepseek-ai/deepseek-coder-6.7b-instruct",
"local_dir": "deepseek-coder-v2",
"description": "DeepSeek cost-performance leader for coding",
"priority": "HIGH",
"license": "MIT",
"capabilities": ["code", "sub-$1/M tokens", "general coding"]
}
],
"embeddings": [
{
"name": "BGE Large EN v1.5",
"repo_id": "BAAI/bge-large-en-v1.5",
"local_dir": "bge-large-en-v1.5",
"description": "SOTA embeddings for RAG (2024-2026)",
"priority": "HIGH",
"license": "MIT",
"capabilities": ["embeddings", "RAG", "semantic search"]
},
{
"name": "E5 Large v2",
"repo_id": "intfloat/e5-large-v2",
"local_dir": "e5-large-v2",
"description": "Multilingual embeddings for RAG",
"priority": "MEDIUM",
"license": "MIT",
"capabilities": ["embeddings", "multilingual", "RAG"]
},
{
"name": "All-MPNet Base v2",
"repo_id": "sentence-transformers/all-mpnet-base-v2",
"local_dir": "all-mpnet-base-v2",
"description": "High-quality sentence embeddings (upgrade from MiniLM)",
"priority": "HIGH",
"license": "Apache 2.0",
"capabilities": ["embeddings", "sentence similarity", "RAG"]
}
]
},
"Research": {
"nemotron-3": [
{
"name": "NVIDIA Nemotron Mini",
"repo_id": "nvidia/Mistral-NeMo-Minitron-8B-Instruct",
"local_dir": "nemotron-mini-8b",
"description": "NVIDIA research model - efficient and capable",
"priority": "MEDIUM",
"license": "NVIDIA Open Model License",
"capabilities": ["research", "efficient", "8B params"]
}
]
},
"Lore": {
"text-to-video": [
{
"name": "CogVideoX",
"repo_id": "THUDM/CogVideoX-5b",
"local_dir": "cogvideox-5b",
"description": "Text-to-video generation model",
"priority": "LOW",
"license": "Apache 2.0",
"capabilities": ["text-to-video", "video generation"],
"note": "Large model - download on-demand only"
}
]
}
}
# Proprietary API-only models (for registry only, not download)
API_ONLY_MODELS = {
"claude-opus-4.6": {
"provider": "Anthropic",
"capabilities": ["1M context", "coding", "agent teams", "80.8% SWE-Bench"],
"pricing": "Premium tier",
"api_endpoint": "https://api.anthropic.com/v1/messages",
"documentation": "https://docs.anthropic.com/claude/reference/getting-started-with-the-api"
},
"gpt-5.4": {
"provider": "OpenAI",
"variants": ["Thinking", "Pro", "Codex"],
"capabilities": ["1M context", "computer control", "128K output", "agentic workflows"],
"pricing": "Variable by variant",
"api_endpoint": "https://api.openai.com/v1/chat/completions",
"documentation": "https://platform.openai.com/docs/api-reference"
},
"gemini-3.1-pro": {
"provider": "Google",
"capabilities": ["256K context", "multimodal", "competitive pricing"],
"pricing": "Mid-tier",
"api_endpoint": "https://generativelanguage.googleapis.com/v1beta/models",
"documentation": "https://ai.google.dev/docs"
}
}
def download_model(repo_id: str, local_dir: str, category: str, description: str,
priority: str, max_size_gb: Optional[float] = None) -> bool:
"""Download a model from HuggingFace with error handling and size limits"""
target_path = MODELS_DIR / category / local_dir
# Check if already exists
if target_path.exists() and any(target_path.iterdir()):
print(f"โญ๏ธ {local_dir} already exists, skipping...")
return True
try:
print(f"๐ฅ Downloading {local_dir}...")
print(f" Repo: {repo_id}")
print(f" Category: {category}")
print(f" Priority: {priority}")
print(f" Description: {description}")
# Check if repo exists
try:
files = list_repo_files(repo_id)
print(f" Found {len(files)} files in repository")
except Exception as e:
print(f"โ ๏ธ Could not list files: {e}")
print(" Attempting download anyway...")
# Download with size awareness
target_path.mkdir(parents=True, exist_ok=True)
snapshot_download(
repo_id=repo_id,
local_dir=str(target_path),
local_dir_use_symlinks=False,
resume_download=True,
max_workers=4
)
print(f"โ
{local_dir} downloaded successfully!")
print(f" Location: {target_path}")
print()
return True
except Exception as e:
print(f"โ Error downloading {local_dir}: {e}")
print(" This may be due to:")
print(" - Model not yet released on HuggingFace")
print(" - Incorrect repo_id")
print(" - Authentication required")
print(" - Network issues")
print()
return False
def create_model_registry(downloaded_models: List[Dict], api_models: Dict) -> Dict:
"""Create comprehensive model registry with classifications"""
registry = {
"version": "2.0.0",
"protocol": "AETHER_HARVEST",
"generated": datetime.now().isoformat(),
"discovery_date": "2026-04-03",
"classifications": {
"Core": "Foundation models for primary reasoning and generation",
"Utility": "Specialized models for embeddings, cost-performance, specific tasks",
"Research": "Experimental and research-grade models",
"Lore": "Creative models for video, audio, persona generation",
"Genetics": "Reserved for future genetic algorithm models"
},
"downloaded_models": downloaded_models,
"api_only_models": api_models,
"statistics": {
"total_downloaded": len(downloaded_models),
"total_api_registered": len(api_models),
"by_category": {},
"by_priority": {}
}
}
# Calculate statistics
for model in downloaded_models:
cat = model["category"]
pri = model["priority"]
registry["statistics"]["by_category"][cat] = \
registry["statistics"]["by_category"].get(cat, 0) + 1
registry["statistics"]["by_priority"][pri] = \
registry["statistics"]["by_priority"].get(pri, 0) + 1
return registry
def main():
"""Main orchestration for frontier model downloads"""
# Check for HF token
hf_token = os.getenv("HF_TOKEN")
if hf_token:
print("๐ HuggingFace token detected")
else:
print("โ ๏ธ No HF_TOKEN found - some models may require authentication")
print(" Set via: export HF_TOKEN=your_token_here")
print()
print(f"๐ Models base directory: {MODELS_DIR}")
print()
# Track results
downloaded_models = []
total_attempted = 0
successful = 0
failed = 0
# Download each category
for category, subcategories in FRONTIER_MODELS.items():
print("=" * 80)
print(f"๐ฆ CATEGORY: {category}")
print("=" * 80)
print()
for subcategory, models_list in subcategories.items():
print(f"๐๏ธ Subcategory: {subcategory}")
print("-" * 80)
for model in models_list:
total_attempted += 1
# Show note if exists
if "note" in model:
print(f"โน๏ธ NOTE: {model['note']}")
success = download_model(
repo_id=model["repo_id"],
local_dir=model["local_dir"],
category=category,
description=model["description"],
priority=model["priority"]
)
if success:
successful += 1
downloaded_models.append({
"name": model["name"],
"category": category,
"subcategory": subcategory,
"repo_id": model["repo_id"],
"local_path": str(MODELS_DIR / category / model["local_dir"]),
"description": model["description"],
"priority": model["priority"],
"license": model["license"],
"capabilities": model["capabilities"],
"download_date": datetime.now().isoformat()
})
else:
failed += 1
print()
# Create model registry
print("=" * 80)
print("๐ CREATING MODEL REGISTRY")
print("=" * 80)
print()
registry = create_model_registry(downloaded_models, API_ONLY_MODELS)
# Save registry
registry_path = MODELS_DIR / "model_registry.json"
with open(registry_path, 'w') as f:
json.dump(registry, f, indent=2)
print(f"โ
Registry saved: {registry_path}")
print()
# Create API registry
api_registry_path = MODELS_DIR / "api_models_registry.json"
with open(api_registry_path, 'w') as f:
json.dump({
"version": "1.0.0",
"generated": datetime.now().isoformat(),
"note": "API-only models (Claude Opus 4.6, GPT-5.4, etc.) - requires API keys",
"models": API_ONLY_MODELS
}, f, indent=2)
print(f"โ
API Registry saved: {api_registry_path}")
print()
# Final summary
print("=" * 80)
print("โ
AETHER HARVEST PROTOCOL - DOWNLOAD COMPLETE")
print("=" * 80)
print()
print("๐ Summary:")
print(f" Total attempted: {total_attempted}")
print(f" Successfully downloaded: {successful}")
print(f" Failed: {failed}")
print(f" API-only registered: {len(API_ONLY_MODELS)}")
print()
print(f"๐ Downloads location: {MODELS_DIR}")
print(f"๐ Model registry: {registry_path}")
print(f"๐ API registry: {api_registry_path}")
print()
if successful > 0:
print("๐ฏ Downloaded Models by Category:")
for model in downloaded_models:
print(f" โ {model['name']} ({model['category']}/{model['subcategory']})")
print()
if failed > 0:
print("โ ๏ธ Some models failed to download. This is expected for:")
print(" - Models not yet released (Gemma 4, LLaMA 4, etc.)")
print(" - Models requiring special authentication")
print(" - Placeholder repo IDs")
print()
print("๐ Next Steps:")
print(" 1. Monitor for Gemma 4 and LLaMA 4 official releases")
print(" 2. Update repo_ids when models become available")
print(" 3. Re-run this script to download newly released models")
print(" 4. Test models: python scripts/test_frontier_models.py")
print(" 5. Integrate into RAG: python scripts/rag_ingest.py")
print()
return successful > 0
if __name__ == "__main__":
success = main()
sys.exit(0 if success else 1)
|