A Bayesian network risk assessment model for hydrogen accidents based on a knowledge graph is proposed. The study uses hydrogen accident report texts to form hydrogen accident knowledge texts by analyzing, processing, and extracting text fragments with transparent causal relationships. Then, the Bert-BilSTM-CRF algorithm is used to extract knowledge, and the results are stored in the Neo4j database to construct a knowledge map, obtain the risk factors of hydrogen accidents, and complete the structural modeling of the Bayesian network. The improved SAM method is used to aggregate expert opinions, calculate the prior and posterior probability, and realize the parameter learning of the Bayesian network. Based on a knowledge graph, this forms a Bayesian network risk assessment model for hydrogen accidents. This model can evaluate and warn against hydrogen accidents in a data-driven manner and promote knowledge acquisition, analysis, and decision-making on hydrogen energy storage and transportation risks.