Great question. I think there are several explanations for this. For one, Tolkien says that Gollum's people were "akin to the fathers of the fathers of the Stoors." This means that Bilbo and Gollum were not very closely related, especially because of the Fallohidish blood in Bilbo's veins. Nevertheless, Gollum was indeed very curious about Bilbo. Gandalf said "Bilbo's story suggests the kinship," and "They understood each other remarkably well." As you mention, the corruption of the Ring, alongside being under a mountain for hundreds of years, were contributing factors to Gollum not remembering. His mind had been bent on food and survival for too long to think of much else, but it is significant that he suggested playing a Riddle Game. For instance, if an Orc or a Man had fallen into his hole, Gollum would very likely not have talked with them, much less play a game with them. I believe he played the Riddle Game with Bilbo because he reminded him of those he played it with before. Thus, I believe that Gollum did remember Bilbo's race, but only subconsciously. Hope this helps!