Skip to main content

HF to GGUF Converter

A Python package for converting Hugging Face models to GGUF files. This tool simplifies the process of transforming models for compatibility with the GGUF format, streamlining model conversion tasks.

Features

  • Convert models from Hugging Face to GGUF format
  • Easy-to-use command-line interface
  • Supports various output types
  • Integrates with Ollama for model creation and execution

Installation

You should have ollama installed in your system: https://ollama.com/

You can install the package from PyPI using pip:

pip install model2gguf

Usage

After installing the package, you can use the model2gguf command to convert models.

Basic Command

To convert a model, use the following command:

model2gguf convert --model_id "huggingface/model-id" --output_file "output_file.gguf"

Command Options

  • --model_id: The Hugging Face model ID (e.g., "microsoft/Phi-3-mini-128k-instruct").
  • --output_file: The desired output file name for the GGUF file.
  • --outtype: The type of output (e.g., q8_0).
  • --local_dir: (Optional) The directory to download the model to, or the directory of the pre-downloaded model. If not specified, defaults to the current directory under the folder named : hf_model

Example

Convert the "distilgpt2" model and save the output as distilgpt2.gguf:

model2gguf --model_id "distilgpt2" --output_file "distilgpt2.gguf"

Specify a folder for downloading the model:

model2gguf --model_id "distilgpt2" --output_file "distilgpt2.gguf" --local_dir "models"

Use a pre-downloaded model from a specific folder:

model2gguf --model_id "path/to/pre-downloaded/model" --output_file "distilgpt2.gguf" 

Ollama Integration

  1. Create an Ollama Model:
model2gguf create_ollama --model_name "model-name" --modelfile_path "modelfile.txt"

This command creates an Ollama model using the GGUF file. The modelfile.txt should contain the path to your GGUF model file.

model2gguf run_ollama --model_name "model-name"
nvidia-smi -L

this command is to switch the usage of the model on top of a graphic card

set CUDA_VISIBLE_DEVICES=GPU-{YOURE UUID}

This uuid comes up when you run the previous command just paste the alphanumerical value next to the gpu- uuid

Contributing

Contributions are welcome! If you'd like to contribute to this project, please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature-branch)
  3. Commit your changes (git commit -am 'Add new feature')
  4. Push to the branch (git push origin feature-branch)
  5. Open a Pull Request Please ensure your code adheres to the existing style and includes tests where applicable.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Authors

Rahul Patnaik (rpatnaik2005@gmail.com) Krishna Dvaipayan (krishnadb.ei21@rvce.edu.in)

Acknowledgments

  • Special thanks to Georgi Gerganov the creator of llama.cpp.
  • Special thanks to ollama for support us run the models locally.
  • Inspired by various open-source projects and tools.

Metadata

Release files for model2gguf 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for model2gguf 1.0.0
File Size Uploaded Provenance
model2gguf-1.0.0.tar.gz 4.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for model2gguf 1.0.0
File Interpreter ABI Platform
model2gguf-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 9.3 kB

Release files / model2gguf-1.0.0.tar.gz

Download URL model2gguf-1.0.0.tar.gz
Size 4.4 kB
Tags Source
SHA-256 checksum
How to use checksums
ed32b7a0e95e0cd7aae380cb506bc2d6596eb9f55ce11a7f8be8138493de19ad
BLAKE2b-256 checksum
How to use checksums
549c7b2dee585446d962e7ec5723913dcddb6732784550055b1c298be9948127
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.4

Release files / model2gguf-1.0.0-py3-none-any.whl

Download URL model2gguf-1.0.0-py3-none-any.whl
Size 4.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c4790576fac1f74edbf0a3377ea357b137d1f141383a68efe05f14208da8a640
BLAKE2b-256 checksum
How to use checksums
236c71c096139ebdce171c4d48d27a2b726cfd17032eaeee3d3002450e493dcd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.4

Security for model2gguf 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page