-
Notifications
You must be signed in to change notification settings - Fork 2k
Description
Bug description
A clear and concise description of what the bug is about.
EmbeddingUtils.toPrimitive(List<Float> floats) unnecessarily converts List<Float> to Float[] that is later converted to float[]. I achieved twice as much operations per seconds by directly converting from List<Float> to float[]
Benchmark Mode Cnt Score Error Units
MyBenchmark.toPrimitive thrpt 5 1671525,687 ± 19770,013 ops/s
MyBenchmark.toPrimitiveNew thrpt 5 3107477,889 ± 29323,152 ops/s
Environment
Please provide as many details as possible: Spring AI version, Java version, which vector store you use if any, etc
- Spring AI 1.0.1
- I benchmarked it on Java 21
Steps to reproduce
Steps to reproduce the issue.
- Run benchmark with long
List<Float>. I created lists of768floats, buttext-embedding-3-largecan be vector of3072floats.
Expected behavior
A clear and concise description of what you expected to happen.
I'll create a PR for fixing it and I'd like you to merge it 😄
Minimal Complete Reproducible example
Please provide a failing test or a minimal complete verifiable example that reproduces the issue.
Bug reports that are reproducible will take priority in resolution over reports that are not reproducible.