Skip to content

Commit

Permalink
add to pip
Browse files Browse the repository at this point in the history
  • Loading branch information
ArvinZhuang committed Mar 29, 2024
1 parent 9e0e425 commit 5bcaa80
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 12 deletions.
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,18 @@ Pointwise, Listwise, Pairwise and [Setwise](https://arxiv.org/pdf/2310.09497.pdf
---
## Installation
Git clone this repository, then pip install the following libraries:
Install via PyP
```bash
pip install llmrankers
```
Or typically for development and research, clone this repo and install as editable,
```bash
https://github.com/ielab/llm-rankers.git
cd llm-rankers
pip install -e .
```

The code is tested with the following dependencies:
```bash
torch==2.0.1
transformers==4.31.0
Expand Down Expand Up @@ -54,8 +65,8 @@ In this repository, we use DL 2019 as an example. That is, we always re-rank `ru
### Python code example:

```Python
from rankers.setwise import SetwiseLlmRanker
from rankers.rankers import SearchResult
from llmrankers.setwise import SetwiseLlmRanker
from llmrankers.rankers import SearchResult

docs = [SearchResult(docid=i, text=f'this is passage {i}', score=None) for i in range(100)]
query = 'Give me passage 34'
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion rankers/listwise.py → llmrankers/listwise.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import tiktoken
from .rankers import LlmRanker, SearchResult
from typing import List, Tuple
from typing import List
import copy
import openai
import torch
Expand Down
2 changes: 1 addition & 1 deletion rankers/pairwise.py → llmrankers/pairwise.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List, Tuple
from typing import List
from .rankers import LlmRanker, SearchResult
from itertools import combinations
from collections import defaultdict
Expand Down
2 changes: 1 addition & 1 deletion rankers/pointwise.py → llmrankers/pointwise.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List, Tuple
from typing import List
from .rankers import LlmRanker, SearchResult
from transformers import T5Tokenizer, T5ForConditionalGeneration
from torch.utils.data import DataLoader
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion rankers/setwise.py → llmrankers/setwise.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List, Tuple
from typing import List
from .rankers import LlmRanker, SearchResult
import openai
import time
Expand Down
10 changes: 5 additions & 5 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
import ir_datasets
from pyserini.search.lucene import LuceneSearcher
from pyserini.search._base import get_topics
from rankers.rankers import SearchResult
from rankers.pointwise import PointwiseLlmRanker, MonoT5LlmRanker
from rankers.setwise import SetwiseLlmRanker, OpenAiSetwiseLlmRanker
from rankers.pairwise import PairwiseLlmRanker, DuoT5LlmRanker, OpenAiPairwiseLlmRanker
from rankers.listwise import OpenAiListwiseLlmRanker, ListwiseLlmRanker
from llmrankers.rankers import SearchResult
from llmrankers.pointwise import PointwiseLlmRanker, MonoT5LlmRanker
from llmrankers.setwise import SetwiseLlmRanker, OpenAiSetwiseLlmRanker
from llmrankers.pairwise import PairwiseLlmRanker, DuoT5LlmRanker, OpenAiPairwiseLlmRanker
from llmrankers.listwise import OpenAiListwiseLlmRanker, ListwiseLlmRanker
from tqdm import tqdm
import argparse
import sys
Expand Down
24 changes: 24 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from setuptools import setup, find_packages

with open("README.md", "r") as fh:
long_description = fh.read()

setup(
name='llm-rankers',
version='0.0.1',
packages=find_packages(),
url='https://github.com/ielab/llm-rankers',
license='Apache 2.0',
author='Shengyao Zhuang',
author_email='[email protected]',
description='Pointwise, Listwise, Pairwise and Setwise Document Ranking with Large Language Models.',
python_requires='>=3.8',
long_description=long_description,
long_description_content_type="text/markdown",
install_requires=[
"transformers>=4.31.0",
"openai>=0.27.10",
"tiktoken>=0.4.0",
"accelerate>=0.22.0"
]
)

0 comments on commit 5bcaa80

Please sign in to comment.