Java Forum Nord - Hannover - The Trinity in GenAI - Spring AI, LangChain4J and OpenAI

juarezjunior 51 views 30 slides Mar 09, 2025
Slide 1
Slide 1 of 30
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30

About This Presentation

Java Forum Nord - The Trinity in GenAI - Spring AI, LangChain4J and OpenAI


Slide Content

The Trinity in GenAI-Spring AI, LangChain4J
and OpenAI
Java Forum Nord 2024
Juarez Barbosa Junior @juarezjunior
Senior Principal Java Developer Evangelist
ORACLE
Copyright © 2024, Oracle and/or its affiliates

Juarez Barbosa Junior
SeniorPrincipal Java DeveloperEvangelist@ Oracle
•Coming from Dublin, Ireland
•28 years of experience in SW Engineering & DevRel
•Oracle, Microsoft, IBM, Nokia, Unisys, Accenture, startups
•Microsoft Azure Developer Relations Lead
•IBM Watson Tech Evangelist & Cloud Rockstar
•IBM Mobile Tech Evangelist & Global Thought Leader
•Nokia Developers Global Champion
•Java, Python, Cloud, DevOps, SRE, Cloud-native, IoT, AI, Blockchain,
Rust
•Speaker at conferences
•Oracle CloudWorld, Oracle Code, Microsoft Ignite & TechX, jPrime,
JCON, DevConf.cz, GeeCon, DevOpsDays, DeveloperWeek, DevOps
Institute, CloudLand, DWX, The Developer’s Conference (TDC),
Sec4Dev, JSNation, NodeConf, Conf42, Shift Conf, Global Azure,
Open-Source Lisbon, CodeFrenzy, Mêlée Numérique, React Summit,
Test.js Summit, Porto TechHubConf, Pyjamas, MiTechCon, Data
Science Summit, OpenSourceNorth, WeAreDevelopers, Global
Software Architecture Summit, JavaCro, JUGs, OUGs, GDGs,
meetups, hackathons, and customer engagements.
@juarezjunior
@juarezjunior

Agenda
•AI and GenAI–Synthetic Content
•Artificial Intelligence and GenAI
•OpenAI
•LangChain4J
•Spring AI
•GenAIwith the Oracle Database 23ai
•Demos
•Technical References
•Audience: Business and Technical
audiences (not necessarily Machine
Learning Engineers)
Copyright © 2024, Oracle and/or its affiliates

AI and GenAI–
Synthetic Content
Hannover pictured in a futuristic
cityscape
Copyright © 2024, Oracle and/or its affiliates

Artificial Intelligence and GenAI
•Core concepts in a nutshell
•GenAI-Artificial intelligence algorithms and transformer
models with the capability of generating content.
•Content-Text, images, videos, code, and others.
•Generation–a result of an input prompt (prompt engineering).
•Ethical issues –misuse, deep fakes, bias and discrimination,
automation and job replacements, cybersecurity and
cybercriminals.
Copyright © 2024, Oracle and/or its affiliates

Artificial Intelligence and GenAI
•Core concepts in a nutshell
•Apps–Applied currently in the fields of content development,
entertainment, drug discovery, software development,
healthcare, material generation sciences, and others.
•AI is now a commodity!
•Artificial General Intelligence (AGI) Research –ultimate goal
Copyright © 2024, Oracle and/or its affiliates

OpenAI
•Generative AI with OpenAI
•Natural Language Processing (NLP)
•Powerful, pre-trained and customizable Machine Learning
Models
•OpenAIAPI (REST interface)
•Scalable infrastructure (GPUs)
•https://openai.com/sora
Copyright © 2024, Oracle and/or its affiliates

Spring AI (1.0.0 M2)
•Spring AI (AI Concepts)
•A Java app framework for building AI-related applications. It provides a robust
abstraction layer that encapsulates many of the complexities required to interact with
various GenAIproviders, such as OpenAI, Cohere, Google Vertex AI/Gemini, and
others.
•API support across AI providers for chat, text-to-image, and embedding models.
•Its goal is to apply to the AI domain Spring ecosystem design principles such as
portability and modular design and promote using POJOs as the building blocks of an
application to the AI domain.
•https://spring.io/projects/spring-ai
Copyright © 2024, Oracle and/or its affiliates

Spring AI
•RAG (Retrieval-Augment Generation) with Spring AI
•LLMs' baseline knowledge might have gaps based on their training data. If you ask
an LLM to write about a recent trend or event, the LLM won't know what you're
talking about, so you may get meaningless responses.
•There's a way to provide LLMs with additional information (including business-
specific data)-that is what RAG is for!
•Oracle -What Is Retrieval-Augmented Generation (RAG)?
•Oracle –What Is Generative AI? How Does It Work?
Copyright © 2024, Oracle and/or its affiliates

Spring AI
•RAG (Retrieval-Augment Generation) with Spring AI
•In a nutshell, RAG is a technique that:
•Reads unstructured data;
•Converts the data intotokens;
•It usesembeddingsto transform the tokens into floating-point
arrays orvectorsso that LLM can process and interpret them;
•It stores the vectors inVector Databases.
Copyright © 2024, Oracle and/or its affiliates

Spring AI
•The Spring AI API covers a wide range of functionalities
•Chat Completion API
•Embeddings API
•Image Generation API
•Speech / Transcription API
•Vector Databases
•Function Calling API
Copyright © 2024, Oracle and/or its affiliates

