If you use a modern Mac machine that is equipped with an SSD as the internal hard drive, it seems impossible to recover data from it. An SSD has the TRIM feature that works to convey the SSD which data blocks are no longer in use and can be erased to make room for new data.
So, once you've factory reset your Mac, SSD will label all the data blocks on it can be used to store other data.
But if you erased your Mac just now and haven't made other operations on it, you can try to use a professional data recovery tool like iBoysoft Mac Recovery Mode.
This tool can give you a chance to restore files from your factory reset Mac. It allows you to load the data recovery tool from its server over the internet rather than downloading the data recovery tool to your Mac. This can reduce the changes on your SSD and increase the data recovery success.