AI / LangChain4j interview questions
What is the EmbeddingModel in LangChain4j and which providers are supported?
An EmbeddingModel in LangChain4j converts text into dense numerical vectors (embeddings) that capture semantic meaning. Texts with similar meanings produce vectors that are geometrically close, enabling similarity search. EmbeddingModels are used during RAG ingestion (to vectorize document chunks) and at query time (to vectorize the user's question so it can be matched against stored chunks).
The core interface is minimal by design:
public interface EmbeddingModel {
Response<Embedding> embed(String text);
Response<List<Embedding>> embedAll(List<TextSegment> textSegments);
}Supported embedding model providers include:
| Provider | Example Model | Notes |
|---|---|---|
| OpenAI | text-embedding-3-small / ada-002 | Most commonly used; cloud API |
| Azure OpenAI | text-embedding-ada-002 | Enterprise Azure deployments |
| Google Vertex AI | textembedding-gecko | GCP-based workloads |
| Ollama | nomic-embed-text, mxbai-embed | Local/on-premise, no API costs |
| HuggingFace | sentence-transformers models | Open-source models via HF Inference API |
| In-process (Onnx) | all-MiniLM-L6-v2 | Embedded in the JVM — no external calls, fastest |
The in-process ONNX option (langchain4j-embeddings module) is particularly useful for offline environments or when minimizing API costs: the model runs entirely within the JVM with no network calls, at the cost of slightly lower embedding quality compared to frontier models.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
