avatarLaxfed Paulacy

Free AI web copilot to create summaries, insights and extended knowledge, download it at here

1976

Abstract

response quality using semantic similarity scores and retrieval quality using the NDCG@10 metric. The results show that <code>voyage-01</code> surpasses OpenAI’s <code>text-embedding-ada-002</code> in both retrieval and response quality. Furthermore, <code>voyage-langchain-01</code> demonstrates the highest retrieval and response quality, indicating a strong correlation between retrieval quality and final response quality.</p><h2 id="0d30">Demonstrating examples</h2><p id="185f">Let’s showcase a few examples to illustrate how Voyage’s embeddings enable more accurate responses in the RAG stack.</p><h2 id="3818">Example 1: voyage-01 vs text-embedding-ada-002</h2><p id="0bd3">Given the query “What is html2texttransformer? Does it omit urls?”, <code>voyage-01</code> fetches the correct document, providing an accurate response. Meanwhile, <code>text-embedding-ada-002</code> retrieves a less relevant document, leading to a less accurate response.</p><h2 id="b128">Example 2: voyage-01 vs voyage-langchain-01</h2><p id="0bff">For the query “I’m running my own model using vllm. How do I connect it to LangChain?”, <code>voyage-01</code> fails to retrieve a relevant document, resulting in an inaccurate response. However, <code>voyage-langchain-01</code> retrieves the correct document and generates an accurate response.</p><h2 id="ae0d">Using Voyage in LangChain</h2><p id="78a1">To leverage Voyage embeddings in LangChain, you can integrate the <code>voyage-01</code> model into your applications. Here's a simple example demonstrating how to use Voyage to power KNN retrieval in LangChain:</p><div id="89e8"><pre><span class="hljs-keyword">from</span> langchain.embeddings import VoyageEmbeddings <span class="hljs-keyword">from</span> langchain.retrievers import KNNRetriever

texts = [ <span class="hljs-string">"Caching embeddings enables the storage or temporary caching of embeddings, eliminating the necessity to recompute them each time."</span>, <span cl

Options

ass="hljs-string">"The agent executor is the runtime for an agent. This is what actually calls the agent and executes the actions it chooses"</span>, <span class="hljs-string">"A Runnable represents a generic unit of work that can be invoked, batched, streamed, and/or transformed."</span> ]

embeddings = VoyageEmbeddings(<span class="hljs-attribute">model</span>=<span class="hljs-string">"voyage-01"</span>, <span class="hljs-attribute">batch_size</span>=8) retriever = KNNRetriever.from_texts(texts, embeddings, <span class="hljs-attribute">k</span>=1)

result = retriever.get_relevant_documents(<span class="hljs-string">"How do I build an agent?"</span>) <span class="hljs-built_in">print</span>(result[0].page_content)</pre></div><p id="4f1f">By following these steps, you can start using Voyage embeddings in LangChain to enhance the retrieval and response quality of your chatbot.</p><div id="506c" class="link-block"> <a href="https://readmedium.com/langchain-what-is-the-purpose-of-data-annotation-queue-a8b997e41d7a"> <div> <div> <h2>LANGCHAIN — What Is the Purpose of Data Annotation Queue?</h2> <div><h3>The most technologically efficient machine that man has ever invented is the book. — Northrop Frye</h3></div> <div><p>medium.com</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/1*nu7ZXSdSXeo6aCLEJYoZpg.jpeg)"></div> </div> </div> </a> </div><p id="89eb">In conclusion, the quality of the final response is highly correlated with the retrieval quality, emphasizing the importance of using high-quality embeddings in your RAG stack. By integrating Voyage embeddings such as <code>voyage-01</code> or <code>voyage-langchain-01</code> into LangChain, you can significantly improve the performance of your chatbot.</p></article></body>

LANGCHAIN — How Can Voyage Embeddings Enhance LangChain and Chat?

The most dangerous phrase in the language is, ‘We’ve always done it this way.’ — Grace Hopper

Voyage embeddings can significantly enhance LangChain and Chat by improving the retrieval quality and, consequently, the overall response quality. By integrating Voyage AI’s embedding models into LangChain, you can achieve more accurate and contextually informed responses in your chatbot. Let’s delve into how Voyage embeddings can be utilized in LangChain and explore some examples demonstrating their effectiveness.

Evaluating the effect of embeddings in the RAG stack

To understand the impact of embedding models on the retrieval-augmented generation (RAG) process, let’s consider an example comparing the retrieval and response quality of different embedding models. In this example, we’ll use Voyage’s generalist embedding model voyage-01 and an enhanced version fine-tuned on LangChain documents, voyage-langchain-01.

Measuring response and retrieval quality

We measure response quality using semantic similarity scores and retrieval quality using the NDCG@10 metric. The results show that voyage-01 surpasses OpenAI’s text-embedding-ada-002 in both retrieval and response quality. Furthermore, voyage-langchain-01 demonstrates the highest retrieval and response quality, indicating a strong correlation between retrieval quality and final response quality.

Demonstrating examples

Let’s showcase a few examples to illustrate how Voyage’s embeddings enable more accurate responses in the RAG stack.

Example 1: voyage-01 vs text-embedding-ada-002

Given the query “What is html2texttransformer? Does it omit urls?”, voyage-01 fetches the correct document, providing an accurate response. Meanwhile, text-embedding-ada-002 retrieves a less relevant document, leading to a less accurate response.

Example 2: voyage-01 vs voyage-langchain-01

For the query “I’m running my own model using vllm. How do I connect it to LangChain?”, voyage-01 fails to retrieve a relevant document, resulting in an inaccurate response. However, voyage-langchain-01 retrieves the correct document and generates an accurate response.

Using Voyage in LangChain

To leverage Voyage embeddings in LangChain, you can integrate the voyage-01 model into your applications. Here's a simple example demonstrating how to use Voyage to power KNN retrieval in LangChain:

from langchain.embeddings import VoyageEmbeddings
from langchain.retrievers import KNNRetriever

texts = [
  "Caching embeddings enables the storage or temporary caching of embeddings, eliminating the necessity to recompute them each time.",
  "The agent executor is the runtime for an agent. This is what actually calls the agent and executes the actions it chooses",
  "A Runnable represents a generic unit of work that can be invoked, batched, streamed, and/or transformed."
]

embeddings = VoyageEmbeddings(model="voyage-01", batch_size=8)
retriever = KNNRetriever.from_texts(texts, embeddings, k=1)

result = retriever.get_relevant_documents("How do I build an agent?")
print(result[0].page_content)

By following these steps, you can start using Voyage embeddings in LangChain to enhance the retrieval and response quality of your chatbot.

In conclusion, the quality of the final response is highly correlated with the retrieval quality, emphasizing the importance of using high-quality embeddings in your RAG stack. By integrating Voyage embeddings such as voyage-01 or voyage-langchain-01 into LangChain, you can significantly improve the performance of your chatbot.

Langchain
Embeddings
ChatGPT
Voyage
Enhance
Recommended from ReadMedium