ENGINEERING NOTEBOOK / REPRESENTATION LEARNING / 04

Hyperbolic Embeddings.

Meaning has layers ↘

From broad intent to fine meaning, represented in Poincaré space.

A research implementation of hierarchical text representations using a frozen Transformer encoder, learnable token-attention pooling, an iterative HRM-style refinement module, and a radial schedule that maps different semantic levels into the Poincaré ball. Retrieval uses hyperbolic distance, with a cosine baseline for comparison.

Research code · evaluation framework Source-grounded technical notes
FIG 04 · SYSTEM SKETCH
11supported MTEB tasksSupported in evaluation runner; not a published averaged score
4default hierarchy segments
5retrieval metricsHits@K, Recall@K, NDCG, MRR, MAP
01
WHY THIS EXISTS

The problem, and the approach.

CHALLENGE

What needed solving?

A single flat embedding must compress topical category and fine-grained meaning into the same geometry. This project investigates whether successive levels of refinement can represent semantic specificity explicitly, rather than treating every text item as one undifferentiated point.

DIRECTION

What was built?

Encode token states with a frozen backbone, learn their pooled representation, refine across several segments, normalize and radially scale segment vectors, then exponential-map them into the Poincaré ball. Train across levels using contrastive hyperbolic NCE and compare retrieval against a backbone-only cosine baseline.

TECHNICAL TOOLKIT
PythonPyTorchTransformersBGE / BERTPoincaré geometryContrastive NCEMTEBHyperbolic distance
02
SYSTEM DESIGN

Architecture, without the noise.

This is a simplified conceptual diagram of the components documented in the repository; it is not a claim that all operations use a single synchronous pipeline.

FIG. 04 / SYSTEM FLOW
01 / STAGEFrozen Transformer

Token hidden states from BGE/BERT.

02 / STAGEToken attention pool

Trainable attention weights aggregate token features.

03 / STAGEHRM refinement

Low-level and high-level recurrent updates over M segments.

04 / STAGEPoincaré mapping

Normalize vectors, apply segment radius, exp-map to hyperbolic ball.

05 / STAGETraining and retrieval

Hyperbolic NCE + distance-based ranking versus cosine baseline.

Source: https://github.com/cRED-f/Hierarchical-Reasoning-Embedding-Model-with-Hyperbolic-Setup · Architecture summarized from repository implementation and documentation.
03
RUNBOOK

How it works, step by step.

  1. 01

    Encode text

    Run a frozen Transformer backbone; token-level hidden states become the input to the trainable pooling layer.

    models/hrm_encoder.py
  2. 02

    Pool important tokens

    A ScoreNet attention pooler learns a weighted representation rather than using a fixed token choice.

    models/hrm_encoder.py
  3. 03

    Refine coarse to fine

    Alternating low-level and high-level MLP updates produce multiple segment-level tangent vectors.

    models/hrm_encoder.py
  4. 04

    Map into curved space

    Normalize and scale each tangent vector according to the radial schedule, then apply expmap0_poincare.

    models/poincare_utils.py
  5. 05

    Train and evaluate

    Use coarse-to-fine hyperbolic NCE, retrieve by Poincaré distance and compare rankings to a cosine baseline.

    scripts/evaluate.py
04
ENGINEERING THINKING

The choices behind the system.

NOTE 01

Freeze the backbone

Train refinement layers and pooling while retaining a reusable pretrained Transformer representation.

NOTE 02

Encode hierarchy by radius

Later segments receive progressively larger radial scales, so geometry represents granularity by construction.

NOTE 03

Keep a fair comparison path

The evaluator supports backbone-only cosine retrieval, avoiding a comparison solely against another custom hyperbolic method.

05
TECHNICAL DETAILS

Inside the implementation.

Geometric design

01

Multi-level embeddings

Each text yields multiple points, one per refinement segment, rather than a single pooled embedding.

02

Hyperbolic geometry

The Poincaré ball uses negative curvature and distance functions implemented in models/poincare_utils.py.

03

Coarse-to-fine contrastive learning

Training optimizes a hyperbolic NCE objective with explicit negatives across segments.

04

Evaluation settings

The runner lists 11 retrieval tasks and Hits@K, Recall@K, NDCG@K, MRR@K and MAP@K.

README COMMANDBash · training invocation

Training configuration

A documented example from the README; actual optimization requires datasets, compute and the repository environment.

python scripts/train.py \
  --backbone_name BAAI/bge-small-en-v1.5 \
  --epochs 1 \
  --batch_size 128 \
  --num_segments 4 \
  --num_negs 4 \
  --temperature 0.05 \
  --hyp_c 1.0
SOURCE REFERENCE / README.md · Quick Start
06
MEASURED EVIDENCE

Results in context.

Breadth of evaluation support

The repository documents an evaluator supporting 11 MTEB retrieval datasets, including FEVER, SciFact, NFCorpus, DBPedia, HotpotQA, Natural Questions, SCIDOCS, FiQA, CQADupstack, ClimateFEVER and Arguana. It does not publish a reproducible summary table proving improvement on all 11 tasks. The page therefore reports evaluation coverage, not benchmark superiority.

Numbers here are reported by the project author in the linked public repository or CV. They are not independent tests performed for this portfolio.

07
ENGINEERING HONESTY

Trade-offs & open questions.

01

Supported does not mean won

Eleven supported tasks are a statement of implementation breadth, not a reported 11-task average or positive gain.

02

More computation

Multiple refinement segments and hyperbolic distance computations add training and serving complexity.

03

Geometry is a hypothesis

The radial schedule imposes a hierarchy prior that should be tested per corpus against normalized cosine embeddings.

08
READ THE CODE

Source directory.

These source paths are identified in the project implementation or accompanying documentation. Links open the corresponding GitHub source location; availability can change as repositories evolve.