Skip to main content
Open In ColabOpen on GitHub

Upstage

Upstage is a leading artificial intelligence (AI) company specializing in delivering above-human-grade performance LLM components.

Solar Pro is an enterprise-grade LLM optimized for single-GPU deployment, excelling in instruction-following and processing structured formats like HTML and Markdown. It supports English, Korean, and Japanese with top multilingual performance and offers domain expertise in finance, healthcare, and legal.

Other than Solar, Upstage also offers features for real-world RAG (retrieval-augmented generation), such as Document Parse and Groundedness Check.

Upstage LangChain integrations

APIDescriptionImportExample usage
ChatBuild assistants using Solar Chatfrom langchain_upstage import ChatUpstageGo
Text EmbeddingEmbed strings to vectorsfrom langchain_upstage import UpstageEmbeddingsGo
Groundedness CheckVerify groundedness of assistant's responsefrom langchain_upstage import UpstageGroundednessCheckGo
Document ParseSerialize documents with tables and figuresfrom langchain_upstage import UpstageDocumentParseLoaderGo

See documentations for more details about the models and features.

Installation and Setup

Install langchain-upstage package:

pip install -qU langchain-core langchain-upstage

Get API Keys and set environment variable UPSTAGE_API_KEY.

import os

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

Chat models

Solar LLM

See a usage example.

from langchain_upstage import ChatUpstage

chat = ChatUpstage()
response = chat.invoke("Hello, how are you?")
print(response)
API Reference:ChatUpstage

Embedding models

See a usage example.

from langchain_upstage import UpstageEmbeddings

embeddings = UpstageEmbeddings(model="solar-embedding-1-large")
doc_result = embeddings.embed_documents(
["Sung is a professor.", "This is another document"]
)
print(doc_result)

query_result = embeddings.embed_query("What does Sung do?")
print(query_result)
API Reference:UpstageEmbeddings

Document loader

Document Parse

See a usage example.

from langchain_upstage import UpstageDocumentParseLoader

file_path = "/PATH/TO/YOUR/FILE.pdf"
layzer = UpstageDocumentParseLoader(file_path, split="page")

# For improved memory efficiency, consider using the lazy_load method to load documents page by page.
docs = layzer.load() # or layzer.lazy_load()

for doc in docs[:3]:
print(doc)

Tools

Groundedness Check

See a usage example.

from langchain_upstage import UpstageGroundednessCheck

groundedness_check = UpstageGroundednessCheck()

request_input = {
"context": "Mauna Kea is an inactive volcano on the island of Hawaii. Its peak is 4,207.3 m above sea level, making it the highest point in Hawaii and second-highest peak of an island on Earth.",
"answer": "Mauna Kea is 5,207.3 meters tall.",
}
response = groundedness_check.invoke(request_input)
print(response)

Was this page helpful?