此仓库包含使用 NLP 模型计算句子向量相似性的各种方法
This repo contains various ways to calculate the similarity between source and target sentences. You can choose the pre-trained models you want to use such as ELMo, BERT and Universal Sentence Encoder (USE).
And you can also choose the method to be used to get the similarity:
1. Cosine similarity
2. Manhattan distance
3. Euclidean distance
4. Angular distance
5. Inner product
6. TS-SS score
7. Pairwise-cosine similarity
8. Pairwise-cosine similarity + IDFYou can experiment with (The number of models) x (The number of methods) combinations!
requirements.txt with bash install.shconda create -n sensim python=3.7
conda activate sensim
git clone https://github.com/Huffon/sentence-similarity.git
cd sentence-similarity
bash install.shI ate an apple.
I went to the Apple.
I ate an orange.
...python sensim.py
--model MODEL_NAME [use, bert, elmo]
--method METHOD_NAME [cosine, manhattan, euclidean, inner,
ts-ss, angular, pairwise, pairwise-idf]
--verbose LOG_OPTION (bool)sentence-similarityTS-SS score might not fit with sentence similarity task, since this method originally devised to calculate the similarity between long documents暂无开放 Issues,或尚未同步最近议题。