Skip to main content

A small wrapper for generating Longformer embeddings.

Project description

Longformer Embedder

A lightweight wrapper around Hugging Face Longformer to easily generate mean-pooled embeddings.

Installation

pip install longformer-embedder

Usage

from longformer_embedder import LongformerEmbedder

embedder = LongformerEmbedder(model_name="allenai/longformer-base-4096")
vec = embedder.get_embedding("This is a test sentence.")
print(vec.shape)  # (768,)

Batch Mode

texts = ["Text one", "Text two", "Text three"]
embeddings = embedder.generate_embeddings(texts)
print(embeddings.shape)  # (3, 768)

Notes

  • Model weights are downloaded from Hugging Face automatically.
  • Ensure torch is installed and compatible with your device (CPU/GPU).
  • For GPU acceleration, install CUDA-enabled PyTorch.

📜 License

MIT License

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

longformer_embedder-0.1.1.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

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

longformer_embedder-0.1.1-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: longformer_embedder-0.1.1.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for longformer_embedder-0.1.1.tar.gz
Algorithm Hash digest
SHA256 26794d4e59af0f85cb81979610ca1d9282d88dfe4dd765f5cbf46783b29e426e
MD5 827078e91ebec43df9cab3c5c590a675
BLAKE2b-256 bdb52cd39d70331cc1c29086481c81b7dbf46f0fcccdc8610ad8b716f5adf3dd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for longformer_embedder-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5636735b4253faf0ebed0c8b7761bfc54126edad0a9a09fcd2dd8b670fc58521
MD5 e0dba15a7ac453b3c0753b8cc152d82f
BLAKE2b-256 956544a044a7633266c1ebc503759a4da43d9ef3aba63ec784cd7301a5b88a6e

See more details on using hashes here.

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