Spaces:
Running
Running
File size: 1,272 Bytes
67b29cd a33bbc9 375dbf3 67b29cd 375dbf3 67b29cd ad9ea09 3227486 ad9ea09 3227486 ad9ea09 7ae5fac 3227486 7ae5fac 3227486 7ae5fac 3227486 ad9ea09 581d6f2 3227486 a077f52 a33bbc9 3227486 e22b331 a33bbc9 |
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 |
import os
import shutil
from huggingface_hub import snapshot_download
# Set up paths
MODEL_REPO = "sentence-transformers/all-MiniLM-L6-v2"
MODEL_CACHE_DIR = "/app/model_cache"
print("⏳ Downloading the SentenceTransformer model...")
model_path = snapshot_download(repo_id=MODEL_REPO, cache_dir=MODEL_CACHE_DIR)
print("Model path: ", model_path)
# Ensure the directory exists
if not os.path.exists(MODEL_CACHE_DIR):
os.makedirs(MODEL_CACHE_DIR)
# Move all contents from the snapshot folder
if os.path.exists(model_path):
print(f"📂 Moving model files from {model_path} to {MODEL_CACHE_DIR}...")
for item in os.listdir(model_path):
source = os.path.join(model_path, item)
destination = os.path.join(MODEL_CACHE_DIR, item)
if os.path.isdir(source):
shutil.copytree(source, destination, dirs_exist_ok=True)
else:
shutil.copy2(source, destination)
print(f"✅ Model extracted and flattened in {MODEL_CACHE_DIR}")
else:
print("❌ No snapshot directory found!")
exit(1)
# Verify structure after moving
print("\n📂 LLM Model Structure (Build Level):")
for root, dirs, files in os.walk(MODEL_CACHE_DIR):
print(f"📁 {root}/")
for file in files:
print(f" 📄 {file}")
|