This works also. It could also level up when you kill a certain creature.
Another neat way is for the sword to be intelligent from the get go, but not have all its power available except for the voice inside the sword that constantly harangues the PC. A wise mentor doesn’t have to quiet or...