Upgrade to Pro — share decks privately, control downloads, hide ads and more …

RagHack - RAG 101 - BR

RagHack - RAG 101 - BR

Apresentação de Slides RagHack. Livestream em 03/09

Avatar for Marco Aurélio Bigélli Cardoso

Marco Aurélio Bigélli Cardoso

September 03, 2024
Tweet

Transcript

  1. RAGHack streams Week 1: September 3 - 8 Week 2:

    September 9 - 14 3 4 5 6 7 8 TUESDAY WEDNESDAY THURSDAY FRIDAY SATURDAY SUNDAY RAG 101 .NET Azure AI Studio Python Langchain4J LangchainJS Responsible AI MongoDB Azure AI Search PostgreSQL Azure SQL GraphRAG Multi-channels Hack! Hack! Hack! Hack! Hack! Hack! 10 11 12 13 14 15 TUESDAY WEDNESDAY THURSDAY FRIDAY SATURDAY SUNDAY VSCode Agent Agentic RAG Code Interpreter AI Studio Advanced AutoGen Data Access Control Fine Tuning Model catalog Evaluations Hack! Hack! Hack! Hack! Hack! Hack! 9 MONDAY Semantic Kernel Spring AI Vision models Internationalization Hack! Hack! Hack! Submissions due September 16, 11:59 PM PT! 9 MONDAY aka.ms/RAGhack
  2. RAGHack streams in more languages! Spanish: aka.ms/RagHack2024Espanol Portuguese: aka.ms/S-1374 Chinese:

    aka.ms/S-1380 RAG: Generación Aumentada de Recuperación Prácticas recomendadas de Azure AI Search AI Multi-Agentes: Patrones, Problemas y Soluciones RAG (Geração Aumentada de Busca) no Azure Construindo RAG com Azure AI Studio e Python Implantando RAG com .NET e Azure Developer CLI Global RAG Hack Together Create RAG apps with Azure AI SDK Create RAG applications with AI Toolkit VSCode Extension Intro to GraphRAG
  3. RAGHack prizes •Best overall •Best in JavaScript/TypeScript •Best in Java

    •Best in .NET •Best in Python •Best use of AI Studio •Best use of AI Search •Best use of PostgreSQL •Best use of Cosmos DB •Best use of Azure SQL Each winning team will receive a cash prize of $500
  4. Processo de submissão 1. Inscreva-se em qualquer livestream do RAGHack

    a partir de aka.ms/raghack/streams 2. Faça a sua submissão até 23:59 do dia 16 de setembro, abrindo um issue no repositório aka.ms/raghack e seguindo as instruções. É necessário um repositório e uma demo em vídeo – um endpoint é opcional. Inclua os membros da equipe. 3. Espere a avaliação!
  5. Agenda  O que é RAG  Técnicas de RAG

    simples e avançadas  RAG no Azure  Exemplo / Demo
  6. LLM: Large Language Model Review: This movie sucks. Sentiment: negative

    Review: I love this movie: Sentiment: Input LLM positive Output
  7. LLMs no Azure Creator Models How to use on Azure?

    OpenAI GPT3.5, GPT4, GPT4o, ada-002, text-embedding-3 Azure OpenAI, GitHub Models Microsoft Phi-3, Phi-3mini Azure AI Model Catalog, GitHub Models Mistral Nemo, Small, Large Cohere Command R, Command R+, Embed Meta LlaMA 3.1-8B, 70B, 405B https://github.com/marketplace/models https://azure.microsoft.com/products/ai-model-catalog https://azure.microsoft.com/products/ai-services/openai-service
  8. LLMs locais https://ollama.com/ Ollama é uma ferramenta para executar LLMs

    localmente na sua máquina Também pode ser usada com Github Codespaces aka.ms/ollama-python: Ollama Python Playground
  9. Usando modelos da OpenAI: Azure AI Studio System message +

    User question = Chat Completion response
  10. Usando modelos da OpenAI: Python response = openai_client.chat.completions.create( stream=True, messages

    = [ { "role": "system", "content": "You are a helpful assistant with very flowery language" }, { "role": "user", "content": "What food would magical kitties eat?” } ]) for event in response: print(event.choices[0].delta.content) https://github.com/pamelafox/python-openai-demos
  11. RAG: Retrieval Augmented Generation Busca vehicle | year | msrp

    | acceleration | --- | --- | --- | --- | --- | --- Prius (1st Gen) | 1997 | 24509.74 | 7.46 | Prius (2nd Gen) | 2000 | 26832.25 | 7.97 | Prius (3rd Gen) | 2009 | 24641.18 | 9.6 | Prius V | 2011 | 27272.28 | 9.51 | Prius C | 2012 | 19006.62 | 9.35 | Prius PHV | 2012 | 32095.61 | 8.82 | Prius C | 2013 | 19080.0 | 8.7 | Prius | 2013 | 24200.0 | 10.2 | Prius Plug-in | 2013 | 32000.0 | 9.17 | LLM The Prius V has an acceleration of 9.51 seconds from 0 to 60 mph. Pergunta How fast is the Prius V?
  12. RAG com OpenAI Python SDK user_query = "How fast is

    the Prius V?" retrieved_content = "vehicle | year | msrp | acceleration | mpg | class --- | --- | --- | --- | --- | --- Prius (1st Gen) | 1997 | 24509.74 | 7.46 | 41.26 | Compact Prius (2nd Gen) | 2000 | 26832.25 | 7.97 | 45.23 | Compact..." response = openai.chat.completions.create( messages = [ { "role": "system", "content": "You must answer questions according to sources provided." }, { "role": "user", "content": user_query + "\n Sources: \n" + retrieved_content } ]) https://github.com/pamelafox/python-openai-demos/blob/main/retrieval_augmented_generation.py
  13. Exemplos de RAG GitHub Copilot (RAG em código) Teams Copilot

    (RAG em conversas) Bing Copilot (RAG na web)
  14. Técnicas de RAG Fluxos RAG: • RAG simples • RAG

    avançado com query rewrite Fontes de RAG: • Dados estruturados (SQL) • Documentos (PDF, MD, etc.) • GraphRAG
  15. RAG Simples LLM Para calçados de trilha, considere o TrekExtreme

    Hiking Shoes 1 ou o Trailblaze Steel-Blue Hiking Shoes 2 Pergunta do usuário Qual o melhor calçado para trilhas? Busca [101]: Name: TrekExtreme Hiking Shoes Price: 135.99 Brand: Raptor Elite Type: Footwear Description: The Trek Extreme hiking shoes by Raptor Elite are built to ensure any trail. …
  16. RAG Simples (com PostgreSQL) Azure OpenAI + Azure PostgreSQL Flexible

    Server + Azure Container Apps Code: aka.ms/rag-postgres Demo: aka.ms/rag-postgres/demo
  17. RAG avançado com query re-writing LLM Para calçados de trilha,

    considere o TrekExtreme Hiking Shoes 1 ou o Trailblaze Steel-Blue Hiking Shoes 2 Pergunta do usuário Qual um bom calçado para trilha na montanha? Busca [101]: Name: TrekExtreme Hiking Shoes Price: 135.99 Brand: Raptor Elite Type: Footwear Description: The Trek Extreme hiking shoes by Raptor Elite are built to ensure any trail. … Calçado trilha montanha LLM
  18. RAG com busca estruturada Pergunta do usuário Vocês vendem equipamento

    de escalada abaixo de $30? LLM search_database( "climbing_gear", {"column": "price", "operator" : "<", "value" : "30" } )
  19. RAG com busca estruturada LLM Temos duas bolsas de escalada

    para o seu orçamento: SummitStone Chalk Bag 1 Guardian Blue Chalk Bag 2 User Question Vocês vendem equipamento de escalada abaixo de $30? [12]: Name: SummitStone Chalk Bag Price:29.99 Brand:Grolltex Type:Climbing Description: The SummitStone Chalk Bag in forest green is a must- have for climbers seeking adventure. … Search price < 30 LLM “Do you sell…” “climbing gear”
  20. RAG em documentos Busca PerksPlus.pdf#page=2: Some of the lessons covered

    under PerksPlus include: · Skiing and snowboarding lessons · Scuba diving lessons · Surfing lessons · Horseback riding lessons These lessons provide employees with the opportunity to try new things, challenge themselves, and improve their physical skills.…. LLM Sim, sua empresa tem benefícios para atividades como scuba e surfe 1 Pergunta Minha empresa cobre atividades aquáticas?
  21. RAG em documentos Azure OpenAI + Azure AI Search +

    Azure App Service Supports simple and advanced flows (Ask tab vs. Chat tab) Code: aka.ms/ragchat Demo: aka.ms/ragchat/demo
  22. Componentes Componente Exemplos Busca: Uma base de conhecimento capaz de

    buscar fragmentos de documentação com base em uma pergunta do usuário Azure AI Search, Azure CosmosDB, PostgreSQL, Qdrant, Pinecone LLM: O modelo de geração de linguagem responsável por interpretar a informação obtida juntamente com a pergunta do usuário OpenAI: GPT 3.5, GPT 4, GPT-4o Azure AI Studio: Meta Llama3, Mistral, Cohere R+ Orquestrador (opcional): Responsável por encadear as requisições ao motor de busca e ao LLM. Community: Langchain, Llamaindex Microsoft: Semantic Kernel, Promptflow Outras funções Histórico de chat, botões de feedback, voz, autenticação, upload de arquivos, etc.
  23. Formas de construir um app RAG No Code Copilot studio

    Azure Studio On Your Data Open source solutions High Code Low Code
  24. Azure OpenAI Studio – On Your Data https://learn.microsoft.com/azure/ai-services/openai/concepts/use-your-data Busca: Azure

    AI Search Azure Blob Storage Azure CosmosDB for MongoDB vCore URL/Web address Uploaded files LLM: GPT 3.5/4 Funçnoes: Autenticação Histórico de chat
  25. Open-source: Python Busca: Azure AI Search LLM: GPT 3.5/4 Funções:

    Autenticação Documentos com imagens github.com/Azure-Samples/azure-search-openai-demo "Building RAG apps in Python" September 3, 10:00 PM UTC / 03:00 PM PT aka.ms/raghack/python
  26. Open-source: .NET Busca: Azure AI Search LLM: GPT 3.5/4 Orquestrador:

    Semantic Kernel Funções: Voz github.com/Azure-Samples/azure-search-openai-demo-csharp "Building RAG apps in .NET" Sept. 3, 6:00 PM UTC / 11:30 AM PT aka.ms/raghack/dotnet
  27. Open-source: .NET Busca: Azure AI Search LLM: GPT 3.5/4 Orquestrador:

    Semantic Kernel Features: Upload de documentos Chat de grupo Histórico de conversa https://github.com/microsoft/chat-copilot
  28. Open-source: JavaScript Busca: Cosmos DB for NoSQL LLM: GPT 3.5/4

    Orquestrador: Langchain.JS Funções: Arquitetura Serverless (Azure Functions) https://github.com/Azure-Samples/serverless-chat-langchainjs "Building RAG apps in Langchain.JS" September 4, 3:00 PM UTC / 8:00 AM PT aka.ms/raghack/js
  29. Open-source: Java Busca: Azure AI Search LLM: GPT 3.5/4 Orquestrador:

    Semantic Kernel https://github.com/Azure-Samples/azure-search-openai-demo-java/ "Building RAG apps with Java + Semantic Kernel" Sept. 9, 3:00 PM UTC / 8:00 AM PT aka.ms/raghack/java-sk
  30. Open-source: Azure AI Studio Busca: Azure AI Search LLM: GPT

    3.5/4 Orquestrador: PromptFlow Funções: Perfil de usuário https://github.com/Azure-Samples/contoso-chat "Building RAG apps with Java + Semantic Kernel" Sept. 9, 3:00 PM UTC / 8:00 AM PT aka.ms/raghack/aistudio
  31. Requisitos • Subscrição do Azure • Pode ser a versão

    grátis, com limitações. • Acesso ao Azure Open AI • Permissões: • Microsoft.Authorization/roleAssignments/write • Microsoft.Resources/deployments/write
  32. RAGHack: Next steps Register for the hackathon @ aka.ms/raghack/register Hack,

    hack, hack! Try our code samples or start from scratch! For any questions, post in GitHub forum or attend Discord Office Hours. Join more live RAG sessions! aka.ms/raghack/streams Submit your project before September 16th 11:59 PM PT to win prizes! aka.ms/raghack