Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Simple Python Script that converts the Weight of a GGUF Model to a PyTorch Tensor

License

NotificationsYou must be signed in to change notification settings

LuisMiSanVe/GGUF-to-PyTorchTensor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

See in spanish/Ver en español

💾 GGUF to PyTorch Tensor Script

PythonimagePyTorchNumPynVIDIA

This Script takes a GGUF model and extracts it's Weight then converts it to NumPy and PyTorch Tensor.

📋 Prerequisites

First of all, you'll need a GGUF Model.
You can get one atHuggingFace or use other programs asLM Studio to get a Model.

Then, make sure you havePython installed and clone the .py Script of the repository.

🛠️ Setup

You can setup the process in two ways:

  • Go to thellama.cpp repos and eitherbuild or download thecompiled.
    To build it, you'll needCMAKE, and in case you use a NVIDIA GPU and you want to use it, make sure you have theCUDA Toolkit installed too.Follow the build guide that fits the best for your system.
    Install the necessary dependencies with the following command in a CMD:
cd llama.cpppip install -r requirements.txt

Or if it fails or you're using a newer version of Python:

cd llama.cpppy -m pip install -r requirements.txt

Then, place the Script and the GGUF Model inllama.cpp\gguf-py\gguf so it takes thegguf library reference necessary for the process.

  • Just install these Python libraries in a CMD: torch, numpy, sentencepiece, pyyaml and gguf
pip install torch numpy sentencepiece pyyaml gguf

Or if it fails or you're using a newer version of Python:

py -m pip install torch numpy sentencepiece pyyaml gguf

Make sure the Script and the GGUF Model is in the same folder.

🚀 Project Usage Explanation

Run the Scriptgguftopytorch.py in the terminal using thepy orpython command in the CMD or in an IDE likeVisual Studio Code with thePython Extension to save GGUF Weigths to PyTorch Tensor.

📂 Files

If the Script runs succesfully, it will generate two files in the same folder:

  • llama-weight.npy: NumPy file with the GGUF LlaMA Model's Weight stored.
  • PyTorchTensor.pt: PyTorch Tensor file with the NumPy converted into a Tensor.

💻 Technologies Used

About

Simple Python Script that converts the Weight of a GGUF Model to a PyTorch Tensor

Topics

Resources

License

Stars

Watchers

Forks

Languages


[8]ページ先頭

©2009-2025 Movatter.jp