The recent decline in artificial intelligence stocks serves as a reminder for investors to diversify their portfolios rather than concentrating holdings in the market's hottest sectors, CNBC's Jim Cramer said on Thursday.

Following months of AI infrastructure stocks leading market gains, Cramer noted that investors with exposure to other sectors are now seeing the benefits of that strategy. On Thursday, Kimberly-Clark rose 4.7%, Waste Management climbed 3.9%, and Eli Lilly advanced 3.6%. For the week, all three stocks have gained at least 6%. In contrast, the iShares Semiconductor ETF (SOXX) recorded its eighth consecutive day of declines, marking its longest losing streak in more than a decade.

Cramer, host of "Mad Money," stated that diversification is often undervalued because it feels less appealing when one group consistently outperforms the rest of the market. However, he argued that when that outperforming group crashes, only diversification can protect a portfolio. He cited the CNBC Investing Club's Charitable Trust as a specific example of this strategy in action. On Sept. 1, the portfolio sold its position in Corning, an AI beneficiary, and purchased shares of Kimberly-Clark, the parent company of Huggies, the next day to reduce exposure to the data center trade. Although Corning continued to rise and Kimberly-Clark initially declined after the swap, the recent rotation has begun to validate the decision.

Cramer observed that Corning shares have fallen almost 5% since the Club's exit, while Kimberly-Clark shares have gained more than 10% from their Oct. 1 low. The Club has added to its Kimberly-Clark position multiple times to lower its cost basis and currently holds an unrealized loss of less than 1%. Cramer acknowledged that it remains unclear how long the rotation away from AI stocks will continue. He warned that excessive concentration in a single sector risks significant losses that could cause investors to abandon the asset class entirely.

The Charitable Trust currently owns shares of Intel (INTC), Kimberly-Clark (KMB), Eli Lilly (LLY), and NVIDIA (NVDA).