- Issue created by @fishfree
- 🇨🇳China fishfree
Edit: I modfied 3 lines according to the latest ollama version doc. Two are in modules/providers/provider_ollama/src/OllamaControlApi.php:
- $result = json_decode($this->makeRequest("api/embeddings", [], 'POST', [
+ $result = json_decode($this->makeRequest("api/embed", [], 'POST', [
- 'prompt' => $text,
+ 'input' => $text,
'model' => $model,The third is in modules/providers/provider_ollama/src/Plugin/AiProvider/OllamaProvider.php:
- return new EmbeddingsOutput($response['embedding'], $response, []);
+ return new EmbeddingsOutput($response['embeddings'], $response, []);Then when manually reindexing, the dpm($responses) error became:
array:2 [ "code" => 1804 "message" => "fail to deal the insert data, error: json: cannot unmarshal array into Go value of type float32: invalid parameter[expected=FloatVector][actual=[[0.0069164913,0.0021438673,0.0065403455,-0.010024414,-0.029039439,0.011868233,-0.010923676,-0.02207415,0.041467343,0.007120738,-0.0134363435,0.0057169143,-0.00522319,-0.012688429,-0.0006849033,0.001478981,-0.0077171754,0.0057560704,-0.008850065,-0.02613559,-0.003200364,0.01103785,0.0059372904,-0.0032610951,-0.024189495,-0.008861378,0.03072281,0.0066399244,-0.02408238,0.0027452302,-0.0149833355,-0.0038356576,0.009427903,0.0028704233,0.0067922943,0.0052720155,......,-0.01320299]]]" ]
- 🇩🇪Germany marcus_johansson
The last problem looks like its because the array is not given back correctly, the first one is because the vector size differs from database and the embeddings engine. To reset it, you will need to remove and recreate the database/index, most vector stores does not allow you to resize this, since you would need to rerun the embeddings engine.
When you use Ollama or LM Studio we do not get the information back about vector size per each model, so you will have to figure it out and set this correctly yourself when settings it up.
One solution to this is that it does an actual query and count the vectors before showing the default number per model. This might be slow, but this is the second support request on the same issue and we need to find a way to set this even on providers that can't give that data back.
- 🇨🇳China fishfree
@Marcus Yes, I did delete database/index end even reinstalled the ai_search and vdb_provider_milvus modules. The error still exists. I could not change the dimension when creating or editing a Milvus search api server as the screenshot below:
So I had to edit it to 4096 with devel config editor. I really counted an embedding dimension using curl command.However, the error ""fail to deal the insert data, error: json: cannot unmarshal array into Go value of type float32: invalid parameter[expected=FloatVector]" I cannot figure it out why.
Do you have some working ollama ai_search configurations to share pls?
- 🇩🇪Germany marcus_johansson
Ah, sorry, I should check versions - if you try to get the DEV version you should have the possibility to set this manually.
- 🇨🇳China fishfree
@marcus_johansson The dimension field is editable now, but it shows up still as 768 when re-editing. The more serious problem is the embedding data type incompatibility with Milvus 2.4+ version as mentioned above.
- 🇬🇧United Kingdom scott_euser
Can you compare a working query that inserts data into Mvua 2.4? Or a working query that inserts data into an earlier version if not. E.g. Are there scenarios where data does get inserted so we can compare the json?
Seems issue summary could use an update with the problem as I think you've solved what's described there and are now encountering a new problem it seems.
- 🇨🇳China fishfree
@scott_euser Thank you! I remember I succeeded with Milvus 2.3 using search_api_ai 2 months ago.
- Status changed to Fixed
5 months ago 4:05am 3 September 2024 - 🇬🇧United Kingdom scott_euser
I believe this is related to 🐛 Vector dimension mismatch when using Zilliz Fixed and sorted in that fix. Please re-open if still an issue (after you resave your related settings and still experience the issue).
- 🇨🇳China fishfree
@scott_euser Thank you! I installed the latest dev version, however, the error still exists. I also changed to try with ollama:phi3 of which the embedding dimension is 3072, but no luck.
- Status changed to Active
5 months ago 4:58pm 10 September 2024 - 🇩🇪Germany marcus_johansson
So I could not replicate this and would need more information from the logs or plain requests to your Ollama instance or some other information on how to replicate this.
What I have tested is:
1. Get latest dev.
2. Setup Ollama with phi3:mini
3. Setup AI Search with Milvus 2.4 locally hosted
4. Create an index with the dimension 3072.
5. Indexed one article succesfully.
6. Try to search for it using the AI API Explorer and it works (see screenshots) - Status changed to Postponed: needs info
5 months ago 8:00am 16 September 2024 - 🇬🇧United Kingdom scott_euser
Same here, just figured its about time I try out Ollama, so from fresh install in Ubuntu, I tested this out with ollama:mxbai-embed-large, set the dimensions in search api > my index to 3072, and was able to index fine into the Milvus DDEV local.
- 🇨🇳China fishfree
@marcus_johansson @scott_euser Thank you, Marcus and Scott!
What are the versions of your ollama? Mine is 0.3.10. - 🇬🇧United Kingdom seogow
@fishfree - I also cannot replicate. I plan to close the ticket on Tuesday, 4 February if nothing new is found/reported.