The increasingly complex international environment has put forward more urgent requirements for China to accelerate technological innovation.This paper exploits the external shock of U.S.tariff increase on China in 2018 to explore the impact of external tariff shocks on Chinese firms'innovation output and efficiency using difference in differences method,and measures entrepreneurs'attention allocation through text analysis and Word2vec machine learning techniques,through which we further analyze the transmission mechanism of external tariff shocks affecting firms'innovation.The results find that:(1)External tariff shocks can significantly reduce Chinese firms'innovation output and efficiency;(2)Entrepreneurs'attention content allocation and attention time allocation are two important channels to produce the above effects;(3)Government increasing R&D subsidies,the media and analysts reducing excessive attention,and entrepreneurs with high stress resistance can mitigate the negative effects of external tariff shocks on firms'innovation.The conclusion of this paper implies that government need to create a favorable policy orientation and public opinion environment for entrepreneurs to alleviate external tariff pressure and thus enables them to better exercise their entrepreneurial spirit in independent innovation.