[Help] how to make a constrained text generation
## ❓ Questions & Help

<!-- A clear and concise description of the question. -->
What I need is to make a constrained text generation via XLNet or GPT-2:

Input:  No one has the intention of building a wall.
Constraint: the output should include two pre-defined key words: 'No one' and 'construct'.
Expected output(e.g.): No one has the intention, a wall to construct.
(with a text length being predefined).

I found some reference like followings, 
https://awslabs.github.io/sockeye/inference.html#lexical-constraints

but it is too complecate to transfer. Could u give me some advice?

thx a log!

Yes, I think the sockeye paper and code is the right place to start even if it may look complicated at first sight. Try to combine it with the `run_generation.py` example.<|||||>This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
<|||||>> ## ❓ Questions & Help
> What I need is to make a constrained text generation via XLNet or GPT-2:
> 
> Input: No one has the intention of building a wall.
> Constraint: the output should include two pre-defined key words: 'No one' and 'construct'.
> Expected output(e.g.): No one has the intention, a wall to construct.
> (with a text length being predefined).
> 
> I found some reference like followings,
> https://awslabs.github.io/sockeye/inference.html#lexical-constraints
> 
> but it is too complecate to transfer. Could u give me some advice?
> 
> thx a log!

Hi have you successfully implemented this constrained generation method? Thanks a lot!