Skip to content

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.

3 participants