Skip to content

Commit

Permalink
bug fix: embeddings -> embedding (#134)
Browse files Browse the repository at this point in the history
wrong spelling in embedding

---------

Co-authored-by: Daisy Mak <[email protected]>
  • Loading branch information
starrywheat and Daisy Mak authored Sep 19, 2023
1 parent 1499924 commit eb9da37
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/ragas/metrics/answer_relevance.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def __post_init__(self: t.Self):

def init_model(self: t.Self):
if self.embeddings is None:
self.embedding = OpenAIEmbeddings() # type: ignore
self.embeddings = OpenAIEmbeddings() # type: ignore

def _score_batch(
self: t.Self,
Expand Down Expand Up @@ -97,9 +97,10 @@ def _score_batch(
def calculate_similarity(
self: t.Self, question: str, generated_questions: list[str]
):
question_vec = np.asarray(self.embedding.embed_query(question)).reshape(1, -1)
assert self.embeddings is not None
question_vec = np.asarray(self.embeddings.embed_query(question)).reshape(1, -1)
gen_question_vec = np.asarray(
self.embedding.embed_documents(generated_questions)
self.embeddings.embed_documents(generated_questions)
)
norm = np.linalg.norm(gen_question_vec, axis=1) * np.linalg.norm(
question_vec, axis=1
Expand Down

0 comments on commit eb9da37

Please sign in to comment.