fairseq
fairseq copied to clipboard
Do any fairseq CLI's support forced decoding?
❓ Questions and Help
What is your question?
Is there some code path to enable forced decoding from the CLI?
Code
It seems like adding encoded inputs as prefix_tokens
to the SequenceGenerator
's forward
method should do this, but I'm not sure if there's a code path for this in the CLI.
What have you tried?
Looked through documentation and code. 😄
What's your environment?
- fairseq Version (e.g., 1.0 or main): main
- PyTorch Version (e.g., 1.0) 1.12
- OS (e.g., Linux): Linux
- How you installed fairseq (
pip
, source): source - Build command you used (if compiling from source): n/a
- Python version: 3.10
- CUDA/cuDNN version: n/a
- GPU models and configuration: n/a
- Any other relevant information: n/a
It seems fairseq-generate
supports a --score-references
flag which seems to do what I expect.
There is a --prefix-size INT
, which make generation initialized by target prefix of given length. Default: 0
This argument makes prefix_tokens
and as you stated prefix_tokens
are passed to generator: https://github.com/facebookresearch/fairseq/blob/main/fairseq_cli/generate.py#L201-L207
--
Does --score-references
helps?
I may not understand your question, but it does not generate, right?
From codes here, it uses SequenceScorer instead of SequenceGenerator.
From SequenceScorer
's forward
L120-121, L145, it returns the answer directly.
Well, if feels like --score-references
is an alternative of validation. (eval_lm
can not be used with translation)