How to get a similarity vector from two vectors? I want to make a classification model for 3 classes,  i have 2 sentences for each observation, firstly i apply a cnn layer for each sentence and then i added dense layer.

inputs = Input(shape=(2,n_timesteps))
embedding_inputs = embedding_layer(inputs) 

sentence1 = Lambda(lambda x: x[:,0,:,:])(embedding_inputs)
sentence2 = Lambda(lambda x: x[:,1,:,:])(embedding_inputs)

conv_sentence1 = Conv1D(filters=64, kernel_size=3, activation='relu', 
input_shape=(n_timesteps,n_features))(sentence1)
conv_sentence2 = Conv1D(filters=64, kernel_size=3, activation='relu', 
input_shape=(n_timesteps,n_features))(sentence2)

pooling_sentence1 = MaxPooling1D(pool_size=2)(conv_sentence1)
pooling_sentence2 = MaxPooling1D(pool_size=2)(conv_sentence2)

flat_sentence1 = Flatten()(pooling_sentence1)
flat_sentence2 = Flatten()(pooling_sentence2)

concat_senrences = concatenate([flat_sentence1,flat_sentence2])
dense_layer = dense(50)(concat_senrences)
dense_prediction = dense(3,activation='softmax')(dense_layer)


but i get an early overfetting, so i thought that the problem comes from "sentence 2", each observation has an unique "sentence 1", ,instead, "sentence 2" can be exists in several observations, in that case the neural network relies strongly on it, so i want to combine two sentences and apply an unique CNN layer, that's why i asked how to obtain a similarity vector.

thanks !!!
If I understand your question correctly, you have 2 sentences and you converted those sentences into 2 vectors, you want to know how those sentences are similar.
If this is the case use cosine similarity between 2 sentences and cosine similarity is a scalar not a vector its the dot product of your 2 embedding vectors.

from numpy import dot
from numpy.linalg import norm

cos_sim = dot(a, b)/(norm(a)*norm(b))


where a and b are your vectors.

There is direct formula as well:

from sklearn.metrics.pairwise import cosine_similarity

cosine_similarity(vector1,vector2)