The S&P 500 index includes the stocks of 500 of the largest U.S.-based companies, and it's frequently treated as the benchmark for overall stock market performance. The index has risen roughly 106% over the past five years (total return). That means that if you invested in a relatively low-risk exchange-traded fund (ETF) that tracked this benchmark index, you would have more than doubled your money over the last half-decade.

Of course, some stocks in the index far surpassed the performance average. For example, Apple delivered a total return of 270%. Meanwhile, Nvidia managed to blow that impressive performance out of the water, posting gains of more than 2,500% across that five-year stretch.

If you're looking for investments that have the potential to repeat such performance over the next five years, read on to see why these two Motley Fool contributors think that two artificial intelligence (AI) stocks are poised to be winners.

This AI stock can keep roaring higher

Keith Noonan: Thanks to accelerating sales growth, momentum in AI, and interest rate cuts, Palantir Technologies' (PLTR -1.09%) share price is up 343% in 2024. On the heels of this incredible performance, the company is now valued at roughly 62 times this year's expected sales and 201 times expected earnings.

Despite this highly growth-dependent valuation, Palantir has avenues to significantly outperform the S&P 500 index over the next five years.

Strong future performance is already baked into the company's valuation, but Palantir nonetheless is serving up great results. The company's revenue increased 30% year over year to hit $726 million in the third quarter, and revenue for its U.S. geographic segment increased 44% to $499 million. Adjusted free cash flow for the period came in at $435 million -- or 60% of overall revenue. That's an incredible margin.

The business has continued to see strong momentum and impressive adoption for its Artificial Intelligence Platform (AIP) suite, and management issued encouraging commentary and guidance. AIP plays a key role in the growth acceleration, and the software specialist has early leadership in commercial services categories with massive room for long-term growth.

The business has heavy exposure to the defense industry, which suggests that the stock could perform relatively well in the event of increased geopolitical instability. If major new conflicts break out in the world, most growth-dependent stocks will likely see dramatic valuation pullbacks. Palantir stock may not be completely immune to this sort of dynamic, but its leading role in AI defense services suggests the company's share price could bounce back relatively quickly or even rise in the event of new fighting.

Using only traditional valuation metrics, it could be fair to say that Palantir looks richly valued compared to most other tech companies in the S&P 500. On the other hand, the company may have an inverse relation to typical geopolitical risk scenarios and looks uniquely well-positioned to benefit from commercial AI demand.

Generative AI is a huge growth driver

Jennifer Saibil: Amazon (AMZN -0.95%) has been outperforming the market for much of its existence, and it has done so by a wide margin over the past two years, up 174% versus 63% for the broader index (total return). Its generative AI business is just getting started, and that could be a massive growth driver over the next five years, leading to further outperformance.

CEO Andy Jassy described generative AI this way: "I don't know if any of us have seen a possibility like this in technology in a really long time, for sure, since the cloud, perhaps since the Internet."

It has been heavily investing in a comprehensive and industry-leading AI business, launching a broad array of solutions to fit most every need and budget. It's the leading global cloud services provider, with 31% of the market, and the AI business is bringing in new clients that want to benefit from Amazon Web Services' game-changing capabilities.

These include services like Amazon Bedrock, which gives developers access to the company's generative tools to create their own AI models, and Amazon Q, an AI assistant that helps businesses get work done faster.

Its AI business is already generating billions of dollars in sales, but Jassy sees an enormous opportunity as businesses move spending on information technology (IT) from on-premises (where 90% of it still goes) to the cloud. He envisions a flip in that proportion, and his company is poised to benefit from that in a huge way.

Jassy also said that the company has lots of opportunities even before taking into account new possibilities in AI. It has no match in e-commerce, a $4 trillion market and growing, and it's making moves to keep that status, incorporating new tech like robotics and drone deliveries into its operations. Then there's digital advertising, streaming, and healthcare, where the business is no slouch, either.

The company is brimming with potential, and Amazon stock could crush the market over the next five years.