A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://python.langchain.com/docs/integrations/text_embedding/upstage below:

UpstageEmbeddings | 🦜️🔗 LangChain

UpstageEmbeddings

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

Installation

Install langchain-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

Initialize UpstageEmbeddings class.

from langchain_upstage import UpstageEmbeddings

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

Use embed_documents to embed list of texts or documents.

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

Use embed_query to embed query string.

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

Use aembed_documents and aembed_query for async operations.


await embeddings.aembed_query("My query to look up")

await embeddings.aembed_documents(
["This is a content of the document", "This is another document"]
)
Using with vector store

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

from langchain_community.vectorstores import 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)

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4