Skip to content

Commit 1ca84ec

Browse files
committed
Release v0.6.0
1 parent a72d9f8 commit 1ca84ec

11 files changed

Lines changed: 20 additions & 44 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ The package can be installed by adding `torus` to your list of dependencies in `
1717
```elixir
1818
def deps do
1919
[
20-
{:torus, "~> 0.5"}
20+
{:torus, "~> 0.6"}
2121
]
2222
end
2323
```
@@ -72,7 +72,7 @@ See [`full_text/5`](https://hexdocs.pm/torus/Torus.html#full_text/5) for more de
7272

7373
See [`similarity/5`](https://hexdocs.pm/torus/Torus.html#similarity/5) for more details.
7474

75-
1. **Full text**: Uses term-document matrix vectors for, enabling efficient querying and ranking based on term frequency. Supports prefix search and is great for large datasets to quickly return relevant results. See [PostgreSQL Full Text Search](https://www.postgresql.org/docs/current/textsearch.html) for internal implementation details.
75+
1. **Full text**: Uses term-document matrix vectors, enabling efficient querying and ranking based on term frequency. Supports prefix search and is great for large datasets to quickly return relevant results. See [PostgreSQL Full Text Search](https://www.postgresql.org/docs/current/textsearch.html) for internal implementation details.
7676

7777
```elixir
7878
insert_post!(title: "Hogwarts Shocker", body: "A spell disrupts the Quidditch Cup.")

config/config.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ config :torus, Torus.Test.Repo,
1414

1515
config :torus, ecto_repos: [Torus.Test.Repo]
1616

17-
config :torus, batcher: Torus.Embeddings.Batcher
17+
config :torus, embedding_module: Torus.Embeddings.Batcher
1818

1919
config :torus, Torus.Embeddings.Batcher,
2020
max_batch_size: 10,
21-
default_batch_timeout: 100,
21+
batch_timeout: 100,
2222
embedding_module: Torus.Embeddings.HuggingFace
2323

2424
if Mix.env() == :test do

guides/semantic_search.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ To use it:
110110
end
111111
```
112112

113-
- Add an API token for Hugging Face to your `runtime.exs`. You can get your token [here](https://aistudio.google.com/app/apikey).
113+
- Add an API token for Gemini to your `runtime.exs`. You can get your token [here](https://aistudio.google.com/app/apikey).
114114

115115
```elixir
116116
# `config/runtime.exs`
@@ -151,7 +151,7 @@ To use it:
151151
config :torus, Torus.Embeddings.OpenAI, token: System.get_env("OPEN_AI_API_KEY")
152152
```
153153

154-
By default, it uses the `sentence-transformers/all-MiniLM-L6-v2` model, but you can specify a different model by explicitly passing `model` in the configuration or when calling `Torus.to_vector/1` function via `model` option:
154+
By default, it uses the `text-embedding-ada-002` model, but you can specify a different model by explicitly passing `model` in the configuration or when calling `Torus.to_vector/1` function via `model` option:
155155

156156
```elixir
157157
config :torus, Torus.Embeddings.OpenAI, model: "your/model"
@@ -168,7 +168,7 @@ config :torus, embedding_module: Torus.Embeddings.PostgresML
168168
config :torus, Torus.Embeddings.PostgresML, repo: YourApp.Repo
169169
```
170170

171-
By default, it uses the `sentence-transformers/all-MiniLM-L6-v2` model, but you can specify a different model by explicitly passing `model` in the configuration or when calling `Torus.to_vector/1` function via `model` option:
171+
By default, it uses the `sentence-transformers/paraphrase-MiniLM-L3-v2` model, but you can specify a different model by explicitly passing `model` in the configuration or when calling `Torus.to_vector/1` function via `model` option:
172172

173173
```elixir
174174
config :torus, Torus.Embeddings.PostgresML, model: "your/model"
@@ -216,7 +216,7 @@ To use it:
216216

217217
You can pass all options directly to the `Nx.Serving.start_link/1` function by passing them to `Torus.Embeddings.LocalNxServing` when starting.
218218

219-
By default, it uses the `sentence-transformers/all-MiniLM-L6-v2` model, but you can specify a different model by explicitly passing `model` in the configuration:
219+
By default, it uses the `sentence-transformers/paraphrase-MiniLM-L3-v2` model, but you can specify a different model by explicitly passing `model` in the configuration:
220220

221221
```elixir
222222
config :torus, Torus.Embeddings.LocalNxServing, model: "your/model"
@@ -237,7 +237,7 @@ To use it:
237237

238238
config :torus, Torus.Embeddings.Batcher,
239239
max_batch_size: 10,
240-
default_batch_timeout: 100,
240+
batch_timeout: 100,
241241
embedding_module: Torus.Embeddings.HuggingFace
242242
```
243243

lib/torus.ex

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ defmodule Torus do
307307
- `0` (default for `ts_rank`) - ignores the document length
308308
- `1` - divides the rank by 1 + the logarithm of the document length
309309
- `2` - divides the rank by the document length
310-
- `4` (default for `ts_rank_cs`) - divides the rank by the mean harmonic
310+
- `4` (default for `ts_rank_cd`) - divides the rank by the mean harmonic
311311
distance between extents (this is implemented only by `ts_rank_cd`)
312312
- `8` - divides the rank by the number of unique words in document
313313
- `16` - divides the rank by 1 + the logarithm of the number of unique words in
@@ -467,29 +467,6 @@ defmodule Torus do
467467
- You're on PostgreSQL < 17
468468
- You need the `concat` filter type
469469
470-
## Multi-column search workaround
471-
472-
Since BM25 indexes work on single columns, you can create a generated column:
473-
474-
```sql
475-
ALTER TABLE posts
476-
ADD COLUMN searchable_text TEXT
477-
GENERATED ALWAYS AS (title || ' ' || body) STORED;
478-
479-
CREATE INDEX posts_searchable_bm25_idx
480-
ON posts USING bm25(searchable_text)
481-
WITH (text_config='english');
482-
```
483-
484-
Then search the generated column:
485-
486-
```elixir
487-
Post
488-
|> Torus.bm25([p], p.searchable_text, "search term")
489-
|> limit(10)
490-
|> Repo.all()
491-
```
492-
493470
## Index options
494471
495472
BM25 indexes support these parameters in the `WITH` clause:

