Skip to content

MinishLab/korok

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Korok

Korok is a lightweight hybrid search and reranking package.

Installation

To install the package, run the following command:

make install

Quickstart

The following code snippet demonstrates how to use Korok for nearest neighbor search with a Model2Vec encoder:

from model2vec import StaticModel
from korok import Pipeline

# Create texts to encode
texts = ["triforce", "master sword", "hylian shield", "boomerang", "hookshot"]

# Initialize the encoder and pipeline
encoder = StaticModel.from_pretrained("minishlab/potion-base-8M")
pipeline = Pipeline.fit(texts=texts, encoder=encoder)

# Query for nearest neighbors
query_text = "sword"
results = pipeline.query([query_text], k=3)

Usage

Rerankers

The following code snippet demonstrates how to use Korok with a reranker:

from model2vec import StaticModel
from korok import Pipeline
from korok.rerankers import CrossEncoderReranker

# Create texts to encode
texts = ["triforce", "master sword", "hylian shield", "boomerang", "hookshot"]

# Initialize the encoder, reranker and pipeline
encoder = StaticModel.from_pretrained("minishlab/potion-base-8M")
reranker = CrossEncoderReranker()
pipeline = Pipeline.fit(texts=texts, encoder=encoder, reranker=reranker)

# Query for nearest neighbors with reranking
query_text = "sword"
results = pipeline.query([query_text], k=3)

About

Lightweight Hybrid Search and Reranking

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published