SouJava - Blazingly Fast GenAI App Development With Java and Spring AI

juarezjunior 41 views 35 slides Mar 09, 2025
Slide 1
Slide 1 of 35
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
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35

About This Presentation

SouJava - Blazingly Fast GenAI App Development With Java and Spring AI


Slide Content

. 2
ORACLE 2 Bal Else =.
ORACLE Database El va

Blazingly Fast GenAl App Development With
Java and Spring Al

S Blazingly Fast GenAl
App Development using
SOUJava Spring Al
SOUJAVA 2024 à LU.
Juarez Barbosa Junior @juarezjunior - 6:00 E
Sr Principal Java Developer Evangelist

ORACLE

[9] ojuarezjunior Juarez Barbosa Junior
Senior Principal Java Developer Evangelist @ 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
. um Python, Cloud, DevOps, SRE, Cloud-native, loT, Al, Blockchain,
ist
+ Speaker at conferences

+ Oracle CloudWorld, Oracle Code, Microsoft Ignite & TechX, ¡Prime,
JCON, DevConf.cz, GeeCon, DevOpsDays, DeveloperWeek, DevOps
Institute, CloudLand, DWX, The Developer's Conference (TDC),
Sec4Dey, JSNation, NodeConf, Conf42, Shift Conf, Global Azure,
Open-Source Lisbon, CodeFrenzy, Mélée Numérique, React Summit,
Tests Summit, Porto TechHub Conf, Pyjamas, MiTechCon, Data
Science Summit, OpenSourceNorth, WeAreDevelopers, Global
Software Architecture Summit, JavaCro, JUGs, OUGs, GDGs,

meetups, hackathons, and customer engagements.

Agenda

» Aland GenAl - Synthetic Content

+ Artificial Intelligence and GenAl

+ OpenAl

+» Spring Al

+ GenAl with the Oracle Database 23ai
« Demos

+ Technical References

« Audience: Business and Technical
audiences (not necessarily Machine
Learning Engineers)

Al and GenAl — Sao Paulo in Brazil pictured in a futuristic
Synthetic Content cityscape

Artificial Intelligence and GenAl

. Core concepts in a nutshell

+ GenAl - 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.

Artificial Intelligence and GenAl

. 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.

« Alis now a commodity!
+ Artificial General Intelligence (AGI) Research - ultimate goal

OpenAl Wegen

- Generative Al with OpenAl
+ Natural Language Processing (NLP)

+ Powerful, pre-trained and customizable Machine Learning
Models

+ OpenAl API (REST interface)
+ Scalable infrastructure (GPUs)
« https://openai.com/sora

© spring

Spring Al (1.0.0 M1)

- Spring Al (Al Concepts)

+ A Java app framework for building Al-related applications. It provides a robust
abstraction layer that encapsulates many of the complexities required to interact with
various GenAl providers, such as OpenAl, Cohere, Google Vertex Al/Gemini, and
others.

+ API support across Al providers for chat, text-to-image, and embedding models.

Its goal is to apply to the Al domain Spring ecosystem design principles such as
portability and modular design and promote using POJOs as the building blocks of an
application to the Al domain.

+ https://spring.io/projects/spring-ai

© spring

- RAG (Retrieval-Augment Generation) with Spring Al

Spring Al

+ 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 Al? How Does It Work?

© spring

- RAG (Retrieval-Augment Generation) with Spring Al
+ In a nutshell, RAG is a technique that:
+ Reads unstructured data;
+ Converts the data into tokens;

+ It uses embeddings to transform the tokens into floating-point
arrays or vectors so that LLM can process and interpret them;

Spring Al

+ It stores the vectors in Vector Databases.

© spring

- The Spring Al API covers a wide range of functionalities
+ Chat Completion API
« Embeddings API
+ Image Generation API
+ Speech / Transcription API
+ Vector Databases
+ Function Calling API

Spring Al

Spring Al

- Spring Al - 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
GraalVM Native Image

mvn -Pnative native:compile
./target/spring-ai-graalvm-oai.exe

plugin
<groupId»org.graalvm.buildtoo1s</grouptd»
<arti factrdonative-maven-pluginc/artifact1é>
<configuration»
<buildargs>
<buildargo-o ./target/spring-ai-graalvm-oaif//buildarg>
<Jouildangs>
</configuration>
</plugin>

© spring

Copyright © 2024, Oracle and/or its affiliates

© spring

Spring Al

- Spring Al - Blazingly Fast Performance
+ Spring with Virtual Threads

- Add the following entry in the application.properties file:
spring.threads.virtual.enabled=true

+ Class VirtualThreadTaskExecutor
+ Embracing Virtual Threads

- All together now: Spring Boot 3.2, GraalVM native images, Java 21, and
virtual threads with Project Loom

Copyright © 2024, Oracle and/or its affiliates

Wy
New | Oracle Database 23ai CZ

Next-Generation Converged Database Services

Over 300 major new features plus thousands of enhancements
Available on OCI and Azure
Major focus on

+ Al for Data features

ai
+ Developer/Analyst features Database 23

+ Mission-Critical features

Addresses data management pain points that have frustrated customers forever

Oracle Database 23ai - Al for Data

Algorithmic Al

