rise-ai / faq_train.py
markpeace's picture
first commit
76c5345
raw
history blame
744 Bytes
from langchain_community.document_loaders.csv_loader import CSVLoader
from langchain.text_splitter import CharacterTextSplitter
from langchain_openai import OpenAIEmbeddings
from langchain_community.vectorstores.faiss import FAISS
from dotenv import load_dotenv
from langchain.document_loaders import WebBaseLoader
load_dotenv();
documents = WebBaseLoader("https://rise.mmu.ac.uk/what-is-rise/").load()
# Split document in chunks
text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=30)
docs = text_splitter.split_documents(documents=documents)
embeddings = OpenAIEmbeddings()
# Create vectors
vectorstore = FAISS.from_documents(docs, embeddings)
# Persist the vectors locally on disk
vectorstore.save_local("_rise_faq_db");