is so large that it achieves general-purpose language understanding and generation. Review: This movie sucks. Sentiment: negative Review: I love this movie: Sentiment: Input LLM positive Output
GPT 3.5 175 B OpenAI ChatGPT, Copilots, APIs GPT 4 Undisclosed OpenAI PaLM 540 B Google Bard Gemini Undisclosed Google Claude 2,3 130 B Anthropic APIs LlaMA 70 B Meta OSS Mistral-7B, Mixtral 7 B Mistral AI OSS
GPT •Andrej Karpathy: Let's build GPT: from scratch, in code GPT models are LLMs based on Transformer architecture from "Attention is all you need" paper
= [ { "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)
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.…. Large Language Model Yes, your company perks cover underwater activities such as scuba diving lessons 1 User Question Do my company perks cover underwater activities?
If the search results don’t contain a good answer, the LLM will be unable to answer or will answer wrongly. Noisy input: If the LLM receives too much information, it may not find the correct answer amidst the noise. Source: Lost in the Middle: How Language Models Use Long Contexts, Liu et al. arXiv:2307.03172 50 55 60 65 70 75 5 15 25 Accuracy Number of documents in input context
search is best for finding semantically related matches Keyword search is best for exact matches (proper nouns, numbers, etc) Hybrid search combines vector search and keyword search, optimally using Reciprocal-Rank-Fusion for merging results and a ML model to re-rank results after https://aka.ms/ragrelevance
your company perks cover underwater activities such as scuba diving lessons 1 User Question Do my company perks cover underwater activities? [[0.0014615238, - 0.015594152, - 0.0072768144, - 0.012787478,…] “Do my company…” “Do my company …” PerksPlus.pdf#page=2: Some of the lessons covered under PerksPlus include: · Skiing and snowboarding lessons · Scuba diving… “Do my company …” Hybrid Search
pptx, md, html, images You need an ingestion process for extracting, splitting, vectorizing, and storing document chunks. On Azure: Azure AI Search with Document Intelligence, OpenAI embedding models, Integrated Vectorization Database rows (Structured data) PostgreSQL, MongoDB, Qdrant, etc. You need a way to vectorize & search target columns. On Azure: • Azure AI Search (by copying data) • PostgreSQL+pgvector • CosmosMongoDB+vector • Container Apps services (Milvus, Qdrant, Weaviate) + OpenAI embedding models
Azure AI Search LLM: GPT 3.5/4 Features: Multi-turn chats User authentication with ACLs Chat with image documents https://github.com/Azure-Samples/azure-search-openai-demo/ aka.ms/ragchat
can be used, but will have limitations. • Access to Azure OpenAI or an openai.com account • Request access to Azure OpenAI today! https://aka.ms/oaiapply • Azure account permissions: • Microsoft.Authorization/roleAssignments/write • Microsoft.Resources/deployments/write on subscription level https://github.com/Azure-Samples/azure-search-openai-demo/#azure-account-requirements
VS Code with Dev Containers extension • Your Local Environment • Python 3.9+ • Node 14+ • Azure Developer CLI https://github.com/Azure-Samples/azure-search-openai-demo/?tab=readme-ov-file#project-setup
env new azd up Login to your Azure account: Create a new azd environment: (to track deployment parameters) Provision resources and deploy app: azd up is a combination of azd provision and azd deploy
vectorization or Local script Azure OpenAI Azure AI Search DATA INGESTION Azure OpenAI Azure App Service or Local server Azure Storage CHAT APP Azure AI Search
with these steps: Upload documents An online version of each document is necessary for clickable citations. Extract data from documents Supports PDF, HTML, docx, pptx, xlsx, images, plus can OCR when needed. Local parsers also available for PDF, HTML, JSON, txt. Split data into chunks Split text based on sentence boundaries and token lengths. Langchain splitters could also be used here. Vectorize chunks Compute embeddings using OpenAI embedding model of your choosing. Indexing • Document index • Chunk index • Both Azure Document Intelligence Azure Blob Storage Python Azure OpenAI Azure AI Search
Azure AI Search Data source access • Blob Storage • ADLSv2 • SQL DB • CosmosDB • … + Incremental change tracking File format cracking • PDFs • Office documents • JSON files • … + Extract images and text, OCR as needed Chunking • Split text into passages • Propagate document metadata Vectorization • Turn chunks into vectors • OpenAI embeddings or your custom model Indexing • Document index • Chunk index • Both In preview Integrated data chunking and embedding in Azure AI Search aka.ms/integrated-vectorization
to the knowledge base) • Are they clear and understandable? • Are they formatted in the desired manner? Yes, underwater activities are included as part of the PerksPlus program. Some of the underwater activities covered under PerksPlus include scuba diving lessons [PerksPlus.pdf#page=3]. Yes, according to the information provided in the PerksPlus.pdf document, underwater activities such as scuba diving are covered under the program. Yes, the perks provided by the PerksPlus Health and Wellness Reimbursement Program cover a wide range of fitness activities, including underwater activities such as scuba diving. The program aims to support employees' physical health and overall well-being, so it includes various lessons and experiences that promote health and wellness. Scuba diving lessons are specifically mentioned as one of the activities covered under PerksPlus. Therefore, if an employee wishes to pursue scuba diving as a fitness-related activity, they can expense it through the PerksPlus program. Do the perks cover underwater activities?
Search) • Search query cleaning • Search options (hybrid, vector, reranker) • Additional search options • Data chunk size and overlap • Number of results returned Search Large Language Model Question • System prompt • Language • Message history • Model (ie. GPT 3.5) • Temperature (0-1) • Max tokens
tools for automating the evaluation of RAG answer quality. • Generate ground truth data • Evaluate with different parameters • Compare the metrics and answers across evaluations Based on the azure-ai-generative SDK: https://pypi.org/project/azure-ai-generative/
The ground truth data is the ideal answer for a question. Manual curation is recommended! Generate Q/A pairs from a search index: Azure AI Search Azure OpenAI azure-ai-generative SDK documents prompt + docs Q/A pairs
feedback dialog to your live app: Then you can: • Manually debug the answers that got rated • Add questions to ground truth data https://github.com/microsoft/sample-app-aoai-chatGPT/pull/396 aka.ms/rag/thumbs
custom metrics for every question in ground truth. Evaluate based off the configuration: Local endpoint Azure OpenAI azure-ai-generative SDK response + ground truth prompt metrics question gpt_coherence gpt_groundedness gpt_relevance length has_citation