Hyperbolics
Hyperbolic Embeddings
Install / Use
/learn @HazyResearch/HyperbolicsREADME
hyperbolics
Hyperbolic embedding implementations of Representation Tradeoffs for Hyperbolic Embeddings + product embedding implementations of Learning Mixed-Curvature Representations in Product Spaces
<p align="center"> <img src="assets/binary_tree.png" alt="Hyperbolic embedding of binary tree" width="400"/> </p>Setup
We use Docker to set up the environment for our code. See Docker/README.md for installation and launch instructions.
In this README, all instructions are assumed to be run inside the Docker container. All paths are relative to the /hyperbolics directory, and all commands are expected to be run from this directory.
Usage
The following programs and scripts expect the input graphs to exist in the /data/edges folder, e.g. /data/edges/phylo_tree.edges. All graphs that we report results on have been prepared and saved here.
Combinatorial construction
julia combinatorial/comb.jl --help to see options. Example usage (for better results on this dataset, raise the precision):
julia combinatorial/comb.jl -d data/edges/phylo_tree.edges -m phylo_tree.r10.emb -e 1.0 -p 64 -r 10 -a -s
Pytorch optimizer
python pytorch/pytorch_hyperbolic.py learn --help to see options. Optimizer requires torch >=0.4.1. Example usage:
python pytorch/pytorch_hyperbolic.py learn data/edges/phylo_tree.edges --batch-size 64 --dim 10 -l 5.0 --epochs 100 --checkpoint-freq 10 --subsample 16
Products of hyperbolic spaces with Euclidean and spherical spaces are also supported. E.g. adding flags -euc 1 -edim 20 -sph 2 -sdim 10 embeds into a product of Euclidean space of dimension 20 with two copies of spherical space of dimension 10.
Experiment scripts
-
scripts/run_exps.pyruns a full set of experiments for a list of datasets. Example usage (note: the default run settings take a long time to finish):python scripts/run_exps.py phylo -d phylo_tree --epochs 20Currently, it executes the following experiments:
- The combinatorial construction with fixed precision in varying dimensions
- The combinatorial construction in dimension 2 (Sarkar's algorithm), with very high precision
- Pytorch optimizer in varying dimensions, random initialization
- Pytorch optimizer in varying dimensions, using the embedding produced by the combinatorial construction as initialization
-
The combinatorial constructor
combinatorial/comb.jlhas an option for reporting the MAP and distortion statistics. However, this can be slow on larger datasets such as wordnetscripts/comb_stats.pyprovides an alternate method for computing stats that can leverage multiprocessing Example usage:python scripts/comb_stats.py phylo_tree -e 1.0 -r 2 -p 1024 -q 4to run on 4 cores
Related Skills
node-connect
349.0kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
109.4kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
349.0kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
349.0kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
