Skip to main content

Enable IPFS model loading for Hugging Face Transformers

Project description

Transformers_IPFS

Load models directly from IPFS for Hugging Face Transformers.

Features

  • 🌐 Direct integration with local IPFS nodes (preferred method)
  • 🔄 Automatic fallback to IPFS gateways when local node isn't available
  • 🔍 Simple URI format: ipfs://CID for easy model sharing
  • ⚡ Zero configuration required - works automatically once installed
  • 🧩 Compatible with any version of Transformers

Installation

# Note: PyPI package names use hyphens
pip install transformers-ipfs
transformers-ipfs activate

Once installed and activated, the transformers_ipfs integration will be loaded automatically whenever you use Python.

Usage

Use the Transformers library with IPFS model URIs:

from transformers import AutoModel, AutoTokenizer

# Load a model directly from IPFS
tokenizer = AutoTokenizer.from_pretrained("ipfs://bafybeichqdarufyutqc7yd43k77fkxbmeuhhetbihd3g32ghcqvijp6fxi")
model = AutoModel.from_pretrained("ipfs://bafybeichqdarufyutqc7yd43k77fkxbmeuhhetbihd3g32ghcqvijp6fxi")

Google Colab Usage

In Google Colab, you need to manually apply the patch after importing:

# Import and manually apply patch
import transformers_ipfs
transformers_ipfs.activate()

# Verify patch is active
print(f"IPFS patch active: {transformers_ipfs.status()}")

Open In Colab

IPFS Node Connectivity

The transformers_ipfs package prioritizes connectivity in the following order:

  1. Local IPFS Node (Recommended): If you have an IPFS daemon running locally (ipfs daemon), the package will automatically detect and use it. This method:

    • Is much faster for repeated downloads
    • More reliably loads complex model directories with multiple files
    • Contributes to the IPFS network by providing content to others
  2. IPFS Gateway (Fallback): If a local node isn't available, the package will fall back to public gateways. This method:

    • Works without installing IPFS
    • May be less reliable for complex model directories
    • Downloads can be interrupted more easily

Command Line Interface

# Note: CLI commands use hyphens
# Activate the auto-loading
transformers-ipfs activate

# Check if the integration is active
transformers-ipfs status

# Test the integration
transformers-ipfs test

# Deactivate the integration
transformers-ipfs deactivate

Dependencies

  • Python 3.7+
  • transformers

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

transformers_ipfs-0.1.1.tar.gz (17.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

transformers_ipfs-0.1.1-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

Details for the file transformers_ipfs-0.1.1.tar.gz.

File metadata

  • Download URL: transformers_ipfs-0.1.1.tar.gz
  • Upload date:
  • Size: 17.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for transformers_ipfs-0.1.1.tar.gz
Algorithm Hash digest
SHA256 e6f8e8949eaa803194f8afd8a41922ccd553166f479bcaa1d32c6b45314d80f4
MD5 afb952aeefdb6c8b9a8ee1fce4aae4eb
BLAKE2b-256 d36185d4cba6117f39f557a60a44d01fa7a1a852bc04e2f45da520bb6845b54c

See more details on using hashes here.

Provenance

The following attestation bundles were made for transformers_ipfs-0.1.1.tar.gz:

Publisher: publish.yml on alexbakers/transformers_ipfs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file transformers_ipfs-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for transformers_ipfs-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d10a1d1ac4d3d4d20c2f012d2c3beca9365ad0dd67aa489dde6a73abc6916ded
MD5 11e37ce12edd091b94de4dc354edb0d5
BLAKE2b-256 0dbb09bb7a4928d56beea42f749498f658ef7402bfd5402910377075f3c2f82c

See more details on using hashes here.

Provenance

The following attestation bundles were made for transformers_ipfs-0.1.1-py3-none-any.whl:

Publisher: publish.yml on alexbakers/transformers_ipfs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page