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

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")
# Equivalent HuggingFace model: "riturajpandey739/gpt2-sentiment-analysis-tweets"
model = AutoModel.from_pretrained("ipfs://bafybeichqdarufyutqc7yd43k77fkxbmeuhhetbihd3g32ghcqvijp6fxi")

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

# 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.2.0.tar.gz (18.5 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.2.0-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: transformers_ipfs-0.2.0.tar.gz
  • Upload date:
  • Size: 18.5 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.2.0.tar.gz
Algorithm Hash digest
SHA256 d6f0f6f1d34a436f31efdd9f67b50d55aec26594a7be157ac3e34fc74e13daff
MD5 26b34f6bbc8b9e34b031bfcbe2da96f7
BLAKE2b-256 c3f3d7b911e37d764369e05ab80e8a0b610582685b9e1e1a97cb7a8c82084168

See more details on using hashes here.

Provenance

The following attestation bundles were made for transformers_ipfs-0.2.0.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.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for transformers_ipfs-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 11ee1aca49a6d227b3779efcc29dc39a48a7741a2c558758bf603edc9f27e365
MD5 76c82aba77e777f8bff09c3c834cff7c
BLAKE2b-256 c624a1ebb708b220466c071e77c5ad99e41aa786132b9afd1d5d1bcf8d0a9d1c

See more details on using hashes here.

Provenance

The following attestation bundles were made for transformers_ipfs-0.2.0-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