How to create a data generator?

is it possible to create a data generator to upload the data on demand and to reduce memory consumption?

Can you describe a bit more what you are looking for and how it relates to OpenNMT-tf?