mashu / PositionalEmbeddings.jl

Positional embeddings for enriching sequence data with positional information
MIT License
2 stars 0 forks source link

PositionalEmbeddings.jl

PositionalEmbeddings.jl

Stable Dev Build Status Coverage

A Julia package providing various positional embedding implementations for enriching sequence data with position information.

Features

Installation

using Pkg
Pkg.add("PositionalEmbeddings")

Quick Start

using PositionalEmbeddings

# Absolute Positional Embeddings
pe = AbsolutePE(512, 1024)  # embedding_size=512, max_length=1024
x = randn(Float32, 100, 512, 32)  # (seq_len, channels, batch)
x_with_pos = pe(x)

# Rotary Position Embeddings
rope = RoPE(512, 1024)  # features=512, max_length=1024
x = randn(Float32, 512, 100, 32)  # (features, seq_len, batch)
x_with_pos = rope(x)

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.