Is it possible to constraint text generation?

I was interested in the possibility of generating text that not uses specific phrases. By a phrase, I mean a sequence of tokens that can’t be together in that specific order. I wrote a constraint that suits my requirement: constraint/constraint.py at main · Saninsusanin/constraint · GitHub.
But it works too slow. Is there a better way to do this? Thanks :hugs: