Redundancy-aware learning of protein structure-function relationships