Slide 1

Slide 1 text

Large Language Models, Daten & APIs: Integration von Generative-AI-Power in Ihre Anwendungen mit LangChain & Co. Christian Weyer @christianweyer CTO, Technology Catalyst

Slide 2

Slide 2 text

§ What & why? § LLM integration aspects § Selected use cases § Agents & LLMs § LLM landscape § Current state & Outlook Large Language Models, Daten & APIs Integration von Generative-AI-Power in Ihre Anwendungen mit LangChain & Co. Talking points 2

Slide 3

Slide 3 text

§ Technology catalyst § AI-powered solutions § Pragmatic end-to-end architectures § Microsoft Regional Director § Microsoft MVP for Developer Technologies & Azure ASPInsider, AzureInsider § Google GDE for Web Technologies [email protected] @christianweyer https://www.thinktecture.com Large Language Models, Daten & APIs Integration von Generative-AI-Power in Ihre Anwendungen mit LangChain & Co. Christian Weyer Co-Founder & CTO @ Thinktecture AG 3

Slide 4

Slide 4 text

Large Language Models, Daten & APIs Integration von Generative-AI-Power in Ihre Anwendungen mit LangChain & Co. Intro 4

Slide 5

Slide 5 text

Large Language Models, Daten & APIs Integration von Generative-AI-Power in Ihre Anwendungen mit LangChain & Co. What’s in a name? 5

Slide 6

Slide 6 text

§ LLMs generate text based on input § LLMs can understand text – this changes a lot § Prompts are the universal interface (“UI”) → unstructured text with semantics § Human language evolves as a first-class citizen in software architecture 🤯 * LLMs are not “perfect” – errors may occur, caveats like non-determinism & hallucination – these are topics to be dealt with Large Language Models, Daten & APIs Integration von Generative-AI-Power in Ihre Anwendungen mit LangChain & Co. Text… – really, just text? 6 Yeah: Large Language Models (LLMs)

Slide 7

Slide 7 text

§ LLMs are programs § LLMs are highly specialized neural networks § LLMs use(d) lots of data § LLMs need a lot of resources to be operated § LLMs have an API to be used through Large Language Models, Daten & APIs Integration von Generative-AI-Power in Ihre Anwendungen mit LangChain & Co. Large Language Models demystified 7

Slide 8

Slide 8 text

Large Language Models, Daten & APIs Integration von Generative-AI-Power in Ihre Anwendungen mit LangChain & Co. Integration 8

Slide 9

Slide 9 text

Large Language Models, Daten & APIs Integration von Generative-AI-Power in Ihre Anwendungen mit LangChain & Co. Using LLMs: It’s just APIs! Inference, FTW. 9

Slide 10

Slide 10 text

GPT-4 API access via OpenAI Playground Large Language Models, Daten & APIs Integration von Generative-AI-Power in Ihre Anwendungen mit LangChain & Co. DEMO 10 Demos are using OpenAI GPT-3.5-turbo or GPT-4(-Turbo)

Slide 11

Slide 11 text

Large Language Models, Daten & APIs Integration von Generative-AI-Power in Ihre Anwendungen mit LangChain & Co. The best tool for Java developers to talk to LLMs! 11 🙈

Slide 12

Slide 12 text

§ Open-source framework for developing applications powered by LLMs § > 1000 contributors § Python and Typescript versions § Chains as a central concept § Sequences of LLM-related actions in code § Abstractions for § Prompts & LLMs (local and remote) § Memory § Vector stores § Tools § Loading text from a wide range of sources Large Language Models, Daten & APIs Integration von Generative-AI-Power in Ihre Anwendungen mit LangChain & Co. LangChain 12

Slide 13

Slide 13 text

§ No official Java version of LangChain available § LangChain4J is community-driven § Works with Java 8 or higher § Supports Spring Boot 2 and 3 Large Language Models, Daten & APIs Integration von Generative-AI-Power in Ihre Anwendungen mit LangChain & Co. LangChain4J 13

Slide 14

Slide 14 text

Large Language Models, Daten & APIs Integration von Generative-AI-Power in Ihre Anwendungen mit LangChain & Co. Use cases 14

Slide 15

Slide 15 text

Text generation § LLMs are good in generating text § Regular text § Code § SQL (beware!) § JSON § etc. Large Language Models, Daten & APIs Integration von Generative-AI-Power in Ihre Anwendungen mit LangChain & Co. Typical LLM use cases 15

Slide 16

Slide 16 text

Understanding text § LLM can be instructed to e.g. § do sentiment analysis § extract information from text § Tools (like Kor, Open AI Functions – or TypeChat) for extracting information in a structured way reliably § JSON, Python classes, TypeScript types etc. Large Language Models, Daten & APIs Integration von Generative-AI-Power in Ihre Anwendungen mit LangChain & Co. Typical LLM use cases 16

Slide 17

Slide 17 text

Extracting structured data (LangChain + Kor) Large Language Models, Daten & APIs Integration von Generative-AI-Power in Ihre Anwendungen mit LangChain & Co. DEMO 17

Slide 18

Slide 18 text

Answering Questions / Chat with documents § Mixed usage of text embedding and a large language model § Retrieval-augmented generation (RAG) § Index one or more documents § Use text embedding to index documents § Store embeddings in a vector database § User asks question § Create embedding for the question § Search vector database to find relevant text § Use LLM with relevant input text & question to create an answer Large Language Models, Daten & APIs Integration von Generative-AI-Power in Ihre Anwendungen mit LangChain & Co. Typical LLM use cases 18

Slide 19

Slide 19 text

