Convergent lines of evidence suggest that globular clusters host multiple stellar populations. It appears that they experience at least two episodes of star formation whereby a fraction of first-generation stars contribute astrated ejecta to form the second generation(s). To identify the polluting progenitors, we require distinguishing chemical signatures such as that provided by lithium. Theoretical models predict that lithium can be synthesized in AGB stars, whereas no net Li production is expected from other candidates. It has been shown that in order to reproduce the abundance pattern found in M4, Li production must occur within the polluters, favoring the AGB scenario. Here, we present Li and Al abundances for a large sample of RGB stars in M12 and M5. These clusters have a very similar metallicity, while demonstrating differences in several cluster properties. Our results indicate that the first-generation and second-generation stars share the same Li content in M12; we recover an abundance pattern similar to that observed in M4. In M5, we find a higher degree of complexity, and a simple dilution model fails in reproducing the majority of the stellar population. In both clusters, we require Li production across the different stellar generations, but production seems to have occurred to different extents. We suggest that such a difference might be related to the cluster mass with the Li production being more efficient in less-massive clusters. This is the first time a statistically significant correlation between the Li spread within a GC and its luminosity has been demonstrated. Finally, although Li-producing polluters are required to account for the observed pattern, other mechanisms, such as MS depletion, might have played a role in contributing to the Li internal variation, though at a relatively low level.