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
- Downloads last month
- 0
Unable to determine this model's library. Check the
docs
.