Guest User

Untitled

a guest
Jan 5th, 2025
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. import os
  2. import subprocess
  3.  
  4. def quantize_model(model_path, gguf_types):
  5. convert_script = "../llama.cpp/convert_hf_to_gguf.py"
  6.  
  7. for gguf_type in gguf_types:
  8. output_file = f"{model_path}-{gguf_type.lower()}.gguf"
  9. outtype = gguf_type.lower()
  10.  
  11. command = [
  12. "python", convert_script,
  13. "--outfile", output_file,
  14. "--outtype", outtype,
  15. model_path,
  16. ]
  17.  
  18. print(f"Запуск квантизации: {command}")
  19.  
  20. try:
  21. subprocess.run(command, check=True)
  22. print(f"Успешно создан файл: {output_file}")
  23. except subprocess.CalledProcessError as e:
  24. print(f"Ошибка при выполнении квантизации для {gguf_type}: {e}")
  25.  
  26. if __name__ == "__main__":
  27. model_path = "distilbert/distilbert-base-uncased"
  28.  
  29. gguf_types = ["Q8_0", "Q6_K_L", "Q5_K_L"]
  30.  
  31. quantize_model(model_path, gguf_types)
Advertisement
Add Comment
Please, Sign In to add comment