From 1cf0a401054c3e3ebde60bfd73ad15e39bc531e6 Mon Sep 17 00:00:00 2001 From: Gustaf Rydholm Date: Fri, 5 Apr 2024 00:42:02 +0200 Subject: Rename llm --- rag/llms/encoder.py | 24 ------------------------ 1 file changed, 24 deletions(-) delete mode 100644 rag/llms/encoder.py (limited to 'rag/llms/encoder.py') diff --git a/rag/llms/encoder.py b/rag/llms/encoder.py deleted file mode 100644 index 758b523..0000000 --- a/rag/llms/encoder.py +++ /dev/null @@ -1,24 +0,0 @@ -from typing import List -import ollama -import numpy as np - -# FIXME: .env -ENCODER_MODEL = "mxbai-embed-large" - - -class Encoder: - def __init__(self) -> None: - self.query_prompt = "Represent this sentence for searching relevant passages: " - - def __encode(self, prompt: str) -> np.ndarray: - x = ollama.embeddings(model=ENCODER_MODEL, prompt=prompt) - x = np.array([x["embedding"]]).astype("float32") - return x - - def encode(self, doc: List[str]) -> List[np.ndarray]: - return [self.__encode(chunk) for chunk in doc] - - def query(self, query: str) -> np.ndarray: - query = self.query_prompt + query - return self.__encode(query) - -- cgit v1.2.3-70-g09d2