Skip to content
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

Visualize discovery scores #134

Merged
merged 13 commits into from
Jan 31, 2024
Merged

Visualize discovery scores #134

merged 13 commits into from
Jan 31, 2024

Conversation

coszio
Copy link
Contributor

@coszio coszio commented Dec 18, 2023

Improves upon the existing visualizer to add the option of also seeing how discovery/context search looks when the score is colored

Internal hackathon submission

Play around with it, this demo is mostly useful for trying out context search (no target)

  1. Checkout this branch
  2. docker run -d -p 6333:6333 qdrant/qdrant && npm start
  3. Browse to http://localhost:5173
  4. Upload the food discovery dataset as food
  5. Go to the visualizer
  6. Play around with it, specially with only specifying only context (no target). Try to think of a certain category of food and see how many tries it takes to get the variety you want. Combine examples differently.

Example

I'm someone who likes italian food. Let's think of a few examples:

"context": [
        {
          "positive": 39,  // pizza with vegetables
          "negative": 7224 // kebab
        },
        {
          "positive": 2964, // pesto pasta
          "negative": 6072  // salad
        },
        {
          "positive": 104,  // salami pizza
          "negative": 5688  // rice plate
        },
        {
          "positive": 1879, // canelloni
          "negative": 285   // croissant
        },
        {
          "positive": 9218, // lasagna
          "negative": 388   // fries
        }
      ]

For this context, check out how it looks:
image

Internals

  • Makes 20/80 split.
    • 20% of limit is selected from discovery
    • 80% is selected randomly (then scored using discovery). The points selected from discovery are shown a little bigger than the randomly selected.
    • It's not true random, since qdrant does not have an easy way to sample, I just scrolled excluding previous results
  • Coloring of points is done by normalizing the scores from the returned points and assigning a color from a red-yellow-green gradient
  • New tooltip for showing image with score and id

Qdrant pain points

I encountered these issues that could improve in qdrant to make it a little nicer to work with

  • There is no sampling endpoint, so 80% split is likely to use the same points every time (lower ids)
  • Inconsistency: /scroll endpoint returns its points in { "points": ... } while searches have { "result": ...}. This is not easy to fix since changes interface.

Copy link
Contributor

@fabribet fabribet left a comment

Choose a reason for hiding this comment

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

I checked the PR, there is some magic at the end I don't entirely understand due to the lack of types context, my comments are just symbolic as this is just a draft :)

@coszio coszio marked this pull request as ready for review January 4, 2024 14:14
}

// Add tag to know which points were returned by the query
queryResponse.data.result = queryResponse.data.result.map((point) => ({
Copy link

Choose a reason for hiding this comment

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

It's better not to modify the original object and instead do:
const result = queryResponse.data.result.map(...)

src/components/VisualizeChart/ImageTooltip.jsx Outdated Show resolved Hide resolved
src/components/VisualizeChart/ImageTooltip.jsx Outdated Show resolved Hide resolved
const bodyFont = toFont(tooltipModel.options.bodyFont);

// Display, position, and set styles for font
tooltipEl.style.opacity = 1;
Copy link

Choose a reason for hiding this comment

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

Let's move the creation and styling to a separate function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think it is trivial to separate these two things, since we are already styling within the jsx part

src/components/VisualizeChart/index.jsx Outdated Show resolved Hide resolved
src/pages/Visualize.jsx Outdated Show resolved Hide resolved
@Rendez Rendez self-requested a review January 9, 2024 16:17
Copy link

@Rendez Rendez left a comment

Choose a reason for hiding this comment

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

Could you please check once that it works on Safari and Firefox before merging?

@coszio
Copy link
Contributor Author

coszio commented Jan 9, 2024

Good check, it works fine in Chrome, Firefox and Safari

@coszio coszio merged commit 54f8dfa into master Jan 31, 2024
1 check passed
@Anush008 Anush008 deleted the visualize-discovery branch March 20, 2024 17:53
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