Skip to content

Commit eb9da37

Browse files
starrywheatDaisy Mak
andauthored
bug fix: embeddings -> embedding (#134)
wrong spelling in embedding --------- Co-authored-by: Daisy Mak <[email protected]>
1 parent 1499924 commit eb9da37

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/ragas/metrics/answer_relevance.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def __post_init__(self: t.Self):
6161

6262
def init_model(self: t.Self):
6363
if self.embeddings is None:
64-
self.embedding = OpenAIEmbeddings() # type: ignore
64+
self.embeddings = OpenAIEmbeddings() # type: ignore
6565

6666
def _score_batch(
6767
self: t.Self,
@@ -97,9 +97,10 @@ def _score_batch(
9797
def calculate_similarity(
9898
self: t.Self, question: str, generated_questions: list[str]
9999
):
100-
question_vec = np.asarray(self.embedding.embed_query(question)).reshape(1, -1)
100+
assert self.embeddings is not None
101+
question_vec = np.asarray(self.embeddings.embed_query(question)).reshape(1, -1)
101102
gen_question_vec = np.asarray(
102-
self.embedding.embed_documents(generated_questions)
103+
self.embeddings.embed_documents(generated_questions)
103104
)
104105
norm = np.linalg.norm(gen_question_vec, axis=1) * np.linalg.norm(
105106
question_vec, axis=1

0 commit comments

Comments
 (0)