Skip to main content

Zero-Training Context Extension for Transformer Encoders via Nonlinear Absolute Positional Embeddings Interpolation

Reason this release was yanked:

Unaccessible scripts

Project description

Zero-Training Context Extension for Transformer Encoders via Nonlinear Absolute Positional Embeddings Interpolation

Official implementation of "Zero-Training Context Extension for Transformer Encoders via Nonlinear Absolute Positional Embeddings Interpolation". Paper preprint is coming soon.

This implementation currently supports only models compatible with Sentence Transformers library.

Models

Models are available at HuggingFace:

Model Context length Language
idanylenko/e5-large-v2-ctx1024 1024 English

Installation

To install the package, use pip:

pip install "context-extension>=0.1.1"

Usage

After installing the package you may use extend-context-spline (recommended) or extend-context-linear scripts for embeddings interpolation.

Spline Interpolation

Use this for smooth, nonlinear interpolation to support arbitrary context lengths:

extend-context-spline \
  --model_name_or_path="intfloat/e5-large-v2" \
  --max_seq_length=1024 \
  --embeddings_attr_name="embeddings.position_embeddings" \
  --offset=0 \
  --output_dir="intfloat/e5-large-v2-ctx1024-spline"

Linear Interpolation

Use this to double the model's positional embedding range using linear averaging between consecutive embeddings:

extend-context-linear \
  --model_name_or_path="intfloat/e5-large-v2" \
  --embeddings_attr_name="embeddings.position_embeddings" \
  --offset=0 \
  --output_dir="intfloat/e5-large-v2-ctx1024-linear"

Both commands modify the positional embeddings of a model and save the updated model to the specified directory. You can then upload the resulting model to Hugging Face or use it locally for inference.

For models like RoBERTa that use special tokens in the first few positions, remember to set appropriate --offset argument.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

context_extension-0.1.1.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

context_extension-0.1.1-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

Details for the file context_extension-0.1.1.tar.gz.

File metadata

  • Download URL: context_extension-0.1.1.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for context_extension-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f25d37c2066146f7b95f06770b4513bb246e80c27bbe7d9af615e9f53c37201f
MD5 4cb4cecf71c40ecb63e21feb7362a54f
BLAKE2b-256 c442af222197abf28b40869842153e7510d10a6d21c6c8bb3304b4edb4e76f59

See more details on using hashes here.

Provenance

The following attestation bundles were made for context_extension-0.1.1.tar.gz:

Publisher: python-publish.yml on Kowd-PauUh/encoders-context-extension

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file context_extension-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for context_extension-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2c7fdc38b5d7bfcf644a7a7726b234d69f9fd2cf97eb6f7d7374ed963c974a17
MD5 cd262e779c911b87eeaa41204a5bb0fc
BLAKE2b-256 506630aed1ebd4fec46f76afaa9a6f354ab445df0e0d255d060ed1df59ad7a7b

See more details on using hashes here.

Provenance

The following attestation bundles were made for context_extension-0.1.1-py3-none-any.whl:

Publisher: python-publish.yml on Kowd-PauUh/encoders-context-extension

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page