File size: 1,362 Bytes
67b29cd
 
 
 
a33bbc9
375dbf3
67b29cd
 
 
375dbf3
1f4d4a1
67b29cd
a33bbc9
7ef344d
 
a33bbc9
 
 
 
 
 
 
 
 
 
 
581d6f2
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
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 now: ", model_path)

# Find the correct snapshot directory
# snapshots_dir = os.path.join(model_path, "snapshots") # snapshot
snapshots_dir = model_path
if os.path.exists(snapshots_dir):
    snapshot_folders = os.listdir(snapshots_dir)
    if snapshot_folders:
        snapshot_dir = os.path.join(snapshots_dir, snapshot_folders[0])  # Get first snapshot folder
        print(f"📂 Moving model files from {snapshot_dir} to {MODEL_CACHE_DIR}...")
        # Move files from snapshot directory to model cache directory
        for filename in os.listdir(snapshot_dir):
            shutil.move(os.path.join(snapshot_dir, filename), os.path.join(MODEL_CACHE_DIR, filename))
        print(f"✅ Model extracted to {MODEL_CACHE_DIR}")
    else:
        print("❌ No snapshot folder found!")
else:
    print("❌ No snapshots directory found!")

# Verify structure
print("\n📂 LLM Model Structure:")
for root, dirs, files in os.walk(MODEL_CACHE_DIR):
    print(f"📁 {root}/")
    for file in files:
        print(f"  📄 {file}")