{"id":23067898,"url":"https://github.com/dhruvdcoder/hypera","last_synced_at":"2025-08-13T17:21:10.029Z","repository":{"id":37591763,"uuid":"173203505","full_name":"dhruvdcoder/HyperA","owner":"dhruvdcoder","description":"Started as a Team Project for CS690D at UMass Amherst, now turning into pytorch implementation of hyperbolic neural networks using Poincare Ball model. [Final report](https://github.com/dhruvdcoder/HyperA/tree/master/report) ","archived":false,"fork":false,"pushed_at":"2022-12-08T05:01:46.000Z","size":1168,"stargazers_count":12,"open_issues_count":18,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-03T14:03:42.763Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dhruvdcoder.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-02-28T23:34:40.000Z","updated_at":"2023-07-17T13:30:52.000Z","dependencies_parsed_at":"2023-01-24T12:00:26.204Z","dependency_job_id":null,"html_url":"https://github.com/dhruvdcoder/HyperA","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dhruvdcoder/HyperA","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhruvdcoder%2FHyperA","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhruvdcoder%2FHyperA/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhruvdcoder%2FHyperA/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhruvdcoder%2FHyperA/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dhruvdcoder","download_url":"https://codeload.github.com/dhruvdcoder/HyperA/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhruvdcoder%2FHyperA/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270278704,"owners_count":24557184,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-13T02:00:09.904Z","response_time":66,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-16T05:19:16.254Z","updated_at":"2025-08-13T17:21:09.948Z","avatar_url":"https://github.com/dhruvdcoder.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hyperbolic Attention\n\n**Unofficial** pytorch implementation of the Neural Network components proposed in [Hyperbolic Neural Networks (NeurIPS)](https://papers.nips.cc/paper/7780-hyperbolic-neural-networks.pdf) plus experiments and implementations with attention mechanisms in Hyperbolic Space. \n\n# Usage\n\n## 1. Setup Python paths\n\n```\n$ export PYTHONPATH=\u003crepo_root_dir\u003e\n```\n\n## 2. Install requirements\n\n```\n$ pip install -r requirements.txt\n```\n\n## 3. Train a model\n\nUse the following comand to see the posible models and training configurations.\n\n```\n$ python hypernn/training.py --help\n\nusage: training.py [-h] [-r ROOT_DIR] [-l {DEBUG,INFO,WARNING,ERROR}]\n                   [--dataset {snli,multinli}] [--train_set TRAIN_SET]\n                   [--val_set VAL_SET] [--test_set TEST_SET]\n                   [--max_seq_len MAX_SEQ_LEN] [--vector_cache VECTOR_CACHE]\n                   [--use_pretrained] [--emb_size EMB_SIZE]\n                   [--emb_init_avg_norm EMB_INIT_AVG_NORM] [--freeze_emb]\n                   [--resume_snapshot RESUME_SNAPSHOT] [--epochs EPOCHS]\n                   [--batch_size BATCH_SIZE] [--save_dir SAVE_DIR]\n                   [--save_every SAVE_EVERY] [--mode {test,train}]\n                   [--device {cpu,gpu}] [--gpu GPU] [--dtype {double,float}]\n                   [--mainlogdir MAINLOGDIR] [--experiment EXPERIMENT]\n                   [--experiment_dir EXPERIMENT_DIR] [--tb_debug]\n                   [--model {hconcatrnn,hdeepavg,haddrnn,hconcatgru,addrnnattn,hdeepavgattn}]\n                   [--rnn {RNN,GRU}] [--combine_op {add,concat}]\n                   [--hidden_dim HIDDEN_DIM] [--hyp_bias_lr HYP_BIAS_LR]\n                   [--hyp_emb_lr HYP_EMB_LR] [--euc_lr EUC_LR]\n                   [--print_every PRINT_EVERY] [--val_every VAL_EVERY]\n                   [--debug_grad]\n\nTo level config for the HyperA project\n\noptional arguments:\n  -h, --help            show this help message and exit\n  -r ROOT_DIR, --root_dir ROOT_DIR\n                        Path to root directory for the project.\n  -l {DEBUG,INFO,WARNING,ERROR}, --logging_level {DEBUG,INFO,WARNING,ERROR}\n  --dataset {snli,multinli}\n                        One of snli or multinli\n  --train_set TRAIN_SET\n                        file name of train dataset\n  --val_set VAL_SET     file name of dev dataset\n  --test_set TEST_SET   file name of test dataset\n  --max_seq_len MAX_SEQ_LEN\n                        Max sentence length. If you want to truncate\n                        sentences. Default: None\n  --vector_cache VECTOR_CACHE\n                        filename for saving word embeddings cache\n  --use_pretrained\n  --emb_size EMB_SIZE   Has to be passed if --use_pretrained is not used\n  --emb_init_avg_norm EMB_INIT_AVG_NORM\n                        Average norm for uniformly initialized word\n                        embs.Required if --use_pretrained is False\n  --freeze_emb          Freeze embedding\n  --resume_snapshot RESUME_SNAPSHOT\n                        File where model snapshot is saved if resuming\n                        training or doing test.\n  --epochs EPOCHS       Number of epochs\n  --batch_size BATCH_SIZE\n  --save_dir SAVE_DIR   Dir where to save model snaps models are saved\n  --save_every SAVE_EVERY\n                        Checkpoint saving after how many iters\n  --mode {test,train}\n  --device {cpu,gpu}\n  --gpu GPU             Used only if device is gpu\n  --dtype {double,float}\n                        double or float\n  --mainlogdir MAINLOGDIR\n                        Top level log dir. Logs for individual experiments are\n                        subdirectories in this dir. (default: root_dir/logs)\n  --experiment EXPERIMENT\n                        name of the experiment. Use to create the logdir as\n                        mainlogdir/experiment/\n  --experiment_dir EXPERIMENT_DIR\n                        if this is passed, --mainlogdir and --experiment are\n                        ignored\n  --tb_debug            Debug using tensorboard\n  --model {hconcatrnn,hdeepavg,haddrnn,hconcatgru,addrnnattn,hdeepavgattn}\n                        Pick the model to train\n  --rnn {RNN,GRU}       Only used when using RNN based sentence encoder\n  --combine_op {add,concat}\n                        Method used to combine the reps of premise and hypo\n                        when using model \"haddrnn\".\n  --hidden_dim HIDDEN_DIM\n  --hyp_bias_lr HYP_BIAS_LR\n                        Learning rate for the bias parameters in the\n                        hyperbolic space (used by RSGD)\n  --hyp_emb_lr HYP_EMB_LR\n                        Learning rate for the embedding parameters in the\n                        hyperbolic space (used by RSGD)\n  --euc_lr EUC_LR       Learning rate for layers parameterized by euclidean\n                        params (used by Adam)\n  --print_every PRINT_EVERY\n                        Print training summary every\n  --val_every VAL_EVERY\n                        Run eval loop on dev data every val_every iterations\n  --debug_grad          Pass this if debugging occurances of NaNs and Infs in\n                        gradients\n\n```\n\nFor instance, to train hyperbolic GRU, execute the following:\n\n```\n$ python hypernn/training.py --mainlogdir logs --experiment hyper_gru_5_5 --tb_debug --emb_size 5 --hidden_dim 5 --hyp_bias_lr 0.01 --hyp_emb_lr 0.2 --emb_init_avg_norm 0.0005 --epochs 30 --model haddrnn --rnn GRU --batch_size 512 --print_every 50 --device gpu\n```\n\n## 4. Extract predictions from the test set using a trained model\n\n```\npython hypernn/test.py --mode test --resume_snapshot .saved_models/hyper_gru_5_5/best_snapshot_devacc_56.85175751400917_devloss_0.9821267057980991__iter_59000_model.pt --experiment_dir logs/hyper_gru_5_5_2019-05-07T19-40-40\n```\nSupply, `--resume_snapshot` and `experiment_dir` appropriately from your training run. (Look at the console log of your training to find the paths to these two).\n\n# Running baselines\n\nPlease see the README file in the Baseline folder.\n\n\n## Running unit tests (NOT MANDATORY)\n\n```\n$ chmod +x run_tests.sh\n$ ./run_tests.sh\n```\n\n# Contributors\n1. [Dhruvesh Patel](https://github.com/dhruvdcoder)\n\n2. [Prashant Ranjan](https://github.com/PrashantRanjan09)\n\n3. [Praful Johri](https://github.com/prafuljohari)\n\n4. [Rishabh Gupta](https://github.com/rishabh1694)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdhruvdcoder%2Fhypera","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdhruvdcoder%2Fhypera","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdhruvdcoder%2Fhypera/lists"}