본문 바로가기
카테고리 없음

Langchain

by 조병희 2023. 4. 17.

LangChain은 언어 모델을 기반으로 하는 애플리케이션을 개발하기 위한 프레임워크입니다. LangChain은 다음 원칙을 고려하여 설계되었습니다.

  • 데이터 인식: 언어 모델을 다른 데이터 소스에 연결합니다.
  • 에이전트 기능: 언어 모델이 환경과 상호작용할 수 있도록 합니다.

LangChain은 Python과 JavaScript 문서가 있으며, 여러 가지 모듈을 지원합니다. 각 모듈에는 시작하는 방법, 참고 문서, 개념 가이드, 사용 예제가 포함됩니다. LangChain은 개인 비서, 질문에 대한 답변, 챗봇, 구조화된 정보 추출, 요약, 평가 등의 다양한 유스케이스를 지원합니다.

LangChain의 대표적인 사용 사례는 개인 비서(Personal Assistants)입니다. 개인 비서는 작업을 수행하고 상호작용을 기억하며 데이터에 대한 지식이 필요합니다. 두 번째로 중요한 사용 사례는 Question Answering입니다. 문서에 대한 질문에 대답하며 해당 문서에 포함된 정보만 사용하여 대답을 구성합니다. 또한 언어 모델은 텍스트 생성에 능숙하기 때문에 챗봇(Chatbots)을 만드는 데 이상적입니다. 또한 LLMs를 사용하여 탭형식의 데이터(csvs, SQL, 데이터 프레임 등)를 쿼리하는 방법을 이해하려면 쿼리 탭형식 데이터 페이지를 참조해야 합니다. 깃허브에서 소스 코드를 쿼리하는 방법을 이해하려면 코드 이해 페이지를 읽어야 합니다. 또한 LLMs가 API와 상호작용하도록 하는 것은 최신 정보를 제공하고 작업을 수행할 수 있도록 하는 데 굉장히 강력합니다. 텍스트에서 구조화된 정보를 추출하는 Extraction, 긴 문서를 요약하여 더 짧고 간략한 정보로 만드는 Summarization, 그리고 평가(Evaluation)도 있습니다. 생성 모델은 전통적인 지표로 평가하기가 어려운데, 언어 모델을 사용하여 평가하는 새로운 방법 중 하나입니다. LangChain은 평가를 지원하기 위한 몇 가지 프롬프트/체인을 제공합니다.

https://python.langchain.com/en/latest/index.html

 

Welcome to LangChain — 🦜🔗 LangChain 0.0.141

Welcome to LangChain LangChain is a framework for developing applications powered by language models. We believe that the most powerful and differentiated applications will not only call out to a language model via an API, but will also: Be data-aware: con

python.langchain.com

(나중에 볼려고 복사해 둔 자료입니다.)

LangChain is a framework for developing applications powered by language models. We believe that the most powerful and differentiated applications will not only call out to a language model via an API, but will also:

  • Be data-aware: connect a language model to other sources of data
  • Be agentic: allow a language model to interact with its environment

The LangChain framework is designed with the above principles in mind.

This is the Python specific portion of the documentation. For a purely conceptual guide to LangChain, see here. For the JavaScript documentation, see here.

Getting Started

Checkout the below guide for a walkthrough of how to get started using LangChain to create an Language Model application.

Modules

There are several main modules that LangChain provides support for. For each module we provide some examples to get started, how-to guides, reference docs, and conceptual guides. These modules are, in increasing order of complexity:

  • Models: The various model types and model integrations LangChain supports.
  • Prompts: This includes prompt management, prompt optimization, and prompt serialization.
  • Memory: Memory is the concept of persisting state between calls of a chain/agent. LangChain provides a standard interface for memory, a collection of memory implementations, and examples of chains/agents that use memory.
  • Indexes: Language models are often more powerful when combined with your own text data - this module covers best practices for doing exactly that.
  • Chains: Chains go beyond just a single LLM call, and are sequences of calls (whether to an LLM or a different utility). LangChain provides a standard interface for chains, lots of integrations with other tools, and end-to-end chains for common applications.
  • Agents: Agents involve an LLM making decisions about which Actions to take, taking that Action, seeing an Observation, and repeating that until done. LangChain provides a standard interface for agents, a selection of agents to choose from, and examples of end to end agents.

Use Cases

The above modules can be used in a variety of ways. LangChain also provides guidance and assistance in this. Below are some of the common use cases LangChain supports.

  • Personal Assistants: The main LangChain use case. Personal assistants need to take actions, remember interactions, and have knowledge about your data.
  • Question Answering: The second big LangChain use case. Answering questions over specific documents, only utilizing the information in those documents to construct an answer.
  • Chatbots: Since language models are good at producing text, that makes them ideal for creating chatbots.
  • Querying Tabular Data: If you want to understand how to use LLMs to query data that is stored in a tabular format (csvs, SQL, dataframes, etc) you should read this page.
  • Code Understanding: If you want to understand how to use LLMs to query source code from github, you should read this page.
  • Interacting with APIs: Enabling LLMs to interact with APIs is extremely powerful in order to give them more up-to-date information and allow them to take actions.
  • Extraction: Extract structured information from text.
  • Summarization: Summarizing longer documents into shorter, more condensed chunks of information. A type of Data Augmented Generation.
  • Evaluation: Generative models are notoriously hard to evaluate with traditional metrics. One new way of evaluating them is using language models themselves to do the evaluation. LangChain provides some prompts/chains for assisting in this.

Reference Docs

All of LangChain’s reference documentation, in one place. Full documentation on all methods, classes, installation methods, and integration setups for LangChain.

LangChain Ecosystem

Guides for how other companies/products can be used with LangChain

Additional Resources

Additional collection of resources we think may be useful as you develop your application!

  • LangChainHub: The LangChainHub is a place to share and explore other prompts, chains, and agents.
  • Glossary: A glossary of all related terms, papers, methods, etc. Whether implemented in LangChain or not!
  • Gallery: A collection of our favorite projects that use LangChain. Useful for finding inspiration or seeing how things were done in other applications.
  • Deployments: A collection of instructions, code snippets, and template repositories for deploying LangChain apps.
  • Tracing: A guide on using tracing in LangChain to visualize the execution of chains and agents.
  • Model Laboratory: Experimenting with different prompts, models, and chains is a big part of developing the best possible application. The ModelLaboratory makes it easy to do so.
  • Discord: Join us on our Discord to discuss all things LangChain!
  • Production Support: As you move your LangChains into production, we’d love to offer more comprehensive support. Please fill out this form and we’ll set up a dedicated support Slack channel.

참고사이트

https://docs.kanaries.net/ko/articles/langchain-openai

 

LangChain: OpenAI API로 빠르게 앱 구축 – Kanaries

OpenAI ChatGPT API를 사용하여 경쟁에서 눈에 띄는 고급 웹 애플리케이션을 만드는 오픈 소스 Python 프레임워크인 LangChain의 기능을 알아보십시오.

docs.kanaries.net

 

댓글