Oracle Cloud Infrastructure Generative AI
Oracle Cloud Infrastructure Generative AI
Oracle Cloud Infrastructure (OCI) Generative AI는 다양한 사용 사례를 아우르는 최신의 커스터마이징 가능한 대규모 언어 모델(LLM) 세트를 단일 API로 제공하는 완전 관리형 서비스예요. OCI Generative AI 서비스를 사용하면 바로 사용 가능한 사전 훈련 모델에 접근하거나, 전용 AI 클러스터에서 자체 데이터를 바탕으로 미세조정한 커스텀 모델을 만들고 호스팅할 수 있어요. 서비스와 API에 대한 자세한 문서는 **여기**와 **여기**에서 확인할 수 있어요.
이 노트북은 LlamaIndex에서 OCI의 Generative AI 임베딩 모델을 사용하는 방법을 설명해요.
출처: 문서
본문
설정 (Setup)
Colab에서 이 노트북을 여는 경우라면 LlamaIndex 🦙 설치가 필요할 거예요.
%pip install llama-index-embeddings-oci-genai
!pip install llama-index
또한 OCI SDK도 설치해야 해요.
!pip install -U oci
기본 사용법 (Basic Usage)
from llama_index.embeddings.oci_genai import OCIGenAIEmbeddings
embedding = OCIGenAIEmbeddings(
model_name="cohere.embed-english-light-v3.0",
service_endpoint="https://inference.generativeai.us-chicago-1.oci.oraclecloud.com",
compartment_id="MY_OCID",
)
e1 = embedding.get_text_embedding("This is a test document")
print(e1[-5:])
e2 = embedding.get_query_embedding("This is a test document")
print(e2[-5:])
docs = ["This is a test document", "This is another test document"]
e3 = embedding.get_text_embedding_batch(docs)
print(e3)