Published on

6 Reasons to Build Your Augmented Application with Langchain

Authors

Langchain is an framework designed to leverage Generative AI in the most straightforward way. As Large Language Models (LLMs) continue to evolve and improve, Langchain provides developers with a range of powerful tools to integrate and utilize these cutting-edge technologies. Here are six reasons why you should consider building your next augmented application with Langchain.

1. Broad LLM Support

As more LLMs are developed, each with its unique strengths, it's becoming increasingly important to integrate multiple models into production for large applications. It will also become more likely that at some point, you will want to change a LLM by another. With the abstraction provided by Langchain, you won't need to rewrite your code. These abstractions allow developers to work with various LLMs without having to learn all of their SDKs, making integration a breeze.

2. Advanced Prompt Templating

Researchers and LLM users agree that some prompts produce better results than others. Knowing the best practices for every case can be challenging. Langchain addresses this by implementing a prompt templating system that makes it easy to reuse best practices and provides default templates for all use cases, ensuring developers always have access to the latest prompt best practices.

3. Utility Functions For Loading Data From Various Sources

When building an augmented application, you often need data from various sources, such as databases, word documents, APIs, and PDFs. Langchain simplifies this process by offering numerous utility functions for loading data from different sources. One use case loved by the community is the Notion loader that creates a vector store in few lines of codes:

import { HNSWLib } from "langchain/vectorstores";
import { OpenAIEmbeddings } from "langchain/embeddings";
import { NotionLoader } from "langchain/document_loaders";

export const run = async () => {
/** Provide the directory path of your notion folder */
const directoryPath = "notion_extract";
const loader = new NotionLoader(directoryPath);
const docs = await loader.load();

/* This creates the vectorstore using the text-embedding-ada-002 model */
const vectorStore = await HNSWLib.fromDocuments(docs, new OpenAIEmbeddings());

vectorStore.save('notionVectorStore');
};

run();

4. High-Level Chains To Implement Complex Use Cases In A Few Lines Of Code

LLMs have unlocked numerous use cases that were previously unattainable. These use cases often require additional computation beyond simply querying an LLM. Langchain provides high-level "chains" that allow developers to implement complex use cases with just a few lines of code. As shown in the following example, you can easily create a chain to query your database using natural language.

const datasource = new DataSource({
    type: "sqlite",
    database: "Chinook.db",
  });

  const db = await SqlDatabase.fromDataSourceParams({
    appDataSource: datasource,
  });

  const chain = new SqlDatabaseChain({
    llm: new OpenAI({ temperature: 0 }),
    database: db,
  });

  const res = await chain.run("How many tracks are there?");
  console.log(res);

Under the hood there are several steps before being able to get the answer:

Steps under the hoods to query a database using the SqlDatabaseChain

5. Personal Assistant Capabilities

Langchain enables developers to create powerful personal assistants (agents), inspired by the infamous Auto-GPT. By building your personal assistant with Langchain, you can leverage the framework's chains, allowing your assistant to perform a wide range of actions and enhancing its overall capabilities.

6. Rapid Community Adoption backed up by a newly created company

Evolution of Github stars on Langchain repository

The good news is that the Langchain company has been created to support the growth of the framwork and has raised $10M. This secure a stable team for the future.

You can ask me a question and my personal AI will answer you.