C API reference · Kjarni 0.2.8
reranker
kjarni_reranker_config_default
struct KjarniRerankerConfig kjarni_reranker_config_default(void);
Get default reranker configuration
kjarni_reranker_new
enum KjarniErrorCode kjarni_reranker_new(const struct KjarniRerankerConfig *config, struct KjarniReranker **out);
Create a new Reranker
Safety
outmust be null, or a live handle returned bykjarni_reranker_newthat has not been freed.
kjarni_reranker_free
void kjarni_reranker_free(struct KjarniReranker *reranker);
Free a Reranker
Safety
rerankermust be null, or a handle returned bykjarni_reranker_newthat has not already been passed to this function. It is invalid to use afterwards.
kjarni_reranker_score
enum KjarniErrorCode kjarni_reranker_score(struct KjarniReranker *reranker, const char *query, const char *document, float *out);
Score a single query-document pair
Safety
rerankermust be null, or a live handle returned bykjarni_reranker_newthat has not been freed.querymust be null, or a valid pointer to a nul-terminated C string.documentmust be null, or a valid pointer to a nul-terminated C string.outmust be a valid, writable pointer to ac_float. It is written on both success and failure, and any buffers it receives are owned by the caller.
kjarni_reranker_rerank
enum KjarniErrorCode kjarni_reranker_rerank(struct KjarniReranker *reranker, const char *query, const char *const *documents, uintptr_t num_docs, struct KjarniRerankResults *out);
Rerank documents by relevance to query
Safety
rerankermust be null, or a live handle returned bykjarni_reranker_newthat has not been freed.querymust be null, or a valid pointer to a nul-terminated C string.documentsmust point tonum_docsreadable pointers, each null or a valid nul-terminated C string that stays valid for the call.outmust be a valid, writable pointer to aKjarniRerankResults. OnKJARNI_OKit receives a value the caller owns and must release with the matching*_free; on failure it is either cleared or left unmodified, and must not be read.
kjarni_reranker_rerank_top_k
enum KjarniErrorCode kjarni_reranker_rerank_top_k(struct KjarniReranker *reranker, const char *query, const char *const *documents, uintptr_t num_docs, uintptr_t top_k, struct KjarniRerankResults *out);
Rerank and return top-k results
Safety
rerankermust be null, or a live handle returned bykjarni_reranker_newthat has not been freed.querymust be null, or a valid pointer to a nul-terminated C string.documentsmust point tonum_docsreadable pointers, each null or a valid nul-terminated C string that stays valid for the call.outmust be a valid, writable pointer to aKjarniRerankResults. OnKJARNI_OKit receives a value the caller owns and must release with the matching*_free; on failure it is either cleared or left unmodified, and must not be read.
Kjarni runs the same engine on every platform: