It is most likely the clutch slipping, though it might also be a problem with the transmission if the problem oonly/always happens in a particular gear.
The clutch slipping can be due to multiple factors, but all would entail having to pull the gearbox and taking apart the clutch assembly to examine the parts:
1. Could be worn out friction disk and/or pressure plate
2. Could be oil/grease contaminated pressure/friction disk (and if oil contaminated, then either rear main seal or oil pump cover seal leaks are most likely culprits)
3. Possible worn out diaphragm spring in clutch assembly.
Are there any mechanical noises or vibrations that accompany this when it happens, and if so, from approximately where on the motorcycle does it seem to come from?
If the clutch splines were gone, you'd rapidly lose all motive power, and the thing would sound like a 50HP food processor chewing up an aluminum can r as soon as you'd try to put it in gear and go.