<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Nikita Usatenko on Medium]]></title>
        <description><![CDATA[Stories by Nikita Usatenko on Medium]]></description>
        <link>https://medium.com/@nusatenko?source=rss-dd20d159936a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*UIIP5n8t01i7IE85XeV19Q.png</url>
            <title>Stories by Nikita Usatenko on Medium</title>
            <link>https://medium.com/@nusatenko?source=rss-dd20d159936a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 20:28:04 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nusatenko/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[An Introduction to Vector Databases]]></title>
            <link>https://medium.com/@nusatenko/an-introduction-to-vector-databases-b0c7775ed0ca?source=rss-dd20d159936a------2</link>
            <guid isPermaLink="false">https://medium.com/p/b0c7775ed0ca</guid>
            <category><![CDATA[vector-database]]></category>
            <category><![CDATA[large-language-models]]></category>
            <category><![CDATA[generative-ai-use-cases]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[genai]]></category>
            <dc:creator><![CDATA[Nikita Usatenko]]></dc:creator>
            <pubDate>Thu, 11 Jul 2024 14:54:34 GMT</pubDate>
            <atom:updated>2024-07-11T14:54:34.512Z</atom:updated>
            <content:encoded><![CDATA[<p>Vector databases represent a modern approach to data storage, where information is kept as high-dimensional vectors — mathematical entities that capture features or attributes of the data. These vectors can span from tens to thousands of dimensions, depending on how detailed the data is. To create these vectors, raw data such as text, images, audio, or video is processed through an embedding function. This function can utilize various techniques, including machine learning models, word embeddings, and feature extraction algorithms, to transform raw data into a numerical vector format.</p><p>The primary benefit of a vector database lies in its ability to perform rapid and precise similarity searches by comparing vector distances. Unlike traditional databases that rely on exact matches or predefined criteria for querying, vector databases excel at finding data that is contextually or semantically similar. This capability is particularly advantageous for tasks such as image retrieval, natural language understanding, and recommendation systems, where understanding the meaning and context of the data is crucial.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r6M7AD7OFlBC981oPI5G-g.png" /></figure><h3>Interacting with a Vector Database</h3><h4><strong>Writing and updating data</strong></h4><p>High-quality data and embeddings are crucial for the accuracy and effectiveness of vector databases. The quality of embeddings, which are the vector representations of the data, directly impacts the performance of similarity searches. Poor-quality embeddings can lead to inaccurate or irrelevant results, undermining the utility of the database. Ensuring high data quality involves preprocessing steps such as normalization, cleaning, and transformation to remove noise and inconsistencies.</p><p>The choice of the embedding model also plays a significant role; models trained on diverse and representative datasets tend to produce more reliable embeddings. Different machine learning models capture various aspects of the data, so selecting a model that aligns with the specific data type and desired application is critical for producing meaningful and accurate embeddings. High-quality embeddings ensure that the vector database can accurately capture the semantic and contextual nuances of the data, leading to more meaningful and relevant search results.</p><ol><li>Select an appropriate ML model for generating vector embeddings.</li><li>Embed various types of information: text, images, audio, or tabular data.</li><li>Convert your data into vector representations using the chosen embedding model.</li><li>Store additional metadata along with the vector embeddings. — <em>This metadata can be used later to filter search results before or after performing the Approximate Nearest Neighbour (ANN) search.</em></li><li>Index the vector embeddings and metadata separately within the vector database. — <em>Techniques such as Random Projection, Product Quantization, and Locality-sensitive Hashing can be employed for this purpose.</em></li><li>Save the vector data along with its corresponding indexes and metadata.</li></ol><h4>Reading Data</h4><p>When discussing retrieval, we mean the process of obtaining a collection of vectors that closely match a given query, which is represented as a vector within the same latent space. This method of retrieval is known as Approximate Nearest Neighbor (ANN) search.</p><p>In this context, a query might be an object such as an image, where the goal is to find similar images. Alternatively, it could be a question, where the aim is to retrieve relevant context that can subsequently be used to generate an answer through a Language Model (LLM).</p><ol><li>Construct a query for performing an ANN search.</li><li>Incorporate a metadata query to exclude vectors with specific attributes. — <em>For instance, when searching for similar apartment images, you might exclude those in certain locations.</em></li><li>Execute the metadata query against the metadata index. — <em>This step can be done either before or after the ANN search procedure.</em></li><li>Embed the query data into the latent space using the same model applied for writing the data into the vector database.</li><li>Perform the ANN search to retrieve a set of vector embeddings. — <em>Common similarity measures for ANN searches include Cosine Similarity, Euclidean Distance, and Dot Product.</em></li></ol><h3>Resource requirements</h3><p>Generating embeddings and performing ANN searches are computationally intensive processes that require significant resources. Embedding generation involves running raw data through complex machine learning models, which demand substantial processing power, memory, and storage. This is particularly true for large datasets or models with many parameters. ANN searches, while optimized for speed, also require considerable computational resources to efficiently traverse high-dimensional vector spaces and maintain performance. These operations benefit from parallel processing capabilities and high-performance computing environments, including GPUs and distributed computing clusters, to handle the intensive computational load and ensure timely query responses.</p><h3>Comparison with other types of databases</h3><p>Traditional databases, such as relational databases, store data in structured formats using tables with predefined schemas, making them proficient at handling structured data and executing precise SQL queries. However, their performance can decline with complex queries involving large datasets. In contrast, vector databases store data as high-dimensional vectors, enabling efficient similarity searches based on vector distances, which is advantageous for applications requiring semantic search and contextual retrieval. Graph databases, on the other hand, represent data as nodes and edges, excelling in applications that require exploring relationships, such as social networks, recommendation systems, and fraud detection. They are particularly strong in traversing complex, interconnected data structures and executing multi-hop queries. While vector databases excel in applications like image retrieval and natural language processing due to their ability to find similar items through distance metrics, they are not designed for the explicit relationship traversals that graph databases handle efficiently.</p><h3>Conclusion</h3><p>Vector databases offer a powerful solution for fast and accurate similarity searches, leveraging high-dimensional vectors and advanced machine-learning models. They are particularly valuable in applications requiring semantic search and contextual retrieval. Ensuring high-quality data and choosing the right embedding model are crucial for their effectiveness. While resource-intensive, the benefits of vector databases in terms of performance and scalability make them a vital tool in modern data management and retrieval systems.</p><h3>Common questions</h3><h4>How do you select the appropriate machine-learning model for generating vector embeddings?</h4><p>Selecting the appropriate machine learning model for generating vector embeddings depends on several factors, including the type of data, the specific application, and the desired outcome. Here are some guidelines:</p><ul><li><strong>Data Type</strong>: For text data, models like BERT, GPT, and Word2Vec are commonly used. For images, convolutional neural networks (CNNs) like ResNet or VGG are popular. For audio, models like Wav2Vec or Mel-frequency cepstral coefficients (MFCCs) are effective. For tabular data, models like CatBoost or TabNet might be appropriate.</li><li><strong>Application Needs</strong>: If the application requires understanding nuanced language context, transformer-based models like BERT or GPT are suitable. For tasks involving image recognition or classification, deep learning models like ResNet are preferable.</li><li><strong>Performance and Resource Constraints</strong>: More complex models like transformers often yield better embeddings but require more computational resources. Consider the balance between model complexity and available computational power.</li><li><strong>Pre-trained vs. Custom Models</strong>: Pre-trained models can save time and resources and are effective for general purposes. However, for domain-specific applications, fine-tuning a pre-trained model or training a custom model might be necessary.</li></ul><h4>What are some common preprocessing steps to ensure high-quality embeddings?</h4><p>Ensuring high-quality embeddings involves several preprocessing steps, which help clean and standardize the data before it is fed into the embedding model:</p><ul><li><strong>Normalization</strong>: Standardizing the data to a common scale, especially important for numerical data, to ensure that no particular feature disproportionately influences the embeddings.</li><li><strong>Cleaning</strong>: Removing noise, such as irrelevant or incorrect data, duplicates, and outliers, to ensure the quality and consistency of the data.</li><li><strong>Tokenization</strong>: For text data, breaking down sentences into tokens (words or subwords) that can be processed by embedding models.</li><li><strong>Lowercasing and Removing Punctuation</strong>: Standardizing text data by converting to lowercase and removing punctuation to reduce variability in the data.</li><li><strong>Handling Missing Values</strong>: Imputing or removing missing values to prevent incomplete data from skewing the embeddings.</li><li><strong>Image and Audio Processing</strong>: For images, this might include resizing, normalization, and augmentation. For audio, it could involve noise reduction, normalization, and segmentation.</li><li><strong>Feature Extraction</strong>: Identifying and extracting relevant features from raw data, which can improve the quality of embeddings, especially for complex data types.</li></ul><h4>What are the practical applications of vector databases in real-world scenarios?</h4><p>Vector databases have a wide range of practical applications across various industries due to their ability to perform efficient and accurate similarity searches. Here are some key applications:</p><ul><li><strong>Recommendation Systems</strong>: In e-commerce and streaming services, vector databases can suggest products, movies, or songs by finding items similar to those the user has previously interacted with, enhancing the user experience through personalized recommendations.</li><li><strong>Image and Video Retrieval</strong>: In platforms like social media and digital asset management, vector databases can quickly retrieve images or videos similar to a given query, enabling efficient organization and search of multimedia content.</li><li><strong>Natural Language Processing (NLP)</strong>: Applications such as chatbots, virtual assistants, and customer support can benefit from vector databases to understand and respond to user queries by retrieving contextually relevant information.</li><li><strong>Fraud Detection</strong>: Financial institutions can use vector databases to detect unusual patterns and similarities in transaction data that may indicate fraudulent activities, improving security measures.</li><li><strong>Medical and Healthcare</strong>: Vector databases can be used to find similar medical records or images, assisting in diagnostics and treatment planning by comparing new patient data with historical cases.</li><li><strong>Search Engines</strong>: Enhanced search capabilities in search engines can be achieved by using vector databases to provide more relevant and semantically meaningful results based on user queries.</li><li><strong>Content Moderation</strong>: Social media platforms can use vector databases to detect and moderate inappropriate or harmful content by finding similarities with known problematic content.</li></ul><h3>Useful links</h3><p>Some popular Vector Databases:</p><ul><li>Qdrant — <a href="https://qdrant.tech/">https://qdrant.tech/</a></li><li>Pinecone — <a href="https://www.pinecone.io/">https://www.pinecone.io/</a></li><li>Weaviate — <a href="https://weaviate.io/">https://weaviate.io/</a></li><li>Milvus — <a href="https://milvus.io/">https://milvus.io/</a></li><li>Vespa — <a href="https://vespa.ai/">https://vespa.ai/</a></li></ul><p>Other links:</p><ul><li><a href="https://learn.deeplearning.ai/courses/vector-databases-embeddings-applications/">https://learn.deeplearning.ai/courses/vector-databases-embeddings-applications/</a></li><li><a href="https://learn.deeplearning.ai/courses/building-applications-vector-databases/">https://learn.deeplearning.ai/courses/building-applications-vector-databases/</a></li><li><a href="https://playground.sednor.ai/">https://playground.sednor.ai/</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b0c7775ed0ca" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Chat with your data using Retrieval-Augmented Generation]]></title>
            <link>https://medium.com/@nusatenko/chat-with-your-data-using-retrieval-augmented-generation-01f49ca03606?source=rss-dd20d159936a------2</link>
            <guid isPermaLink="false">https://medium.com/p/01f49ca03606</guid>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[genai]]></category>
            <category><![CDATA[retrieval-augmented]]></category>
            <category><![CDATA[generative-ai-use-cases]]></category>
            <category><![CDATA[large-language-models]]></category>
            <dc:creator><![CDATA[Nikita Usatenko]]></dc:creator>
            <pubDate>Tue, 19 Mar 2024 16:12:37 GMT</pubDate>
            <atom:updated>2024-03-19T16:12:37.282Z</atom:updated>
            <content:encoded><![CDATA[<h3>Overview of Retrieval-Augmented Generation (RAG) Systems</h3><p>General-purpose language models can be adapted to perform various routine tasks, like sentiment analysis and named entity recognition, without needing extra information.</p><p>For tasks that are more complex and require significant knowledge, it’s feasible to develop a system based on language models that pulls information from external sources to complete these tasks. This approach enhances factual accuracy, increases the reliability of the outputs, and addresses the issue of generating false information.</p><p><strong>Retrieval-Augmented Generation (RAG)</strong> is the process of optimizing the output of a large language model, so it references a knowledge base outside of its training data sources before generating a response. RAG system allows changes to its built-in knowledge base efficiently without the need to retrain the whole model.</p><p>RAG operates by taking an input and retrieving a group of relevant documents based on that input. These documents are then combined with the original input and provided to the text generator, which creates the final output. This method makes RAG adaptable to situations where factual information may change over time, which is valuable since the knowledge within large language models is fixed. RAG enables language models to forego retraining, offering a way to access the most up-to-date information for producing dependable outputs through retrieval-based generation.</p><p>Creating a RAG system involves intricate processes and requires careful consideration of various factors to ensure its effectiveness. Here’s how to develop such a system step by step.</p><figure><img alt="Retrieval-Augmented Generation" src="https://cdn-images-1.medium.com/max/1024/1*pe7pbf599Z1TgSOgnI96eA.png" /></figure><h3>I. Preparation and Storage of Knowledge</h3><p>The first step involves storing the knowledge contained in your internal documents in a format that is appropriate for querying. This is achieved by embedding the information using an embedding model.</p><ol><li><strong>Chunking:</strong> Split the text corpus of the knowledge base into chunks. This can be from various sources, such as documentation and reports. The chunk size and the method, whether sliding or tumbling window, impacts retrieval efficiency. Finding the right balance is important to ensure enough context is preserved for accurate retrieval while avoiding overly broad chunks that could dilute relevance.</li><li><strong>Embedding:</strong> Use an embedding model to transform each chunk into a vector embedding. The choice of embedding model that effectively captures the nuances of the data is crucial as it affects the retrieval quality.</li><li><strong>Storage:</strong> Store all vector embeddings in a Vector Database, alongside the text representing each embedding and a pointer to it for later retrieval. Ensure the vector database can handle high query volumes with low latency, especially for dynamic, user-facing applications.</li></ol><h3>II. Retrieval of Information</h3><ol><li><strong>Query Embedding:</strong> Embed the query using the same model used for the knowledge base, producing a vector embedding.</li><li><strong>Vector Database Search:</strong> Use the query’s vector embedding to run a search in the Vector Database, choosing how many vectors to retrieve based on the needed context. The database performs an Approximate Nearest Neighbour (ANN) search to find the most similar vectors in a given Embedding/Latent space. Balancing between metadata-driven searches and ANN searches to optimize for both accuracy and speed is important. Implementing heuristics that align with business objectives, such as prioritizing more recent information or ensuring diversity in retrieved documents can be beneficial.</li><li><strong>Retrieval Fine-tuning:</strong> Considerations include choosing the database, hosting options, indexing strategy, and how to apply heuristics like time importance, reranking based on diversity, and source retrieval strategies.</li></ol><h3>III. Generation of Responses</h3><ol><li><strong>Context and Prompt Engineering:</strong> Map the returned vector embeddings to their textual representations and pass them with the query to the LLM. The prompts need careful engineering to ensure that the LLM uses only the provided context for generating answers, guarding against generating unfounded answers.</li><li><strong>LLM Selection:</strong> Selecting the right LLM becomes critical as it powers the generation process. The choice is between proprietary and self-hosted models, with considerations extending to performance and customization needs.</li></ol><h3>IV. System Integration and Tuning</h3><ol><li><strong>Chat Interface:</strong> Implement a web UI that acts as the chat interface for user interaction, making the chatbot accessible and user-friendly.</li><li><strong>Continuous Tuning:</strong> Building a RAG system is complex and requires continuous tuning of all its components. This includes refining the retrieval process, enhancing prompt engineering to align outputs closely with expectations, and adapting the system based on user feedback and an evolving knowledge base.</li></ol><p>This comprehensive approach highlights the complexity of building a RAG-based LLM system, moving beyond basic implementations to create a robust, efficient, and responsive chatbot capable of querying a private knowledge base. It underscores the need for meticulous planning, continuous refinement, and the integration of advanced techniques in data retrieval, processing, and language model generation.</p><h3>What are the challenges and limitations of implementing RAG systems in real-world applications?</h3><ol><li><strong>Complexity of Integration</strong>: Implementing a RAG system involves integrating multiple components, including the knowledge base, retrieval mechanisms, and the generative language model itself. This complexity can pose significant challenges, particularly when ensuring these components work seamlessly together in real time.</li><li><strong>Quality of the Knowledge Base</strong>: The effectiveness of a RAG system is heavily dependent on the quality, comprehensiveness, and currency of the knowledge base. Curating and maintaining a knowledge base that is both broad and deep enough to cover the required domains can be a substantial challenge.</li><li><strong>Retrieval Accuracy</strong>: Ensuring that the retrieval component accurately identifies and selects the most relevant documents or information chunks from the knowledge base can be difficult, especially for ambiguous or complex queries. There’s also the challenge of balancing speed and accuracy in retrieval to maintain efficient performance without sacrificing the quality of results.</li></ol><h3>How do RAG systems perform compared to other knowledge augmentation strategies?</h3><p>Compared to other augmentation strategies, RAG systems offer a flexible and dynamic way to enhance language models with the ability to pull in the most current information without needing a model to retrain.</p><h4>Fine-tuning</h4><p><strong>Fine-tuning</strong> is recognized as the most intuitive method for training a Large Language Model. In this approach, you teach an LLM to “learn” your data enabling it to retrieve and then respond to queries.</p><ul><li><strong>Fine-tuning requires more time:</strong> it often involves training an LLM on a new dataset using reinforcement learning.</li><li><strong>Fine-tuning requires more money:</strong> the process of fine-tuning models is more expensive to execute. Moreover, training a model requires intensive operation to ensure it learns effectively during practice.</li><li><strong>Fine-tuning is much harder to change:</strong> imagine successfully training your model, but then needing to update it due to changing facts. New information emerges, and old information becomes outdated, necessitating a model update. This involves retraining the model to stay current, thus constantly risking that your data may become obsolete and unmodifiable.</li></ul><h4>Knowledge Graph</h4><p>A <strong>Knowledge Graph</strong> is a network consisting of concepts, entities, or events and their interconnections. This facilitates easier access to structured data and reduces the uncertainty regarding how different elements are related.</p><ul><li><strong>Knowledge Graph needs high-quality data:</strong> the data must be of high quality and well-understood to create an effective graph. If your data is flawed, a knowledge graph will merely encode these inaccuracies.</li><li><strong>Knowledge Graph demands more expertise:</strong> organizing the data correctly requires both time and expertise. Lacking these means this approach might not be suitable.</li><li><strong>Knowledge Graph has fewer resources and tools available:</strong> although there are numerous resources for supporting RAG and their number is increasing rapidly, integrating LLMs with knowledge graphs is less common, indicating less available support for those who choose this path.</li></ul><h3>How do the cost and scalability of RAG systems compare to traditional language models?</h3><ol><li><strong>Cost</strong>: The implementation and maintenance costs of RAG systems can be significantly higher than traditional language models due to the additional infrastructure required for storing, updating, and querying the knowledge base. This includes the costs associated with data storage solutions (like vector databases) and the computational resources needed for embedding processes and real-time retrieval. However, these costs can be offset by the enhanced performance and reduced need for frequent retraining of the model with new data.</li><li><strong>Scalability</strong>: RAG systems are designed to be scalable, as they can dynamically retrieve information from a constantly updating knowledge base. The scalability largely depends on the choice of technologies for the vector database and the efficiency of the embedding and retrieval processes. Modern cloud-based solutions and advancements in database technologies can support high query volumes with low latency, making RAG systems suitable for large-scale applications. However, the system’s design must be carefully planned to ensure it remains efficient as the amount of data grows.</li></ol><h3>Useful Links</h3><ul><li><a href="https://www.deeplearning.ai/short-courses/langchain-for-llm-application-development/">LangChain for LLM Application Development — DeepLearning.AI</a></li><li><a href="https://www.deeplearning.ai/short-courses/langchain-chat-with-your-data/">LangChain: Chat with Your Data — DeepLearning.AI</a></li><li><a href="https://youtu.be/7Itfr9iN1Gs?si=wRpF_y1L6uOfEN1o">LangChain Zero to Hero | Episode 3: Retrieval Augmented Generation</a></li><li><a href="https://playground.sednor.ai/">Sednor | AI Playground</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=01f49ca03606" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Enhancing travel tech platforms with Generative AI applications]]></title>
            <link>https://medium.com/@nusatenko/enhancing-travel-tech-platforms-with-generative-ai-applications-dedb4d5c1d0d?source=rss-dd20d159936a------2</link>
            <guid isPermaLink="false">https://medium.com/p/dedb4d5c1d0d</guid>
            <category><![CDATA[travel-app]]></category>
            <category><![CDATA[generative-ai-consulting]]></category>
            <category><![CDATA[generative-ai-use-cases]]></category>
            <category><![CDATA[travel-technology]]></category>
            <category><![CDATA[generative-ai-solution]]></category>
            <dc:creator><![CDATA[Nikita Usatenko]]></dc:creator>
            <pubDate>Wed, 14 Feb 2024 14:49:43 GMT</pubDate>
            <atom:updated>2024-02-14T14:49:43.190Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article, we explore five practical uses of generative AI in travel tech applications. These include creating concise property listings, compiling personalized travel guides, providing real-time support chat assistance, moderating user chats for safety, and analyzing user reviews for insights. Each use case demonstrates how AI can streamline processes and enhance user experiences for both hosts and guests in the travel industry.</p><h3>AI-generated listing summary</h3><p>The concept for an <strong>AI-generated listing summary</strong> aims to streamline the process of creating property listings on a rental platform. By leveraging AI, this tool would automatically generate a concise and informative summary based on details provided by the host, such as location, amenities, sleeping arrangements, property size, etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l_eDw6OJAit70mfEtk9QfQ.png" /></figure><p><strong>How It Works:</strong></p><ol><li>Hosts input details about their property.</li><li>Hosts can provide a custom prompt to guide the AI in emphasizing certain aspects of the property.</li><li>The AI uses the provided information to create a summary.</li><li>Hosts can edit the generated summary to match their preferences better. While the AI provides a strong starting point, hosts retain full control to customize and perfect their listing summaries.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gYoTK7BRO7US8aujLCjgcw.png" /></figure><p><strong>Benefits:</strong></p><ul><li>Eliminates the need for hosts to spend a lot of time crafting the perfect listing description.</li><li>Utilizes AI to ensure that the summaries are engaging, informative, and optimized for attracting guests.</li><li>Offers the ability to adjust the focus of the summary through custom prompts, giving hosts control over how their property is presented.‍</li></ul><p>This tool could significantly reduce the time and effort required for hosts to create engaging and detailed property listings. Its implementation would aim to enhance the user experience for hosts, potentially leading to a richer and more diverse array of property listings on the platform.</p><h3>AI-generated travel guides</h3><p>The <strong>AI-generated travel guides</strong> concept aims to enrich the travel experience for guests by providing them with detailed, locally-informed travel guides. These guides would be created for each specific area based on information provided by hosts about their neighborhood, including food spots, leisure activities, and must-visit places. By aggregating suggestions from various hosts in a particular area, the AI would compile a comprehensive travel guide, categorically organized to facilitate easy navigation for guests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8qJ_VMflz8en7X5x2K5EWg.png" /></figure><p><strong>How It Works:</strong></p><ol><li>Hosts submit details about their neighborhood, focusing on categories like food, leisure, and attractions.</li><li>The AI system aggregates information from different hosts in the same area to create a nuanced and comprehensive guide to the area.</li><li>The guide is organized into categories, making it easy for guests to find the type of suggestions they are interested in.</li><li>These AI-generated travel guides are made available to guests through the platform, offering them insider knowledge to enhance their stay.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nNJ5XMgPKv8m70mlohRgCw.png" /></figure><p><strong>Benefits:</strong></p><ul><li>Guests gain access to a curated selection of local insights that might not be readily available in commercial travel guides.</li><li>By compiling suggestions from multiple hosts, the guide offers a wide range of activities and spots to explore, catering to different interests.</li><li>Provides guests with a ready-to-use guide, saving them time on research and planning for their trip.‍</li></ul><p>AI-generated travel Guides could offer a unique value proposition by connecting guests with authentic local recommendations, directly from the hosts’ perspectives.</p><h3>AI support assistant</h3><p>The <strong>AI support assistant</strong> concept introduces an advanced level of customer service on the platform, complementing the traditional support chat system. This feature envisions an AI-powered chatbot capable of interacting with users in real time, answering their questions, and providing assistance with various inquiries. The aim is to enhance user experience by offering immediate, accurate responses to common questions, thus streamlining the support process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uXzNCblH_WZa5cGV0Ftn4g.png" /></figure><p><strong>How It Works:</strong></p><ol><li>Users can initiate a conversation with the AI Support Assistant at any time via the support chat bubble on the platform.</li><li>The bot is equipped to understand and respond to a wide range of user queries, from simple questions about platform usage to more complex inquiries related to bookings and listings.</li><li>The AI assistant serves as a first line of support, capable of handling common questions and issues. If the inquiry requires human intervention, the bot seamlessly escalates the query to a customer support agent.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UkWpzStj_T3dwE8fiZAg-w.png" /></figure><p><strong>Benefits:</strong></p><ul><li>Users receive instant responses to their inquiries, reducing wait times and enhancing their overall experience on the platform.</li><li>The AI Support Assistant is available around the clock, ensuring users have access to support whenever they need it.</li><li>By handling routine questions, the AI frees up human agents to focus on more complex issues, improving the efficiency of the support team.‍</li></ul><p>By integrating AI technology into the support system, the platform can offer users a more responsive, efficient, and satisfying support experience.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rAikTpj59HIoUXsImaBKBA.png" /></figure><h3>AI user chat moderation</h3><p>The <strong>AI user chat moderation</strong> feature introduces an AI-driven layer of oversight to enhance the safety and integrity of user interactions within the platform’s chat system. This service operates in the background, analyzing conversations in real time to identify potential violations of the platform’s terms and conditions, as well as instances of rude or inappropriate behavior. When such content is detected, it is flagged for administrative review, complementing the existing mechanism that allows users to report inappropriate messages manually.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VQ3zUFqsmCqpt3z308I5tw.png" /></figure><p><strong>How It Works:</strong></p><ol><li>The AI service continuously monitors user chats to understand the context and content of conversations.</li><li>Upon identifying messages that potentially violate platform policies or exhibit inappropriate behavior, the AI automatically flags these for further review by the platform’s administrative team.</li><li>The system is designed to prioritize user privacy, focusing on the detection of policy violations while safeguarding personal information and chat content.</li><li>This feature acts as an additional layer of moderation, working alongside user reports to ensure a thorough review process for maintaining a respectful and safe communication environment.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a75K23BPBjvH1MeuWgUA9A.png" /></figure><p><strong>Benefits:</strong></p><ul><li>By proactively identifying and flagging inappropriate content, the platform can more effectively prevent harassment, abuse, and other forms of misconduct.</li><li>A cleaner, more respectful chat environment encourages positive interactions and fosters a supportive community.</li><li>Automating the initial detection of potential issues allows the administrative team to focus on reviewing and addressing flagged content, streamlining the moderation process.‍</li></ul><p>By leveraging AI for real-time chat analysis and moderation, the platform aims to enhance the effectiveness of its community management efforts.</p><h3>AI user review analysis</h3><p>The <strong>AI user review analysis</strong> feature aims to enhance the understanding and management of guest feedback on the platform. Utilizing AI, this service analyzes the sentiment of user reviews, categorizing them as positive or negative, and assigns a score to each review. Additionally, the AI is capable of identifying inappropriate content within reviews and flagging them for moderation. This dual approach ensures that feedback is accurately interpreted and that the platform maintains high standards of respect and appropriateness in user-generated content.‍</p><p><strong>How It Works:</strong></p><ol><li>The AI service examines the language and context of user reviews to determine the overall sentiment — positive or negative — and assigns a score.</li><li>Alongside sentiment analysis, the AI monitors for content that violates the platform’s terms of service, such as offensive language or inappropriate comments, flagging such reviews for human moderation.</li><li>By quantifying sentiment, the platform can provide hosts with aggregated insights into the guest experience, highlighting areas of strength and opportunities for improvement.</li><li>The identification and flagging of inappropriate reviews complement the platform’s content moderation efforts, ensuring a respectful and constructive feedback environment.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lY9UWScSVc1Zqtl3EImQgw.png" /></figure><p><strong>Benefits:</strong></p><ul><li>Hosts receive nuanced insights into guest sentiment, beyond simple star ratings, helping them to better understand and respond to guest feedback.</li><li>Automatic detection of inappropriate reviews helps maintain the quality and integrity of the review system, ensuring that it remains a reliable source of information for future guests.</li><li>Automating the initial detection of sentiment and inappropriate content streamlines the moderation process, allowing for quicker and more effective management of reviews.</li><li>A cleaner, more accurate review system enhances the decision-making process for guests, contributing to a more positive overall experience on the platform.‍</li></ul><p>By automatically analyzing the sentiment of reviews and identifying content that requires moderation, the platform can offer more valuable feedback to hosts and a safer, more reliable review system for users.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dedb4d5c1d0d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Generative AI Web App with AWS Bedrock: A Step-by-Step Guide]]></title>
            <link>https://medium.com/@nusatenko/building-a-generative-ai-web-app-with-aws-bedrock-a-step-by-step-guide-7eb2a9c839f0?source=rss-dd20d159936a------2</link>
            <guid isPermaLink="false">https://medium.com/p/7eb2a9c839f0</guid>
            <category><![CDATA[aws-bedrock]]></category>
            <category><![CDATA[generative-ai-tools]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[generative-ai-use-cases]]></category>
            <dc:creator><![CDATA[Nikita Usatenko]]></dc:creator>
            <pubDate>Wed, 13 Dec 2023 10:07:51 GMT</pubDate>
            <atom:updated>2023-12-13T10:07:51.070Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>In this tutorial, we’re going to create a simple yet powerful Generative AI web application using AWS Bedrock. Our project? A Web Page Summarizer. This application allows users to input a URL, which it then processes to deliver a concise summary of the web page’s content in bullet points. Let’s dive into how we can build this using a robust tech stack.</p><h3>Tech Stack Overview</h3><p>Our project leverages the following technologies:</p><ul><li>AWS Bedrock</li><li>AWS Lambda</li><li>AWS API Gateway</li><li>ReactJS / NextJS</li><li>NodeJS</li></ul><h3>Understanding AWS Bedrock: Features and Pricing</h3><p>AWS Bedrock is a fully managed service that simplifies building generative AI applications. It offers high-performing foundation models (FMs) from leading AI companies like AI21 Labs, Anthropic, Cohere, Meta, Stability AI, and Amazon. These are accessible via a single API, providing a rich set of features for secure, private, and responsible AI development. With serverless architecture, AWS Bedrock integrates seamlessly with familiar AWS services, eliminating the need for infrastructure management.</p><p><strong>Read more: </strong><a href="https://aws.amazon.com/bedrock/">Build Generative AI Applications with Foundation Models — Amazon Bedrock — AWS</a></p><p><strong>Example Pricing for AI21 Labs Models:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fpp2oKqTGxFjtSz9O4W90Q.png" /></figure><p><strong>Read more: </strong><a href="https://aws.amazon.com/bedrock/pricing/">Build Generative AI Applications with Foundation Models — Amazon Bedrock Pricing — AWS</a></p><h3>Setting Up AWS Bedrock</h3><p><strong>Step 1.</strong> Log in to your AWS console with an IAM user having the necessary permissions. (<a href="https://aws.amazon.com/console/">Manage AWS Resources — AWS Management Console — AWS</a>).</p><p><strong>Step 2. </strong>Choose your working region, noting that AWS Bedrock’s availability varies by region and model provider.</p><p><strong>Step 3.</strong> Navigate to the AWS Bedrock service.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-DERWcp3K8bbIJLYKCbY8w.png" /></figure><p><strong>Step 4.</strong> Inside AWS Bedrock navigate to “Model Access” and click “Manage model access“.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1KcnmFw8HVWVychcgMSQ_Q.png" /></figure><p>For this example, we will use the Jurassic model by AI21 Labs.</p><p><strong>Step 5.</strong> Select the “Jurassic-2 Ultra” model and click “Request model access“. You should be granted access shortly.</p><p>You can find more details about this model if you go to the “Providers” section and select AI21 Labs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9zl9u9NrqcsDzIBjTTKcxA.png" /></figure><p>Here you can see the supported use cases, example API request and Playground link.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XaNEvSGKi4ixA1e40AnDSg.png" /></figure><p>You can use the playground to test the model with different parameters like “Temperature“ and “Top P“. “Temperature” and “Top P” are parameters used in LLMs to control the randomness or creativity in the model’s responses.</p><ul><li><strong>Temperature: </strong>This parameter, typically ranging from 0 to 1, controls the randomness in the model’s predictions.</li><li><strong>TopP (Top-k Probability):</strong> This parameter, also known as “nucleus sampling,” is a way to control the model’s generation process based on the probability distribution of the next word. Instead of taking the top-k most likely words, TopP considers a subset of the vocabulary where the cumulative probability exceeds the value of TopP (which ranges from 0 to 1).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kbrFJCYdMzcjgA2HUhdqHA.png" /></figure><h3>Configuring AWS Lambda</h3><p>We will use AWS Lambda to create a function that will</p><ul><li>Accept input</li><li>Create a prompt for our model</li><li>Call AWS Bedrock</li><li>Process and return the response</li></ul><p><strong>Step 1.</strong> First, let’s navigate to the AWS Lambda service.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*otqf8_NTA6nExq6x9VnnCw.png" /></figure><p><strong>Step 2.</strong> Here we will create a new function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oojpMMRxmbIRpNSSh8bjlA.png" /></figure><p><strong>Step 3.</strong> We will call this function summarize_web_page and we will use the latest available Node version.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bmna2V0xzMjchW4G9IZO9w.png" /></figure><p><strong>Step 4.</strong> Under “General configuration” in the “Configuration“ tab let’s adjust our function’s “Timeout“ to be 1 minute to give our model more time to process the request.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SVNbDd-cqXuGJzjrlOIC8Q.png" /></figure><p><strong>Step 5.</strong> Then under “Permissions“ we need to give our Lambda function permission to use the AWS Bedrock service.</p><h3>AWS Lambda Code</h3><p>After we’ve completed the setup steps let’s get to coding.</p><p><strong>Step 1.</strong> In the index.mjs file you will see the default handler function. This will be our entry point. Let’s change it as follows:</p><pre>export const handler = async (event) =&gt; {<br>    const body = JSON.parse(event.body);<br>    const result = await summarizeWebPage(body);<br><br>    return {<br>        statusCode: 200,<br>        body: JSON.stringify(result),<br>    };<br>};</pre><p><em>Please note that we’ve omitted any validation and security steps for the sake of simplicity.</em></p><p><strong>Step 2.</strong> The next step would be to implement the summarizeWebPage function. Here we assume that our request body will have the following structure:</p><pre>{<br>  url: &quot;https://www.sednor.io/&quot;<br>}</pre><p>Let’s create the summarizeWebPage function and outline its body:</p><pre>const summarizeWebPage = async (data) =&gt; {<br>    const text = await fetchWebPageText(data.url);<br>    const promptText = buildPromptText(text);<br>    const response = await bedrockQuery(promptText);<br><br>    return parseResponse(response);<br>};</pre><ul><li>fetchWebPageText – a function that will call the provided</li><li>buildPromptText – a function that will build the prompt for our model</li><li>bedrockQuery – a function that will query the AWS Bedrock service</li><li>parseResponse – a function that will get a response from the model and format it</li></ul><p><strong>Step 3.</strong> Let’s look at the fetchWebPageText function:</p><pre>import { load } from &#39;cheerio&#39;;<br>// ...<br>const fetchWebPageText = async (url) =&gt; {<br>    try {<br>        const response = await fetch(url);<br>        const data = await response.text();<br>        const $ = load(data);<br>        const body = $(&#39;body&#39;);<br>        body.find(&#39;script, style&#39;).remove();<br>        return body.text().trim().split(&#39; &#39;).slice(0, 1000).join(&#39; &#39;);<br>    } catch (e) {<br>        console.error(e);<br>        return &quot;&quot;;<br>    }<br>};</pre><p>Here we are using the load function from the cheerio library to get the text contents of the web page. We are slicing the text to reduce its length and avoid hitting the token length limit of our model.</p><p><strong>Step 4.</strong> Next, let’s implement the buildPromptText function:</p><pre>const buildPromptText = (text) =&gt; {<br>    return `&quot;${text}&quot;<br>        Summarize the above web page content in 5 bullet points.<br>        Start each bullet point with a *.<br>    `;<br>};</pre><p>Here we are asking the model to give us a summary in 5 bullet points and to start each bullet point with the “*“ symbol so that it is easier to parse the response.</p><p><strong>Step 5.</strong> Now let’s implement bedrockQuery:</p><pre>import { BedrockRuntimeClient, InvokeModelCommand } from &#39;@aws-sdk/client-bedrock-runtime&#39;;<br>// ...<br>const bedrockClient = new BedrockRuntimeClient({region: &quot;us-west-2&quot;});<br>// ...<br>const bedrockQuery = async () =&gt; {<br>    const modelId = &#39;ai21.j2-ultra-v1&#39;;<br>    const requestBody = {<br>        prompt: promptText,<br>        maxTokens: 1024,<br>        temperature: 0.7,<br>        topP: 1,<br>        stopSequences: [],<br>        countPenalty: {scale: 0},<br>        presencePenalty: {scale: 0},<br>        frequencyPenalty: {scale: 0},<br>    };<br>    try {<br>        const params = {<br>            modelId: modelId,<br>            body: JSON.stringify(requestBody),<br>            accept: &#39;application/json&#39;,<br>            contentType: &#39;application/json&#39;,<br>        };<br><br>        const command = new InvokeModelCommand(params);<br>        const response = await bedrockClient.send(command);<br>        const buffer = Buffer.from(response.body);<br>        const text = buffer.toString();<br>        const responseData = JSON.parse(text);<br>        <br>        return responseData.completions[0].data.text;<br>    } catch (error) {<br>        console.error(`Error: ${error}`);<br>        return &quot;&quot;;<br>    }<br>};</pre><p>Here we are using BedrockRuntimeClient and InvokeModelCommand from the @aws-sdk/client-bedrock-runtime library. We’ve set the temperature to 0.7 and topP to 1.</p><p><strong>Step 6.</strong> Finally, let’s implement the parseResponse function:</p><pre>const parseResponse = (responseText) =&gt; {<br>    return responseText<br>        .trim()<br>        .split(&quot;*&quot;)<br>        .map((item) =&gt; item.trim())<br>        .filter((item) =&gt; !!item);<br>};</pre><p>Here we want to turn a list of bullet points into an array of strings.</p><h3>Integrating AWS API Gateway</h3><p>We’ll use the AWS API Gateway to make our Lambda function accessible via an HTTP API.</p><p><strong>Step 1.</strong> Let’s navigate to the API Gateway service:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7UoQ6NrtKdCF2sx9_9X45w.png" /></figure><p><strong>Step 2.</strong> Here we will create an HTTP API.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OtsIfD3LvxWMuepNpjoBtQ.png" /></figure><p><strong>Step 3.</strong> Let’s set a name for our API and click “Review and Create“.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uT6TeafPsZ8nuZGGXqcYRA.png" /></figure><p><strong>Step 4.</strong> After the API is created we need to create a route.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DQMQr4cfWVweZBet9V2Zvw.png" /></figure><p><strong>Step 5.</strong> We will create a POST route with /summarize-web-page path.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gDIiVPevDy8PaGGqXHUCkw.png" /></figure><p><strong>Step 6.</strong> Now we need to connect our route with our Lambda function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*byDOdsMnHu6eiJZsUAIFMQ.png" /></figure><p>Let’s select “Integration type“, select our Lambda function and click Create.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HgC9r2XkFK3vzHiNzDTkwQ.png" /></figure><p><strong>Step 7.</strong> If we go to our API details we will see the “Invoke URL“ that we can use.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RJjbMKXu3PQS31NOPj988w.png" /></figure><p>Now we should be able to use our API as follows:</p><pre>POST https://1llvsgdb2g.execute-api.us-east-1.amazonaws.com/summarize-web-page<br><br>Body:<br>{<br>  &quot;url&quot;: &quot;https://www.sednor.io/&quot;<br>}</pre><p>You can test it in Postman before moving to the next steps.</p><h3>Developing the User Interface with React</h3><p>Now let’s build a simple user interface in React to call our API.</p><p><strong>Step 1.</strong> We can create an application using NextJS create-next-app (<a href="https://nextjs.org/">Next.js by Vercel — The React Framework</a>).</p><p><strong>Step 2.</strong> Right in the main page.tsx file we can add the following code:</p><pre>&quot;use client&quot;;<br><br>import { Box, Button, TextField } from &quot;@mui/material&quot;;<br><br>export default function HomePage() {<br>  const [url, setURL] = useState(&quot;&quot;);<br>  const [summary, setSummary] = useState([]);<br>  <br>  const handleSummarize = async () =&gt; {<br>    // ...<br>  };<br>  <br>  const buildSummaryItem = (item) =&gt; {<br>    return (<br>      &lt;Box&gt;{item}&lt;/Box&gt;<br>    );<br>  };<br><br>  return (<br>    &lt;&gt;<br>        &lt;TextField<br>            value={url}<br>            onChange={(e) =&gt; setURL(e.target.value)}<br>            label=&quot;Webpage to summarize&quot;<br>        /&gt;<br>        &lt;Button onClick={handleSummarize}&gt;<br>            Summarize<br>        &lt;/Button&gt;<br>        {<br>          summary.map((item) =&gt; buildSummaryItem(item))<br>        }<br>    &lt;/&gt;<br>  );<br>}</pre><p><strong><em>Note:</em></strong><em> here we are borrowing some components from the MUI library (</em><a href="https://mui.com/">MUI: The React component library you always wanted</a><em>)</em></p><p><strong>Step 3.</strong> Now let’s implement the handleSummarize function:</p><pre>const SUMMARIZE_WEB_PAGE_URL = &quot;https://1llvsgdb2g.execute-api.us-east-1.amazonaws.com/summarize-web-page&quot;<br><br>const handleSummarize = async () =&gt; {<br>    const response = await fetch(SUMMARIZE_WEB_PAGE_URL, {<br>      method: &quot;POST&quot;,<br>      body: JSON.stringify({ url }),<br>    });<br>    const data = await response.json();<br>    setSummary(data);<br>};</pre><h3>Live Demo</h3><p>After adding some styling, your application is ready to go!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tgb-wYgqhVoyr1TdlDWCpw.png" /></figure><p>Try out the live demo on our AI Playground — <a href="https://playground.sednor.ai/web-page-summarizer">Sednor | Web Page Summarizer</a></p><h3>Useful Links</h3><ul><li><a href="https://aws.amazon.com/bedrock/">Build Generative AI Applications with Foundation Models — Amazon Bedrock — AWS</a></li><li><a href="https://aws.amazon.com/bedrock/pricing/">Build Generative AI Applications with Foundation Models — Amazon Bedrock Pricing — AWS</a></li><li><a href="https://www.ai21.com/">AI21 Labs</a></li><li><a href="https://playground.sednor.ai/">Sednor | AI Playground</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7eb2a9c839f0" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>