BA-Chatbot/backend/embeddings/llama.py

18 lines
434 B
Python
Raw Permalink Normal View History

2023-11-15 14:28:48 +01:00
from llama_cpp import Llama
class Embedder:
def __init__(self, llama_model_path:str) -> None:
self.llama = Llama(
model_path=llama_model_path,
n_ctx=2048,
n_parts=1,
f16_kv=3,
embedding=True,
)
def embed_text_llama(self, doc: str):
embeddings_query = self.llama.embed(doc)
return embeddings_query