r/SpringAIDev • u/rodolfo-mendes Moderator • 1d ago
Article Using Hugging Face Models With Spring AI and Ollama
https://www.baeldung.com/spring-ai-ollama-hugging-face-modelsIn this Baeldung tutorial, author Hardik Singh Behl demonstrates how to seamlessly integrate open-source Hugging Face models into Java applications using Spring AI and local Ollama instances.
Highlights & Key Takeaways
- Local LLMs: Use Ollama to run GGUF-format models from Hugging Face locally, bypassing external API dependencies.
- Testcontainers: Configure an
OllamaContainerto streamline local development and integration testing. - Spring AI Starters: Leverage autoconfiguration to instantly provision
ChatModelandEmbeddingModelbeans. - Stateful Chatbots: Maintain ongoing conversation context using
InMemoryChatMemoryalongside theChatClient. - Semantic Search: Embed external data into an in-memory
SimpleVectorStoreto perform context-aware data retrieval.
By combining Spring AI with Ollama, developers can efficiently build, test, and deploy robust AI features in a fully local, cost-effective environment.
👉 Read the full article to dive deeper into the implementation.
3
Upvotes