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
torchis installed and compatible with your device (CPU/GPU). - For GPU acceleration, install CUDA-enabled PyTorch.
📜 License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
26794d4e59af0f85cb81979610ca1d9282d88dfe4dd765f5cbf46783b29e426e
|
|
| MD5 |
827078e91ebec43df9cab3c5c590a675
|
|
| BLAKE2b-256 |
bdb52cd39d70331cc1c29086481c81b7dbf46f0fcccdc8610ad8b716f5adf3dd
|
File details
Details for the file longformer_embedder-0.1.1-py3-none-any.whl.
File metadata
- Download URL: longformer_embedder-0.1.1-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5636735b4253faf0ebed0c8b7761bfc54126edad0a9a09fcd2dd8b670fc58521
|
|
| MD5 |
e0dba15a7ac453b3c0753b8cc152d82f
|
|
| BLAKE2b-256 |
956544a044a7633266c1ebc503759a4da43d9ef3aba63ec784cd7301a5b88a6e
|