Add save functionality to CTCDecoder
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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