Warren Buffett doesn't typically invest in high-flying growth stocks building cutting-edge technology. "Berkshire is not big on newcomers," he jokes in his most recent annual letter to shareholders. Nonetheless, he's invested a huge portion of Berkshire Hathaway's (BRK.A -0.23%) (BRK.B -0.28%) portfolio in two artificial intelligence (AI) giants, both of whom are members of the vaunted Magnificent Seven.

The Magnificent Seven is a group of megacap companies whose stocks have largely driven the performance of the S&P 500 since the start of 2023. They're mostly technology leaders and not the typical Buffett investment. But if Buffett sees value in these two stocks, they can likely produce strong returns for investors regardless of whether they lean more toward Buffett's investment style or more toward growth stocks.

Here are the two Magnificent Seven AI stocks Buffett has sunk $158 billion into.

A graphic depicting a computer chip with AI printed on it.

Image source: Getty Images.

1. Apple ($155.3 billion)

Apple (AAPL 2.48%) has grown to become Berkshire Hathaway's largest equity position by a wide margin. Buffett initially started accumulating shares of Apple between 2016 and 2018. And with the phenomenal growth of the stock since then, Berkshire's position has ballooned to a value of about $155 billion today.

While Buffett has trimmed his Apple position a few times in the past, it appears to be for tax purposes more than anything. In fact, Buffett expressed regret over selling shares given a tax opportunity in the past, but he seemed to repeat the same mistake at the end of last year.

Given the size of Berkshire's position in Apple, no one should question Buffett's belief in the company and the stock to produce strong results going forward. Buffett called Apple "a better business than any we own," at Berkshire's annual shareholder meeting last year.

So, what does Buffett like so much about Apple?

While Apple builds various technologies, including artificial intelligence, Buffett sees it as an unparalleled consumer products company. There's no consumer product more ubiquitous than the smartphone, and Apple's share of the smartphone market, especially the premium smartphone market, is unmatched.

Apple has capitalized on that position in more recent years by expanding its ecosystem and building a large services business. The iPhone has become a platform business, in a sense, which has helped Apple produce expanding profit margins. Services, as a group, generate nearly twice the profit per dollar as Apple's hardware sales.

Buffett is also a fan of Apple's massive capital return program. He notes that every year Berkshire's stake in Apple increases a little bit because Apple buys back so much of its shares. The company produces around $100 billion in free cash flow annually, and it returns practically all of that to shareholders through dividends and buybacks. As a result, shareholders, including Berkshire Hathaway, can claim a bigger stake in Apple's earnings every year.

Apple shares trade for a forward P/E multiple of 26, a slight premium to the S&P 500. But that premium is justified by its big cash position and share buyback program.

2. Amazon ($1.8 billion)

The other member of the Magnificent Seven found in Berkshire's portfolio is Amazon (AMZN 0.75%). Amazon is far from a Buffett stock. He even said the business is outside his circle of competence in an interview several years ago, so he doesn't consider missing the boat on the stock a mistake. Nonetheless, his company owns about $1.8 billion worth of Amazon stock.

That's likely due to one of Buffett's partner portfolio managers, Ted Weschler or Todd Combs, initiating a position in 2019.

There's a lot to like about Amazon. "It's changed your behavior, everybody's behaviors," Buffett said of the company back in 2017. Indeed, the Amazon Prime network has become a significant moat for the business, pushing shoppers and merchants to become more loyal to Amazon. That creates a flywheel whereby Amazon can invest more into Prime benefits and faster shipping, drawing in more shoppers and more merchants.

Buffett is also impressed by Amazon's cloud-computing business, which accounts for the bulk of Amazon's operating income. That could grow quickly with the growth of artificial intelligence, and Amazon is investing heavily to keep up with competitors in the space. That includes a $4 billion investment in Anthropic and designing its own AI training and inference chips for its servers to support new large language models and AI-powered applications.

The fast growth of Amazon's cloud-computing business along with its burgeoning advertising sales should support continued margin expansion for the company, producing strong free-cash-flow growth -- the main metric by which management judges its financial results.

Amazon trades for a price-to-sales ratio of just 3.29, which sits below its five-year average despite increasingly promising prospects of margin expansion.