Skip to content

agonzc34/huggingface-hub-cpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

huggingface-hub-cpp

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.

GitHub License GitHub release Code Size Last Commit GitHub issues GitHub pull requests Contributors Build Doxygen Deployment

Table of Contents

Installation

Prerequisites

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

Build

To build the project, follow these steps:

git clone https://github.com/agonzc34/huggingface-hub-cpp
mkdir build
cd build
cmake ..
make

Usage

Integrating the library

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;
  }

Running the demo app

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

License

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