์ด ํ์ด์ง์์๋ RAG ์ฝํผ์ค๋ฅผ Pinecone ๋ฐ์ดํฐ๋ฒ ์ด์ค์ ์ฐ๊ฒฐํ๋ ๋ฐฉ๋ฒ์ ๋ณด์ฌ์ค๋๋ค.
์ด Pinecone์ ์ฌ์ฉํ Vertex AI RAG Engine ๋ ธํธ๋ถ์ ์ฌ์ฉํ์ฌ ๋ฐ๋ผํ ์๋ ์์ต๋๋ค.
Vertex AI RAG Engine๊ณผ ํจ๊ป Pinecone ๋ฐ์ดํฐ๋ฒ ์ด์ค ์ธ์คํด์ค๋ฅผ ์ฌ์ฉํ์ฌ ์์ธ์ ์์ฑํ๊ณ ๋ฒกํฐ ๊ธฐ๋ฐ ์ ์ฌ์ฑ ๊ฒ์์ ์คํํ ์ ์์ต๋๋ค. ์ ์ฌ์ฑ ๊ฒ์์ ์ฐพ๊ณ ์๋ ํ ์คํธ์ ์ ์ฌํ ํ ์คํธ๋ฅผ ์ฐพ๋ ๋ฐฉ๋ฒ์ผ๋ก, ์๋ฒ ๋ฉ ๋ชจ๋ธ์ ์ฌ์ฉํด์ผ ํฉ๋๋ค. ์๋ฒ ๋ฉ ๋ชจ๋ธ์ ๋น๊ต๋๋ ๊ฐ ํ ์คํธ์ ๋ํ ๋ฒกํฐ ๋ฐ์ดํฐ๋ฅผ ์์ฑํฉ๋๋ค. ์ ์ฌ์ฑ ๊ฒ์์ LLM์์ ๊ฐ์ฅ ์ ํํ ์ฝํ ์ธ ๋ฅผ ๋ฐํํ๊ธฐ ์ํด ๊ทธ๋ผ์ด๋ฉ์ ์๋งจํฑ ์ปจํ ์คํธ๋ฅผ ๊ฒ์ํ๋ ๋ฐ ์ฌ์ฉ๋ฉ๋๋ค.
Vertex AI RAG Engine์ ์ฌ์ฉํ๋ฉด ํ๋ก๋น์ ๋ํ ์ฑ ์์ด ์๋ ์์ ๊ด๋ฆฌํ ๋ฒกํฐ ๋ฐ์ดํฐ๋ฒ ์ด์ค ์ธ์คํด์ค๋ฅผ ๊ณ์ ์ฌ์ฉํ ์ ์์ต๋๋ค. Vertex AI RAG Engine์ ์คํ ๋ฆฌ์ง, ์์ธ ๊ด๋ฆฌ, ๊ฒ์์ ๋ฒกํฐ ๋ฐ์ดํฐ๋ฒ ์ด์ค๋ฅผ ์ฌ์ฉํฉ๋๋ค.
Vertex AI RAG Engine์์ Pinecone์ ์ฌ์ฉํ ์ง ๊ณ ๋ ค
๋ค์์ ๊ฒํ ํ์ฌ Pinecone ๋ฐ์ดํฐ๋ฒ ์ด์ค๋ฅผ ์ฌ์ฉํ๋ ๊ฒ์ด RAG ์ ํ๋ฆฌ์ผ์ด์ ์ ๊ฐ์ฅ ์ ํฉํ ์ ํ์ธ์ง ๊ณ ๋ คํ์ธ์.
Pinecone ๋ฐ์ดํฐ๋ฒ ์ด์ค ์ธ์คํด์ค์ ํ์ฅ์ ๋ง๋ค๊ณ ๊ตฌ์ฑํ๊ณ ๊ด๋ฆฌํด์ผ ํฉ๋๋ค.
Vertex AI RAG Engine์ ์์ธ์ ๊ธฐ๋ณธ ๋ค์์คํ์ด์ค๋ฅผ ์ฌ์ฉํฉ๋๋ค. ์ด ๋ค์์คํ์ด์ค๋ ๋ค๋ฅธ ํญ๋ชฉ์์ ์์ ํ ์ ์์ด์ผ ํฉ๋๋ค.
Vertex AI RAG Engine์ด Pinecone ๋ฐ์ดํฐ๋ฒ ์ด์ค์ ์ํธ์์ฉํ ์ ์๋๋ก ํ๋ Pinecone API ํค๋ฅผ ์ ๊ณตํด์ผ ํฉ๋๋ค. Vertex AI RAG Engine์ Pinecone API ํค๋ฅผ ์ ์ฅํ๊ณ ๊ด๋ฆฌํ์ง ์์ต๋๋ค. ๋์ ๋ค์์ ์ํํด์ผ ํฉ๋๋ค.
- Google Cloud Secret Manager์ ํค๋ฅผ ์ ์ฅํฉ๋๋ค.
- ๋ณด์ ๋น๋ฐ์ ์ก์ธ์คํ ์ ์๋ ๊ถํ์ ํ๋ก์ ํธ์ ์๋น์ค ๊ณ์ ์ ๋ถ์ฌํฉ๋๋ค.
- Vertex AI RAG Engine์ ๋ณด์ ๋น๋ฐ์ ๋ฆฌ์์ค ์ด๋ฆ์ ๋ํ ์ก์ธ์ค ๊ถํ์ ๋ถ์ฌํฉ๋๋ค.
- RAG ์ฝํผ์ค์ ์ํธ์์ฉํ ๋ Vertex AI RAG Engine์ ์๋น์ค ๊ณ์ ์ ์ฌ์ฉํ์ฌ ๋ณด์ ๋น๋ฐ ๋ฆฌ์์ค์ ์ก์ธ์คํฉ๋๋ค.
RAG ์ฝํผ์ค์ Pinecone ์์ธ์ ์ผ๋์ผ๋ก ๋งคํ๋ฉ๋๋ค. ์ด ์ฐ๊ฒฐ์
CreateRagCorpus
API ํธ์ถ ๋๋UpdateRagCorpus
API ํธ์ถ์ ์ผ๋ถ๋ก ์ด๋ฃจ์ด์ง๋๋ค.
Pinecone ์์ธ ๋ง๋ค๊ธฐ
Pinecone ์์ธ์ ๋ง๋ค๋ ค๋ฉด ๋ค์ ๋จ๊ณ๋ฅผ ๋ฐ๋ฅด์ธ์.
์์ธ์ RAG ์ฝํผ์ค์ ํธํ๋๋๋ก ์์ธ์ ์ง์ ํด์ผ ํ๋ ์์ธ ๊ตฌ์ฑ์ ํ์ธํ๋ ค๋ฉด Pinecone ๋น ๋ฅธ ์์ ๊ฐ์ด๋๋ฅผ ์ฐธ๊ณ ํ์ธ์.
๋ค์๊ณผ ๊ฐ์ ์ด์ ๋ก Pinecone ์์ธ์ ์์น๊ฐ Vertex AI RAG Engine์ ์ฌ์ฉํ๋ ์์น์ ๋์ผํ๊ฑฐ๋ ๊ทธ ๊ทผ์ฒ์ ์์ด์ผ ํฉ๋๋ค.
- ์ง์ฐ ์๊ฐ์ ์ค์ด๋ ค๊ณ ํฉ๋๋ค.
- ๊ด๋ จ ๋ฒ๊ท์์ ์ ํ ๋ฐ์ดํฐ ์์ฃผ ์๊ตฌ์ฌํญ์ ์ถฉ์กฑํ๋ ค๊ณ ํฉ๋๋ค.
Pinecone ์์ธ์ ๋ง๋๋ ๋์ Vertex AI RAG Engine๊ณผ ํจ๊ป ์ฌ์ฉํ ์๋ฒ ๋ฉ ์ฐจ์์ ์ง์ ํฉ๋๋ค. ์ด ํ์๋ ์ฐจ์ ํฌ๊ธฐ ๋๋ ์ฐจ์ ํฌ๊ธฐ์ ์์น๊ฐ ๋์ ์์ต๋๋ค.
๋ชจ๋ธ ์ฐจ์ ํฌ๊ธฐ ํผ์คํธ ํํฐ Gecko 768 ๋ฏธ์ธ ์กฐ์ ๋ ํผ์คํธ ํํฐ Gecko 768 E5 OSS ์๋ฒ ๋ฉ ๋ชจ๋ธ ์ฌ์ฉ์ ์ฐธ๊ณ ํ์ธ์. ์ง์๋๋ ๋ค์ ๊ฑฐ๋ฆฌ ์ธก์ ํญ๋ชฉ ์ค ํ๋๋ฅผ ์ ํํฉ๋๋ค.
cosine
dotproduct
euclidean
์ ํ์ฌํญ: ํฌ๋ ๊ธฐ๋ฐ ์์ธ์ ๋ง๋ค ๋๋
pod.metadata_config.indexed
ํ๋์file_id
๋ฅผ ์ง์ ํด์ผ ํฉ๋๋ค. ์์ธํ ๋ด์ฉ์ ์ ํ์ ๋ฉํ๋ฐ์ดํฐ ์์ธ ์์ฑ์ ์ฐธ๊ณ ํ์ธ์.
Pinecone API ํค ๋ง๋ค๊ธฐ
Vertex AI RAG Engine์ ์ธ์ฆ ๋ฐ ์น์ธ์ API ํค๋ฅผ ์ฌ์ฉํ์ฌ Pinecone ์์ธ์๋ง ์ฐ๊ฒฐํ ์ ์์ต๋๋ค. Pinecone ํ๋ก์ ํธ์์ API ํค ๊ธฐ๋ฐ ์ธ์ฆ์ ๊ตฌ์ฑํ๋ ค๋ฉด ์ธ์ฆ์ ๊ดํ Pinecone ๊ณต์ ๊ฐ์ด๋๋ฅผ ๋ฐ๋ผ์ผ ํฉ๋๋ค.
Secret Manager์ API ํค ์ ์ฅ
API ํค์๋ ๋ฒ์ ์๊ฑด์ด ์ ์ฉ๋๋ ๋ฏผ๊ฐํ ๊ฐ์ธ ์๋ณ ์ ๋ณด(SPII)๊ฐ ํฌํจ๋ฉ๋๋ค. SPII ๋ฐ์ดํฐ๊ฐ ์ ์ถ๋๊ฑฐ๋ ์ค์ฉ๋๋ฉด ๊ฐ์ธ์๊ฒ ์ฌ๊ฐํ ์ํ์ด๋ ํผํด๊ฐ ๋ฐ์ํ ์ ์์ต๋๋ค. Vertex AI RAG Engine์ ์ฌ์ฉํ๋ ๋์ ๊ฐ์ธ์ ๋ํ ์ํ์ ์ต์ํํ๋ ค๋ฉด API ํค๋ฅผ ์ ์ฅ ๋ฐ ๊ด๋ฆฌํ์ง ๋ง์ธ์. ๋ํ ์ํธํ๋์ง ์์ API ํค๋ฅผ ๊ณต์ ํ์ง ๋ง์ธ์.
SPII๋ฅผ ๋ณดํธํ๋ ค๋ฉด ๋ค์ ๋จ๊ณ๋ฅผ ๋ฐ๋ฅด์ธ์.
Secret Manager์ API ํค๋ฅผ ์ ์ฅํฉ๋๋ค.
Vertex AI RAG Engine ์๋น์ค ๊ณ์ ์ ๋ณด์ ๋น๋ฐ์ ๋ํ ๊ถํ์ ๋ถ์ฌํ๊ณ ๋ณด์ ๋น๋ฐ ๋ฆฌ์์ค ์์ค์์ ์ก์ธ์ค ์ ์ด๋ฅผ ๊ด๋ฆฌํฉ๋๋ค.
ํ๋ก์ ํธ ๊ถํ์ผ๋ก ์ด๋ํฉ๋๋ค.
Google ์ ๊ณต ์ญํ ๋ถ์ฌ ํฌํจ ์ต์ ์ ์ฌ์ฉ ์ค์ ํฉ๋๋ค.
๋ค์๊ณผ ๊ฐ์ ํ์์ ์๋น์ค ๊ณ์ ์ ์ฐพ์ต๋๋ค.
service-{project number}@gcp-sa-vertex-rag.iam.gserviceaccount.com
์๋น์ค ๊ณ์ ์ ์ฃผ ๊ตฌ์ฑ์์ ์์ ํฉ๋๋ค.
Secret Manager Secret Accessor
์ญํ ์ ์๋น์ค ๊ณ์ ์ ์ถ๊ฐํฉ๋๋ค.
RAG ์ฝํผ์ค๋ฅผ ๋ง๋ค๊ฑฐ๋ ์ ๋ฐ์ดํธํ๋ ๋์ ๋ณด์ ๋น๋ฐ ๋ฆฌ์์ค ์ด๋ฆ์ Vertex AI RAG Engine์ ์ ๋ฌํ๊ณ ๋ณด์ ๋น๋ฐ ๋ฆฌ์์ค ์ด๋ฆ์ ์ ์ฅํฉ๋๋ค.
Pinecone ์์ธ์ API ์์ฒญ์ ์ํํ๋ฉด Vertex AI RAG Engine์ ๊ฐ ์๋น์ค ๊ณ์ ์ ์ฌ์ฉํ์ฌ ํ๋ก์ ํธ์์ Secret Manager์ ๋ณด์ ๋น๋ฐ ๋ฆฌ์์ค์ ํด๋นํ๋ API ํค๋ฅผ ์ฝ์ต๋๋ค.
Vertex AI RAG Engine ์๋น์ค ๊ณ์ ํ๋ก๋น์ ๋
ํ๋ก์ ํธ์์ ์ฒซ ๋ฒ์งธ RAG ์ฝํผ์ค๋ฅผ ๋ง๋ค๋ฉด Vertex AI RAG Engine์ด ์ ์ฉ ์๋น์ค ๊ณ์ ์ ๋ง๋ญ๋๋ค. ํ๋ก์ ํธ์ Identity and Access Management ํ์ด์ง์์ ์๋น์ค ๊ณ์ ์ ์ฐพ์ ์ ์์ต๋๋ค.
์๋น์ค ๊ณ์ ์ ๋ค์ ๊ณ ์ ํ์์ ๋ฐ๋ฆ ๋๋ค.
service-{project number}@gcp-sa-vertex-rag.iam.gserviceaccount.com
์๋ฅผ ๋ค๋ฉด ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
service-123456789@gcp-sa-vertex-rag.iam.gserviceaccount.com
RAG ์ฝํผ์ค ์ค๋น
Vertex AI RAG Engine์์ Pinecone ์์ธ์ ์ฌ์ฉํ๋ ค๋ฉด ์์ฑ ๋จ๊ณ์์ ์์ธ์ RAG ์ฝํผ์ค์ ์ฐ๊ฒฐํด์ผ ํฉ๋๋ค. ์ฐ๊ฒฐ์ด ์ด๋ฃจ์ด์ง๋ฉด ์ด ๋ฐ์ธ๋ฉ์ RAG ์ฝํผ์ค์ ์ ์ฒด ๊ธฐ๊ฐ ๋์ ์๊ตฌ์ ์ผ๋ก ์ ์ง๋ฉ๋๋ค. CreateRagCorpus
๋๋ UpdateRagCorpus
API๋ฅผ ์ฌ์ฉํ์ฌ ์ฐ๊ฒฐํ ์ ์์ต๋๋ค.
์ฐ๊ฒฐ์ด ์๋ฃ๋ ๊ฒ์ผ๋ก ๊ฐ์ฃผ๋๋ ค๋ฉด RAG ์ฝํผ์ค์ ๋ค์ ์ธ ๊ฐ์ง ํค ํ๋๋ฅผ ์ค์ ํด์ผ ํฉ๋๋ค.
rag_vector_db_config.pinecone
: ์ด ํ๋๋ RAG ์ฝํผ์ค์ ์ฐ๊ฒฐํ ๋ฒกํฐ ๋ฐ์ดํฐ๋ฒ ์ด์ค๋ฅผ ์ ํํ๋ ๋ฐ ๋์์ด ๋๋ฉฐCreateRagCorpus
API ํธ์ถ ์ค์ ์ค์ ํด์ผ ํฉ๋๋ค. ์ค์ ๋์ง ์์ ๊ฒฝ์ฐ ๊ธฐ๋ณธ ๋ฒกํฐ ๋ฐ์ดํฐ๋ฒ ์ด์ค ์ ํ์ฌํญRagManagedDb
๊ฐ RAG ์ฝํผ์ค์ ํ ๋น๋ฉ๋๋ค.rag_vector_db_config.pinecone.index_name
: RAG ์ฝํผ์ค์ ํจ๊ป ์ฌ์ฉ๋๋ Pinecone ์์ธ์ ๋ง๋๋ ๋ฐ ์ฌ์ฉ๋๋ ์ด๋ฆ์ ๋๋ค.CreateRagCorpus
ํธ์ถ ์ค์ ์ด๋ฆ์ ์ค์ ํ๊ฑฐ๋UpdateRagCorpus
API๋ฅผ ํธ์ถํ ๋ ์ด๋ฆ์ ์ง์ ํ ์ ์์ต๋๋ค.rag_vector_db_config.api_auth.api_key_config.api_key_secret_version
: Secret Manager์ ์ ์ฅ๋ ๋ณด์ ๋น๋ฐ์ ์ ์ฒด ๋ฆฌ์์ค ์ด๋ฆ์ผ๋ก, Pinecone API ํค๊ฐ ํฌํจ๋์ด ์์ต๋๋ค.CreateRagCorpus
ํธ์ถ ์ค์ ์ด๋ฆ์ ์ค์ ํ๊ฑฐ๋UpdateRagCorpus
API๋ฅผ ํธ์ถํ ๋ ์ด๋ฆ์ ์ง์ ํ ์ ์์ต๋๋ค. ์ด ํ๋๋ฅผ ์ง์ ํ ๋๊น์ง๋ ๋ฐ์ดํฐ๋ฅผ RAG ์ฝํผ์ค์ ๊ฐ์ ธ์ฌ ์ ์์ต๋๋ค.
์ด ํ๋์ ํ์์ ๋ค์๊ณผ ๊ฐ์์ผ ํฉ๋๋ค.
projects/{PROJECT_NUMBER}/secrets/{SECRET_ID}/versions/{VERSION_ID}
RAG ์ฝํผ์ค ๋ง๋ค๊ธฐ
๊ถํ์ด ์ค์ ๋ Pinecone ์์ธ ์ด๋ฆ๊ณผ ๋ณด์ ๋น๋ฐ ๋ฆฌ์์ค ์ด๋ฆ์ ์ก์ธ์คํ ์ ์๋ ๊ฒฝ์ฐ RAG ์ฝํผ์ค๋ฅผ ๋ง๋ค๊ณ Pinecone ์์ธ๊ณผ ์ฐ๊ฒฐํ ์ ์์ต๋๋ค. ์ด ์ํ ์ฝ๋์์ ์ด๋ฅผ ๋ณด์ฌ์ค๋๋ค.
RAG ์ฝํผ์ค๋ฅผ ์ฒ์ ๋ง๋๋ ๊ฒฝ์ฐ ์๋น์ค ๊ณ์ ์ ๋ณด๊ฐ ์ค๋น๋์ด ์์ง ์์ต๋๋ค. ๊ทธ๋ฌ๋ ์ด ํ๋๋ ์ ํ์ฌํญ์ด๋ฉฐ UpdateRagCorpus
API๋ฅผ ์ฌ์ฉํ์ฌ RAG ์ฝํผ์ค์ ์ฐ๊ฒฐํ ์ ์์ต๋๋ค.
์๋น์ค ๊ณ์ ์ ๋ณด๋ฅผ ์ ๊ณตํ์ง ์๊ณ RAG ์ฝํผ์ค๋ฅผ ๋ง๋๋ ๋ฐฉ๋ฒ์ ์์๋ ์์ธ ์ด๋ฆ ๋๋ API ํค ์์ด RAG ์ฝํผ์ค ๋ง๋ค๊ธฐ๋ฅผ ์ฐธ๊ณ ํ์ธ์.
Python
์ด ์ํ์ ์ฌ์ฉํด ๋ณด๊ธฐ ์ ์ Vertex AI ๋น ๋ฅธ ์์: ํด๋ผ์ด์ธํธ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ฌ์ฉ์ Python ์ค์ ์๋ด๋ฅผ ๋ฐ๋ฅด์ธ์. ์์ธํ ๋ด์ฉ์ Vertex AI Python API ์ฐธ๊ณ ๋ฌธ์๋ฅผ ์ฐธ์กฐํ์ธ์.
Vertex AI์ ์ธ์ฆํ๋ ค๋ฉด ์ ํ๋ฆฌ์ผ์ด์ ๊ธฐ๋ณธ ์ฌ์ฉ์ ์ธ์ฆ ์ ๋ณด๋ฅผ ์ค์ ํฉ๋๋ค. ์์ธํ ๋ด์ฉ์ ๋ก์ปฌ ๊ฐ๋ฐ ํ๊ฒฝ์ ์ธ์ฆ ์ค์ ์ ์ฐธ์กฐํ์ธ์.
REST
# Set your project ID under which you want to create the corpus
PROJECT_ID = "YOUR_PROJECT_ID"
# Choose a display name for your corpus
CORPUS_DISPLAY_NAME=YOUR_CORPUS_DISPLAY_NAME
# Set your Pinecone index name
PINECONE_INDEX_NAME=YOUR_INDEX_NAME
# Set the full resource name of your secret. Follows the format
# projects/{PROJECT_NUMER}/secrets/{SECRET_ID}/versions/{VERSION_ID}
SECRET_RESOURCE_NAME=YOUR_SECRET_RESOURCE_NAME
# Call CreateRagCorpus API with all the Vector DB information.
# You can also add the embedding model choice or set other RAG corpus parameters on
# this call per your choice.
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
https://us-central1-aiplatform.googleapis.com}/v1beta1/projects/${PROJECT_ID}/locations/us-central1/ragCorpora -d '{
"display_name" : '\""${CORPUS_DISPLAY_NAME}"\"',
"rag_vector_db_config" : {
"pinecone": {"index_name": '\""${PINECONE_INDEX_NAME}"\"'},
"api_auth": {"api_key_config":
{"api_key_secret_version": '\""${SECRET_RESOURCE_NAME}"\"'}
}
}
}'
# To poll the status of your RAG corpus creation, get the operation_id returned in
# response of your CreateRagCorpus call.
OPERATION_ID="YOUR_OPERATION_ID"
# Poll Operation status until done = true in the response.
# The response to this call will contain the ID for your created RAG corpus
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
https://us-central1-aiplatform.googleapis.com/v1beta1/projects/${PROJECT_ID}/locations/us-central1/operations/${OPERATION_ID}
์์ธ ์ด๋ฆ ๋๋ API ํค ์์ด RAG ์ฝํผ์ค ๋ง๋ค๊ธฐ
์ฒซ ๋ฒ์งธ RAG ์ฝํผ์ค์ด๋ฉฐ ์๋น์ค ๊ณ์ ์ธ๋ถ์ ๋ณด์ ์ก์ธ์คํ ์ ์๊ฑฐ๋ Pinecone ์์ธ์ ํ๋ก๋น์ ๋ ๋จ๊ณ๋ฅผ ์๋ฃํ์ง ์์ ๊ฒฝ์ฐ์๋ RAG ์ฝํผ์ค๋ฅผ ๋ง๋ค ์ ์์ต๋๋ค. ๊ทธ๋ฐ ๋ค์ RAG ์ฝํผ์ค๋ฅผ ๋น Pinecone ๊ตฌ์ฑ๊ณผ ์ฐ๊ฒฐํ๊ณ ๋์ค์ ์ธ๋ถ์ ๋ณด๋ฅผ ์ถ๊ฐํ ์ ์์ต๋๋ค.
๋ค์ ์ฌํญ์ ๊ณ ๋ คํด์ผ ํฉ๋๋ค.
- ์์ธ ์ด๋ฆ๊ณผ API ํค ๋ณด์ ๋น๋ฐ ์ด๋ฆ์ ์ ๊ณตํ์ง ์์ผ๋ฉด ํ์ผ์ RAG ์ฝํผ์ค์ ๊ฐ์ ธ์ฌ ์ ์์ต๋๋ค.
- RAG ์ฝํผ์ค์ ๋ฒกํฐ ๋ฐ์ดํฐ๋ฒ ์ด์ค๋ก Pinecone์ ์ ํํ๋ฉด ๋์ค์ ๋ค๋ฅธ ๋ฐ์ดํฐ๋ฒ ์ด์ค๋ก ์ ํํ ์ ์์ต๋๋ค.
์ด ์ฝ๋ ์์์์๋ Pinecone ์์ธ ์ด๋ฆ์ด๋ API ๋ณด์ ๋น๋ฐ ์ด๋ฆ์ ์ ๊ณตํ์ง ์๊ณ Pinecone์ผ๋ก RAG ์ฝํผ์ค๋ฅผ ๋ง๋๋ ๋ฐฉ๋ฒ์ ๋ณด์ฌ์ค๋๋ค. UpdateRagCorpus
API๋ฅผ ์ฌ์ฉํ์ฌ ๋์ค์ ๋๋ฝ๋ ์ ๋ณด๋ฅผ ์ง์ ํฉ๋๋ค.
Python
import vertexai
from vertexai.preview import rag
# Set Project
PROJECT_ID = "YOUR_PROJECT_ID"
vertexai.init(project=PROJECT_ID, location="us-central1")
# Configure the Pinecone vector DB information
vector_db = rag.Pinecone()
# Name your corpus
DISPLAY_NAME = "YOUR_CORPUS_NAME"
rag_corpus = rag.create_corpus(display_name=DISPLAY_NAME, vector_db=vector_db)
REST
# Set your project ID under which you want to create the corpus
PROJECT_ID = "YOUR_PROJECT_ID"
# Choose a display name for your corpus
CORPUS_DISPLAY_NAME=YOUR_CORPUS_DISPLAY_NAME
# Call CreateRagCorpus API with all the Vector DB information.
# You can also add the embedding model choice or set other RAG corpus parameters on
# this call per your choice.
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
https://us-central1-aiplatform.googleapis.com}/v1beta1/projects/${PROJECT_ID}/locations/us-central1/ragCorpora -d '{
"display_name" : '\""${CORPUS_DISPLAY_NAME}"\"',
"rag_vector_db_config" : {
"pinecone": {}
}
}'
# To poll the status of your RAG corpus creation, get the operation_id returned in
# response of your CreateRagCorpus call.
OPERATION_ID="YOUR_OPERATION_ID"
# Poll Operation status until done = true in the response.
# The response to this call will contain the ID for your created RAG corpus
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
https://us-central1-aiplatform.googleapis.com/v1beta1/projects/${PROJECT_ID}/locations/us-central1/operations/${OPERATION_ID}
RAG ์ฝํผ์ค ์ ๋ฐ์ดํธ
UpdateRagCorpus
API๋ฅผ ์ฌ์ฉํ๋ฉด ๋ฒกํฐ ๋ฐ์ดํฐ๋ฒ ์ด์ค ๊ตฌ์ฑ์ ์
๋ฐ์ดํธํ ์ ์์ต๋๋ค.
Pinecone ์์ธ ์ด๋ฆ๊ณผ API ํค ๋ณด์ ๋น๋ฐ ๋ฒ์ ์ด ์ด์ ์ ์ค์ ๋์ง ์์ ๊ฒฝ์ฐ Pinecone API๋ฅผ ์ฌ์ฉํ์ฌ ํ๋๋ฅผ ์
๋ฐ์ดํธํ ์ ์์ต๋๋ค. ์ ํํ ๋ฒกํฐ ๋ฐ์ดํฐ๋ฒ ์ด์ค๋ฅผ ์
๋ฐ์ดํธํ ์ ์์ต๋๋ค. API ํค ๋ณด์ ๋น๋ฐ์ ์ ๊ณตํ๋ ๊ฒ์ ์ ํ์ฌํญ์
๋๋ค. ํ์ง๋ง API ํค ๋ณด์ ๋น๋ฐ์ ์ง์ ํ์ง ์์ผ๋ฉด ๋ฐ์ดํฐ๋ฅผ RAG ์ฝํผ์ค์ ๊ฐ์ ธ์ฌ ์ ์์ต๋๋ค.
ํ๋ | ๋ณ๊ฒฝ ๊ฐ๋ฅ ์ฌ๋ถ | ํ์ ๋๋ ์ ํ์ฌํญ |
---|---|---|
rag_vector_db_config.vector_db |
์ ํํ ํ์๋ ๋ณ๊ฒฝํ ์ ์์ต๋๋ค. | ํ์ |
rag_vector_db_config.pinecone.index_name |
RAG ์ฝํผ์ค์์ ํ๋๋ฅผ ์ค์ ํ๋ฉด ๋ณ๊ฒฝํ ์ ์์ต๋๋ค. | ํ์ |
rag_vector_db_config.api_auth.api_key_config.api_key_secret_version |
๋ณ๊ฒฝ ๊ฐ๋ฅํฉ๋๋ค. API ํค๋ฅผ ์ค์ ํ ํ์๋ ํค๋ฅผ ์ญ์ ํ ์ ์์ต๋๋ค. | ์ ํ์ฌํญ |
Python
import vertexai
from vertexai.preview import rag
# Set Project
PROJECT_ID = "YOUR_PROJECT_ID"
vertexai.init(project=PROJECT_ID, location="us-central1")
# Configure the Pinecone vector DB information
vector_db = rag.Pinecone(index_name=)
# Name your corpus
DISPLAY_NAME = "YOUR_CORPUS_NAME"
rag_corpus = rag.create_corpus(display_name=DISPLAY_NAME, vector_db=vector_db)
REST
# Set your project ID for the corpus that you want to create.
PROJECT_ID = "YOUR_PROJECT_ID"
# Set your Pinecone index name
PINECONE_INDEX_NAME=YOUR_INDEX_NAME
# Set the full resource name of your secret. Follows the format
# projects/{PROJECT_NUMER}/secrets/{SECRET_ID}/versions/{VERSION_ID}
SECRET_RESOURCE_NAME=YOUR_SECRET_RESOURCE_NAME
# Call UpdateRagCorpus API with the Vector DB information.
curl -X PATCH \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
https://us-central1-aiplatform.googleapis.com}/v1beta1/projects/${PROJECT_ID}/locations/us-central1/ragCorpora -d '{
"rag_vector_db_config" : {
"pinecone": {"index_name": '\""${PINECONE_INDEX_NAME}"\"'},
"api_auth": {"api_key_config":
{"api_key_secret_version": '\""${SECRET_RESOURCE_NAME}"\"'}
}
}
}'
# To poll the status of your RAG corpus creation, get the operation_id returned in
# response of your CreateRagCorpus call.
OPERATION_ID="YOUR_OPERATION_ID"
# Poll Operation status until done = true in the response.
# The response to this call will contain the ID for your created RAG corpus
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
https://us-central1-aiplatform.googleapis.com/v1beta1/projects/${PROJECT_ID}/locations/us-central1/operations/${OPERATION_ID}