Skip to content

Commit

Permalink
changed embedding model to HuggingFace mpnet
Browse files Browse the repository at this point in the history
  • Loading branch information
b3v committed Dec 4, 2024
1 parent 0283da1 commit a0b734e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app1.1.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from langchain.text_splitter import CharacterTextSplitter
from langchain.chat_models import ChatOpenAI
from langchain.schema import Document
from langchain.embeddings import HuggingFaceEmbeddings
import json

# Load environment variables from .env file
Expand All @@ -33,7 +34,8 @@ def setup_vector_store_from_json(json_data):
documents = [Document(page_content=item["content"], metadata={"url": item["url"]}) for item in json_data]

# Create embeddings and store them in FAISS
embeddings = OpenAIEmbeddings(openai_api_key=OPENAI_API_KEY)
#embeddings = OpenAIEmbeddings(openai_api_key=OPENAI_API_KEY)
embeddings = HuggingFaceEmbeddings(model_name="sentence-transformers/all-mpnet-base-v2")
vector_store = FAISS.from_documents(documents, embeddings)
return vector_store

Expand Down

0 comments on commit a0b734e

Please sign in to comment.