MOUNTAIN VIEW, Calif. — In its quest to maintain a United States military advantage, the Pentagon is aggressively turning to Silicon Valley’s hottest technology — artificial intelligence.

On Wednesday, Secretary of Defense Ashton B. Carter made his fourth trip to the tech industry’s heartland since being named to his post last year. Before that, it had been 20 years since a defense secretary had visited the area, he noted in a speech at a Defense Department research facility near Google’s headquarters.

The Pentagon’s intense interest in A.I. — and by connection the Silicon Valley companies specializing in that technology — has grown out of the “Third Offset” strategy articulated by Mr. Carter last fall. Concerned about the re-emergence of China and Russia as military competitors, he stated that computer-based, high-tech weapons would give the American military an edge in the future.

Third Offset is a reference to two earlier eras when Pentagon planners turned to technology to compensate for a smaller military. In the 1950s, President Eisenhower emphasized nuclear weapons as a deterrence to larger Warsaw Pact armies. A second “offset” occurred in the 1970s and ’80s when military planners turned to improved technology in conventional weapons to again compensate for smaller numbers.