Large Language Models, Daten & APIs Integration von Generative-AI-Power in Ihre Anwendungen mit LangChain & Co. Answering Questions / Chat with documents - RAG Cleanup & Split Text Embedding Question Text Embedding Save Query Relevant Text Question Answer LLM 19 Vector DB Embedding model Embedding model 💡 Indexing / Embedding QA

Slide 20

Slide 20 text

Chat with my company’s policies (LangChain) Large Language Models, Daten & APIs Integration von Generative-AI-Power in Ihre Anwendungen mit LangChain & Co. DEMO 20

Slide 21

Slide 21 text

Large Language Models, Daten & APIs Integration von Generative-AI-Power in Ihre Anwendungen mit LangChain & Co. Agents 21

Slide 22

Slide 22 text

§ Involve an LLM making decisions (via ReAct – Reasoning & Acting) § Which actions to take (thought) § Taking that action (executed via your code) § Seeing an observation § Repeating until done § Tools to interact with the workflow from the LLM § LangChain tools and agents § Semantic Kernel native functions § OpenAI function calling § Reliable (structured) way to interact from the LLM with your code § Proprietary to OpenAI models (fine-tuned) Large Language Models, Daten & APIs Integration von Generative-AI-Power in Ihre Anwendungen mit LangChain & Co. Agents: Multi-steps workflows with LLM interaction 22

Slide 23

Slide 23 text

Large Language Models, Daten & APIs Integration von Generative-AI-Power in Ihre Anwendungen mit LangChain & Co. ReAct – with function calling 23 LLM My code Query Some API Some database Prompt Function definitions Final answer Answer ❓ ❓ ❗ 💡

Slide 24

Slide 24 text

Stock market agent with OpenAI function calling (Python OpenAI SDK) Large Language Models, Daten & APIs Integration von Generative-AI-Power in Ihre Anwendungen mit LangChain & Co. DEMO 24

Slide 25

Slide 25 text

Large Language Models, Daten & APIs Integration von Generative-AI-Power in Ihre Anwendungen mit LangChain & Co. Landscape 25

Slide 26

Slide 26 text

Large Language Models, Daten & APIs Integration von Generative-AI-Power in Ihre Anwendungen mit LangChain & Co. LLMs everywhere 26 OpenAI-related (cloud) OpenAI Azure OpenAI Service Big cloud providers Google Model Garden on Vertex AI Amazon Bedrock Other providers Antrophic Cohere HuggingFace … Open-source Edge IoT Server Desktop Mobile Web Open-source

Slide 27

Slide 27 text

§ Open-source community drives innovation in Generative AI § HuggingFace is central place for it § Literally, every week a new and “better” LLM shows up 🤓 § Important factors § Use case § Parameter size § Quantization § Processing power needed § Mistral-based family shows big potential for local use cases (7B params) Large Language Models, Daten & APIs Integration von Generative-AI-Power in Ihre Anwendungen mit LangChain & Co. Open-source LLMs thrive 27

Slide 28

Slide 28 text

Mistral OSS LLM locally on Apple M1 Max (llama.cpp & LM Studio) Large Language Models, Daten & APIs Integration von Generative-AI-Power in Ihre Anwendungen mit LangChain & Co. DEMO 28

Slide 29

Slide 29 text

Running OSS LLM offline in the browser - with Wasm & WebGPU (web-llm) Large Language Models, Daten & APIs Integration von Generative-AI-Power in Ihre Anwendungen mit LangChain & Co. DEMO 29

Slide 30

Slide 30 text

Large Language Models, Daten & APIs Integration von Generative-AI-Power in Ihre Anwendungen mit LangChain & Co. Wrap-Up 30

Slide 31

Slide 31 text

§ Fast moving and changing field § Every week something “big” happens in LLM space § Frameworks & ecosystem are evolving together with LLMs § Closed vs open LLMs § Competition drives invention & advancement § SISO (sh*t in, sh*t out) § Quality of results heavily depends on your data Large Language Models, Daten & APIs Integration von Generative-AI-Power in Ihre Anwendungen mit LangChain & Co. Current state 31

Slide 32

Slide 32 text

Huge potential for LLM-driven human-machine workflows via universal interface agents Large Language Models, Daten & APIs Integration von Generative-AI-Power in Ihre Anwendungen mit LangChain & Co. Outlook 32

Slide 33

Slide 33 text

Large Language Models, Daten & APIs Integration von Generative-AI-Power in Ihre Anwendungen mit LangChain & Co. Outlook 33

Slide 34

Slide 34 text

§ Prompt Engineering Guide § https://www.promptingguide.ai/ § OpenAI API reference § https://platform.openai.com/docs/api-reference § Azure OpenAI Service REST API reference § https://learn.microsoft.com/en-us/azure/ai- services/openai/reference § Hugging Face Inference Endpoints § https://huggingface.co/docs/inference- endpoints/api_reference § LangChain § https://www.langchain.com/ § LangChain4J § https://github.com/langchain4j/langchain4j § ReAct: Synergizing Reasoning and Acting in Language Models § https://react-lm.github.io/ § Llama.cpp § https://github.com/ggerganov/llama.cpp § Web-llm § https://webllm.mlc.ai/ § The Dawn of LMMs: Preliminary Explorations with GPT-4V(ision) § https://arxiv.org/pdf/2309.17421.pdf § OWASP Top 10 for LLM Applications § https://owasp.org/www-project-top-10-for- large-language-model- applications/assets/PDF/OWASP-Top-10-for- LLMs-2023-slides-v1_0_1.pdf Large Language Models, Daten & APIs Integration von Generative-AI-Power in Ihre Anwendungen mit LangChain & Co. Links 34