This message was deleted.
# community-help
s
This message was deleted.
k
This seems like a recommendation problem?
👍 1
> I tried with embeddings but it requires at least 3 nodes with GPU to work properly You can try using a remote embedder (we support OpenAI out of the box). This way the embedding generation is offloaded to an API call, but the downside is that it's slower (and costs per API call). Will depend on what kind of latency / concurrency your app requires.
b
Yes I know about open ai but if you have 10 loop multi search that means, 10 calls to open ai with average response time 100ms each one so 1sec total. I think the multi search implementation is not right for a suggestion system. If we could have in 1 query multiple terms instead of the multi query, that would be better for this case.
k
Ok got it, you want to identify each of the 10 favorite item's recommendation and aggregate them, correct?
b
Yes
Is there any other way except from multi search?
k
You don't have to actually do 10 vector searches. You can store the vector for each book and then when people want recommendation, fetch those 10 vectors, average them, and do a single vector search with the average vector. This should produce recent recommendations. The average operation will approximate the individual search + aggregation.
b
@Kishore Nallan each user has its own favorites. These 10 are not the same for every user.
k
I know but you can store the
id -> embedding
and look them up right.
b
For example, we have a recommendation system for recipes. User A wants the following ingredients: egg, tomato, bacon. In order to get recipes with these ingredients I do a multi search for each one. So if user has 10 ingredients, that’s a 10 loop multi search
@Kishore Nallan so when a new book is created store the embedding and lookup. Does this require a GPU as well?
In this case I won’t have dynamic embedding for search, i search based on the embedding
k
The averaging operation is still dynamic.
You probably don't need a GPU for the searches. But will depend on the concurrency.
b
Okay I’ll test it, thank you
👍 1
If I use vector search based on id, can I have hybrid search?
k
Yes. The docs should have an example.
b
Ok checked it but in my case it’s not a solution because the user’s variables are not static so I can’t store standard embeddings
k
What are user variables? Free text? I suggested this approach because earlier you said user had a list of items.
b
A user can have a dynamic list of items (recent searches)
k
Search queries?
b
It’s free text that I store and then do a multi search
Yes search queries
k
Ok then that won't work.
b
My issue is with the multi search that takes a lot of time for 10 loops
k
You don't need to do search for 10 times though. You need to generate embeddings for all 10 items, average them and then do single hybrid search with that average vector
Generating embedding for 10 items still intensive without GPU but just saying.
b
I don’t use open ai or Google, I use auto embedding, so how can I generate embedding for the search term?
k
Not possible within typesense presently. You have to do it on your application side.
b
Okay so I have to generate embeddings for each search term (10 terms). What do you mean average them?
k
Take the ith float value in each of the 10 embedding and divide by 10.
I mean, sum and divide by 10
b
What do you mean ith float value?
k
Given two vectors
[a1, a2, a3]
and
[b1, b2, b3]
average vector is:
[a1+b1/2, a2+b2/2, a3+b3/2]
👍 1
b
Ok got it thank you
Will it be available in a future release to just get only the embedding without storing in a document? That would be very helpful for dynamic search terms
k
Please create an issue, we will add to our roadmap.
b
Ok
@Kishore Nallan I sum up the embeddings and it works great! But, I tested (Nearest-neighbor vector search) in 2 different instances and I get same response time. In instance A (2vCPU - 4 GB RAM) with 60 concurrent requests I get average response time to 1.33s and in instance B (4 vCPU - 8GB RAM) with 60 concurrent requests I get 1.29s. Is this right?
Payload (combined embeddings for 10 search terms): { "searches": [ { "collection": "test", "q": "*", "per_page":200, "include_fields": "test", "vector_query": "embedding:([-0.1110641211271286,0.757041597738862,-0.098668213468045,0.46491856407374144,0.1574960257858038,.......-1.0089502930641174], k:50)" } ] }
Does it use all cores?
k
Can you run htop on your server when the benchmark runs? That will tell us if CPU is saturated or not.
b
All cores seems like working at 37% max
tested on 50 cocnurrent reqs and I got 1.13sec response time
I tested also in 2vCPU - 50 concurrent reqs -> also 1.13 sec
typesense version 0.25.2.rc9
k
What is the time with concurrency of say 3
b
avg=159.39ms min=118.87ms med=150.76ms max=395.87ms
k
How many vectors in index?
b
k
per_page
will override
k
btw so you are fetching 200 records which might be slow.
b
ok i'll test it with 20
k
Set both to 20
b
3 concurrent reqs: avg=148.65ms min=99.79ms med=139.81ms max=370.75ms
50 concurrent reqs: avg=1.11s min=111.6ms med=795.87ms max=6.56s
How is possible the 2vCPU instance have the same response time like the 4vCPU?
Any idea? @Kishore Nallan @Jason Bosco
Tested it today with a 16vCPU - 32gb RAM CPU Optimized instance and I get again 1.1 seconds for 50 concurrent requests, Does Nearest-neighbor vector search use all instance's RAM-CPU?
k
I'm surprised that the additional cpu cores are not helping with lower latency on higher concurrency. This usually happens when the determining factor is memory bandwidth rather than cpu. For example this is the same behaviour you see with LLM inference. Memory access is a bottleneck so more CPUs don't help. This is my hypothesis, have to independently verify.
b
@Kishore Nallan I have tested it with many different instances and all latest versions of typesense (0.25.2.rc, 0.26.0.rc) and I get the same response time.
k
I mean verifying the memory bandwidth part which will require instrumentation of that.
One other thing you could try doing is to increase the default thread pool size. Try setting --thread-pool-size to 500 and check.
Default is 8 * number of cpu cores.
b
What can be the issue here? I used htop and all cpu cores (16) were at 3-7% usage
k
Memory bandwidth is shared across all CPUs.
Use multiple smaller instances than a few larger ones.
b
What’s the solution? I don’t understand. Isn’t vector search cpu intensive?
k
All CPUs share the same memory bandwidth. Once that's saturated CPUs will be waiting for the data to be read from the memory. So you have to use more smaller machines than few larger machines for throughput.
b
So every instance can support only 50 concurrent requests even if it has more CPUs?
I don’t think that this is scalable
k
I need to investigate further before I can comment further.
How many records are you searching on?
b
Ok, 250
k
250 docs in the collection being searched on?
b
Yes
k
Please export those docs, collection schema and exact query you are using for benchmarking and email contact@typesense.org I'll have to look.
b
Ok. It’s a basic collection with one field (title). Nothing special
I set thread-pool-size=500 but nothing changed. 1.09 seconds response time
I sent you an email with the payload, collection scheme and docs to reproduce it. Subject of email: Embeddings search issue with concurrent requests.
For benchmarking I use k6 -> k6 run --vus 50 --duration 10s script.js
j
Will take a look this coming week
b
@Jason Bosco Ok. This is very critical because it's not scalable. Can I have more than 5 nodes in typesense? (As a temporary solution)
j
You can, any odd number of nodes should work. But each added node will increase write latency, since that many more nodes need to ack the write
b
Ok, so it's not the best solution. Please check, in addition to this issue with concurrent requests, if it's possible just to generate the embedding from the model without storing it in a document. For example, just generate the embedding for search term: "ship". In this way, it doesn't need an external service to generate only embeddings (eg. Hugging face).
Is there progress about this critical issue?
k
We've not had a chance to setup the benchmarking suite on AWS instances because we've been tied up with higher priority items. However, I took some time off to do a quick check locally using siege. Here's what I am getting:
Copy code
{
  "transactions": 22439,
  "availability": 100,
  "elapsed_time": 19.42,
  "data_transferred": 17.44,
  "response_time": 0.04,
  "transaction_rate": 1155.46,
  "throughput": 0.9,
  "concurrency": 49.84,
  "successful_transactions": 22439,
  "failed_transactions": 0,
  "longest_transaction": 0.14,
  "shortest_transaction": 0.01
}
Command used: https://gist.github.com/kishorenc/4be95e9242bd4b183d5cf74f7eae202c Can you give this a shot locally so we have a quicker common reference point?
b
In local environment you can't check response time. You should check it in specific instance sizes in order to check that the response time is the same across different instances.
k
I know, but they won't vary 1000x
Also with remote benchmarking, there is an issue of networking overhead as well. I want to first rule out that there is nothing wrong with core vector search performance. For that a local benchmark is a good starting point. Otherwise the issue is either networking or a bug in the benchmarking setup.
b
I think that issue is how the the multi_search works. It runs queries in sequence instead of parallel
k
That's not a problem here: there's only one query in multi search.
b
In 50 concurrent requests per second, it runs the requests in secuence
k
No, it doesn't.
b
How can be possible a 2 vCPU has the same response time as a 4 vCPU or even a 8 vCPU?
k
The sequential part is searches within a single multi search request body. Independent HTTP requests are processed in parallel. When I run the siege benchmark I see all CPU cores shoot up to 100%. When I reduce concurrency to 10 requests, response time decreases.
How can be possible a 2 vCPU has the same response time as a 4 vCPU or even a 8 vCPU?
I don't know, but can you try with the siege command above? You can run it from another instance if you want.
b
Yes I also see the CPU cores to 100% with 50 concurrent requests.
Have you tried it with more CPU cores?
It's like it has a fixed response time at x requests
k
But at 50 concurrency, I'm getting 40 ms response times already
I urge you to try with siege and see what you get. At this point I suspect the benchmark harness. I just don't see how it can vary so widely if there is a problem.
b
Ok I'll check it with siege. Did you try the benchmark with k6?
k
Not yet, our hands have been full with some high priority items the past couple of days.
b
Ok