added script to help download the model
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Lädt das Qwen2.5-0.5B-Instruct Modell (GGUF) herunter.
|
||||
Klein, schnell, gut für Deutsch geeignet.
|
||||
|
||||
Aufruf:
|
||||
python download_model.py
|
||||
"""
|
||||
|
||||
import urllib.request
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
SCRIPT_DIR = Path(__file__).parent
|
||||
MODELS_DIR = SCRIPT_DIR / "models"
|
||||
|
||||
MODEL_URL = "https://huggingface.co/Qwen/Qwen2.5-0.5B-Instruct-GGUF/resolve/main/qwen2.5-0.5b-instruct-q4_k_m.gguf"
|
||||
MODEL_FILE = MODELS_DIR / "qwen2.5-0.5b-instruct-q4_k_m.gguf"
|
||||
MODEL_SIZE = "~400 MB"
|
||||
|
||||
def download_with_progress(url: str, dest: Path):
|
||||
"""Lädt eine Datei herunter mit Fortschrittsanzeige."""
|
||||
dest.parent.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
def progress(block_num, block_size, total_size):
|
||||
downloaded = block_num * block_size
|
||||
if total_size > 0:
|
||||
pct = min(downloaded / total_size * 100, 100)
|
||||
mb_done = downloaded / 1024 / 1024
|
||||
mb_total = total_size / 1024 / 1024
|
||||
bar = "█" * int(pct // 2) + "░" * (50 - int(pct // 2))
|
||||
print(f"\r [{bar}] {pct:5.1f}% {mb_done:.1f}/{mb_total:.1f} MB", end="", flush=True)
|
||||
|
||||
print(f"Lade herunter: {url}")
|
||||
print(f"Ziel: {dest}")
|
||||
print(f"Größe: ca. {MODEL_SIZE}\n")
|
||||
|
||||
urllib.request.urlretrieve(url, dest, reporthook=progress)
|
||||
print(f"\n\n✅ Modell erfolgreich gespeichert: {dest}")
|
||||
|
||||
def main():
|
||||
if MODEL_FILE.exists():
|
||||
size_mb = MODEL_FILE.stat().st_size / 1024 / 1024
|
||||
print(f"✅ Modell bereits vorhanden: {MODEL_FILE} ({size_mb:.1f} MB)")
|
||||
return
|
||||
|
||||
print("=" * 60)
|
||||
print(" Qwen2.5-0.5B-Instruct Download")
|
||||
print("=" * 60)
|
||||
print(f" Modell: Qwen2.5-0.5B-Instruct Q4_K_M (quantisiert)")
|
||||
print(f" Größe: {MODEL_SIZE}")
|
||||
print(f" Quelle: Hugging Face")
|
||||
print("=" * 60)
|
||||
|
||||
try:
|
||||
download_with_progress(MODEL_URL, MODEL_FILE)
|
||||
except KeyboardInterrupt:
|
||||
print("\n\n[Abgebrochen] Download unterbrochen.")
|
||||
if MODEL_FILE.exists():
|
||||
MODEL_FILE.unlink() # Unvollständige Datei löschen
|
||||
sys.exit(1)
|
||||
except Exception as e:
|
||||
print(f"\n\n❌ Fehler beim Download: {e}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user