microsoft / microsoft/semantic-kernel-java

Java: API - What about manipulating an array of float in Embedding ?

Open
#131 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

java
Dominant language
Java
Stars
276
Forks
56
Avg merge
17h 45m
Merged PRs (30d)
4

Description

The Embedding contains a List<Float> to represent the vector. You can pass this list to the constructor and get its content as a List

    private final List<Float> vector;

    public Embedding(@Nonnull List<Float> vector) {
        Objects.requireNonNull(vector);
        this.vector = Collections.unmodifiableList(vector);
    }

    public List<Float> getVector() {
        return vector;
    }

But there are several external APIs (such as PGVector for example) that manipulate arrays of floats. So we end up casting arrays to lists back and forth.

It would be handy if Embedding had a constructor that takes an array of float, and a method to return the vector as an array:

    public Embedding(float[] vector);

    public float[] toArray();

WDYT ?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the Embedding class and its existing constructor and getVector API. Review how vectors are currently stored and any nearby tests, then verify the proposed array-based construction and retrieval preserve the expected values and that the API behavior is covered before considering the feature complete.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.