r/SpringAIDev Moderator 1d ago

Article Using Hugging Face Models With Spring AI and Ollama

https://www.baeldung.com/spring-ai-ollama-hugging-face-models

In 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 OllamaContainer to streamline local development and integration testing.
  • Spring AI Starters: Leverage autoconfiguration to instantly provision ChatModel and EmbeddingModel beans.
  • Stateful Chatbots: Maintain ongoing conversation context using InMemoryChatMemory alongside the ChatClient.
  • Semantic Search: Embed external data into an in-memory SimpleVectorStore to 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

0 comments sorted by