neembed
Fine-tune pretrained sentence embedding models in non-Euclidean spaces with Geoopt.
Status: v0.1 is implemented and being prepared for its first public PyPI release. The API is intentionally small and may still evolve before a stable 1.0 release.
neembed is a lightweight integration layer between pretrained Sentence Transformer models and manifold-valued representations. It keeps the pretrained encoder intact, optionally projects its Euclidean output, and delegates Poincaré-ball geometry to Geoopt.
Pretrained Sentence Encoder
↓
Euclidean sentence embedding
↓
Projection head (optional)
↓
Tangent-space representation
↓
Geoopt manifold map
↓
Non-Euclidean embedding
Why non-Euclidean embeddings?
Hierarchical and tree-like relations can be awkward to represent in a flat Euclidean space. Hyperbolic spaces are a natural fit for rapidly expanding structures such as:
- taxonomies and concept hierarchies
- knowledge graphs
- hierarchical labels
- tree-like semantic relations
v0.1 deliberately focuses on one geometry: the Poincaré ball.
v0.1
The first release includes:
- Sentence Transformers as the pretrained encoder backend
- Poincaré-ball embeddings through Geoopt
- optional lower-dimensional tangent-space projection
- geodesic distance
- manifold-aware multiple-negatives ranking / InfoNCE-style loss
- ordinary
AdamWfine-tuning encode()anddistance()inference helperssave_pretrained()/from_pretrained()local persistence- numerical-stability tests, a runnable example, and a Euclidean baseline experiment
Detailed behavior, assumptions, and API signatures live in the documentation.
Installation
After v0.1.0 is published to PyPI:
pip install neembed-geoopt
The PyPI distribution is named neembed-geoopt; the Python import package remains neembed.
For development:
git clone https://github.com/t-yamsaki/neembed.git
cd neembed
pip install -e ".[dev]"
Quick start
from neembed import (
ManifoldSentenceTransformer,
ManifoldMultipleNegativesRankingLoss,
ManifoldTrainer,
)
model = ManifoldSentenceTransformer(
"sentence-transformers/all-MiniLM-L6-v2",
manifold="poincare",
embedding_dim=64,
curvature=1.0,
)
loss = ManifoldMultipleNegativesRankingLoss(
model=model,
temperature=0.1,
)
trainer = ManifoldTrainer(model=model, loss=loss)
train_batches = [
(["Shiba Inu", "Siamese cat"], ["dog", "cat"]),
(["dog", "cat"], ["mammal", "feline"]),
]
trainer.fit(train_batches, epochs=1)
embeddings = model.encode(["Shiba Inu", "dog", "mammal"])
distance = model.distance(embeddings[0], embeddings[1])
print(float(distance))
Each anchor is paired with the positive at the same batch index. Because off-diagonal candidates become in-batch negatives, avoid duplicate positives within one batch. See the Training guide for the objective and batching details.
Documentation
The full guide is hosted on Read the Docs:
Examples and validation
Run the end-to-end example:
python examples/train_poincare.py
- examples/train_poincare.py contains the workflow.
- experiments/README.md documents the fixed Euclidean-vs-Poincaré comparison experiment and its interpretation limits.
License
neembed is released under the MIT License. Third-party dependencies retain their own licenses.
Metadata
Release files for neembed-geoopt 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| neembed_geoopt-0.1.0.tar.gz | 16.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| neembed_geoopt-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 25.8 kB
Release files / neembed_geoopt-0.1.0.tar.gz
| Download URL | neembed_geoopt-0.1.0.tar.gz |
|---|---|
| Size | 16.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cc58e297f9ccbd565e67d83c6b92f9bd7e62ae3212a68d5e16e74258fe0d836c
|
|
BLAKE2b-256 checksum How to use checksums |
114757bd71e32f43855ba6e09783a6dd1692ea1ce107c89ac324088436d07a62
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 10, 2026.
Transparency logRelease files / neembed_geoopt-0.1.0-py3-none-any.whl
| Download URL | neembed_geoopt-0.1.0-py3-none-any.whl |
|---|---|
| Size | 9.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1068f90d8ff04b69d0a4cb806f6a5a650e90e06383439e48854e1d4d15afd88a
|
|
BLAKE2b-256 checksum How to use checksums |
ac919b9f8edbf9cdf55131b24f632e86b6b71ae35d61b41cff78099c3c4cc65f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 10, 2026.
Transparency log