Spring AI With PostgreSQL pgvector: Building Generative AI Apps in Java

  Рет қаралды 6,595

Denis Magda

Denis Magda

Күн бұрын

Learn how to build generative AI applications in Java using the Spring AI EmbeddingClient and the PostgreSQL pgvector extension.
First, you’ll be introduced to the Spring AI ChatClient that uses the OpenAI GPT-4 model to generate recommendations based on user prompts. Next, explore how to deploy PostgreSQL with the pgvector extension and perform vector similarity searches using the Spring AI EmbeddingClient and Spring JdbcClient. In the end, discover how to optimize and scale the application using specialized indexes such as HNSW and distributed PostgreSQL (YugabyteDB).
Here you can find a complete version of the application:
github.com/YugabyteDB-Samples...
0:00 Learning plan
0:45 Sample application
1:29 Spring AI chatclient
3:30 Limitations of the current implementation
4:49 Deploying PostgreSQL pgvector in Docker
5:42 Preloading an Airbnb dataset
7:12 Exploring the dataset
8:59 Using spring AI embeddingclient with pgvector
14:10 Pptimizing the search with HNSW index
17:42 Scaling with distributed PostgreSQL (YugabyteDB)
21:12 Homework
Curious to learn more about databases? Follow me here:
* Medium: / magda7817
* Twitter: / denismagda

Пікірлер: 15
@mallikarjunmongolla4519
@mallikarjunmongolla4519 4 ай бұрын
Thanks for this video very useful to get into Spring AI . world need spring AI
@DevMastersDb
@DevMastersDb 4 ай бұрын
Excellent, thank you! I've shared your feedback with the Spring team ;)
@rafastepniewski6135
@rafastepniewski6135 Ай бұрын
Great job done here. Thanks a lot for sharing this.
@DevMastersDb
@DevMastersDb Ай бұрын
Many thanks!
@christianendres4650
@christianendres4650 5 ай бұрын
Thanks for the video but you should revoke and change your OpenAI-API-key (if the one shown is valid) and only set it via environment variables in the future to prevent leakage in videos.
@DevMastersDb
@DevMastersDb 5 ай бұрын
Sure, you're right. The key was deleted before the video was published. Overall, I take many shortcuts while recording videos to make a tutorial as short as possible. With this specific one, my hope/assumption was that Java devs know how to initialize sensitive/private parameters. Anyway, thanks for highlighting this here! It's a good reminder for everyone who will come across the video later. And here is the repo that shows how to initialize the key via an env variable.github.com/YugabyteDB-Samples/YugaPlus/blob/main/backend/src/main/resources/application.properties
@GSUGambit
@GSUGambit 5 ай бұрын
Itd be nice if you had a tutorial that showed how to create the embeddings. That will be the situation most developers will be in. We have the data in postgres but we need to generate the embeddings based on data already in our database
@GSUGambit
@GSUGambit 5 ай бұрын
At 10:21 you show aiClient.embed function. My assumption is we need to list the key value pairs of our Domain Objects into a string and call this function and that will give us the embeddings we should save in the database.
@DevMastersDb
@DevMastersDb 5 ай бұрын
@@GSUGambit Good point. I should have shown how to generate embeddings for my original dataset. The process is follows. Assume that you have the "value" column of a text type in Postgres. And you want to do a vector similarity search against its content. Then, this is how you can generated embeddings (pseudo-code): 1. Add a column that will store the embedding value (1536 is a dimenstion for OpenAi text-ada-2 model, you can set another value for another model): alter table myTable add column value_vector vector(1536). Repeat for every row in the table: 1. select id, value from myTable; 2. embedding = aiClient.embed(value); 3. update myTable set value_vector = embedding where id = row.id Hope it makes things clear.
@GSUGambit
@GSUGambit 5 ай бұрын
@DevMastersDb thank you I believe this is everything I need
@DevMastersDb
@DevMastersDb 5 ай бұрын
Ping me if anything doesn’t work as expected. I’ll do my best to send you over a code snippet in Java if necessary
@DevMastersDb
@DevMastersDb 4 ай бұрын
@@GSUGambit in case you still need it, this is a new video that shows how to generate embeddings with Spring AI: kzfaq.info/get/bejne/fJZ2esap0LOpnJ8.html
@sundarsravanivlogs9619
@sundarsravanivlogs9619 3 ай бұрын
What to learn as java full stack developer for AI future?? Do i need to learn python and completely switch fron java developer to python with AI
@DevMastersDb
@DevMastersDb 3 ай бұрын
Python is still a better fit for those who need to create and train models. As for general purpose apps that use LLMs and other models, Java is a great choice. So, stick to Java unless you’re creating your own models. Study Spring AI, LangChain4j and other frameworks that are gonna evolve rapidly within the Java ecosystem.
PostgreSQL pgvector for Python developers: Practical Guide
18:25
Sigma Kid Hair #funny #sigma #comedy
00:33
CRAZY GREAPA
Рет қаралды 32 МЛН
Heartwarming Unity at School Event #shorts
00:19
Fabiosa Stories
Рет қаралды 18 МЛН
Clown takes blame for missing candy 🍬🤣 #shorts
00:49
Yoeslan
Рет қаралды 38 МЛН
Spring Tips: Distributed Job Scheduling with Jobrunr
19:03
SpringDeveloper
Рет қаралды 10 М.
DB-GPT: Multi-Agent Framework - All-In-One Opensource Model!
8:49
Налог на незнание JavaScript - [Hamster Kombat]
50:20
EXEED VX 2024: Не өзгерді?
9:06
Oljas Oqas
Рет қаралды 48 М.
S24 Ultra and IPhone 14 Pro Max telephoto shooting comparison #shorts
0:15
Photographer Army
Рет қаралды 9 МЛН
Что не так с раскладушками? #samsung #fold
0:42
Не шарю!
Рет қаралды 215 М.
تجربة أغرب توصيلة شحن ضد القطع تماما
0:56
صدام العزي
Рет қаралды 58 МЛН