Skip to content
Andrei Bondarev edited this page May 26, 2023 · 10 revisions

Langchain.rb a is library for building LLM-backed Ruby applications. It is an abstraction layer that sits on top of the emerging AI-related tools that makes it easy for developers to consume and string those services together.

Installation

Install the gem and add to the application's Gemfile by executing:

$ bundle add langchainrb

If bundler is not being used to manage dependencies, install the gem by executing:

$ gem install langchainrb

Require the gem to start using it:

require "langchain"

Concepts

Processors load and parse/process various data types such as CSVs, PDFs, Word documents, HTML pages, and others.

Chunkers split data based on various available options such as delimeters, chunk sizes or custom-defined functions. Chunkers are used when data needs to be split up before being imported in vector databases.

Prompts are structured inputs to the LLMs. Prompts provide instructions, context and other user input that LLMs use to generate responses.

LLM is a language model consisting of a neural network with many parameters (typically billions of weights or more), trained on large quantities of unlabeled text using self-supervised learning or semi-supervised learning.

Vector database is a type of database that stores data as high-dimensional vectors, which are mathematical representations of features or attributes. Each vector has a certain number of dimensions, which can range from tens to thousands, depending on the complexity and granularity of the data.

Embedding

Word embedding or word vector is an approach with which we represent documents and words. It is defined as a numeric vector input that allows words with similar meanings to have the same representation. It can approximate meaning and represent a word in a lower dimensional space.

Logging

LangChain.rb uses standard logging mechanisms and defaults to :debug level. Most messages are at info level, but we will add debug or warn statements as needed. To show all log messages:

Langchain.logger.level = :info