|
|
|
|
|
import os |
|
|
from huggingface_hub import hf_hub_download |
|
|
|
|
|
|
|
|
|
|
|
REPO_ID = "TheBloke/TinyLlama-1.1B-Chat-v1.0-GGUF" |
|
|
|
|
|
FILENAME = "tinyllama-1.1b-chat-v1.0.Q4_K_M.gguf" |
|
|
|
|
|
|
|
|
SAVE_DIRECTORY = os.path.join(os.path.dirname(__file__), '..', 'llm_model') |
|
|
|
|
|
def download_language_model(): |
|
|
""" |
|
|
Downloads the specified GGUF language model from Hugging Face. |
|
|
""" |
|
|
print(f"--- Starting download for Language Model: {FILENAME} ---") |
|
|
|
|
|
|
|
|
file_path = os.path.join(SAVE_DIRECTORY, FILENAME) |
|
|
|
|
|
|
|
|
if os.path.exists(file_path): |
|
|
print(f"✅ Model '{FILENAME}' already exists at: {SAVE_DIRECTORY}") |
|
|
print("Skipping download.") |
|
|
return |
|
|
|
|
|
|
|
|
os.makedirs(SAVE_DIRECTORY, exist_ok=True) |
|
|
|
|
|
print(f"Downloading model to: {SAVE_DIRECTORY}") |
|
|
print("This may take a moment (approx 700-800MB)...") |
|
|
|
|
|
try: |
|
|
|
|
|
hf_hub_download( |
|
|
repo_id=REPO_ID, |
|
|
filename=FILENAME, |
|
|
local_dir=SAVE_DIRECTORY, |
|
|
local_dir_use_symlinks=False |
|
|
) |
|
|
|
|
|
print("\n" + "="*50) |
|
|
print(f"✅ Language Model '{FILENAME}' downloaded successfully!") |
|
|
print("="*50 + "\n") |
|
|
|
|
|
except Exception as e: |
|
|
print(f"🚨 An error occurred during download: {e}") |
|
|
|
|
|
if __name__ == "__main__": |
|
|
download_language_model() |