Module: RerankerRuby

Defined in:
lib/reranker_ruby.rb,
lib/reranker_ruby/rrf.rb,
lib/reranker_ruby/base.rb,
lib/reranker_ruby/jina.rb,
lib/reranker_ruby/onnx.rb,
lib/reranker_ruby/batch.rb,
lib/reranker_ruby/cohere.rb,
lib/reranker_ruby/result.rb,
lib/reranker_ruby/voyage.rb,
lib/reranker_ruby/logging.rb,
lib/reranker_ruby/railtie.rb,
lib/reranker_ruby/version.rb,
lib/reranker_ruby/ensemble.rb,
lib/reranker_ruby/middleware.rb,
lib/reranker_ruby/rerank_job.rb,
lib/reranker_ruby/cache/redis.rb,
lib/reranker_ruby/cache/memory.rb,
lib/reranker_ruby/configuration.rb,
lib/reranker_ruby/model_downloader.rb,
lib/reranker_ruby/score_normalizer.rb,
lib/reranker_ruby/generators/install_generator.rb

Defined Under Namespace

Modules: Cache, Generators, Logging, ScoreNormalizer Classes: APIError, Base, Batch, Cohere, Configuration, Ensemble, Error, Jina, Middleware, ModelDownloader, Onnx, RRF, Railtie, RateLimitError, RerankJob, Result, TimeoutError, ValidationError, Voyage

Constant Summary collapse

VERSION =
"0.2.0"

Class Method Summary collapse

Class Method Details

.configuration ⇒ Object



77
78
79
# File 'lib/reranker_ruby/configuration.rb', line 77

def configuration
  @configuration ||= Configuration.new
end

.configure {|configuration| ... } ⇒ Object

Yields:



81
82
83
# File 'lib/reranker_ruby/configuration.rb', line 81

def configure
  yield(configuration)
end

.rerank(query, documents, top_k: nil) ⇒ Object

Convenience method for quick reranking



96
97
98
99
# File 'lib/reranker_ruby/configuration.rb', line 96

def rerank(query, documents, top_k: nil)
  top_k ||= configuration.default_top_k
  reranker.rerank(query, documents, top_k: top_k)
end

.reranker ⇒ Object

Global reranker instance built from configuration



91
92
93
# File 'lib/reranker_ruby/configuration.rb', line 91

def reranker
  @reranker ||= configuration.build_reranker
end

.reset_configuration! ⇒ Object



85
86
87
88
# File 'lib/reranker_ruby/configuration.rb', line 85

def reset_configuration!
  @configuration = Configuration.new
  @reranker = nil
end