Instructions to use Kushalguptaiitb/table_test with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Kushalguptaiitb/table_test with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("object-detection", model="Kushalguptaiitb/table_test")# pip install -U transformers accelerate # Load model directly from transformers import AutoImageProcessor, AutoModelForObjectDetection processor = AutoImageProcessor.from_pretrained("Kushalguptaiitb/table_test") model = AutoModelForObjectDetection.from_pretrained("Kushalguptaiitb/table_test", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Delete reranker.py
Browse files- reranker.py +0 -32
reranker.py
DELETED
|
@@ -1,32 +0,0 @@
|
|
| 1 |
-
from rank_bm25 import BM25Okapi
|
| 2 |
-
from typing import List, Dict
|
| 3 |
-
|
| 4 |
-
class Reranker:
|
| 5 |
-
def __init__(self):
|
| 6 |
-
self.tokenized_docs = []
|
| 7 |
-
self.bm25 = None
|
| 8 |
-
|
| 9 |
-
def prepare(self, documents: List[Dict]):
|
| 10 |
-
"""Prepare the reranker with documents."""
|
| 11 |
-
self.tokenized_docs = [doc['content'].split() for doc in documents]
|
| 12 |
-
self.bm25 = BM25Okapi(self.tokenized_docs)
|
| 13 |
-
|
| 14 |
-
def rerank(self, query: str, initial_results: List[Dict], top_k: int) -> List[Dict]:
|
| 15 |
-
"""Rerank initial search results using BM25."""
|
| 16 |
-
tokenized_query = query.split()
|
| 17 |
-
scores = self.bm25.get_scores(tokenized_query)
|
| 18 |
-
|
| 19 |
-
# Combine initial scores with BM25 scores
|
| 20 |
-
reranked = []
|
| 21 |
-
for idx, result in enumerate(initial_results):
|
| 22 |
-
doc_idx = int(result['id'].split('_')[1])
|
| 23 |
-
combined_score = result['score'] + scores[doc_idx]
|
| 24 |
-
reranked.append({
|
| 25 |
-
'id': result['id'],
|
| 26 |
-
'content': result['content'],
|
| 27 |
-
'score': combined_score
|
| 28 |
-
})
|
| 29 |
-
|
| 30 |
-
# Sort by combined score
|
| 31 |
-
reranked.sort(key=lambda x: x['score'], reverse=True)
|
| 32 |
-
return reranked[:top_k]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|