Update README.md
Browse files
README.md
CHANGED
@@ -117,10 +117,16 @@ try:
|
|
117 |
"Deep learning uses neural networks with multiple layers to process data.",
|
118 |
"Neural networks are computing systems inspired by biological neural networks.",
|
119 |
"Artificial intelligence encompasses machine learning and deep learning.",
|
120 |
-
"Here is how you train dogs",
|
121 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
|
123 |
-
# Test single query ranking
|
124 |
print("\n=== Single Query Ranking ===")
|
125 |
query = "How does deep learning work?"
|
126 |
results = colbert.rank_documents(query, documents, top_k=3)
|
@@ -501,10 +507,16 @@ documents = [
|
|
501 |
"Deep learning uses neural networks with multiple layers to process data.",
|
502 |
"Neural networks are computing systems inspired by biological neural networks.",
|
503 |
"Artificial intelligence encompasses machine learning and deep learning.",
|
504 |
-
"Here is how you train dogs",
|
505 |
]
|
506 |
|
507 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
508 |
print("\n=== ONNX Standalone Single Query Ranking ===")
|
509 |
query = "How does deep learning work?"
|
510 |
results = onnx_colbert.rank_documents(query, documents, top_k=3)
|
|
|
117 |
"Deep learning uses neural networks with multiple layers to process data.",
|
118 |
"Neural networks are computing systems inspired by biological neural networks.",
|
119 |
"Artificial intelligence encompasses machine learning and deep learning.",
|
|
|
120 |
]
|
121 |
+
|
122 |
+
# Encode and find similarity
|
123 |
+
q_reps = colbert.encode_queries(queries, batch_size=4, to_cpu=True)
|
124 |
+
p_reps = colbert.encode_documents(documents, batch_size=4, to_cpu=True)
|
125 |
+
|
126 |
+
print("Computing similarities...")
|
127 |
+
scores = colbert.compute_similarity(q_reps, p_reps)
|
128 |
|
129 |
+
# or Test single query ranking
|
130 |
print("\n=== Single Query Ranking ===")
|
131 |
query = "How does deep learning work?"
|
132 |
results = colbert.rank_documents(query, documents, top_k=3)
|
|
|
507 |
"Deep learning uses neural networks with multiple layers to process data.",
|
508 |
"Neural networks are computing systems inspired by biological neural networks.",
|
509 |
"Artificial intelligence encompasses machine learning and deep learning.",
|
|
|
510 |
]
|
511 |
|
512 |
+
# Encode and find similarity
|
513 |
+
q_reps = onnx_colbert.encode_queries(queries, batch_size=4, to_cpu=True)
|
514 |
+
p_reps = onnx_colbert.encode_documents(documents, batch_size=4, to_cpu=True)
|
515 |
+
print("Computing similarities...")
|
516 |
+
scores = onnx_colbert.compute_similarity(q_reps, p_reps)
|
517 |
+
|
518 |
+
|
519 |
+
# or Test single query ranking
|
520 |
print("\n=== ONNX Standalone Single Query Ranking ===")
|
521 |
query = "How does deep learning work?"
|
522 |
results = onnx_colbert.rank_documents(query, documents, top_k=3)
|