Skip to main content

Sotastream

image License: MIT Read the Docs

Sotastream is a tool for data augmentation for training pipeline. It uses infinibatch internally to generate an infinite stream of shuffled training data and provides a means for on-the-fly data manipulation, augmentation, mixing, and sampling.

Setup

To install from PyPI (https://pypi.org/project/sotastream/)

pip install sotastream

Developer Setup:

# To begin, clone the repository:
git clone https://github.com/marian-nmt/sotastream
cd sotastream
# option 1:
python -m pip install .
# option 2: install in --editable mode
python -m pip install -e .

Entry points

  • As a module: python -m sotastream
  • As a bin in your $PATH: sotastream

Development

Install development tools

python -m pip install -e .[dev,test]   # editable mode

Editable mode (-e / --editable) is recommended for development purposes, pip creates symbolic link to your source code in a way that any edits made are reflected directly to the installed package. [dev,test] installs depencies for development and tests which includes black, pytest etc.

We use black to reformat code to a common code style.

make reformat

Before creating any pull requests, run

make check          # runs reformatter and tests

Running tests

make test           # run unit tests
make regression     # run regression tests

See Makefile for more details.

Usage examples

A folder like split/parallel contains training data in tsv format (src<tab>tgt) split into *.gz files of around 100,000 lines for better shuffling. The below will output an infinite stream of data generated from the gzipped files in these folders, according to the "wmt" recipe found in sotastream/pipelines/example_pipeline.py.

python -m sotastream example split/parallel split/backtrans

You can also provide compressed TSV files directly, in which case sotastream will split them to checksummed folders under /tmp/sotastream/{checksum}:

python -m sotastream example parallel.tsv.gz backtrans.tsv.gz

There are currently two main pipelines: "default", and "wmt". These vary according to the data sources they take as well as the other options available to them.

There are global options that control behavioral aspects such as splitting and parallelization, and also pipeline-specific arguments. You can see these by running

# see global options
python -m sotastream -h

# see default pipeline options
python -m sotastream default -h

# see wmt pipeline options
python -m sotastream wmt -h

Don't cross the streams!

Sotastream workflows build a directed acyclic graph (DAG) consisting of cascades of generators that pass through mutable lines from the graph inputs to the pipeline output. Since each step provides transformations and manipulations of each input line, the only requirement is that modifications along separate branches must not be merged into a single node in the graph, or at least, that great care should be taken when doing so. An example is the Mixer, which does not actually merge modifications from alternate branches, but instead selects across multiple incoming branches using a provided probability distribution.

Custom/private pipelines from own (private) directory

You can create a custom pipeline by adding a file in the current (invocation) directory with a file name matching the pattern "*_pipeline.py". This should follow the interface defined in sotastream/pipelines, namely:

  • Call @pipeline("name") to give your pipeline a name. This name must not conflict with existing names.
  • Inherit from Pipeline base class from sotastream.pipeline. For document pipelines, use DocumentPipeline as base class.

You can find some examples in test/dummy_pipeline.py, as well as the real examples in sotastream/pipelines.

Authors

Sotastream is developed by TextMT Team @ Microsoft Translator.

If you use this tool, please cite:

@misc{post2023sotastream,
      title={SOTASTREAM: A Streaming Approach to Machine Translation Training}, 
      author={Matt Post and Thamme Gowda and Roman Grundkiewicz and Huda Khayrallah and Rohit Jain and Marcin Junczys-Dowmunt},
      year={2023},
      eprint={2308.07489},
      archivePrefix={arXiv},
      primaryClass={cs.CL}
}

Paper link: https://arxiv.org/abs/2308.07489

Metadata

Release files for sotastream 1.0.1

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

Source distribution (sdist)

Source distribution for sotastream 1.0.1
File Size Uploaded
sotastream-1.0.1.tar.gz 30.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sotastream 1.0.1
File Interpreter ABI Platform
sotastream-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 58.2 kB

Release files / sotastream-1.0.1.tar.gz

Download URL sotastream-1.0.1.tar.gz
Size 30.5 kB
Tags Source
SHA-256 checksum
How to use checksums
f3709874c96f2feb4307dea0f26fbab79c757c0567753b9ca20f93109beba4ad
BLAKE2b-256 checksum
How to use checksums
317847bb3daab2f444d193c172394b50693a2661fb8bdb7e7ef459c630d12a34
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release files / sotastream-1.0.1-py3-none-any.whl

Download URL sotastream-1.0.1-py3-none-any.whl
Size 27.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a03644b40ac960bde0a41217e5f108aaa5fd5202a18a0373207c257ce522c020
BLAKE2b-256 checksum
How to use checksums
f4153bb4e438a8c5cfece8f4c9f2280f7878282cd634a34d3bc3e1424d129138
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

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