Class: LLM::RAG
- Inherits:
-
Object
- Object
- LLM::RAG
- Defined in:
- lib/scout/llm/rag.rb
Class Method Summary collapse
Class Method Details
.index(data) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/scout/llm/rag.rb', line 3 def self.index(data) require 'hnswlib' dim = data.first.length t = Hnswlib::HierarchicalNSW.new(space: 'l2', dim: dim) t.init_index(max_elements: data.length) data.each_with_index do |vector,i| t.add_point vector, i end t end |
.load(path, dim) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/scout/llm/rag.rb', line 16 def self.load(path, dim) require 'hnswlib' u = Hnswlib::HierarchicalNSW.new(space: 'l2', dim: dim) u.load_index(path) u end |