Skip to content

Commit 58096f1

Browse files
committed
Updated Informers examples [skip ci]
1 parent a88528b commit 58096f1

4 files changed

Lines changed: 7 additions & 7 deletions

File tree

examples/hybrid/Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ source "https://rubygems.org"
22

33
gemspec path: "../.."
44

5-
gem "informers", ">= 1"
5+
gem "informers", ">= 1.0.2"
66
gem "pg"

examples/hybrid/example.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
conn.exec("CREATE TABLE documents (id bigserial PRIMARY KEY, content text, embedding vector(384))")
1010
conn.exec("CREATE INDEX ON documents USING GIN (to_tsvector('english', content))")
1111

12-
model = Informers::Model.new("Xenova/multi-qa-MiniLM-L6-cos-v1")
12+
model = Informers.pipeline("embedding", "Xenova/multi-qa-MiniLM-L6-cos-v1")
1313

1414
input = [
1515
"The dog is barking",
1616
"The cat is purring",
1717
"The bear is growling"
1818
]
19-
embeddings = model.embed(input)
19+
embeddings = model.(input)
2020
input.zip(embeddings) do |content, embedding|
2121
conn.exec_params("INSERT INTO documents (content, embedding) VALUES ($1, $2)", [content, embedding])
2222
end
@@ -45,7 +45,7 @@
4545
LIMIT 5
4646
SQL
4747
query = "growling bear"
48-
query_embedding = model.embed(query)
48+
query_embedding = model.(query)
4949
k = 60
5050
result = conn.exec_params(sql, [query, query_embedding, k])
5151
result.each do |row|

examples/informers/Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ source "https://rubygems.org"
22

33
gemspec path: "../.."
44

5-
gem "informers", ">= 1"
5+
gem "informers", ">= 1.0.2"
66
gem "pg"

examples/informers/example.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
conn.exec("DROP TABLE IF EXISTS documents")
99
conn.exec("CREATE TABLE documents (id bigserial PRIMARY KEY, content text, embedding vector(384))")
1010

11-
model = Informers::Model.new("sentence-transformers/all-MiniLM-L6-v2")
11+
model = Informers.pipeline("embedding", "sentence-transformers/all-MiniLM-L6-v2")
1212

1313
input = [
1414
"The dog is barking",
1515
"The cat is purring",
1616
"The bear is growling"
1717
]
18-
embeddings = model.embed(input)
18+
embeddings = model.(input)
1919

2020
input.zip(embeddings) do |content, embedding|
2121
conn.exec_params("INSERT INTO documents (content, embedding) VALUES ($1, $2)", [content, embedding])

0 commit comments

Comments
 (0)