Giter Club home page Giter Club logo

trittention-transformer's Introduction

Trittention: Exploring N-way Attention in Transformer Models

CI Python License: MIT

This repository contains the implementation and exploration of N-way attention, particularly focusing on 3-way attention (trittention), in transformer models. The goal of this project is to investigate the potential benefits and applications of higher-order attention mechanisms.

Table of Contents

Features

  • Implementation of standard attention, trittention, trittention cube, local trittention, and mixed attention mechanisms.
  • Configurable hyperparameters for customizing the model architecture.
  • Preprocessing utilities for handling text data and creating input tensors.
  • Evaluation utilities for computing various performance metrics.
  • Example scripts for training and evaluating the models on toy problems.
  • Comprehensive unit tests for ensuring code correctness and reliability.
  • Support for CUDA and Apple MPS for accelerated training on compatible hardware.

Installation

To install the required dependencies, run the following command:

pip install -r requirements.txt

Usage

Modify the script to specify the desired model configuration, dataset paths, and training hyperparameters.

python examples/evaluate_models.py

Code Structure

The code is organized into the following directories:

TrittentionTransformer/
├── README.md
├── LICENSE
├── .gitignore
├── MANIFEST.in
├── requirements.txt
├── pyproject.toml
├── data/
│   └── toy_problems/
│       ├── longest_increasing_subsequence.txt
│       └── arithmetic_operations.txt
├── models/
│   ├── __init__.py
│   ├── attention.py
│   ├── trittention.py
│   ├── trittention_cube.py
│   ├── local_trittention.py
│   └── mixed_attention.py
├── config/
│   ├── __init__.py
│   └── cfgs.py
├── utils/
│   ├── __init__.py
│   ├── data_utils.py [**pending**]
│   └── evaluation_utils.py [**pending**]
├── experiments/
│   ├── induction_head.ipynb [**pending**]
│   └── ...
├── results/
├── tests/
│   ├── __init__.py
│   ├── test_attention.py
│   ├── test_trittention.py
│   └── ...
└── examples/
    ├── evaluate_models.py
    └── ...
  • config: Contains configuration classes for the models.
  • data: Contains sample datasets for toy problems.
  • examples: Contains example scripts for training and evaluation.
  • models: Contains the implementation of various attention mechanisms.
  • tests: Contains unit tests for the models and utilities.
  • utils: Contains utility functions for data preprocessing and evaluation.

Experiments

We conducted experiments on various toy problems to evaluate the performance of different attention mechanisms. The experiments include:

  • Longest Increasing Subsequence: Finding the length of the longest increasing subsequence in a given sequence.
  • Arithmetic Operations: Evaluating arithmetic expressions and predicting the result.

Results

Our experiments showed that trittention and its variants (trittention cube, local trittention, mixed attention) outperformed standard attention on certain toy problems, particularly those involving higher-order dependencies and complex patterns.

Detailed results and analysis can be found in the results directory.

Contributing

Contributions to this project are welcome! If you encounter any issues or have suggestions for improvements, please open an issue or submit a pull request.

License

This project is licensed under the MIT License.

Acknowledgements

We would like to acknowledge the following resources and papers that inspired and influenced this project:

References

Feel free to reach out if you have any questions or need further assistance!


trittention-transformer's People

Contributors

muditbhargava66 avatar

Watchers

Kostas Georgiou avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.