Walmart’s ongoing battle with Amazon for the retail crown is expanding well beyond retail, and it’s forcing one of the largest companies in the world to reexamine its DNA. In the last six months alone, Walmart has partnered with scores of tech firms to better compete with Amazon and make progress in markets that may become pivotal years down the line. It’s also begun rethinking how it views itself: a traditional big-box retail giant that now hopes it can be nimble enough to compete with one of technology’s most powerful players.

Following its purchase of Jet.com to advance its e-commerce efforts in 2016, Walmart has starting accelerating its shift from retail giant to tech-focused partner. Those deals now include a partnership with Alphabet’s Waymo for rides to and from stores; Japan’s Rakuten for Kobo e-readers; and Uber, Lyft, and Postmates for grocery delivery.

Walmart is partnering with tech companies left and right

In July, Walmart announced that it’s switched its entire cloud operation to Microsoft Azure and Office 365, in addition to working with the company on artificial intelligence projects in a new five-year deal. (Microsoft is Amazon’s primary competitor in the cloud computing industry.) That Microsoft partnership might include helping open a cashier-less, brick-and-mortar retail store to compete with Amazon Go, which the Windows maker is said to be working on as of June of this year, and it’s something Walmart reportedly started working on as earlier as last year.

In addition to all that, Walmart reportedly has plans to transform its Vudu subsidiary into a legitimate Amazon Prime Video competitor by the end of the year. The company also now maintains two tech incubators, one in San Bruno, California, and one in Austin, Texas, designed around experimenting with ideas like cashier-less stores and personal shopping services and investing in areas like artificial intelligence and computer vision.

The big picture this paints is of a legacy retail brand — one of the biggest on the planet — that’s now fiercely hungry to compete and stay relevant in a world moving slowly but surely toward online commerce, on-demand delivery, and bundled services.

Amazon pioneered that model, losing money for years while it built a logistics network and used cutthroat tactics to gain dominant market share across industries as diverse as books (Kindle), shoes (Zappos), and video streaming (Prime Video and Twitch). All the while, Amazon built up a loyalty program (Amazon Prime) to lock customers into its ecosystem — it now counts more than 100 million subscribers — and a lucrative cloud computing division (AWS) to help bolster profits and improve its own network infrastructure.

Walmart’s financial numbers tell a clear strategy story

Last year, CEO Jeff Bezos placed a target squarely on Walmart and every other big-box retailer in the market when he helped orchestrate the acquisition of Whole Foods. The chain is now tied directly to Prime, helping Amazon further branch out into everyday purchases as well as last-mile delivery of groceries and household goods. It’s clear why Amazon wants to compete with Walmart: Bezos’ plan includes providing everything to everyone, at all hours of the day, and anywhere it can reasonably reach with trucks and, soon, drones. But why would Walmart, with its enormous revenues and physical footprint, need to compete with Amazon?

The financial numbers provide a more telling story. Walmart earns more revenue than any other corporation in the US; in fiscal 2018, it reported a staggering $500 billion in annual sales. But its margins are razor thin because its operational costs are astronomical. Walmart employs more than 2 million people worldwide and more than 1.4 million in the US alone. Yet, despite quarterly profit and sales that are typically more than double the size of Amazon’s, investors see Walmart as worth about a quarter of Amazon’s nearly $1 trillion market valuation.

That’s largely because Amazon continues to grow, specifically in key areas like cloud computing, where its profit margins are huge, and offline retail, where it can steal Walmart customers, thanks to its purchase of Whole Foods and its aggressive expansion into grocery and household good delivery. Meanwhile, Walmart’s growth is minuscule. Its profits are also declining as it continues to spend money to beef up its online operation and compete with Amazon.

That’s how the two companies have arrived at an embittered rivalry, with Amazon increasingly moving offline as its online business continues to dominate e-commerce, and Walmart rethinking its future as customers decide to buy more everyday items online and have them delivered.

“When I think of Walmart, it’s not so much to me that they want to keep up with Amazon,” says Robert Hetu, the research vice president for retail at analyst firm Gartner. “I think clearly if you look at it historically, you can say Walmart missed an opportunity that Amazon captured, but I don’t think Amazon took business from Walmart.”

Walmart’s future depends on its ability to compete with Amazon

After all, both companies have grown at eye-popping rates over the last two decades, mostly serving different customers for different needs. Rather, Hetu explains, Amazon created a new paradigm for online retail that rethought ideas of convenience and cost that were prescient and forward-looking in ways only technology companies can typically achieve. But the ways of Amazon, and how its customers shop, are fast becoming the norm, and Walmart now risks actively losing customers to its e-commerce rival.

For Walmart to compete going forward, Hetu says, it needs to invest in how it thinks people will want to shop in the future. “Walmart believes today is that in order to be relevant in the future, they have to get the technology — the relationship with the consumer through technology — into their physical environment,” he says.

Nowhere is that more apparent than in grocery delivery, which is shaping up to be Amazon and Walmart’s biggest battleground. Groceries are an $800 billion market, and while countless industries have shifted from brick-and-mortar to online venues, a very tiny fraction — just 2 percent — of grocery purchase occur online. Amazon clearly sees the opportunity to accelerate the shift, especially with trends showing how Americans are increasingly eating out, using on-demand delivery, and blending grocery purchases with meal kit programs like Blue Apron.

Amazon’s Prime Pantry program now ships non-perishable goods and household supplies, while its programmable Dash buttons now let Prime customers reorder everyday items like laundry detergent in mere seconds. Amazon’s grocery delivery service, which launched under the Amazon Fresh brand to inconsistent success, is now bolstered by Whole Foods’ physical footprint around the country. Amazon has started integrating Whole Foods deliveries into its Prime Now same-day delivery initiative. That’s the same network of contractors that Amazon is using for its growing Seamless-style food delivery service called Amazon Restaurants.

Walmart, on the other hand, seems only interested in protecting its business, with more than half of its revenues coming from grocery purchases. In addition to its partnerships with Uber, Lyft, Waymo, and Postmates, the company is trying to expand its grocery delivery service — which costs $9.95 per order with no subscription required — into 100 metro areas by the end of 2018.

Walmart has 4,700 stores nationwide that give it access within 10 miles to 90 percent of the US population, so the company is better poised than any other to crack the last-mile delivery problem, so long as it can build a reliable logistics network.

Walmart will have to match Amazon’s ability to understand customers

According to Reuters, Walmart initially thought it could use its existing store workforces to deliver groceries on their way home, earning additional wages on top of the $11-per-hour rates they earned working the floor. It has since shuttered the initiative, Reuters says, and started experimenting with other methods to get its grocery delivery network built out, including those partnerships with ride-hailing giants.

Ultimately, the winner of the grocery battle, and the greater retail war, will come down to which company understands human behavior better, according to Hetu. That’s something that Bezos, who has created a corporate culture zealously obsessed with customer satisfaction and dedicated to data-driven decision-making — has prided himself on throughout Amazon’s rise. And it’s a way of thinking that Walmart will have to continue adapting to.

“Why people behave the way they do is still a great mystery, and that is going to be the things these companies have to understand,” Hetu explains. “The motivators in retail are the same as they’ve always been: availability, price, service, and convenience. When you get over and above that, it gets a lot more complicated.”