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

Preparing the ES Embeddings Rewriter #1

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Preparing the ES Embeddings Rewriter #1

wants to merge 2 commits into from

Conversation

mkr
Copy link
Collaborator

@mkr mkr commented Mar 22, 2023

  • Fixing parsing embeddings containing numbers without decimals (mostly for tests)
  • Using the Lucene query for boosting directly to avoid re-parsing in ES

Copy link
Collaborator

@renekrie renekrie left a comment

Choose a reason for hiding this comment

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

Please see comment inline


public Embedding parseEmbeddingFromResponse(InputStream is) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not understanding why this has been changed. What is the benefit of not using JsonUtil.readJson()?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The code before was
(List<Double>) JsonUtil.readJson(con.getInputStream(), Map.class).get("embedding")

What happens here is that the Jackson Objectmapper will just read the object as a map and the embedding field as a List. It does not try to coerce into a common List element type, i.e. you get a List of (Double, Integer, Double) if you parse a JSON array [1.2, 1, 1.3]. You then get a class java.lang.Integer cannot be cast to class java.lang.Double when the element of the List is accessed as a Double.

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.

2 participants