Williams, who suffered a back spasm during the match, looked on course for victory after securing the first set 6-3 and then breaking serve early in the second set.
Stephens said that she did not want to wave the white flag and changed her mentality accordingly, believing that she had nothing to left to lose.
"I think I was convinced that I was able to do it when I lost serve in the first game in the second set and I went down 2-0," said the teenager.
"I was like 'hmm, this is not the way you want it to happen'. But if you just fight and just get every ball back, run every ball down, and just get a lot of balls in play, I think you'll be okay.
"From then on I got aggressive, started coming to the net more, and just got a lot more comfortable. I just kind of played my game from there, I think."
Stephens said that she convinced herself that she was able to pull off an upset this morning.
"Last night someone asked me 'do you think you can win?'" she said.
"I was like 'yeah, I think so' but I wasn't too clear about it. Then this morning when I got up, I was like 'look, dude, like, you can do this. Like, go out and play and do your best'."
She will now play Victoria Azarenka in the last four in Melbourne.