Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
OurBuilding Ambient Agents with LangGraph course is now available on LangChain Academy!
Open In ColabOpen on GitHub

UpstageEmbeddings

This notebook covers how to get started with Upstage embedding models.

Installation

Installlangchain-upstage package.

pip install -U langchain-upstage

Environment Setup

Make sure to set the following environment variables:

import os

os.environ["UPSTAGE_API_KEY"]="YOUR_API_KEY"

Usage

InitializeUpstageEmbeddings class.

from langchain_upstageimport UpstageEmbeddings

embeddings= UpstageEmbeddings(model="solar-embedding-1-large")
API Reference:UpstageEmbeddings

Useembed_documents to embed list of texts or documents.

doc_result= embeddings.embed_documents(
["Sung is a professor.","This is another document"]
)
print(doc_result)

Useembed_query to embed query string.

query_result= embeddings.embed_query("What does Sung do?")
print(query_result)

Useaembed_documents andaembed_query for async operations.

# 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"]
)

Using with vector store

You can useUpstageEmbeddings with vector store component. The following demonstrates a simple example.

from langchain_community.vectorstoresimport DocArrayInMemorySearch

vectorstore= DocArrayInMemorySearch.from_texts(
["harrison worked at kensho","bears like to eat honey"],
embedding=UpstageEmbeddings(model="solar-embedding-1-large"),
)
retriever= vectorstore.as_retriever()
docs= retriever.invoke("Where did Harrison work?")
print(docs)

Related


[8]ページ先頭

©2009-2025 Movatter.jp