Companies are investing heavily in artificial intelligence, and the adoption of the advanced technology promises to further divide successful firms from those struggling to adapt to the new digital world.

Second-quarter earnings at Target and Walmart, which are leading the field in AI adoption, exceeded expectations, providing early evidence to investors and analysts that investments in this field can help cut costs.

While some firms regularly tout the new tech offerings, the vast majority of companies are staying quiet on AI.

Click here for more BI Prime stories.

Legacy retailers like Target and Walmart are upping artificial-intelligence efforts to get the desired products into the customer's hands easier, cheaper, and faster.

The better-than-expected earnings for some firms — along with the uneven performance of others — demonstrates the potential that AI has to transform the retail industry and the treacherous road ahead to get there.

And other major companies are jumping on board the digital bandwagon. Macy's, for example, said it would close 100 stores and lay off 2,000 employees to help fund new technology investments. In a leaked memo, chief technology officer Naveen Krishna said the goal is to empower its frontline workers with new digital tools to "support growth and profitability initiatives."

Macy's has some catching up to do. Walmart is already rolling out new technology in thousands of its stores, with the goal of eliminating the "mundane" tasks done by store associates so they can spend more time with customers.

"Pretty much everything that we focus on is just making things that you know and do today a lot easier," John Crecelius, Walmart's senior vice president of central operations, told Business Insider. "What makes this exciting and fun is the ecosystem you create. It's the art of the possible when you have several pieces of technology in the same store gathering data and interacting with each other."

Walmart and Target provide parallel examples of AI implementations.

Investment in AI-based startups specific to the retail industry grew to $1.8 billion between 2012 and 2018, the marketing-intelligence firm CB Insights found. Global spending on AI is expected to reach $7.3 billion by 2022, based on estimates from Juniper Research.

Walmart has implemented an automated process to unload shipments from trucks and speed the time under which new products reach the floor. The technology will be used in 1,800 stores this year, according to Crecelius. The company is also using its partner Bossa Nova's robots to scrub floors and restock shelves and cameras to monitor self-checkouts to curb theft.

That emphasis on operational efficiencies helped underscore solid second-quarter earnings, including a better-than-expected 2.8% growth in same-store sales, according to a UBS report provided to Business Insider.

Walmart doesn't view any single offerings as a key cost-cutting mechanism. Instead, they're "individual, small changes that add up to an ecosystem for our stores," Crecelius said.

The firm is also testing a number of new applications in a store in Levittown, New York, including using cameras, sensors, and other hardware to inform when store employees need to restock certain items on the shelves.

Meanwhile, Target reported second-quarter earnings this month that far exceeded expectations. Among other initiatives, the retailer is using new technology to help dictate employee tasks and improve shipping, according to John Mulligan, its chief operating officer.

Target has also explored using blockchain to better manage its supply-chain operations, initially experimenting with a database to certify its paper providers, according to a blog post earlier this year.

The Minneapolis-based firm is also investing in additional automation in the backroom of its stores to "help them become more productive," Mulligan recently told investors.

But while AI might be a popular topic, executives are shying from touting the tech they're adopting.

Executives are typically coy on the actual initiatives under development, but trends around AI deployment have developed. Implementations generally focus on improving online operations, streamlining in-store inventory through better supply-chain management, analyzing vast amounts of consumer behavior to better match the customer with preferred products, and even using robots to clean the floors of their brick-and-mortar locations.

And while AI is a popular buzzword for some retailers, many companies have refrained from mentioning it publicly. Among more than 50 publicly traded firms, just nine retailers discussed strategies for using AI in their operations on earnings calls through the start of 2018, according to a recent analysis of 1,600 calls by CB Insights.

Executives remain hesitant to move too quickly to implement new AI-based applications.

Target and Walmart are approaching the adoption of AI cautiously, limiting investments to tech that can help reduce costs for the company and improve the shopping experience. Such returns are difficult to predict on a large scale, indicating that customers could be waiting a while before their preferred locations roll out the advanced offerings.

And while investors saw promising results from the two retailers, other companies have yet to show any material impact from their own AI-related initiatives.

Last year, Nordstrom acquired two firms that would allow store associates to better communicate with shoppers when they are not physically in stores in hope of ultimately creating a more seamless shopping experience. Like other retailers, the firm is also experimenting with AI-based visual-search tools that allow customers to better find the desired items more quickly.

But the department store's results remain lackluster. On Wednesday, Nordstrom reported uneven second-quarter earnings. Analysts didn't pinpoint AI as a factor, instead questioning the extent of price discounts implemented in the three-month period to counter slowing sales.

The outcome, however, is evidence that simply ramping up technology within stores does not produce instant financial returns.

"The decision to pursue AI does not imply immediate impact. It's more than just [getting] the right technology," David Simchi-Levi, a professor at the Massachusetts Institute of Technology and a consultant for several top retailers, told Business Insider. "You need the right processes, you need the right transformation, and you need the people with the right skills — and that's probably the main bottleneck."

Some firms have been successful without pivoting to AI, but experts say that's not the case for the majority of companies

Adding pressure to legacy retailers is the rise of upstart companies that are entirely AI-based. San-Francisco-based Stitch Fix offers personal-styling services online, using the technology to determine which clothes a user might like before shipping them. The firm then analyzes returns to craft a better profile of the customer. It now has over 3 million customers.

For the bulk of retailers, experts say it's no longer a question of whether to put resources toward AI-based applications. Still, implementing AI is not guaranteed to lead to major savings. Companies like T.J. Maxx continue to excel despite largely forgoing major investments in new technology.

"You start learning and investing in this, or you will be behind the competition that surely is going to invest in this type of technology," Simchi-Levi added.