{"id":13543832,"url":"https://github.com/LogiTorch/logitorch","last_synced_at":"2025-04-02T13:31:11.739Z","repository":{"id":50266944,"uuid":"395025860","full_name":"LogiTorch/logitorch","owner":"LogiTorch","description":"LogiTorch is a PyTorch-based library for logical reasoning on natural language","archived":false,"fork":false,"pushed_at":"2024-09-10T18:52:00.000Z","size":543,"stargazers_count":70,"open_issues_count":0,"forks_count":5,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-10T21:47:07.952Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://logitorch.ai","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LogiTorch.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-08-11T14:56:38.000Z","updated_at":"2024-11-27T06:55:17.000Z","dependencies_parsed_at":"2023-02-13T20:25:20.789Z","dependency_job_id":"c20d1188-14c7-4d9f-a98d-4152238a7c4c","html_url":"https://github.com/LogiTorch/logitorch","commit_stats":null,"previous_names":["chadihelwe/logitorch"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LogiTorch%2Flogitorch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LogiTorch%2Flogitorch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LogiTorch%2Flogitorch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LogiTorch%2Flogitorch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LogiTorch","download_url":"https://codeload.github.com/LogiTorch/logitorch/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246823676,"owners_count":20839760,"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","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-08-01T11:00:36.983Z","updated_at":"2025-04-02T13:31:06.720Z","avatar_url":"https://github.com/LogiTorch.png","language":"Python","funding_links":[],"categories":["A01_文本生成_文本对话","Other Useful Resources","Python"],"sub_categories":["大语言对话模型及数据","2022"],"readme":"# LogiTorch\r\n\r\n![image](docs/source/_static/logo_with_text.jpg)\r\n\r\n[![Downloads](https://static.pepy.tech/badge/logitorch)](https://pepy.tech/project/logitorch)\r\n\r\nLogiTorch is a PyTorch-based library for logical reasoning on natural language, it consists of:\r\n\r\n- Textual logical reasoning datasets\r\n- Implementations of different logical reasoning neural architectures\r\n- A simple and clean API that can be used with PyTorch Lightning\r\n\r\n## 📦 Installation\r\n\r\n```console\r\nfoo@bar:~$ pip install logitorch==0.0.1a2\r\n```\r\n\r\nOr\r\n\r\n```console\r\nfoo@bar:~$  pip install git+https://github.com/LogiTorch/logitorch.git\r\n```\r\n\r\n## 📖 Documentation\r\n\r\nYou can find the documentation for LogiTorch on [ReadTheDocs](https://logitorch.readthedocs.io).\r\n\r\n## 🖥️ Features\r\n\r\n### 📋 Datasets\r\n\r\nDatasets implemented in LogiTorch:\r\n\r\n- [x] [AR-LSAT](https://arxiv.org/abs/2104.06598) \u003csub\u003e(MIT LICENSE)\u003c/sub\u003e\r\n- [x] [ConTRoL](https://arxiv.org/abs/2011.04864) \u003csub\u003e(GitHub LICENSE)\u003c/sub\u003e\r\n- [x] [LogiQA](https://arxiv.org/abs/2007.08124) \u003csub\u003e(GitHub LICENSE)\u003c/sub\u003e\r\n- [x] [ReClor](https://arxiv.org/abs/2002.04326) \u003csub\u003e(Non-Commercial Research Use)\u003c/sub\u003e\r\n- [x] [RuleTaker](https://arxiv.org/abs/2002.05867) \u003csub\u003e(APACHE-2.0 LICENSE)\u003c/sub\u003e\r\n- [x] [ProofWriter](https://arxiv.org/abs/2012.13048) \u003csub\u003e(APACHE-2.0 LICENSE)\u003c/sub\u003e\r\n- [x] [SNLI](https://arxiv.org/abs/1508.05326) \u003csub\u003e(CC-BY-SA-4.0 LICENSE)\u003c/sub\u003e\r\n- [x] [MultiNLI](https://arxiv.org/abs/1704.05426) \u003csub\u003e(CC-BY-SA-4.0 LICENSE)\u003c/sub\u003e\r\n- [x] [RTE](https://tac.nist.gov/publications/2010/additional.papers/RTE6_overview.proceedings.pdf) \u003csub\u003e([TAC User Agreements](https://tac.nist.gov//data/forms/index.html))\u003c/sub\u003e\r\n- [x] [Negated SNLI](https://aclanthology.org/2020.emnlp-main.732/) \u003csub\u003e(MIT LICENSE)\u003c/sub\u003e\r\n- [x] [Negated MultiNLI](https://aclanthology.org/2020.emnlp-main.732/) \u003csub\u003e(MIT LICENSE)\u003c/sub\u003e\r\n- [x] [Negated RTE](https://aclanthology.org/2020.emnlp-main.732/) \u003csub\u003e(MIT LICENSE)\u003c/sub\u003e\r\n- [x] [PARARULES Plus](https://github.com/Strong-AI-Lab/PARARULE-Plus) \u003csub\u003e(MIT LICENSE)\u003c/sub\u003e\r\n- [x] [AbductionRules](https://arxiv.org/abs/2203.12186) \u003csub\u003e(MIT LICENSE)\u003c/sub\u003e\r\n- [x] [FOLIO](https://arxiv.org/abs/2209.00840) \u003csub\u003e(CC-BY-SA-4.0 LICENSE)\u003c/sub\u003e\r\n- [x] [FLD](https://proceedings.mlr.press/v202/morishita23a.html)  \u003csub\u003e(CC-BY-SA-4.0 LICENSE)\u003c/sub\u003e\r\n- [x] [LogiQA2.0](https://arxiv.org/abs/2007.08124) \u003csub\u003e(CC-BY-SA-4.0 LICENSE)\u003c/sub\u003e\r\n- [ ] [LogiQA2.0 NLI](https://arxiv.org/abs/2007.08124) \r\n- [ ] [HELP](https://aclanthology.org/S19-1027.pdf) \r\n- [ ] [SimpleLogic](https://arxiv.org/abs/2205.11502)\r\n- [ ] [RobustLR](https://arxiv.org/abs/2205.12598)\r\n- [ ] [LogicNLI](https://aclanthology.org/2021.emnlp-main.303/)\r\n\r\n### 🤖 Models\r\n\r\nModels implemented in LogiTorch:\r\n\r\n- [x]  [RuleTaker](https://arxiv.org/abs/2002.05867)\r\n- [x]  [ProofWriter](https://arxiv.org/abs/2012.13048)\r\n- [x]  [BERTNOT](https://arxiv.org/abs/2105.03519)\r\n- [x]  [PRover](https://arxiv.org/abs/2010.02830)\r\n- [x]  [FLDProver](https://proceedings.mlr.press/v202/morishita23a.html)\r\n- [ ]  [TINA](https://suchanek.name/work/publications/emnlp-2022.pdf)\r\n- [ ]  [FaiRR](https://arxiv.org/abs/2203.10261)\r\n- [ ]  [LReasoner](https://arxiv.org/abs/2105.03659)\r\n- [ ]  [DAGN](https://arxiv.org/abs/2103.14349)\r\n- [ ]  [Focal Reasoner](https://arxiv.org/abs/2105.10334)\r\n- [ ]  [AdaLoGN](https://arxiv.org/abs/2203.08992)\r\n- [ ]  [Logiformer](https://arxiv.org/abs/2205.00731)\r\n- [ ]  [LogiGAN](https://arxiv.org/abs/2205.08794)\r\n- [ ]  [MERit](https://arxiv.org/abs/2203.00357)\r\n- [ ]  [APOLLO](https://arxiv.org/abs/2212.09282)\r\n- [ ]  [LAMBADA](https://arxiv.org/abs/2212.13894)\r\n- [ ]  [Chainformer](https://aclanthology.org/2023.findings-acl.588/)\r\n- [ ]  [IDOL](https://aclanthology.org/2023.findings-acl.513/)\r\n## 🧪 Example Usage\r\n\r\n### Training Example\r\n\r\n```python\r\nimport pytorch_lightning as pl\r\nfrom pytorch_lightning.callbacks import ModelCheckpoint\r\nfrom torch.utils.data.dataloader import DataLoader\r\n\r\nfrom logitorch.data_collators.ruletaker_collator import RuleTakerCollator\r\nfrom logitorch.datasets.qa.ruletaker_dataset import RuleTakerDataset\r\nfrom logitorch.pl_models.ruletaker import PLRuleTaker\r\n\r\ntrain_dataset = RuleTakerDataset(\"depth-5\", \"train\")\r\nval_dataset = RuleTakerDataset(\"depth-5\", \"val\")\r\n\r\nruletaker_collate_fn = RuleTakerCollator()\r\n\r\ntrain_dataloader = DataLoader(\r\n    train_dataset, batch_size=32, collate_fn=ruletaker_collate_fn\r\n)\r\nval_dataloader = DataLoader(\r\n    val_dataset, batch_size=32, collate_fn=ruletaker_collate_fn\r\n)\r\n\r\nmodel = PLRuleTaker(learning_rate=1e-5, weight_decay=0.1)\r\n\r\ncheckpoint_callback = ModelCheckpoint(\r\n    save_top_k=1,\r\n    monitor=\"val_loss\",\r\n    mode=\"min\",\r\n    dirpath=\"models/\",\r\n    filename=\"best_ruletaker\",\r\n)\r\n\r\ntrainer = pl.Trainer(callbacks=[checkpoint_callback], accelerator=\"gpu\", gpus=1)\r\ntrainer.fit(model, train_dataloader, val_dataloader)\r\n```\r\n\r\n### Pipeline Example\r\n\r\nWe provided pre-configured pipelines for some datasets to train models.\r\n\r\n```python\r\nfrom logitorch.pipelines.qa_pipelines import ruletaker_pipeline\r\nfrom logitorch.pl_models.ruletaker import PLRuleTaker\r\n\r\nmodel = PLRuleTaker(learning_rate=1e-5, weight_decay=0.1)\r\n\r\nruletaker_pipeline(\r\n    model=model,\r\n    dataset_name=\"depth-5\",\r\n    saved_model_name=\"models/\",\r\n    saved_model_path=\"best_ruletaker\",\r\n    batch_size=32,\r\n    epochs=10,\r\n    accelerator=\"gpu\",\r\n    gpus=1,\r\n)\r\n\r\n```\r\n\r\n### Testing Example\r\n\r\n```python\r\nfrom logitorch.pl_models.ruletaker import PLRuleTaker\r\nfrom logitorch.datasets.qa.ruletaker_dataset import RULETAKER_ID_TO_LABEL\r\n\r\nmodel = PLRuleTaker.load_from_checkpoint(\"models/best_ruletaker.ckpt\")\r\n\r\ncontext = \"Bob is smart. If someone is smart then he is kind.\"\r\nquestion = \"Bob is kind.\"\r\n\r\npred = model.predict(context, question)\r\nprint(RULETAKER_ID_TO_LABEL[pred])\r\n```\r\n\r\n## Citing\r\n\r\nUsers of LogiTorch should distinguish the datasets and models of our library from the originals. They should always credit and cite both our library and the original data source, as in ``We used LogiTorch's \\cite{helwe2022logitorch} re-implementation of BERTNOT \\cite{hosseini2021understanding}''.\r\n\r\nIf you want to cite LogiTorch, please refer to the publication in the [Empirical Methods in Natural Language Processing](https://2022.emnlp.org/):\r\n\r\n```code\r\n@inproceedings{helwe2022logitorch,\r\n  title={LogiTorch: A PyTorch-based library for logical reasoning on natural language},\r\n  author={Helwe, Chadi and Clavel, Chlo\\'e and Suchanek, Fabian},\r\n  booktitle={Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing: System Demonstrations},\r\n  year={2022}\r\n}\r\n```\r\n\r\n## Acknowledgments\r\n\r\nThis work was partially funded by ANR-20-CHIA-0012-01 (“NoRDF”).\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLogiTorch%2Flogitorch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FLogiTorch%2Flogitorch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLogiTorch%2Flogitorch/lists"}