lib/torus/embeddings/batch_server.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ defmodule Torus.Embeddings.Batcher do
3939
- Add the following to your `config.exs`:
4040
4141
```elixir
42-
config :torus, batcher: Torus.Embeddings.Batcher
42+
config :torus, embedding_module: Torus.Embeddings.Batcher
4343
4444
config :torus, Torus.Embeddings.Batcher,
4545
max_batch_size: 10,
46-
default_batch_timeout: 100,
46+
batch_timeout: 100,
4747
embedding_module: Torus.Embeddings.HuggingFace
4848
```
4949

lib/torus/embeddings/hugging_face.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ if Code.ensure_loaded?(Req) do
2121
end
2222
```
2323
24-
- Add an API token for hugging face to your `runtime.exs`. You can get your token [here](https://huggingface.co/settings/tokens).
24+
- Add an API token for Hugging Face to your `runtime.exs`. You can get your token [here](https://huggingface.co/settings/tokens).
2525
2626
```elixir
2727
config :torus, Torus.Embeddings.HuggingFace, token: System.get_env("HUGGING_FACE_API_KEY")

lib/torus/embeddings/local_nx_serving.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ if Code.ensure_loaded?(Bumblebee) and Code.ensure_loaded?(Nx) do
4242
4343
You can pass all options directly to `Nx.Serving.start_link/1` function by passing them to `Torus.Embeddings.LocalNxServing` when starting.
4444
45-
By default, it uses `sentence-transformers/all-MiniLM-L6-v2` model, but you can specify a different model by explicitly passing `model` to the config:
45+
By default, it uses `sentence-transformers/paraphrase-MiniLM-L3-v2` model, but you can specify a different model by explicitly passing `model` to the config:
4646
4747
```elixir
4848
config :torus, Torus.Embeddings.LocalNxServing, model: "your/model"
@@ -115,7 +115,7 @@ else
115115
@error_message """
116116
`Torus.Embeddings.LocalNxServing` is not available. Please add `:bumblebee` and `:nx` to your dependencies.
117117
118-
See `Torus.SemanticSearch` docs for more info.
118+
See `Torus.semantic/5` docs for more info.
119119
"""
120120

121121
def child_spec(_opts) do

lib/torus/embeddings/nebulex_cache.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ if Code.ensure_loaded?(Nebulex) and Code.ensure_loaded(Decorator.Decorate) do
1010
- Add the following to your `config.exs`:
1111
1212
```elixir
13-
config :torus, cache: Torus.Embeddings.NebulexCache
13+
config :torus, embedding_module: Torus.Embeddings.NebulexCache
1414
config :torus, Torus.Embeddings.NebulexCache,
1515
embedding_module: Torus.Embeddings.PostgresML
1616
cache: Nebulex.Cache,

lib/torus/embeddings/open_ai.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ if Code.ensure_loaded?(Req) do
2727
config :torus, Torus.Embeddings.OpenAI, token: System.get_env("OPEN_AI_API_KEY")
2828
```
2929
30-
By default, it uses `sentence-transformers/all-MiniLM-L6-v2` model, but you can specify a different model by explicitly passing `model` to the config:
30+
By default, it uses `text-embedding-ada-002` model, but you can specify a different model by explicitly passing `model` to the config:
3131
3232
```elixir
3333
config :torus, Torus.Embeddings.OpenAI, model: "your/model"

lib/torus/embeddings/postgres_ml.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
defmodule Torus.Embeddings.PostgresML do
22
@moduledoc """
3-
`Torus.Embeddings.PostgresML` uses PostgreSQL [PostgresML extension](https://PostgresML.org/docs) to generate embeddings. It allows you to generate embeddings using a variety of models and performs inference directly in the database. This would require your database to have GPU support.
3+
`Torus.Embeddings.PostgresML` uses the PostgreSQL [PostgresML extension](https://postgresml.org/docs) to generate embeddings. It allows you to generate embeddings using a variety of models and performs inference directly in the database. This would require your database to have GPU support.
44
55
To use it, add the following to your `config.exs`:
66
@@ -9,13 +9,13 @@ defmodule Torus.Embeddings.PostgresML do
99
config :torus, Torus.Embeddings.PostgresML, repo: YourApp.Repo
1010
```
1111
12-
By default, it uses `sentence-transformers/all-MiniLM-L6-v2` model, but you can specify a different model by explicitly passing `model` to the config:
12+
By default, it uses `sentence-transformers/paraphrase-MiniLM-L3-v2` model, but you can specify a different model by explicitly passing `model` to the config:
1313
1414
```elixir
1515
config :torus, Torus.Embeddings.PostgresML, model: "your/model"
1616
```
1717
18-
Read more about in [PostgresML](https://PostgresML.org/blog/semantic-search-in-postgres-in-15-minutes).
18+
Read more in the [PostgresML blog](https://postgresml.org/blog/semantic-search-in-postgres-in-15-minutes).
1919
2020
See `Torus.semantic/5` on how to use this module to introduce semantic search in your application.
2121
"""

0 commit comments

Comments
 (0)