MCPcopy Create free account
hub / github.com/alibaba/zvec / my_rerank_callback

Method my_rerank_callback

python/tests/test_collection.py:1176–1188  ·  view source on GitHub ↗
(query_results, fields, topn)

Source from the content-addressed store, hash-verified

1174 callback_invoked = []
1175
1176 def my_rerank_callback(query_results, fields, topn):
1177 callback_invoked.append(True)
1178 all_docs = []
1179 for docs in query_results:
1180 all_docs.extend(docs)
1181 seen = set()
1182 unique_docs = []
1183 for doc in all_docs:
1184 if doc.pk() not in seen:
1185 seen.add(doc.pk())
1186 unique_docs.append(doc)
1187 unique_docs.sort(key=lambda d: d.score(), reverse=True)
1188 return unique_docs[:topn]
1189
1190 reranker = CallbackReRanker(callback=my_rerank_callback)
1191 result = collection_with_multiple_docs.query(

Callers

nothing calls this directly

Calls 6

extendMethod · 0.80
setFunction · 0.50
appendMethod · 0.45
addMethod · 0.45
sortMethod · 0.45
scoreMethod · 0.45

Tested by

no test coverage detected