Deep learning has widespread use in various domains, including computer vision, audio processing, and natural language processing. The hyperparameters of deep learning algorithms have a significant impact on the performance of these algorithms. However, it can be challenging to calculate the hyperparameters of complicated machine learning models like deep neural networks due to the nature of the models. This research suggested a strategy for hyperparameter optimization utilizing the Long Short-Term Memory with Sparrow Search Algorithm (LSTM-SSA) model. The model that has been presented uses a deep neural network, which can recognize and classify instances of hate speech as either hate speech or neither. Experiments are conducted to validate the suggested technique in both straightforward and intricate network environments. The LSTM-SSA model is validated using a dataset consisting of hate speech, and an experimental investigation into the model's sensitivity, accuracy, and specificity is carried out. The outcomes of the experiments demonstrated that the suggested model might be improved upon, as it had an accuracy of 0.936.