Skip to main content

RATransformers 🐭

PyPI - Latest Package Version GitHub - License

RATransformers, short for Relation-Aware Transformers, is a package built on top of transformers 🤗 that enables the training/fine-tuning of models with extra relation-aware input features.

Example - Encoding a table in TableQA (Question Answering on Tabular Data)

[Notebook Link]

In this example we can see that passing the table as text with no additional information to the model is a poor representation.

With RATransformers 🐭 you are able to encode the table in a more structured way by passing specific relations within the input. RATransformers 🐭 also allows you to pass further features related with each input word/token.

Check more examples in [here].

Installation

Install directly from PyPI:

pip install ratransformers

Usage

from ratransformers import RATransformer
from transformers import AutoModelForSequenceClassification


ratransformer = RATransformer(
    "nielsr/tapex-large-finetuned-tabfact", # define the 🤗 model you want to load
    relation_kinds=['is_value_of_column', 'is_from_same_row'], # define the relations that you want to model in the input
    model_cls=AutoModelForSequenceClassification, # define the model class
    pretrained_tokenizer_name_or_path='facebook/bart-large' # define the tokenizer you want to load (in case it is not the same as the model)
)
model = ratransformer.model
tokenizer = ratransformer.tokenizer

With only these steps your RATransformer 🐭 is ready to be trained.

More implementation details in the examples here.

How does it work?

We modify the self-attention layers of the transformer model as explained in the section 3 of the RAT-SQL paper.

Supported Models

Currently we support a limited number of transformer models:

Want another model? Feel free to open an Issue or create a Pull Request and let's get started 🚀

Metadata

Release files for ratransformers 1.3.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ratransformers 1.3.2
File Size Uploaded Provenance Actions
ratransformers-1.3.2.tar.gz 27.1 kB Without provenance Details for ratransformers-1.3.2.tar.gz

Release files / ratransformers-1.3.2.tar.gz

Download URL ratransformers-1.3.2.tar.gz
Size 27.1 kB
Tags Source
SHA-256 checksum
How to use checksums
a76385a422fcc0350c66c2cd1980609efe2370e7891744c90a9ea0956a2c1ae7
BLAKE2b-256 checksum
How to use checksums
937ddb6ab82e4837e46b9ac436c9637deda3fd0545f519a5600d66844463e50e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Security for ratransformers 1.3.2

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page