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.…. 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?
for RAG apps • Lots of passages in prompt → degraded quality → Can’t only focus on recall • Incorrect passages in prompt → possibly well-grounded yet wrong answers → Helps to establish thresholds for “good enough” grounding data Source: Lost in the Middle: How Language Models Use Long Contexts, Liu et al. arXiv:2307.03172 50 55 60 65 70 75 5 10 15 20 25 30 Accuracy Number of documents in input context
of floating-point numbers. ”dog” → [0.017198, -0.007493, -0.057982, 0.054051, -0.028336, 0.019245,…] Different models output different embeddings, with varying lengths. Model Encodes Vector length word2vec words 300 Sbert (Sentence-Transformers) text (up to ~400 words) 768 OpenAI ada-002 text (up to 8191 tokens) 1536 Azure Computer Vision image or text 1024 ….and many more models! Demo: Compute a vector with ada-002 (aka.ms/aitour/vectors)
similarity between inputs. The most common distance measurement is cosine similarity. Demo: Vector Embeddings Comparison (aka.ms/aitour/vector-similarity) Demo: Compare vectors with cosine similarity (aka.ms/aitour/vectors) Similar: θ near 0 cos(θ) near 1 Orthogonal: θ near 90 cos(θ) near 0 Opposite: θ near 180 cos(θ) near -1 def cosine_sim(a, b): return dot(a, b) / (mag(a) * mag(b)) *For ada-002, cos(θ) values range from 0.7-1
Enterprise-ready → scalability, security and compliance Integrated with Semantic Kernel, LangChain, LlamaIndex, Azure OpenAI Service, Azure AI Studio, and more Generally available Demo: Azure AI search with vectors (aka.ms/aitour/azure-search)
Neighbors • Fast vector search at scale • Uses HNSW, a graph method with excellent performance-recall profile • Fine control over index parameters Exhaustive KNN search • KNN = K Nearest Neighbors • Per-query or built into schema • Useful to create recall baselines • Scenarios with highly selective filters • e.g., dense multi-tenant apps r = search_client.search( None, top=5, vector_queries=[VectorizedQuery( vector=search_vector, k_nearest_neighbors=5, fields="embedding")]) r = search_client.search( None, top=5, vector_queries=[VectorizedQuery( vector=search_vector, k_nearest_neighbors=5, fields="embedding", exhaustive=True)])
to date ranges, categories, geographic distances, access control groups, etc. • Rich filter expressions • Pre-/post-filtering • Pre-filter: great for selective filters, no recall disruption • Post-filter: better for low-selectivity filters, but watch for empty results r = search_client.search( None, top=5, vector_queries=[VectorizedQuery( vector=query_vector, k_nearest_neighbors=5, fields="embedding")], vector_filter_mode=VectorFilterMode.PRE_FILTER, filter= "tag eq 'perks' and created gt 2023-11-15T00:00:00Z") r = search_client.search( None, top=5, vector_queries=[ VectorizedQuery( vector=query1, fields="body_vector", k_nearest_neighbors=5,), VectorizedQuery( vector=query2, fields="title_vector", k_nearest_neighbors=5,) ]) Multi-vector scenarios Multiple vector fields per document Multi-vector queries Can mix and match as needed Filters in vector queries (aka.ms/aisearch/vectorfilters)
own code to add data to an index. Data ingestion guide: Adding documents aka.ms/ragchat/add-data Azure Storage Document Intelligence Example: prepdocs.py Azure OpenAI Azure AI Search Computes embeddings Stores in index Extracts data from PDFs Splits data into chunks Python Stores PDFs
data source, and it will index the data periodically or on a trigger. •Azure Blob Storage •Azure Cosmos DB •Azure Data Lake Storage Gen2 •Azure SQL Database •SharePoint in Microsoft 365 •Azure Cosmos DB for MongoDB …and more! Data source Indexer Target Index Indexers in Azure AI Search (aka.ms/aisearch/indexers)
chunking and vectorization. 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)
merged, you can opt to use it via: PR: Adding integrated vectorization support (aka.ms/ragchat/intvect) azd env set USE_FEATURE_INT_VECTORIZATION true azd up
local and easy to change. Cons: • Hard to connect to indexers for cloud- based data. • Has to be manually re-run for new data. Pros: • Easily connect to indexers that can add new data on triggers or periodically. • You don’t need to maintain chunking or embedding code yourself. Cons: • Currently in preview mode. • Customizing the skills takes more effort, if the built-in skills are not sufficient.
processing strings during indexing and query execution. • Language analyzers: If you’re indexing non-English documents in particular, consider customizing the analyzer used. • Custom analyzers: Useful for custom tokenization, like to recognize phone numbers, word normalization, etc. Analyzers for text processing in Azure AI Search (aka.ms/aisearch/analyzers)
yourself in our discussion forum • Deploy the repo with the sample data • See steps on low cost deployment → • Start customizing the project! • Post in forum if you have any issues deploying or questions about customization. • Join tomorrow’s session: GPT-4 with Vision aka.ms/hacktogether/chatapp aka.ms/ragchat/free