🤖
RAG를 활용한 LLM Application 개발 (feat. LangChain)
인프런 강의 바로가기 ↗️
  • RAG를 활용한 LLM Application 개발 (feat. LangChain)
  • 1. 강의의 목적과 대상
    • 1.1 우리가 만들어낼 결과물로 보는 강의의 목적
    • 1.2 강의자료
  • 2. 본격적인 개발 전 필요한 배경지식
    • 2.1 Retrieval Augmented Generation(RAG)란?
    • 2.2 Vector Database와 Embedding Model 성능 비교
  • 3. LangChain을 활용한 Retrieval Augmented Generation(RAG) 구성
    • 3.1 환경 설정과 LangChain의 ChatOpenAI를 활용한 검증
    • 3.2 LangChain과 Chroma를 활용한 RAG 구성
    • 3.3 LangChain 없이 구성하는 RAG의 불편함
    • 3.4 LangChain을 활용한 Vector Database 변경 (Chroma ➡️ Pinecone)
    • 3.5 Retrieval 효율 개선을 위한 데이터 전처리
    • 3.6 Retrieval 효율 개선을 위한 키워드 사전 활용
  • 4. Streamlit을 활용한 ChatBot 구현
    • 4.1 Streamlit 설치와 user message 작성
    • 4.2 LangChain으로 작성한 코드를 활용한 LLM 답변 생성
    • 4.3 Chat History추가와 streaming 구현
    • 4.4 Few Shot을 활용한 답변 정확도 향상과 포맷 수정
    • 4.5 Streamlit Cloud를 활용한 서비스 배포
  • 5. 서비스 배포했다고 끝이 아니다
    • 5.1 LangSmith를 활용한 LLM Evaluation
    • 5.2 이제는 AI Agent의 시대
Powered by GitBook
On this page
  1. 3. LangChain을 활용한 Retrieval Augmented Generation(RAG) 구성

3.4 LangChain을 활용한 Vector Database 변경 (Chroma ➡️ Pinecone)

Previous3.3 LangChain 없이 구성하는 RAG의 불편함Next3.5 Retrieval 효율 개선을 위한 데이터 전처리

Last updated 11 months ago

  • LangChain을 활용하면 쉽게 Vector Database 변경가능

  • LangChain 공식문서의 ↗️ 를 기준으로 보면 한줄만 변경하면 됨

# import
from langchain_chroma import Chroma
from langchain_community.document_loaders import TextLoader
from langchain_community.embeddings.sentence_transformer import (
    SentenceTransformerEmbeddings,
)
from langchain_text_splitters import CharacterTextSplitter

# load the document and split it into chunks
loader = TextLoader("../../how_to/state_of_the_union.txt")
documents = loader.load()

# split it into chunks
text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)
docs = text_splitter.split_documents(documents)

# create the open-source embedding function
embedding_function = SentenceTransformerEmbeddings(model_name="all-MiniLM-L6-v2")

# load it into Chroma


db = PineconeVectorStore.from_documents(docs, embeddings, index_name=index_name)


# query it
query = "What did the president say about Ketanji Brown Jackson"
docs = db.similarity_search(query)

# print results
print(docs[0].page_content)
Chroma 사용 가이드