from keras.models import load_model

model = load_model('/content/gdrive/My Drive/Colab Notebooks/model.h5', custom_objects={'TFBertModel': transformers.TFBertModel})


def check_similarity(sentence1, sentence2):
    sentence_pairs = np.array([[str(sentence1), str(sentence2)]])
    test_data = BertSemanticDataGenerator(
        sentence_pairs, labels=None, batch_size=1, shuffle=False, include_targets=False,
    )

    proba = model.predict(test_data[0])[0]
    idx = np.argmax(proba)
    proba = f"{proba[idx]: .2f}%"
    pred = labels[idx]
    return pred, proba
    
sentence1 = "Menschen essen futter"
sentence2 = "Hund greift Katze an"
check_similarity(sentence1, sentence2)

Trained on https://github.com/liamhb03/BERT-bratwurst-dataset-small and https://github.com/liamhb03/SNLI-bratwurst
{"license": "apache-2.0"}
license:apache-2.0 region:us
TAGS
#license-apache-2.0 #region-us 

from URL import load_model

model = load_model('/content/gdrive/My Drive/Colab Notebooks/model.h5', custom_objects={'TFBertModel': transformers.TFBertModel})


def check_similarity(sentence1, sentence2):
    sentence_pairs = URL([[str(sentence1), str(sentence2)]])
    test_data = BertSemanticDataGenerator(
        sentence_pairs, labels=None, batch_size=1, shuffle=False, include_targets=False,
    )

    proba = model.predict(test_data[0])[0]
    idx = URL(proba)
    proba = f"{proba[idx]: .2f}%"
    pred = labels[idx]
    return pred, proba
    
sentence1 = "Menschen essen futter"
sentence2 = "Hund greift Katze an"
check_similarity(sentence1, sentence2)

Trained on URL and URL
TAGS
#license-apache-2.0 #region-us 

passage: TAGS
#license-apache-2.0 #region-us 
