Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions graphrag/query/indexer_adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,12 @@ def embed_community_reports(
raise ValueError(error_msg)

if embedding_col not in reports_df.columns:
reports_df[embedding_col] = reports_df.loc[:, source_col].apply(
lambda x: embedder.embed(x)
)
# Avoid using .apply with a lambda for improved performance.
# Use a list comprehension, which is faster for element-wise operations in pandas.
src = reports_df[source_col].to_list()
# No change in behavior, ensures a list of same length as DataFrame
embeddings = [embedder.embed(x) for x in src]
reports_df[embedding_col] = embeddings

return reports_df

Expand Down