Spring AI
•Spring AI –Blazingly Fast Performance
•GraalVM
•Native Image -compile Java code ahead
of time (AOT) to a binary –a native
executable
•Developing an Oracle JDBC app with
GraalVMNative Image
•mvn-Pnativenative:compile
•./target/spring-ai-graalvm-oai.exe
Copyright © 2024, Oracle and/or its affiliates

Spring AI
•Spring AI –Blazingly Fast Performance
•Spring with Virtual Threads
•Add the following entry in the application.propertiesfile:
spring.threads.virtual.enabled=true
•Class VirtualThreadTaskExecutor
•Embracing Virtual Threads
•All together now: Spring Boot 3.2, GraalVMnative images, Java 21, and
virtual threads with Project Loom
Copyright © 2024, Oracle and/or its affiliates

LangChain4J
•LangChain4J
•Easy interaction with LLMs and Vector Stores
•All major commercial and open-source LLMs and Vector Stores are easily
accessible through a unified API
•Easy integration with Java frameworks –Quarkusand Spring Boot
•AI Services, RAG, Tools, Chains
•https://docs.langchain4j.dev/
Copyright © 2024, Oracle and/or its affiliates

New| Oracle Database 23ai
Next-Generation Converged Database Services
Over300 major new features plusthousands of enhancements
Available on OCI and Azure
Major focus on
•AI for Data features
•Developer/Analyst features
•Mission-Critical features
Addresses data management pain points that have frustrated customers forever
Copyright © 2024, Oracle and/or its affiliates

Oracle Database 23ai -AI for Data
Algorithmic AI AI Vector Search Augmented Generative AI (LLMs)
Distributed AI AI Storage AI Developer Tools
Copyright © 2024, Oracle and/or its affiliates

Oracle Database 23ai -Dev for Data
JSON Relational
Duality Views
Property Graph Views
JavaScript
Stored Procedures
Data Intent
Language
Lock-free Consistent Updates,
Long-running Transactions
True
Cache
Copyright © 2024, Oracle and/or its affiliates

Oracle Database 23ai -Mission-Critical Data
RAFT Replication for
Globally Distributed Database
In-Database
Firewall
Real-Time SQL Plan
Management
RAC, Exadata, Data Guard
Simplicity and Scalability
Analytic SQL
Simplicity and Scalability
Priority
Transactions
Copyright © 2024, Oracle and/or its affiliates

Free| Oracle Database 23ai For Developers
Oracle Always Free ADB
Available on OCI
ADB Free Container Image
Available for download
Oracle Database Free
Available as RPM, Docker
Image, VBoxVM
Copyright © 2024, Oracle and/or its affiliates | Confidential -Internal
Very Low Cost Supported DeveloperEdition of ADB, BaseDB, ExaDB-D, and ExaDB-C@C

Demos
20 Copyright © 2024, Oracle and/or its affiliates
Spring AI –Chat, RAG,others
LangChain4J –Chat, RAG
Oracle Database 23ai
Oracle AI Vector Search
OpenAI

Reference
Architecture
for GenAIApps
Copyright © 2024, Oracle and/or its affiliates
Source: Architectural Approach for Building Generative AI Applications

Function Calling -Spring AI with Open AI
•Demo -Function Calling -Spring AI with Open AI
Copyright © 2024, Oracle and/or its affiliates

Chatbot -Spring AI with Open AI
•Demo -Direct LLM calls -Chatbot
Copyright © 2024, Oracle and/or its affiliates

RAG –Retrieval Augment Generation with
Spring AI, Open AI and Oracle Database 23ai
•Demo –RAG
•Spring AI + OracleVectorStore+ OpenAI+ Oracle
Database 23ai
Copyright © 2024, Oracle and/or its affiliates

RAG –Retrieval Augment Generation with
LangChain4J, Open AI and Oracle Database 23ai
•Demo –RAG
•LangChain4J + OracleVectorStore+ OpenAI+
Oracle Database 23ai
Copyright © 2024, Oracle and/or its affiliates

Image Generation -Spring AI with Open AI
•Demo -Direct LLM calls –Image Generation
Copyright © 2024, Oracle and/or its affiliates

Multimodality -Spring AI with Open AI
•Demo -Multimodality -Spring AI with Open AI
Copyright © 2024, Oracle and/or its affiliates

Copyright © 2024, Oracle and/or its affiliates
Technical References
•Spring AI -https://spring.io/projects/spring-ai
•RAG with Spring AI, Oracle Database 23ai, and OpenAI-https://rb.gy/e1mwt4
•OpenAI-https://openai.com/
•Oracle AI Vector Search -https://rb.gy/sp41uk
•Oracle AI Vector Search for Java Developers with the Oracle Database 23ai -
https://rb.gy/7ivwxr
•Java / JDBC –https://www.oracle.com/jdbc
•Introduction to Oracle JDBC Driver Support for Virtual Threads -https://bit.ly/3UlNJWP
•Developing an Oracle JDBC app with GraalVMNative Image -https://rb.gy/iy3sgh
•Getting Started with Reactive Relational Database Connectivity and the Oracle R2DBC
Driver -https://rb.gy/42dnz5
•Getting Started with the Java library for Reactive Streams Ingestion (RSI) -
https://bit.ly/3rEiRnC
•Introduction to JDBC Reactive Extensions with the Oracle Database —Developer
Release –https://rb.gy/qxlrbx
•Pipelined Database Operations -https://rb.gy/iy3sgh

Juarez Junior
@juarezjunior