She sees mentors as “social vaccines.” Just as medical vaccines prepare the immune system to deal with infections, good mentors inoculate the mind against the stultifying effects of negative stereotypes. “And this study isn’t just about women,” adds Radhika Nagpal, from Harvard University. “It’s about all the groups who have been historically and legally excluded, and are now slowly entering a world from which their members were barred. There’s a famous saying: You can’t be what you can’t see.”

Between 2011 and 2015, Dasgupta and her colleague Tara Dennehy recruited 150 women who enrolled in the university’s engineering course, and randomly assigned them to either a female mentor, a male mentor, or no mentor. The mentors were all high-performing senior students who shared the same majors as their mentees. After a brief training session, they were asked to meet with their charges once a month, and help them to wrestle with academic problems, develop long-term plans, find a social network, and more.

A year later, Dennehy and Dasgupta surveyed the volunteers. Compared to their mentor-less peers, the students with female mentors felt more accepted by their peers and less invisible. They were more confident in their engineering skills, and more likely to think they had a talent for the subject. They were more likely to think that their ability to overcome their academic challenges outweighed the stress and uncertainty they felt.

“It’s not that having a female mentor increased belonging or confidence—it just preserved it,” Dasgupta notes. This is a critical point. Without any mentorship at all, the volunteers felt increasingly anxious, under-confident, and out of the place through the year. But the mentors helped to straighten these arcs that, by default, veer towards exclusion and attrition.

That has long-term effects. As the months wore on, Dennehy and Dasgupta found that women without mentors increasingly thought about switching majors, and became less keen on pursuing graduate degrees in engineering. By the end of the first year, 11 percent of them had dropped out. By contrast, the students with female mentors remained equally committed to their fields, and every single one of them stayed the course.

Why? The answer had nothing to do with academic performance: The students’ actual grades had no bearing on their odds of staying in engineering. Instead, “the active ingredients are belonging and confidence,” says Dasgupta. “Humans are social animals. Our ability alone doesn’t determine whether we stay in or leave a field. It’s ability mixed in that feeling that these are your people, this is where you belong. Absent, that even high-performers might not feel motivated to stay.” Which makes you wonder: How many brilliant minds have been lost from engineering and other STEM disciplines because those disciplines didn’t create spaces for them?