Skip to content

Conversation

@camilleislasse
Copy link

Q A
Bug fix? yes
New feature? no
Docs? no
Issues n/a
License MIT

Description

The DistanceCalculator was calculating distances but not returning them in the VectorDocument results. This meant queries to CacheStore and InMemoryStore returned
documents without score information, making it impossible to determine result relevance.

Changes

This fix creates new VectorDocument instances with the calculated distance as the score property, matching the pattern used by other stores (Redis, MariaDb, Postgres).

@carsonbot carsonbot added Bug Something isn't working Store Issues & PRs about the AI Store component Status: Needs Review labels Nov 11, 2025

return array_map(
static fn (array $embedding): VectorDocument => $embedding['document'],
static fn (array $embedding): VectorDocument => new VectorDocument(
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we implement a withScore method to VectorDocument instead?

Copy link
Author

Choose a reason for hiding this comment

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

@chr-hertel chr-hertel force-pushed the fix-cache-store-vector-scores branch from 5259e36 to 65e85c3 Compare November 12, 2025 22:20
@chr-hertel
Copy link
Member

Thank you @camilleislasse.

@chr-hertel chr-hertel merged commit 806d6be into symfony:main Nov 12, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working Status: Reviewed Store Issues & PRs about the AI Store component

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants