ClovaXEmbeddings
This notebook covers how to get started with embedding models provided by CLOVA Studio.
Installationโ
# install package
!pip install -U langchain-community
Environment Setupโ
CLOVA Studio requires 3 keys (NCP_CLOVASTUDIO_API_KEY
, NCP_APIGW_API_KEY
and NCP_CLOVASTUDIO_APP_ID
) for embeddings.
NCP_CLOVASTUDIO_API_KEY
andNCP_CLOVASTUDIO_APP_ID
is issued per serviceApp or testAppNCP_APIGW_API_KEY
is issued per account
The two API Keys could be found by clicking App Request Status
> Service App, Test App List
> โDetailsโ button for each app
in CLOVA Studio.
import getpass
import os
os.environ["NCP_CLOVASTUDIO_API_KEY"] = getpass.getpass("NCP CLOVA Studio API Key: ")
os.environ["NCP_APIGW_API_KEY"] = getpass.getpass("NCP API Gateway API Key: ")
os.environ["NCP_CLOVASTUDIO_APP_ID"] = input("NCP CLOVA Studio App ID: ")
## Usage
- There are several embeddings models available in CLOVA Studio. Please refer [here](https://guide.ncloud-docs.com/docs/en/clovastudio-explorer03#์๋ฒ ๋ฉAPI) for further details.
from langchain_community.embeddings import ClovaXEmbeddings
embeddings = ClovaXEmbeddings(
#model="clir-emb-dolphin" #default is `clir-emb-dolphin`. change with the model name of corresponding App ID if needed.
)
API Reference:ClovaXEmbeddings
embeddings.embed_query("My query to look up")
embeddings.embed_documents(
["This is a content of the document", "This is another document"]
)
# async embed query
await embeddings.aembed_query("My query to look up")
# async embed documents
await embeddings.aembed_documents(
["This is a content of the document", "This is another document"]
)
Additional functionalitiesโ
Service Appโ
When going live with production-level application using CLOVA Studio, you should apply for and use Service App. (See here.)
For a Service App, corresponding NCP_CLOVASTUDIO_API_KEY
and NCP_CLOVASTUDIO_APP_ID
are issued and can only be called with the API Keys.
#### Update environment variables
os.environ["NCP_CLOVASTUDIO_API_KEY"] = getpass.getpass("NCP CLOVA Studio API Key for Service App: ")
os.environ["NCP_CLOVASTUDIO_APP_ID"] = input("NCP CLOVA Studio Service App ID: ")
embeddings = ClovaXEmbeddings(service_app=True)
Relatedโ
- Embedding model conceptual guide
- Embedding model how-to guides