This library is a C++ port of the Hugging Face Hub that provides an implementation of hf_hub_download for C++. It enables seamless downloading of models and other assets from the Hugging Face Hub while maintaining full compatibility with its Python counterpart.
With this library, C++ developers can integrate Hugging Face model downloads directly into their applications, ensuring efficient and reliable access to AI resources without requiring Python dependencies.
Before installing, ensure you have the following dependencies installed:
- CMake (Minimum version recommended: 3.x)
- libcurl (Required for handling downloads)
On Debian-based systems, you can install libcurl using:
sudo apt-get install libcurl4-openssl-dev
To build the project, follow these steps:
git clone https://github.com/agonzc34/huggingface-hub-cpp
mkdir build
cd build
cmake ..
make
To use this library in your C++ project, include the necessary headers and call hf_hub_download
.
#include "huggingface_hub.h"
int main() {
std::string repo_id = "<huggingface-repo>";
std::string filename = "<file-to-download>";
if (huggingface_hub::hf_hub_download(repo_id, filename).success) {
std::cout << "Model downloaded!" << std::endl;
} else {
std::cout << "Error" << std::endl;
}
A demo application is included to showcase the library in action. To build and run the demo:
./build/hfhub_demo
This will execute a sample download for the qwen2.5-0.5b-instruct-q2_k.gguf model
This project is licensed under the MIT License. See the LICENSE file for more details.