LogiTorch
LogiTorch is a PyTorch-based library for logical reasoning in natural language, it consists of:
- Textual logical reasoning datasets
- Implementations of different logical reasoning neural architectures
- A simple and clean API that can be used with PyTorch Lightning
📦 Installation
📖 Documentation
🖥️ Features
📋 Datasets
Datasets implemented in LogiTorch:
- AR-LSAT
- ConTRoL
- LogiQA
- ReClor
- RuleTaker
- ProofWriter
- SNLI
- MultiNLI
- RTE
- Negated SNLI
- Negated MultiNLI
- Negated RTE
- PARARULES Plus
- AbductionRules
🤖 Models
Models implemented in LogiTorch:
🧪 Example Usage
Training Example
import pytorch_lightning as pl
from logitorch.data_collators.ruletaker_collator import RuleTakerCollator
from logitorch.datasets.qa.ruletaker_dataset import RuleTakerDataset
from logitorch.pl_models.ruletaker import PLRuleTaker
from pytorch_lightning.callbacks import ModelCheckpoint
from torch.utils.data.dataloader import DataLoader
train_dataset = RuleTakerDataset("depth-5", "train")
val_dataset = RuleTakerDataset("depth-5", "val")
ruletaker_collate_fn = RuleTakerCollator()
train_dataloader = DataLoader(
train_dataset, batch_size=32, collate_fn=ruletaker_collate_fn
)
val_dataloader = DataLoader(
train_dataset, batch_size=32, collate_fn=ruletaker_collate_fn
)
model = PLRuleTaker(learning_rate=1e-5, weight_decay=0.1)
checkpoint_callback = ModelCheckpoint(
save_top_k=1,
monitor="val_loss",
mode="min",
dirpath="models/",
filename="best_ruletaker.ckpt",
)
trainer = pl.Trainer(accelerator="gpu", gpus=1)
trainer.fit(model, train_dataloader, val_dataloader)
Testing Example
from logitorch.pl_models.ruletaker import PLRuleTaker
from logitorch.datasets.qa.ruletaker_dataset import RULETAKER_ID_TO_LABEL
import pytorch_lightning as pl
model = PLRuleTaker.load_from_checkpoint("best_ruletaker.ckpt")
context = "Bob is smart. If someone is smart then he is kind"
question = "Bob is kind"
pred = model.predict(context, question)
print(RULETAKER_ID_TO_LABEL[pred])
Metadata
Release files for logitorch 0.0.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 | Provenance | Actions |
|---|---|---|---|---|
| logitorch-0.0.0.tar.gz | 35.1 kB | Without provenance | Details for logitorch-0.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| logitorch-0.0.0-py3-none-any.whl | Python 3 | none | any | Details for logitorch-0.0.0-py3-none-any.whl |
Total release size: 89.6 kB
Release files / logitorch-0.0.0.tar.gz
| Download URL | logitorch-0.0.0.tar.gz |
|---|---|
| Size | 35.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4d395620150e5e6dc2e5a6410c3356524198d9a5a90ba03e5f7546b5748b2f99
|
|
BLAKE2b-256 checksum How to use checksums |
2ab319f2cf566136f711fbf992f50be4e8d9869b1151df9816420d6170e5001b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.12
|
Release files / logitorch-0.0.0-py3-none-any.whl
| Download URL | logitorch-0.0.0-py3-none-any.whl |
|---|---|
| Size | 54.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
070fca830e7373537f200d75cc66d1c8dcac750543468951dfffef3561e66bf5
|
|
BLAKE2b-256 checksum How to use checksums |
e9bcabe7543a7a914b5cbc7d5dfe5c6975e51624ea35af2a222b41d44c35899c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.12
|
Security for logitorch 0.0.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.