Update README.md
Browse files
README.md
CHANGED
@@ -37,6 +37,30 @@ size_categories:
|
|
37 |
!pip install -U ipywidgets
|
38 |
```
|
39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
####
|
41 |
|
42 |
***
|
|
|
37 |
!pip install -U ipywidgets
|
38 |
```
|
39 |
|
40 |
+
#### Search for MIDIs
|
41 |
+
|
42 |
+
```python
|
43 |
+
import pickle
|
44 |
+
import numpy as np
|
45 |
+
from sentence_transformers import SentenceTransformer, util
|
46 |
+
|
47 |
+
model = SentenceTransformer("all-mpnet-base-v2")
|
48 |
+
|
49 |
+
corpus = pickle.load(open('corpus.pickle', 'rb'))
|
50 |
+
corpus_embeddings = np.load('corpus-embeddings-all-mpnet-base-v2.npy')
|
51 |
+
|
52 |
+
query = ['Hotel California']
|
53 |
+
|
54 |
+
query_embedding = model.encode(query, convert_to_tensor=True)
|
55 |
+
|
56 |
+
hits = util.semantic_search(query_embedding, corpus_embeddings, top_k=10)
|
57 |
+
|
58 |
+
hits = hits[0]
|
59 |
+
|
60 |
+
for hit in hits:
|
61 |
+
print(corpus[hit['corpus_id']], "(Score: {:.4f})".format(hit['score']))
|
62 |
+
```
|
63 |
+
|
64 |
####
|
65 |
|
66 |
***
|