Giter Site home page Giter Site logo

search-and-reranking-system's Introduction

Search and ReRanking System

Description

This project combines the integration of Weaviate, a vector database, and Cohere, a natural language processing platform, to perform dense retrieval and reranking tasks.

Overview

The main components of this project are:

  1. app.py: The main application file that showcases different examples of dense retrieval and reranking using Weaviate and Cohere.
  2. utils.py: A utility module containing helper functions for keyword search, dense retrieval, and result printing.
  3. requirements.txt: A file listing the required Python dependencies for running the project.

Setup

  1. Install the required dependencies by running:
pip install -r requirements.txt
  1. Set up the necessary environment variables:

    COHERE_API_KEY: Your Cohere API key. WEAVIATE_API_KEY: Your Weaviate API key. WEAVIATE_API_URL: The URL of your Weaviate instance.

Examples

The app.py file contains three examples demonstrating different use cases:

Dense Retrieval:
    Performs a dense retrieval search using Weaviate's vector search capabilities.
    The query is "What is the capital of Canada?".
    The results are printed using the print_result function from utils.py.
Keyword Search with Reranking:
    Performs a keyword search using Weaviate's BM25 retrieval.
    The query is "What is the capital of Canada?".
    The top 500 results are retrieved and then reranked using Cohere's reranking model.
    The reranked results are printed.
Improving Dense Retrieval with Reranking:
    Performs a dense retrieval search using Weaviate's vector search capabilities.
    The query is "Who is the tallest person in history?".
    The retrieved results are then reranked using Cohere's reranking model.
    The reranked results are printed.

Utility Functions

The utils.py module provides the following utility functions:

keyword_search: Performs a keyword search using Weaviate's BM25 retrieval.
dense_retrieval: Performs a dense retrieval search using Weaviate's vector search capabilities.
print_result: Prints the search results with colorful formatting.

Getting Started

Make sure you have a Weaviate instance set up and running.
Obtain the necessary API keys from Cohere and Weaviate.
Set up the environment variables as mentioned in the Setup section.
Run the app.py file to see the examples in action:

```bash
python app.py
```

search-and-reranking-system's People

Contributors

alami64 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.