Class: Langchain::LLM::Base Abstract
- Inherits:
-
Object
- Object
- Langchain::LLM::Base
- Includes:
- DependencyHelper
- Defined in:
- lib/langchain/llm/base.rb
Overview
A 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.
Langchain.rb provides a common interface to interact with all supported LLMs:
Direct Known Subclasses
AI21, Anthropic, AwsBedrock, Cohere, GooglePalm, GoogleVertexAi, HuggingFace, LlamaCpp, MistralAI, Ollama, OpenAI, Replicate
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
A client for communicating with the LLM.
Instance Method Summary collapse
-
#chat ⇒ Object
Generate a chat completion for a given prompt.
-
#complete ⇒ Object
Generate a completion for a given prompt.
- #default_dimensions ⇒ Object
-
#embed ⇒ Object
Generate an embedding for a given text.
-
#summarize ⇒ Object
Generate a summary for a given text.
Methods included from DependencyHelper
Instance Attribute Details
#client ⇒ Object (readonly)
A client for communicating with the LLM
25 26 27 |
# File 'lib/langchain/llm/base.rb', line 25 def client @client end |
Instance Method Details
#chat ⇒ Object
Generate a chat completion for a given prompt. Parameters will depend on the LLM
35 36 37 |
# File 'lib/langchain/llm/base.rb', line 35 def chat(...) raise NotImplementedError, "#{self.class.name} does not support chat" end |
#complete ⇒ Object
Generate a completion for a given prompt. Parameters will depend on the LLM.
43 44 45 |
# File 'lib/langchain/llm/base.rb', line 43 def complete(...) raise NotImplementedError, "#{self.class.name} does not support completion" end |
#default_dimensions ⇒ Object
27 28 29 |
# File 'lib/langchain/llm/base.rb', line 27 def default_dimensions self.class.const_get(:DEFAULTS).dig(:dimensions) end |
#embed ⇒ Object
Generate an embedding for a given text. Parameters depends on the LLM.
52 53 54 |
# File 'lib/langchain/llm/base.rb', line 52 def (...) raise NotImplementedError, "#{self.class.name} does not support generating embeddings" end |
#summarize ⇒ Object
Generate a summary for a given text. Parameters depends on the LLM.
61 62 63 |
# File 'lib/langchain/llm/base.rb', line 61 def summarize(...) raise NotImplementedError, "#{self.class.name} does not support summarization" end |