spring-projects / spring-projects/spring-ai

Using VertexAI Embeddings model backed by the Predict API over gRPC is extremely slow

Open
#4,248 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: waiting-for-triage
Dominant language
Java
Stars
9.5k
Forks
2.9k
Avg merge
1d 7h
Merged PRs (30d)
6

Description

Bug description

Hello! We are experimenting with lots of different models etc for both conversation and embedding, and we ran into an issue using the spring-ai-starter-model-vertex-ai-embedding.

We set up the library mostly using auto-configuration, except we use our own GoogleCredentials using the example in the docs. Under the hood, it looks like the library is using the Google SDK predict API over gRPC.

When we call something that uses embeddings, the call takes over 10 seconds. I tried to drill down why that is using the profiler, and this is all I could find:

Image

In the screenshot, you will see that I ran 3 similarity search calls, each that took more than 10 seconds (total of 30k milliseconds in the right column). All of them just seem to be parked for almost all of that time. I doubt the gRPC call (that I assume happens on another thread) should take over 10 seconds.

It also could be that maybe this is completely outside of your control. I just thought I would mention it here.

Environment
Spring AI version: 1.0.1
Java version: 21 (with Kotlin 2.1)

Steps to reproduce

val hits = vectorStore.similaritySearch(
    SearchRequest.builder()
        .query(query)
        .topK(10)
        .build()
)

Expected behavior
When I run the predict API myself using their regular HTTP equivalent, making these predictions takes sub-200ms.

Of course - I did this attempt completely bypassing the Google SDK - simply using the Spring RestClient instead.

Minimal Complete Reproducible example
I can return to this later if needed.

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 reproducing the delay with spring-ai-starter-model-vertex-ai-embedding, service-account credentials, and the similaritySearch call, then profile the gRPC Predict API path and compare it with the RestClient HTTP path. Done means identifying the source of the latency and either correcting it or documenting a confirmed limitation with supporting measurements.

Written by the indexing model from the issue text.

Assessment

Tech stack
google-cloud, grpc, java, kotlin, spring
Domain
ai, backend, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.