pytorch / pytorch/audio

Add save functionality to CTCDecoder

Open
#4,113 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
2.9k
Forks
798
Avg merge
58m
Merged PRs (30d)
3

Description

🚀 The feature

Add a CTCDecoder.save_to_dir(save_dir: str | Path) function , which saves the lexicon, tokens, kenlm file, decoder_options, and anything else required to build the decoder to a directory.

Saving the kenlm file either requires support in flashlight-text or passing the path to the CTCDecoder init instead of the KenLM object, so the file can be copied to the save_dir.

Motivation, pitch

HF transformers is looking at changing its dependency on pyctcdecode to the torchaudio CTCDecoder (huggingface/transformers/issues/41230).

In order to support pushing the decoder to the hub, it needs to support something equivalent to pyctcdecode.BeamSearchDecoderCTC.save_to_dir.

I'll be happy to make a PR.

Alternatives

No response

Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the CTCDecoder constructor and the proposed CTCDecoder.save_to_dir(save_dir) entry point. Review how the lexicon, tokens, decoder_options, and KenLM object are supplied, then check flashlight-text for KenLM file support. Done means a saved directory contains everything required to rebuild an equivalent decoder and supports the Hugging Face Hub use case.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
machine-learning
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.