Module: Leann
- Defined in:
- lib/leann.rb,
lib/leann/index.rb,
lib/leann/rails.rb,
lib/leann/errors.rb,
lib/leann/builder.rb,
lib/leann/version.rb,
lib/leann/searcher.rb,
lib/leann/backend/base.rb,
lib/leann/configuration.rb,
lib/leann/rails/builder.rb,
lib/leann/rails/railtie.rb,
lib/leann/search_result.rb,
lib/leann/embedding/base.rb,
lib/leann/rails/searcher.rb,
lib/leann/ruby_llm/search.rb,
lib/leann/embedding/ollama.rb,
lib/leann/embedding/openai.rb,
lib/leann/embedding/ruby_llm.rb,
lib/leann/backend/leann_graph.rb,
lib/leann/embedding/fastembed.rb,
lib/leann/rails/active_record/index.rb,
lib/leann/rails/active_record/passage.rb,
lib/leann/rails/storage/active_record_backend.rb,
lib/generators/leann/install/install_generator.rb
Overview
LEANN - Lightweight Embedding-Aware Neural Neighbor search
A Ruby gem for building and searching vector indexes with minimal storage. Stores only the graph structure, achieving 85-96% storage savings by recomputing embeddings on-the-fly during search.
Defined Under Namespace
Modules: Backend, Embedding, Generators, Rails, RubyLLM Classes: Builder, Configuration, ConfigurationError, CorruptedIndexError, EmbeddingError, EmptyIndexError, Error, Index, IndexExistsError, IndexNotFoundError, LLMError, SearchResult, SearchResults, Searcher
Constant Summary collapse
- VERSION =
"0.1.0"
Class Method Summary collapse
-
.build(name, **options, &block) ⇒ Index
Build a new index with a DSL block.
-
.configuration ⇒ Configuration
Global configuration.
-
.configure {|Configuration| ... } ⇒ Object
Configure Leann globally.
-
.delete(name) ⇒ Boolean
Delete an index.
-
.exists?(name) ⇒ Boolean
Check if an index exists.
-
.list(path: ".") ⇒ Array<String>
List all indexes in a directory.
-
.open(name) ⇒ Index
Open an existing index for advanced operations.
-
.search(name, query, limit: 5, threshold: nil, filters: nil) ⇒ Array<SearchResult>
Search an existing index.
Class Method Details
.build(name, **options, &block) ⇒ Index
Build a new index with a DSL block
75 76 77 78 79 |
# File 'lib/leann.rb', line 75 def build(name, **, &block) builder = Builder.new(name, **) builder.instance_eval(&block) if block_given? builder.save end |
.configuration ⇒ Configuration
Global configuration
36 37 38 |
# File 'lib/leann.rb', line 36 def configuration @configuration ||= Configuration.new end |
.configure {|Configuration| ... } ⇒ Object
Configure Leann globally
49 50 51 |
# File 'lib/leann.rb', line 49 def configure yield(configuration) end |
.delete(name) ⇒ Boolean
Delete an index
129 130 131 |
# File 'lib/leann.rb', line 129 def delete(name) Index.delete(name) end |
.exists?(name) ⇒ Boolean
Check if an index exists
121 122 123 |
# File 'lib/leann.rb', line 121 def exists?(name) Index.exists?(name) end |
.list(path: ".") ⇒ Array<String>
List all indexes in a directory
113 114 115 |
# File 'lib/leann.rb', line 113 def list(path: ".") Index.list(path) end |
.open(name) ⇒ Index
Open an existing index for advanced operations
105 106 107 |
# File 'lib/leann.rb', line 105 def open(name) Index.open(name) end |
.search(name, query, limit: 5, threshold: nil, filters: nil) ⇒ Array<SearchResult>
Search an existing index
96 97 98 99 |
# File 'lib/leann.rb', line 96 def search(name, query, limit: 5, threshold: nil, filters: nil) index = Index.open(name) index.search(query, limit: limit, threshold: threshold, filters: filters) end |