Share
Embed
Transcript
32 slides
-
Supersonic, Subatomic intelligent applications. Build AI-Infused applications with Quarkus Kevin
Dubois(@kevindubois) Principal Developer Advocate -
Kevin Dubois ★ Principal Developer Advocate at Red Hat ★
Based in Belgium ★ 🗣 Speak English, Dutch, French, Italian ★ Open Source Contributor (Quarkus, Camel, Knative, ..) @[email protected] youtube.com/@thekevindubois linkedin.com/in/kevindubois github.com/kdubois @kevindubois.com -
Set goals App developer IT operations Data engineer Data scientists
ML engineer Gather and prepare data Develop model Integrate models in app dev Model monitoring & management Retrain models Business leadership AI as a team initiative -
Boring Stuff Artificial Intelligence Artificial Intelligence “Ability of a machine
to imitate human intelligent behaviour” -
Machine Learning Artificial Intelligence “Application of AI to automatically learn
and improve from experience” Machine Learning -
Boring Stuff Deep Learning Artificial Intelligence “Vast volumes of data
and complex algorithms to train a model using Neural Networks.” Machine Learning Deep Learning -
Boring Stuff Generative AI Artificial Intelligence “Focuses on creating new
and original content ” Machine Learning Deep Learning Generative AI -
▸ Transformers (recognize, predict and generate human language) ▸ Trained
in a huge amount of data (trillions of tokens) ▸ Relationship between words and phrases ▸ Fine-tuned for specific domains What are Large Language Models (LLMs)? -
Prompts ▸ Interacting with the model for asking questions ▸
Interpreting messages to get important information ▸ Populating Java classes from natural language ▸ Structuring output -
@RegisterAiService interface Assistant { String chat(String message); } @Inject private
final Assistant assistant; quarkus.langchain4j.openai.api-key=sk-... Configure API key Define Ai Service Create the instance -
Prompting @SystemMessage("You are a professional poet") @UserMessage(""" Write a poem
about {topic}. The poem should be {lines} lines long. """) String writeAPoem(String topic, int lines); Add a context on the calls Chat message Placeholder -
class TransactionInfo { @Description("full name") public String name; @Description("IBAN value")
public String iban; @Description("Date of the transaction") public LocalDate transactionDate; @Description("Amount in dollars of the transaction") public double amount; } interface TransactionExtractor { @UserMessage("Extract information about a transaction from {{it}}") TransactionInfo extractTransaction(String text); } Marshalling objects -
Chains & Memory ▸ Create conversations ▸ Refer to past
answers ▸ Manage concurrent interactions -
@Inject private final ChatLanguageModel model; ConversationalChain chain = ConversationalChain.builder() .chatLanguageModel(model)
.build(); String userMessage1 = "Can you give a brief explanation of Kubernetes, 3 lines max?"; String answer1 = chain.execute(userMessage1); String userMessage2 = "Can you give me a YAML example to deploy an application for that?"; String answer2 = chain.execute(userMessage2); Conversation like chat Remember previous interactions -
Tools ▸ Mixing business code with model ▸ Delegating to
external services -
@RegisterAiService(tools = EmailService.class) public interface MyAiService { @SystemMessage("You are a
professional poet") @UserMessage("Write a poem about {topic}. Then send this poem by email.") String writeAPoem(String topic); @ApplicationScoped public class EmailService { @Inject Mailer mailer; @Tool("send the given content by email") public void sendAnEmail(String content) { mailer.send(Mail.withText("[email protected]", "A poem", content)); } } Describe when to use the tool Register the tool Need to run code -
Embedding Documents ▸ Adding terms of use rules into the
model ▸ Asking questions of legal documents ▸ Natural queries -
@Inject RedisEmbeddingStore store; @Inject EmbeddingModel embeddingModel; public void ingest(List<Document> documents)
{ EmbeddingStoreIngestor ingestor = EmbeddingStoreIngestor.builder() .embeddingStore(store) .embeddingModel(embeddingModel) .documentSplitter(recursive(500, 0)) .build(); ingestor.ingest(documents); } Loaded document from CSV, Spreadsheet, text.. Ingested documents stored in Redis Ingest documents -
@ApplicationScoped public class DocumentRetrieverExample implements Retriever<TextSegment> { private final EmbeddingStoreRetriever
retriever; DocumentRetrieverExample(RedisEmbeddingStore store, EmbeddingModel model) { retriever = EmbeddingStoreRetriever.from(store, model, 20); } @Override public List<TextSegment> findRelevant(String s) { return retriever.findRelevant(s); } } CDI injection Augmentation interface -
Local Models ▸ Use models on-prem ▸ Evolve a model
privately ▸ Sentiment Analysis of private data -
Run LLMs locally and build AI applications podman-desktop.io Download now
at: Supported platforms: From getting started with AI, to experimenting with models and prompts, Podman AI Lab enables you to bring AI into your applications without depending on infrastructure beyond your laptop. Podman AI Lab