Skip to content

Commit

Permalink
add explanation for embedding
Browse files Browse the repository at this point in the history
  • Loading branch information
Leg0shii committed Oct 1, 2024
1 parent a31e35b commit 19a741a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion backend/app/ai.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ async def generate_summary(file_path: str) -> str:
)


# generate numerical representations of the text, capture semantic information
async def generate_embeddings(file_path: str) -> str:
try:
with open(file_path, "r", encoding="utf-8") as f:
Expand Down Expand Up @@ -108,7 +109,8 @@ async def perform_semantic_search(
logger.warning("No texts available for semantic search.")
return []

# Create the FAISS vector store with texts and metadata
# create a vector store from the collected texts and their embeddings
# vector store does efficient similarity searches by indexing the embeddings
vector_store = FAISS.from_texts(texts, embeddings, metadatas=metadatas)
similar_docs = vector_store.similarity_search(query, k=top_k)

Expand Down

0 comments on commit 19a741a

Please sign in to comment.