The stock market is coming off a great year in 2023, with the S&P 500 index surging 26.3%, including dividends. It's on the cusp of setting a new all-time high for the first time in two years. It only has to gain another 2.2% to get there, and it would mark the official beginning of a new bull market.

^SPX Chart

^SPX data by YCharts

Artificial intelligence (AI) was the hottest stock market theme in 2023, led by Nvidia which seized a dominant share in the market for AI data center chips. Its stock soared a whopping 239% for the year.

But investors also scooped up shares of smaller AI powerhouses like Palo Alto Networks (PANW 0.91%) and Duolingo (DUOL 3.64%). They recorded incredible gains of 114% and 219%, respectively in 2023.

With a new bull market potentially around the corner, here's why they might be great places to put your money yet again in 2024.

1. Palo Alto Networks is a leader in AI-powered cybersecurity

Successful cyberattacks can deal significant financial harm to businesses of all sizes, but they also cause reputational damage especially when customers' private data is stolen. Companies are storing an increasing amount of valuable information online thanks to cloud computing, and it opens them up to malicious actors who can strike from anywhere in the world, at any time of the day.

Palo Alto Networks estimates that 93% of security operations centers within organizations continue to rely on manual, human-led processes. Unfortunately, the workload on security managers is so heavy that 23% of security alerts are going uninvestigated, and that creates substantial vulnerabilities.

In late 2022, Palo Alto launched a new platform called Cortex XSIAM. It's a security operations solution focused on speeding up incident response through automation and AI. As of Palo Alto's fiscal 2024 first quarter, ended Oct. 31, 2023, Cortex XSIAM had amassed $1 billion in bookings -- that number doubled from just three months prior. One customer is using the platform to protect 300,000 computers and devices (endpoints) used by employees.

In mid-2023, Palo Alto said it had 35 products powered by AI across its three main segments: cloud security, network security, and security operations. That number has quadrupled since 2019 and it continues to grow; the company has installed sensors with 48,000 customers which collect 4.8 petabytes of cybersecurity data every single day, helping to train its AI models to be as accurate as possible.

Palo Alto expects to generate a record $8.2 billion in revenue during fiscal 2024, representing an 18% year-over-year increase. It also believes it can grow its non-GAAP earnings per share by 23% to $5.47.

The stock soared 114% in 2023 and currently trades at $283. Based on its fiscal 2024 earnings estimate, it trades at a forward price-to-earnings (P/E) ratio of 51.7. It's expensive relative to the Nasdaq 100 index, which trades at a current P/E ratio of 30.1, but Palo Alto is a world leader in cybersecurity. It has more customers than competing providers which means it collects more data, and that's going to drive a significant advantage in an increasingly AI-driven industry.

Plus, there could be an estimated $1.8 trillion gap between what the corporate sector should be spending on cybersecurity right now, and what it is actually spending. The cost of cyberattacks continues to rise, so that gap is likely to close over time much to the benefit of providers like Palo Alto Networks. It could help to accelerate the company's growth in the future.

2. Duolingo is using AI to transform language education

Duolingo is the largest language education platform in the world. It takes a digital, mobile-first approach which places an interactive and engaging learning experience right in the pocket of its 83.1 million monthly active users. Despite economic headwinds in 2023 like elevated inflation and rising interest rates, Duolingo consistently beat its own financial forecasts, which led to a 219% gain in its stock price.

The Duolingo mobile application is free to use, but it offers paid subscriptions for learners who want to accelerate their progress. In 2023's third quarter (ended Sept. 30), a record 5.8 million of its users were paying which represented a whopping 60% increase year over year.

Last year, Duolingo introduced a new, more expensive subscription tier called Max. It gives users access to two powerful new AI features: Roleplay, which is a chatbot designed to help users practice their conversational skills in foreign languages, and Explain My Answer, which gives users personalized feedback based on their mistakes in each lesson to accelerate their learning.

The company has been working on its own AI models since 2013. Its users complete 10 billion lessons every week so the company has more data with which to train its AI than any other education provider in the world. Duolingo also partnered with ChatGPT developer OpenAI in 2021 to further enhance its efforts. Now, the company not only uses AI to improve the learning experience, but also to rapidly craft new lesson content which gives employees more free time to develop new features instead.

Duolingo has now integrated its mathematics education platform into its flagship language app, in addition to a new music education service. Over time, the company hopes this will increase engagement and lead to new monetization opportunities.

On that note, Duolingo delivered $137.6 million in revenue in the third quarter, marking a 43% year-over-year increase and blowing away its forecast of $131 million. It prompted the company to increase its full-year revenue guidance for the third time, to $526.5 million. Its official 2023 results will be released in February.

Duolingo still has a long runway for growth. It estimates more than 2 billion people are learning a foreign language around the world, so it has barely scratched the surface of that opportunity based on its current monthly active user base. Math and music will increase that addressable market even further, so investors have plenty to look forward to in 2024.