huggingface.js  by huggingface

JS utils for Hugging Face Hub API interaction

created 2 years ago
2,185 stars

Top 21.1% on sourcepulse

GitHubView on GitHub
Project Summary

This collection of TypeScript libraries provides programmatic access to the Hugging Face Hub API, enabling developers to interact with models, repositories, and inference services. It targets web developers, Node.js users, and researchers looking to integrate Hugging Face's extensive ML ecosystem into their applications. The libraries offer a unified interface for tasks like model inference, repository management, and agent-based interactions.

How It Works

The libraries leverage modern JavaScript features and ES modules, targeting Node.js >= 18, Bun, and Deno, as well as modern browsers. They abstract the complexities of the Hugging Face Hub API, providing type-safe interfaces for various functionalities. Key packages include @huggingface/inference for accessing serverless inference providers and dedicated endpoints, @huggingface/hub for Git-like repository operations, and @huggingface/agents for natural language interaction with models.

Quick Start & Requirements

  • Installation: npm install @huggingface/inference @huggingface/hub @huggingface/agents
  • Prerequisites: Node.js >= 18, Bun, or Deno. An Hugging Face access token is required for most operations.
  • CDN Usage: Available via ES modules for vanilla JS projects.
  • Docs: https://huggingface.co/docs/huggingface.js/

Highlighted Details

  • Supports a wide range of Inference Providers (Together, Fal.ai, Replicate, Cohere, etc.) and dedicated Inference Endpoints.
  • Includes utilities for GGUF and DDUF formats, Jinja templating for chat, and Ollama compatibility.
  • Offers a HfAgent for generating and executing code based on natural language prompts.
  • Provides streaming capabilities for inference tasks.

Maintenance & Community

The project is actively maintained by Hugging Face. Community interaction is encouraged via opening issues.

Licensing & Compatibility

The libraries are distributed under a permissive license, allowing for commercial use and integration into closed-source projects.

Limitations & Caveats

The libraries are described as "very young" and may have evolving APIs. They rely on modern JavaScript features, limiting compatibility with older environments.

Health Check
Last commit

16 hours ago

Responsiveness

1 day

Pull Requests (30d)
67
Issues (30d)
10
Star History
571 stars in the last 90 days

Explore Similar Projects

Feedback? Help us improve.