Skip to content

Commit

Permalink
Update model.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Gautam-Rajeev authored Mar 19, 2024
1 parent e1ac251 commit 9a5d162
Showing 1 changed file with 1 addition and 32 deletions.
33 changes: 1 addition & 32 deletions src/embeddings/colbert/local/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,6 @@



class Model():
def __new__(cls, context):
cls.context = context
if not hasattr(cls, 'instance'):
cls.instance = super(Model, cls).__new__(cls)
# Initialize Colbert
cls.df = pd.read_csv('/Testing1.csv')
cls.df['PID'] = cls.df.index.astype(str)
with Run().context(RunConfig(experiment='notebook')):
cls.searcher = Searcher(index='import pandas as pd
from ragatouille import RAGPretrainedModel
from request import ModelRequest
from colbert import Indexer, Searcher
from colbert.infra import Run, RunConfig, ColBERTConfig
from colbert.data import Queries, Collection



class Model():
def __new__(cls, context):
cls.context = context
Expand All @@ -41,20 +23,7 @@ def __new__(cls, context):

async def inference(self, request: ModelRequest):
query = request.text
k = request.k
column_returned = 'id'
results = self.searcher.search(query, k)
searched_ids = self.df.loc[results[0], column_returned].to_list()
searched_content = self.df.loc[results[0], 'content'].to_list()
return {"ids": searched_ids, "content": searched_content, "scores": results[2]}
/', collection=cls.df['content'].to_list())
print(cls.df.columns)

return cls.instance

async def inference(self, request: ModelRequest):
query = request.text
k = request.k
k = int(request.k )
column_returned = 'id'
results = self.searcher.search(query, k)
searched_ids = self.df.loc[results[0], column_returned].to_list()
Expand Down

0 comments on commit 9a5d162

Please sign in to comment.