Skip to content

Add Python 3.13 and fastembed 0.6 support #1102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Apr 15, 2025
Merged

Conversation

tgasser-nv
Copy link
Collaborator

@tgasser-nv tgasser-nv commented Apr 7, 2025

Description

Upgrading fastembed to 0.6.0 and adding Python 3.13 support (tested at Python 3.13.2).

Note spacy does not support Python 3.13 (explosion/spaCy#13658). Once compile-from-source or wheels are available we'll add.

Checklist

  • I've read the CONTRIBUTING guidelines.
  • [N/A] I've updated the documentation if applicable.
  • [N/A] I've added tests if applicable.
  • [] @mentions of the person or team responsible for reviewing proposed changes.

@tgasser-nv tgasser-nv self-assigned this Apr 7, 2025
In `test_examples_included_in_prompts` and `test_examples_included_in_pr≈ompts_2`
we make an HTP call to GET /api/models/qdrant/all-MiniLM-L6-v2-onnx to download
an embedding model to look up the most similar user intent to the user saying "Hi".

Our pyproject.toml has:

```
fastembed = [
  { version = ">=0.2.2, <0.5", python = ">=3.9,<3.10" },
  { version = ">=0.5.0, <=0.6.0", python = ">=3.10, <3.14" },
]
```

In Python 3.9.21 poetry instaled fastembed 0.2.7, giving a similarity of [(0.9502324275672436, 'hi')]
In Python 3.11.11 we use fastembed 0.6.0, giving a similairty of [(0.7792390137910843, 'hi')]

Prior to this commit, the threshold was set at 0.8. This means for Python 3.9.21
(fastembed 0.2.7) no LLM call was made (0.95>0.8). For fastembed 0.6.0 the same embedding
model gives 0.78 < 0.8. There's an issue here since the same embedding model should give
the same results regardless of the API/toolkit we use to call it.

But a bigger issue is that we should be mocking the fastembed call anyway
so we can return a value above, below, and exactly at the threshold and test each.
We shouldn't need internet access for unit-tests. Will file an issue for this.
@tgasser-nv tgasser-nv changed the title [WIP] Test upgrade fastembed to 0.6 [WIP] Test support Python 3.13 and fastembed to 0.6 Apr 10, 2025
@tgasser-nv tgasser-nv force-pushed the chore/upgrade-fastembed branch from 236e190 to 734a991 Compare April 10, 2025 02:38
@tgasser-nv tgasser-nv force-pushed the chore/upgrade-fastembed branch from a358169 to c321c1e Compare April 10, 2025 17:16
Signed-off-by: Tim Gasser <200644301+tgasser-nv@users.noreply.github.com>
@tgasser-nv tgasser-nv changed the title [WIP] Test support Python 3.13 and fastembed to 0.6 [WIP] Add Python 3.13 and fastembed 0.6 support Apr 14, 2025
@tgasser-nv tgasser-nv marked this pull request as ready for review April 14, 2025 21:34
@tgasser-nv tgasser-nv requested a review from Pouyanpi April 14, 2025 21:34
@tgasser-nv tgasser-nv changed the title [WIP] Add Python 3.13 and fastembed 0.6 support Add Python 3.13 and fastembed 0.6 support Apr 15, 2025
@tgasser-nv tgasser-nv requested a review from cparisien April 15, 2025 15:17
@@ -42,7 +42,7 @@ def colang_1_config():
dialog:
user_messages:
embeddings_only: True
embeddings_only_similarity_threshold: 0.8
embeddings_only_similarity_threshold: 0.99
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where did this change come from? Related to the fast-embed update?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're downloading and calling live production embedding models in our unit-tests (this needs to be fixed). The same all-minilm-l6-v2 model gives two different similarities for the same user string and colang rule (see this commit message) for fastembed 0.2.7 and 0.6.0. If the threshold isn't updated the test fails on Python 3.9 but passes everywhere else.

We should be mocking these embedding model calls rather than running it. Calling other services from a test makes it an integration test (which we should also add).

@tgasser-nv tgasser-nv merged commit 1cc3124 into develop Apr 15, 2025
43 checks passed
@tgasser-nv tgasser-nv deleted the chore/upgrade-fastembed branch April 15, 2025 20:01
Copy link
Collaborator

@Pouyanpi Pouyanpi Apr 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about opening a separate PR(s) for all the embedding and indexing issues and address them there. Let's not include this change in this PR.

Just a note so that we don't forget, the poetry.lock file is updated to test the changes work, which is great, but we should delete it and only do poetry lock --no-update before merging this PR.

fastembed = ">=0.2.2, <0.4.1"
fastembed = [
{ version = ">=0.2.2, <0.5", python = ">=3.9,<3.10" },
{ version = ">=0.5.0, <=0.6.0", python = ">=3.10, <3.14" },
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cannot we support the other fastembed versions?
{ version = ">=0.2.2, <=0.6.0", python = ">=3.10, <3.14" },

@Pouyanpi
Copy link
Collaborator

My bad, I didn’t realize it had been merged. Here are some comments that apply to similar PRs:

  • We should avoid updating dependencies to the latest version until the first RC has been successfully QA’ed (currently it is not clear what has happened to the dependencies in poetry.lock I assume poetry update and poetry add fastembed==0.2.7 was done as we are using 0.2.7 version of fastembed)
  • Styling changes should be handled in a separate PR.
  • Each pull request should have a narrow and well-defined scope (the change to the embedding value as Tim explained deserves its own set of PRs)

There seems to be a dependency resolution bug where Poetry is not properly enforcing python version specific constraints.
For py 3.12, it should only allow versions between 0.5.0 and 0.6.0, but poetry update is allowing 0.4.2 which is outside this range. So when I do poetry update fastembed it gets updated to 0.4.2.

We can open a PR to revert changes made to the lock file.

@tgasser-nv @cparisien

Pouyanpi added a commit that referenced this pull request Apr 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants