FIX: Improvment to embeddings index task (#238)

This commit is contained in:
Rafael dos Santos Silva 2023-10-02 16:37:13 -03:00 committed by GitHub
parent 9d96c4d242
commit 453928e7bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 6 deletions

View File

@ -24,10 +24,7 @@ module DiscourseAi
USING
ivfflat (embeddings #{pg_index_type})
WITH
(lists = #{lists})
WHERE
model_version = #{version} AND
strategy_version = #{@strategy.version};
(lists = #{lists});
SQL
end

View File

@ -33,8 +33,10 @@ task "ai:embeddings:index", [:work_mem] => [:environment] do |_, args|
vector_representation_klass = DiscourseAi::Embeddings::Vectors::Base.find_vector_representation
strategy = DiscourseAi::Embeddings::Strategies::Truncation.new
DB.exec("SET work_mem TO '#{args[:work_mem] || "1GB"}';")
DB.exec("SET work_mem TO '#{args[:work_mem] || "100MB"}';")
DB.exec("SET maintenance_work_mem TO '#{args[:work_mem] || "100MB"}';")
vector_representation_klass.new(strategy).create_index(lists, probes)
DB.exec("RESET work_mem;")
DB.exec("SET ivfflat.probes = #{probes};")
DB.exec("RESET maintenance_work_mem;")
DB.exec("ALTER SYSTEM SET ivfflat.probes = #{probes};")
end