{"id":26067702,"url":"https://github.com/joaolages/ratransformers","last_synced_at":"2026-02-25T19:13:45.297Z","repository":{"id":43868736,"uuid":"449333492","full_name":"JoaoLages/RATransformers","owner":"JoaoLages","description":"RATransformers 🐭- Make your transformer (like BERT, RoBERTa, GPT-2 and T5) Relation Aware!","archived":false,"fork":false,"pushed_at":"2022-12-14T11:06:27.000Z","size":398,"stargazers_count":41,"open_issues_count":1,"forks_count":6,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-25T13:21:08.485Z","etag":null,"topics":["bert","deep-learning","language-model","natural-language-processing","neural-network","nlp","pytorch","t5","transformer","transformers"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JoaoLages.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-01-18T15:12:00.000Z","updated_at":"2024-01-04T17:05:01.000Z","dependencies_parsed_at":"2023-01-28T22:15:36.442Z","dependency_job_id":null,"html_url":"https://github.com/JoaoLages/RATransformers","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JoaoLages%2FRATransformers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JoaoLages%2FRATransformers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JoaoLages%2FRATransformers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JoaoLages%2FRATransformers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JoaoLages","download_url":"https://codeload.github.com/JoaoLages/RATransformers/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248448498,"owners_count":21105309,"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":["bert","deep-learning","language-model","natural-language-processing","neural-network","nlp","pytorch","t5","transformer","transformers"],"created_at":"2025-03-08T21:45:38.180Z","updated_at":"2026-02-25T19:13:45.256Z","avatar_url":"https://github.com/JoaoLages.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# RATransformers 🐭\n\n![PyPI - Latest Package Version](https://img.shields.io/pypi/v/ratransformers?logo=pypi\u0026style=flat\u0026color=orange) ![GitHub - License](https://img.shields.io/github/license/JoaoLages/ratransformers?logo=github\u0026style=flat\u0026color=green)\n\n**RATransformers**, short for Relation-Aware Transformers, is a package built on top of [transformers 🤗](https://github.com/huggingface/transformers)\nthat enables the training/fine-tuning of models with extra relation-aware input features.\n\u003c/div\u003e\n\n### Example - Encoding a table in TableQA (Question Answering on Tabular Data)\n![](assets/tableQA.gif)\n\n[[Notebook Link](https://github.com/JoaoLages/RATransformers/blob/main/notebooks/TableQA_tabfact_example.ipynb)]\n\nIn this example we can see that passing the table as text with no additional information to the model is a poor representation.\n\nWith RATransformers 🐭 you are able to encode the table in a more structured way by passing specific relations within the input.\nRATransformers 🐭 also allows you to pass further features related with each input word/token.\n\nCheck more examples in [[here](https://github.com/JoaoLages/RATransformers/blob/main/notebooks/)].\n\n## Installation\n\nInstall directly from PyPI:\n\n    pip install ratransformers\n\n## Usage\n\n```python\nfrom ratransformers import RATransformer\nfrom transformers import AutoModelForSequenceClassification\n\n\nratransformer = RATransformer(\n    \"nielsr/tapex-large-finetuned-tabfact\", # define the 🤗 model you want to load\n    relation_kinds=['is_value_of_column', 'is_from_same_row'], # define the relations that you want to model in the input\n    model_cls=AutoModelForSequenceClassification, # define the model class\n    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)\n)\nmodel = ratransformer.model\ntokenizer = ratransformer.tokenizer\n```\n\nWith only these steps your RATransformer 🐭 is ready to be trained. \n\nMore implementation details in [the examples here](https://github.com/JoaoLages/RATransformers/blob/main/notebooks/).\n\n## How does it work?\nWe modify the self-attention layers of the transformer model as explained in the section 3 of [the RAT-SQL paper](https://arxiv.org/pdf/1911.04942.pdf).\n\n## Supported Models\nCurrently we support a limited number of transformer models:\n- [BART](https://huggingface.co/docs/transformers/model_doc/bart)\n- [BERT](https://huggingface.co/docs/transformers/model_doc/bert)\n- [GPT-2](https://huggingface.co/docs/transformers/model_doc/gpt2)\n- [RoBERTa](https://huggingface.co/docs/transformers/model_doc/roberta)\n- [T5](https://huggingface.co/docs/transformers/model_doc/t5)\n- [LongT5](https://huggingface.co/docs/transformers/model_doc/longt5)\n\nWant another model? Feel free to open an [Issue](https://github.com/JoaoLages/RATransformers/issues) or create a [Pull Request](https://github.com/JoaoLages/RATransformers/pulls) and let's get started 🚀\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoaolages%2Fratransformers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoaolages%2Fratransformers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoaolages%2Fratransformers/lists"}