textgen: add learning mechanism for length of the text