-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fix models according to new schema
- Loading branch information
Showing
3 changed files
with
23 additions
and
13 deletions.
There are no files selected for viewing
10 changes: 8 additions & 2 deletions
10
...uery-engine/unoplat_code_confluence_query_engine/embedding/unoplat_embedding_generator.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,20 @@ | ||
from sentence_transformers import SentenceTransformer | ||
from typing import List | ||
|
||
#TODO: this code is duplicated across ingestion and query engine. We will not refactor | ||
# as we move the embedding part to infrastructure such as vespa/marqo | ||
class UnoplatEmbeddingGenerator: | ||
def __init__(self, model_name: str): | ||
self.model = SentenceTransformer(model_name, trust_remote_code=True) | ||
|
||
self.dimensions = self.model.get_sentence_embedding_dimension() | ||
|
||
def generate_embeddings(self, texts: List[str]) -> List[List[float]]: | ||
task = 'retrieval.query' | ||
return self.model.encode(texts, task=task).tolist() | ||
|
||
def generate_embeddings_for_single_text(self, text: str) -> List[float]: | ||
task = 'retrieval.query' | ||
return self.model.encode(text, task=task, convert_to_tensor=False) | ||
return self.model.encode(text, task=task, convert_to_tensor=False) | ||
|
||
def get_dimensions(self) -> int: | ||
return self.dimensions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters