{"id":20527082,"url":"https://github.com/flashlight/sequence","last_synced_at":"2025-07-19T11:14:01.483Z","repository":{"id":93046470,"uuid":"527733322","full_name":"flashlight/sequence","owner":"flashlight","description":"Sequence algorithms for use in Flashlight.","archived":false,"fork":false,"pushed_at":"2025-03-18T03:02:25.000Z","size":77,"stargazers_count":14,"open_issues_count":0,"forks_count":2,"subscribers_count":29,"default_branch":"main","last_synced_at":"2025-03-27T18:13:05.006Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C++","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/flashlight.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":"CITATION","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-08-22T21:11:12.000Z","updated_at":"2025-03-18T03:02:29.000Z","dependencies_parsed_at":null,"dependency_job_id":"a2df5f76-806a-4d1e-9fee-721aee2edbfe","html_url":"https://github.com/flashlight/sequence","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flashlight%2Fsequence","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flashlight%2Fsequence/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flashlight%2Fsequence/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flashlight%2Fsequence/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flashlight","download_url":"https://codeload.github.com/flashlight/sequence/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248819650,"owners_count":21166516,"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":[],"created_at":"2024-11-15T23:17:13.752Z","updated_at":"2025-04-14T04:21:27.850Z","avatar_url":"https://github.com/flashlight.png","language":"C++","readme":"# Flashlight Sequence: Algorithms for Sequence Data\n\n[**Quickstart**](#quickstart)\n| [**Installation**](#building-and-installing)\n| [**Python Documentation**](bindings/python)\n| [**Citing**](#citing)\n\n[![CircleCI](https://circleci.com/gh/flashlight/sequence.svg?style=shield)](https://app.circleci.com/pipelines/github/flashlight/sequence)\n[![Join the chat at https://gitter.im/flashlight-ml/community](https://img.shields.io/gitter/room/flashlight-ml/community)](https://gitter.im/flashlight-ml/community?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge) [![Codecov](https://img.shields.io/codecov/c/github/flashlight/sequence)](https://codecov.io/gh/flashlight/sequence) [![Vcpkg](https://img.shields.io/vcpkg/v/flashlight-sequence)](https://vcpkg.link/ports/flashlight-sequence)\n\n*Flashlight Sequence* is a library with fast implementations of sequence-based operations. It includes:\n- A fast, parallel CPU implementation of the Viterbi algorithm for greedy \"`argmax`-style\" decoding\n- Fast implementations (CPU and CUDA) of the [Wav2letter ASG loss](https://arxiv.org/pdf/1609.03193.pdf) function including the fully-connected and forced-alignment algorithms.\n\n## Quickstart\n\nFlashlight Sequence has Python bindings. To install the bindings from source, [optionally install CUDA] then clone the repo and build:\n```shell\ngit clone https://github.com/flashlight/sequence \u0026\u0026 cd sequence\npip install .\n```\nTo install with CUDA support, set the environment variable `USE_CUDA=1` when running the install command. By default, bindings are installed with OpenMP support; to build and install without OpenMP, set the environment to have `USE_OPENMP=0` when buildling.\n\nSee the [full Python binding documentation](bindings/python) for examples and more.\n\n## Building and Installing\n[**From Source (C++)**](#building-from-source) | [**With `vcpkg` (C++)**](#with-vcpkg) | [**From Source (Python)**](bindings/python#build-instructions) | [**Adding to Your Own Project (C++)**](#adding-flashlight-sequence-to-a-c-project)\n\n### Requirements\nAt minimum, C++ compilation requires:\n- A C++ compiler with good C++17 support (e.g. gcc/g++ \u003e= 7)\n- [CMake](https://cmake.org/) — version 3.16 or later, and ``make``\n- A Linux-based operating system.\n\n**CUDA Support:** If building with CUDA support, CUDA \u003e= 9 is recommended. To toggle CUDA support use the `FL_SEQUENCE_USE_CUDA` CMake option or the `USE_CUDA` environment variable when building the Python bindings. To toggle OpenMP support, use the `FL_SEQUENCE_USE_OPENMP` CMake option or use the `USE_OPENMP` environment variable when building the Python bindings.\n\n**Tests:** If building tests, [Google Test](https://github.com/google/googletest) \u003e= 1.12 is required, but is installed automatically on build if not found. The `FL_SEQUENCE_BUILD_TESTS` CMake option toggles building tests.\n\nInstructions for building/installing the Python bindings from source [can be found here](bindings/python/README.md).\n\n### Building from Source\n\nBuilding the C++ project from source is simple:\n```bash\ngit clone https://github.com/flashlight/sequence \u0026\u0026 cd sequence\ncmake -S . -B build\ncmake --build build --parallel\ncd build \u0026\u0026 ctest \u0026\u0026 cd .. # run tests\ncmake --install build # install at the CMAKE_INSTALL_PREFIX\n```\nTo enable CUDA while building, pass `-DFL_SEQUENCE_USE_CUDA=ON` to CMake. To enable building with OpenMP, pass `-DFL_SEQUENCE_USE_OPENMP=ON` to CMake. To disable building tests, pass `-DFL_SEQUENCE_BUILD_TESTS=OFF`.\n\nIf building with CUDA \u003c 11, [NVIDIA cub](https://github.com/NVIDIA/cub) is required. It will be downloaded automatically if not found; the `FL_SEQUENCE_BUILD_STANDALONE` build option controls this behavior.\n\n#### With [`vcpkg`](https://vcpkg.io/)\n\nFlashlight Sequence can also be installed and used downstream with the [`vcpkg`](https://vcpkg.io/) package manager. The [port](https://github.com/microsoft/vcpkg/blob/master/ports/flashlight-sequence/) contains optional features for building with OpenMP and/or CUDA:\n```bash\nvcpkg install flashlight-sequence # no dependencies, or:\nvcpkg install \"flashlight-sequence[cuda]\" # with CUDA\nvcpkg install \"flashlight-sequence[openmp]\" # with OpenMP\nvcpkg install \"flashlight-sequence[cuda,openmp]\" # with both!\n```\n\n### Adding Flashlight Sequence to a C++ Project\n\nGiven a simple `project.cpp` file that includes and links to Flashlight Sequence:\n```c++\n#include \u003ciostream\u003e\n\n#include \u003cflashlight/lib/sequence/criterion/cpu/ViterbiPath.h\u003e\n\nint main() {\n  auto res = fl::lib::cpu::ViterbiPath\u003cfloat\u003e::compute(...);\n  std::cout \u003c\u003c \"ViterbiPath result[0] \" \u003c\u003c res[0] \u003c\u003c std::endl;\n return 0;\n}\n```\n\nThe following CMake configuration links Flashlight and sets include directories:\n\n```cmake\ncmake_minimum_required(VERSION 3.16)\nset(CMAKE_CXX_STANDARD 17)\nset(CMAKE_CXX_STANDARD_REQUIRED ON)\n\nadd_executable(myProject project.cpp)\n\nfind_package(flashlight-sequence CONFIG REQUIRED)\ntarget_link_libraries(myProject PRIVATE flashlight::flashlight-sequence)\n```\n\n### Contributing and Contact\nContact: jacobkahn@fb.com\n\nFlashlight Sequence is actively developed. See\n[CONTRIBUTING](CONTRIBUTING.md) for more on how to help out.\n\n## Citing\nYou can cite [Flashlight](https://arxiv.org/abs/2201.12465) using:\n```\n@misc{kahn2022flashlight,\n      title={Flashlight: Enabling Innovation in Tools for Machine Learning},\n      author={Jacob Kahn and Vineel Pratap and Tatiana Likhomanenko and Qiantong Xu and Awni Hannun and Jeff Cai and Paden Tomasello and Ann Lee and Edouard Grave and Gilad Avidov and Benoit Steiner and Vitaliy Liptchinsky and Gabriel Synnaeve and Ronan Collobert},\n      year={2022},\n      eprint={2201.12465},\n      archivePrefix={arXiv},\n      primaryClass={cs.LG}\n}\n```\n\nFor the AutoSegmentation Criterion (ASG), cite:\n```\n@article{collobert2016wav2letter,\n  title={Wav2letter: an end-to-end convnet-based speech recognition system},\n  author={Collobert, Ronan and Puhrsch, Christian and Synnaeve, Gabriel},\n  journal={arXiv preprint arXiv:1609.03193},\n  year={2016}\n}\n```\n\n## License\nFlashlight Sequence is under an MIT license. See [LICENSE](LICENSE) for more information.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflashlight%2Fsequence","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflashlight%2Fsequence","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflashlight%2Fsequence/lists"}