TR

Distributed Al



Pad
dz

—+

Al Vector Search Augmented Generative Al (LLMs)

a

Al Storage Al Developer Tools

Oracle Database 23ai - Dev for Data

SÉËE
JSON Relational
Duality Views

sed

Data Intent
Language

Lock-free Consistent Updates,
Long-running Transactions

JavaScript
Stored Procedures

Oracle Database 23ai - Mission-Critical Data

Hl,
EFT
RAFT Replication for
Globally Distributed Database

Ebo

Priority
Transactions

Cape ©2024 Once a/a

NN
soi © ©

Real-Time SQL Plan
Management

RAC, Exadata, Data Guard
Simplicity and Scalability

So

In-Database
Firewall

saL

Analytic SQL
Simplicity and Scalability

Free | Oracle Database 23ai For Developers

Oracle Always Free ADB ADB Free Container Image Oracle Database Free

Available on OCI Available for download Available as RPM, Docker
Image, VBox VM

Very Low Cost Supported Developer Edition of ADB, BaseDB, ExaDB-D, and ExaDB-C@C

Cape © 2024 Orca o/o as Cor ral

Confidential - Oracle Restricted

Demos

Confidential Orale Restricted

Reference Architecture for GenAl
MIC TO
[search apı | chatapı | Prompt ut |

a oros … Reference
= ER |. ES

oon (en En = Architecture
DM

=
=
Se el oe for GenAl Apps

Doe
=
rn ee

=

Source: Architectural Approach for Building Generative Al Applications

Image Generation - Spring Al with Open Al

TITAN

- Demo - Direct LLM calls - Image Generation

Chatbot - Spring Al with Open Al

IT |

. Demo - Direct LLM calls - Chatbot

RAG - Retrieval Augment Generation
Spring Al with Open Al and Oracle Database 23ai

TITAN

- Demo - RAG
- Spring Al + SimpleVectorStore + Open Al

. Spring Al + OracleVectorStore + OpenAl + Oracle
Database 23ai

Multimodality - Spring Al with Open Al

IT |

- Demo - Multimodality - Spring Al with Open Al

Function Calling - Spring Al with Open Al

TITAN

- Demo -Function Calling - Spring Al with Open Al

Confidential - Oracle Restricted

Technical References

+ Spring Al - https://spring.io/projects/spring-ai
+ OpenAl - https://openai.com/
+ Oracle Al Vector Search - https: //rb.gy/sp41uk
+ Oracle Al Vector Search for Java Developers with the Oracle Database 23ai - https: //rb.gy/7ivwxr
+ Spring Al - https: //github.com/kousen / https: //github.com/ThomasVitale/Ilm-apps-java-
spring-ai
. Java / JDBC - https://www.oracle.com/jdbe
Introduction to Oracle JDBC Driver Support for Virtual Threads - https: //bit ly/3UINIWP
+ Developing an Oracle JDBC app with GraalVM Native 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.ev/axlrbx
+ Pipelined Database Operations - https: / /rb.gv/iv3sgh
+ What's in Oracle Database 23ai for Java Developers? -
https: //www.oracle.com/a/tech/docs/database/whats-in-oracledb23ai-for-java-

developers.pdf

pyright © 2024, Oracle and/or ts afte
‘confidentia - Oracle Rested

Juarez Junior

Y | @juarezjunior

ORACLE

Confidential - Oracle Restricted

Java Developers

Configential- Oracle Restricted

te ©

Grave oca Koon Java App
paa Dev with
Oracle
Database

— Gpgo- 28eecs

Zo

Overview of Oracle DB Access with Java

operators (map, reduce, filters),
concurrency modeling,

monitoring, tracing,
User Java code + JDBC

JavaucFlow

Database Access with

|

ut

Async call with non-blocking backpressut Oracle Database

|" Synchronous blocking cas

Copyright © 2024, Oracle and/or its affiliates

Oracle JDBC - Support for the Latest Java
Versions

. Support to the latest Java versions

(11,17,

* Project Loom - Virtual Threads
support

; 2 sl
J ava 2 2 + Java Virtual Threads and Pipelined
Database Operations

Launch Stream

1) and GraalVM

+ JDBC Standards - 4.2 and 4.3
+ Reactive Streams - Java Flow API
support

Re Reactive Streams Ingestion
March 19th 17 + Pipelined Database Operations

Oracle LiveLabs

Showcasing how Oracle's solutions can
solve your business problems

500+

free workshops,
available or in
development

people have already visited
LiveLabs

600+

events run
using LiveLabs
workshops

developer.oracle.com/livelabs
learn something new ...at your pace!

Qos

Oracle ACE Program

3 membership tiers à Oracle ACE

Oracle ACE à Oracle ACE Oracle ACE ás
Director Pro Associate Nominate

yourself or a candidate:

ace.oracle.com/nominate
Learn more - ace.oracle.com

Connect: EP [email protected] E @oracleace facebook.com/OracleACEs — [8] blogs.oracle.com/ace

Create your FREE
Cloud Account

* Goto

https://signup.cloud.oracle.com/

ORACLE
Cloud Infrastructure

de

~—_

Oracle Cloud Free Tier

Get started with.

Terms of Use