replace generate_tokens

benchmark result
https://gist.github.com/hhatto/8223007