Hi Praveen,
Yes, you can integrate a custom embedding model with Mendix for semantic search. The key is to implement the embedding-generation step and connect it to your vector database; you do not necessarily need to use the default OpenAI embedding model.
I would recommend the following approach:
1. Host your custom embedding model
If you are using a Sentence Transformers model such as all-MiniLM-L6-v2, expose it through a REST API (for example, using FastAPI). The API should accept text and return the generated embedding vector.
2. Integrate the model with Mendix
In Mendix, use a Call REST service activity in a microflow to send text to your embedding endpoint and parse the returned vector.
If you are using Mendix GenAI Commons, you can also implement a custom connector compatible with its model and embedding interfaces. The official documentation explains how to build your own GenAI connector or adapt an existing connector.
3. Store the embeddings in PostgreSQL with pgvector
Use the PgVector Knowledge Base module or your own SQL integration to store the text chunks and their embedding vectors.
Make sure the database vector column has the correct dimensionality for your model. For example, all-MiniLM-L6-v2 produces 384-dimensional embeddings.
4. Implement semantic search
When a user submits a search query:
5. Keep the embedding model consistent
This is essential: use the same embedding model and compatible configuration for indexing documents and generating search-query embeddings. If you change models, you will generally need to regenerate the stored embeddings and ensure the vector dimensions and similarity metric are compatible.
Official references:
My recommendation: If you already have a custom embedding model running in Python, start by exposing it through a REST API and calling it from Mendix. Use pgvector for storage and similarity search. If you also want the model to work with Mendix's GenAI Commons components, implement the appropriate custom connector rather than replacing the default model configuration blindly.
Hope this helps!