Localised high electromagnetic energy and elevated temperatures arising from early latent insulation failures can lead to varying degrees of decomposition of transformer oil, resulting in by-products such as C2H2, C2H4, CH4, and H2. This study employs first-principles density functional theory (DFT) to analyze the optimal doping sites of transition metal atom-modified WS2 systems from perspectives including adsorption distance, charge transfer, binding energy, charge density, and density of states. The adsorption energies for C2H2 gas in V-WS2 and Cr-WS2 systems were calculated as - 2.937 eV and -2.939 eV, respectively, indicating a strong chemical adsorption process. At room temperature, the desorption time for CH4 in the V-WS2 system was merely 0.01 s, facilitating effective detection of CH4, while the longer desorption times for C2H2, C2H4, and H2 suggest that this system could act as an effective adsorbent for these gases at ambient conditions. The Cr-WS2 system exhibited a rapid desorption time of only 0.07 s for CH4 at room temperature, also indicating its potential as an adsorbent for C2H2, C2H4, and H2 at ambient conditions. This work provides theoretical guidance for the development of efficient semiconductor sensors for gas detection in transformer oil, enhanced by transition metal modifications.