<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Muhammad Saim</title>
    <description>The latest articles on DEV Community by Muhammad Saim (@muhammad_saim_7).</description>
    <link>https://dev.to/muhammad_saim_7</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1679888%2Fc87371bc-2ae1-4e85-a1dc-cf2d676a8c9e.png</url>
      <title>DEV Community: Muhammad Saim</title>
      <link>https://dev.to/muhammad_saim_7</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/muhammad_saim_7"/>
    <language>en</language>
    <item>
      <title>Qdrant Explained: The Future of Vector Databases</title>
      <dc:creator>Muhammad Saim</dc:creator>
      <pubDate>Mon, 05 Aug 2024 08:17:57 +0000</pubDate>
      <link>https://dev.to/muhammad_saim_7/qdrant-explained-the-future-of-vector-databases-18f5</link>
      <guid>https://dev.to/muhammad_saim_7/qdrant-explained-the-future-of-vector-databases-18f5</guid>
      <description>&lt;h2&gt;
  
  
  Introduction to Vector Databases
&lt;/h2&gt;

&lt;p&gt;In the rapidly evolving landscape of data management, vector databases are emerging as a transformative technology, particularly in the realm of artificial intelligence and machine learning. Unlike traditional relational databases that organize data in rows and columns, vector databases are designed to handle and efficiently query high-dimensional vector data.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffdecsjemmaolq1t7mxxz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffdecsjemmaolq1t7mxxz.png" alt="Image description" width="800" height="316"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What Are Vector Databases?
&lt;/h2&gt;

&lt;p&gt;Vector databases store and manage data in the form of vectors, which are mathematical representations of objects in a multi-dimensional space. Each vector encapsulates features or attributes of an object, making it possible to perform complex similarity searches and analytical operations. This vectorized representation is crucial for tasks such as nearest neighbor search, recommendation systems, and semantic search, where traditional indexing methods fall short.&lt;/p&gt;

&lt;p&gt;To summarize, vector databases make it possible for computer programs to draw comparisons, identify relationships, and understand context. This enables the creation of advanced artificial intelligence (AI) programs like large language models (LLMs).&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a vector?
&lt;/h2&gt;

&lt;p&gt;A vector is an array of numerical values that expresses the location of a floating point along several dimensions.&lt;/p&gt;

&lt;h2&gt;
  
  
  What are embeddings?
&lt;/h2&gt;

&lt;p&gt;Embeddings are representations of values or objects like text, images, and audio that are designed to be consumed by machine learning models and semantic search algorithms. They translate objects like these into a mathematical form according to the factors or traits each one may or may not have, and the categories they belong to.&lt;/p&gt;

&lt;h2&gt;
  
  
  Qdrant
&lt;/h2&gt;

&lt;p&gt;Qdrant is a vector similarity search engine designed to offer a production-ready service through a user-friendly API. It allows you to store, search, and manage vectors, or "points," along with additional payloads. These payloads act as supplementary information that can refine your searches and provide valuable insights for users.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to Get Started with Qdrant
&lt;/h3&gt;

&lt;p&gt;You can begin using Qdrant in several ways:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Python Client:&lt;/strong&gt; Utilize the Python qdrant-client to integrate Qdrant into your applications.&lt;br&gt;
&lt;strong&gt;Docker:&lt;/strong&gt;  Pull the latest Qdrant Docker image to run it locally and connect to it.&lt;br&gt;
&lt;strong&gt;Qdrant Cloud:&lt;/strong&gt; Experiment with the free tier of Qdrant’s Cloud service before committing to a full deployment.&lt;/p&gt;
&lt;h2&gt;
  
  
  Qdrant: Advanced Vector Similarity Search
&lt;/h2&gt;

&lt;p&gt;Qdrant is an advanced vector similarity search engine designed to handle the complexities of high-dimensional data efficiently. It offers several key features and benefits that make it a powerful tool for various applications:&lt;/p&gt;
&lt;h3&gt;
  
  
  1. Vector Indexing and Search Efficiency
&lt;/h3&gt;

&lt;p&gt;Qdrant excels in indexing and querying high-dimensional vectors. It uses advanced algorithms to ensure fast and accurate similarity searches, even with large datasets. This efficiency is crucial for real-time applications where response times are critical.&lt;/p&gt;
&lt;h3&gt;
  
  
  2. Rich Data Representation with Payloads
&lt;/h3&gt;

&lt;p&gt;In addition to vectors, Qdrant allows you to attach payloads—additional metadata or contextual information—to each vector. This capability enhances search results by incorporating relevant data, such as tags, descriptions, or user preferences, into the search process.&lt;/p&gt;
&lt;h2&gt;
  
  
  Core Components
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F99ng1w2vyl60sqgn93cd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F99ng1w2vyl60sqgn93cd.png" alt="Image description" width="800" height="703"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  Qdrant:
&lt;/h4&gt;

&lt;p&gt;This appears to be the central vector database system. It's likely designed to store and manage high-dimensional vectors efficiently.&lt;/p&gt;
&lt;h4&gt;
  
  
  Clients:
&lt;/h4&gt;

&lt;p&gt;The image shows various clients interacting with Qdrant, including Python, Rust, Go, and TypeScript. This suggests Qdrant supports multiple programming languages.&lt;/p&gt;
&lt;h4&gt;
  
  
  Collections:
&lt;/h4&gt;

&lt;p&gt;Within Qdrant, data is organized into collections. These likely group related vectors together.&lt;/p&gt;
&lt;h4&gt;
  
  
  Points:
&lt;/h4&gt;

&lt;p&gt;Each collection contains points, which are individual vector representations.&lt;/p&gt;
&lt;h4&gt;
  
  
  Vectors:
&lt;/h4&gt;

&lt;p&gt;Vectors are mathematical representations of data, often used in machine learning and natural language processing.&lt;/p&gt;
&lt;h4&gt;
  
  
  Data:
&lt;/h4&gt;

&lt;p&gt;This likely refers to the original data used to create the vector representations.&lt;/p&gt;
&lt;h4&gt;
  
  
  Deep Learning Model:
&lt;/h4&gt;

&lt;p&gt;A model, probably trained on the original data, is responsible for generating the vector representations.&lt;/p&gt;
&lt;h2&gt;
  
  
  Functionality
&lt;/h2&gt;
&lt;h4&gt;
  
  
  Vectorization:
&lt;/h4&gt;

&lt;p&gt;The deep learning model processes the original data (e.g., images, text) and converts it into numerical vectors.&lt;/p&gt;
&lt;h4&gt;
  
  
  Storage:
&lt;/h4&gt;

&lt;p&gt;Qdrant stores these vectors in its collections.&lt;br&gt;
Similarity Search: Clients can query Qdrant using various similarity metrics like Euclidean distance, dot product, and cosine similarity. This allows for finding vectors that are similar to a given query vector.&lt;br&gt;
Possible Use Cases&lt;/p&gt;
&lt;h4&gt;
  
  
  Image Search:
&lt;/h4&gt;

&lt;p&gt;Finding similar images based on visual content.&lt;/p&gt;
&lt;h4&gt;
  
  
  Recommendation Systems:
&lt;/h4&gt;

&lt;p&gt;Suggesting items or content based on user preferences or past behavior.&lt;/p&gt;
&lt;h4&gt;
  
  
  Natural Language Processing:
&lt;/h4&gt;

&lt;p&gt;Finding semantically similar text passages or documents.&lt;/p&gt;
&lt;h4&gt;
  
  
  Anomaly Detection:
&lt;/h4&gt;

&lt;p&gt;Identifying outliers or unusual data points.&lt;/p&gt;
&lt;h2&gt;
  
  
  Additional Notes
&lt;/h2&gt;

&lt;p&gt;The image mentions "Programmers" and "ML Engineers," suggesting that Qdrant is used by both software developers and data scientists.&lt;br&gt;
The presence of "Payload" and "Metadata" fields indicates that Qdrant can store additional information along with the vectors.&lt;br&gt;
Limitations&lt;/p&gt;

&lt;p&gt;Without more context, it's difficult to determine the specific use case or domain of this system.&lt;br&gt;
The image doesn't provide details about the dimensionality of the vectors, which is crucial for understanding the complexity of the calculations involved.&lt;br&gt;
The efficiency and scalability of Qdrant in handling large datasets are unknown without further information.&lt;/p&gt;

&lt;p&gt;Code Introduction&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from qdrant_client import QdrantClient
from qdrant_client.http import models
import numpy as np
from faker import Faker
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;from qdrant_client import QdrantClient:&lt;/strong&gt; This imports the QdrantClient class from the qdrant_client module, which is used to interact with the Qdrant vector search engine.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;from qdrant_client.http import models:&lt;/strong&gt; This imports the models module from qdrant_client.http, which typically contains various data models or schemas used for interacting with the Qdrant API.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;import numpy as np:&lt;/strong&gt; This imports the numpy library and aliases it as np. NumPy is used for numerical operations, such as handling arrays and performing mathematical computations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;from faker import Faker:&lt;/strong&gt; This imports the Faker class from the faker library, which is used to generate fake data, such as names, addresses, and other random values for testing or development purposes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;client = QdrantClient(host="localhost",port=6333)
client
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code creates an instance of QdrantClient to connect to a Qdrant server running on localhost at port 6333. The client object allows you to interact with the Qdrant API for operations like indexing and querying vectors.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;my_collection = "first_collection"
client.create_collection(
    collection_name = my_collection,
    vectors_config= models.VectorParams(size = 100,distance=models.Distance.COSINE)
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Creates a new collection named "first_collection" in Qdrant. The collection is configured to store vectors of size 100 and uses cosine distance for similarity calculations.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;data = np.random.uniform(low=-1.0,high=1.0,size=(1_000,100))
index = list(range(1_000))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Generates a NumPy array data with 1,000 vectors, each of size 100, with values uniformly distributed between -1.0 and 1.0. The index is a list of integers from 0 to 999, used to uniquely identify each vector.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;client.upsert(
    collection_name = my_collection,
    points = models.Batch(
        ids= index,
        vectors=data.tolist()
    )
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Uploads or updates vectors in the "first_collection" collection of Qdrant. The client.upsert method adds or modifies vectors using the index list as IDs and the data array (converted to a list) as the vector values.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;client.retrieve(
    collection_name=my_collection,
    ids = [10,14,100],
    #with_vectors=True
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Retrieves vectors with IDs [10, 14, 100] from the "first_collection" collection in Qdrant. If the with_vectors=True parameter is uncommented, it would also return the vectors associated with those IDs.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fake_something = Faker()
fake_something.name() , fake_something.address()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Generates a random name and address using the Faker library. fake_something.name() returns a random name, while fake_something.address() returns a random address.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;payload = []
for i in range(1000):
    payload.append(
        {
            "artist":fake_something.name(),
            "song" : " ".join(fake_something.words()),
            "url_Song" : fake_something.url(),
            "year": fake_something.year(),
            "country" : fake_something.country()
        }
    )
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code creates a list of 1,000 dictionaries, each representing a song entry with random details. Each dictionary includes:&lt;/p&gt;

&lt;p&gt;"artist": A random artist name.&lt;br&gt;
"song": A random song title generated from a list of words.&lt;br&gt;
"url_Song": A random URL for the song.&lt;br&gt;
"year": A random year.&lt;br&gt;
"country": A random country.&lt;br&gt;
The payload list will contain these 1,000 entries, each with unique, fake data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;client.upsert(
    collection_name = my_collection,
    points = models.Batch(
        ids = index,
        vectors = data.tolist(),
        payloads=payload
    )
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Updates vectors in the "first_collection" collection of Qdrant. It uses the client.upsert method to add or modify vectors with the following details:&lt;/p&gt;

&lt;p&gt;ids: List of unique identifiers for each vector.&lt;br&gt;
vectors: The vector data, converted to a list.&lt;br&gt;
payloads: Additional metadata (such as artist, song, URL, year, and country) associated with each vector.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;client.search(
    collection_name = my_collection,
    query_vector = living_la_vida_loca,
    limit=5
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aussie_songs= models.Filter(
    must = [
        models.FieldCondition(
            key="country",match = models.MatchValue(value="Taiwan")
        )
    ]
)
aussie_songs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;client.search(
    collection_name = my_collection,
    query_vector = living_la_vida_loca,
    query_filter=aussie_songs,
    limit=5
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Performs a search in the "first_collection" collection of Qdrant:&lt;br&gt;
query_vector: The vector representation of the search query (living_la_vida_loca), used to find similar vectors.&lt;br&gt;
query_filter: A filter (aussie_songs) applied to restrict search results based on specific criteria (e.g., only Australian songs).&lt;br&gt;
limit: Specifies that only the top 5 most similar results should be returned.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;client.recommend(
    collection_name = my_collection,
    #query_vector = living_la_vida_loca,
    positive = [17],
    negative = [100,444],
    limit = 5
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Vector databases, such as Qdrant, represent a significant advancement in data management, particularly for applications involving high-dimensional data and similarity searches. Unlike traditional databases, which handle data in structured formats, vector databases excel in managing and querying complex, multi-dimensional vectors.&lt;/p&gt;

&lt;p&gt;Qdrant stands out as a powerful tool for handling vector-based data. It supports efficient vector indexing and similarity searches, making it suitable for various applications including recommendation systems, semantic search, and anomaly detection. Its ability to store vectors along with additional metadata, or "payloads," enhances the richness of the data and improves search precision.&lt;/p&gt;

&lt;p&gt;The provided code snippets illustrate practical usage of Qdrant:&lt;/p&gt;

&lt;p&gt;Creating and Configuring Collections: Establishing a collection with specific vector dimensions and similarity metrics.&lt;br&gt;
Inserting Data: Adding vectors and associated metadata into the collection.&lt;br&gt;
Retrieving Data: Fetching vectors and metadata by their IDs.&lt;br&gt;
Searching: Performing similarity searches based on vector representations and optional filters.&lt;br&gt;
These operations demonstrate how Qdrant facilitates the management and querying of high-dimensional data, enabling sophisticated AI and machine learning applications. Whether used locally, via Docker, or through Qdrant Cloud, it offers flexibility for integration into various environments and applications.&lt;/p&gt;

</description>
      <category>nlp</category>
      <category>vectordatabase</category>
      <category>qdran</category>
      <category>ai</category>
    </item>
    <item>
      <title>YouTube Video Sentiment</title>
      <dc:creator>Muhammad Saim</dc:creator>
      <pubDate>Mon, 29 Jul 2024 14:01:30 +0000</pubDate>
      <link>https://dev.to/muhammad_saim_7/youtube-video-sentiment-5g7h</link>
      <guid>https://dev.to/muhammad_saim_7/youtube-video-sentiment-5g7h</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;In today's digital age, YouTube has become a major platform for sharing opinions, experiences, and information. With millions of videos uploaded daily, understanding the sentiment expressed in these videos can provide valuable insights for various stakeholders, from marketers to social scientists. However, analyzing the sentiment of video content poses unique challenges, particularly when dealing with the audio component.&lt;br&gt;
This project aims to tackle these challenges by developing a comprehensive approach to YouTube video sentiment analysis. By leveraging state-of-the-art tools and technologies, we extract audio from YouTube videos, transcribe the audio into text, and classify the sentiment of the transcribed text. The process involves using &lt;strong&gt;Pythonfixtube&lt;/strong&gt; for audio extraction, &lt;strong&gt;OpenAI Whisper&lt;/strong&gt; for transcription, and fine-tuning a &lt;strong&gt;BERTSequenceClassifier&lt;/strong&gt; for sentiment classification. The final model is deployed on Hugging Face, making it accessible for broader use and evaluation.&lt;br&gt;
Approach wads not only automates the sentiment analysis process but also provides a scalable solution that can be applied to datasets of YouTube videos. This project showcases the power of combining modern AI techniques with practical applications, offering a valuable tool for sentiment analysis in the digital content space.&lt;/p&gt;

&lt;h2&gt;
  
  
  Project Overview
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F87ytgbt5sep67lx5nuxg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F87ytgbt5sep67lx5nuxg.png" alt="Image description" width="624" height="331"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Fetching Data
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Start Here:&lt;/strong&gt; The initial step in the process.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fetching&lt;/strong&gt; Audio: Extract audio from YouTube videos using
Pythonfix tube.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Preparing Data
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Using OpenAI Whisper:&lt;/strong&gt; Transcribe the audio to text.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cleaning + Preprocessing:&lt;/strong&gt; Process the transcribed text for further analysis.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Converting to Sentences + Tokenization:&lt;/strong&gt; Prepare the text data by breaking it into sentences and tokenizing it.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. Model Training
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;BERT:&lt;/strong&gt; Utilize the BERT model for sentiment analysis.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Fine-Tuning:&lt;/strong&gt; Fine-tune the BERT model on the prepared data.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Performance Metrics:&lt;/strong&gt; Evaluate the model's performance using various metrics.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  4. Deploying Model
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Gradio:&lt;/strong&gt; Utilize Gradio for creating a user-friendly interface.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hugging Face:&lt;/strong&gt; Deploy the model on Hugging Face for broader accessibility.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Data Collection and Preparation
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;1.Collecting Video Links&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The first step in the project was to gather links to YouTube videos that represented both positive and negative sentiments. These links were curated based on the content and context of the videos to ensure a balanced dataset.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2.Storing Links&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The collected video links were stored in a text file, with separate files for positive and negative sentiment videos. This organization facilitated the subsequent data processing steps.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3.Downloading Audio&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Using the Pythonfix tube tool, the audio from each video was downloaded. The tool was configured to save the audio files into respective folders based on their sentiment category (positive or negative). This organization helped maintain clarity and ease of access for further processing.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Audio Transcription
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;4.Transcribing Audio to Text&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;After downloading the audio files, the next step was to transcribe the audio into text. For this, we used OpenAI Whisper, a powerful tool for converting spoken language into written text.&lt;/li&gt;
&lt;li&gt;Each audio file was processed, and the resulting text was stored in the respective folders based on their sentiment category (positive or negative). This structured approach ensured that the transcriptions were organized and easily accessible for the next stages of the project.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  5.Data Augmentation and Processing
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;To enhance the robustness of the sentiment analysis model, we supplemented the transcriptions from the YouTube videos with another well-curated dataset optimized for sentiment classification. This additional dataset helped provide a broader range of sentiment examples.&lt;/li&gt;
&lt;li&gt;The two datasets were merged and processed to create a combined dataframe. This step involved cleaning the text data, removing noise, and ensuring consistency in formatting. The data was then tokenized and converted into a suitable format for training the model.
## 6.Fine-Tuning the BERT Model&lt;/li&gt;
&lt;li&gt;The combined dataset served as the training data for fine-tuning a BERT model. BERT (Bidirectional Encoder Representations from Transformers) is a state-of-the-art model for natural language understanding tasks.&lt;/li&gt;
&lt;li&gt;The fine-tuning process involved adjusting the pre-trained BERT model to the specific nuances of our sentiment classification task. The model was trained on the combined dataset, optimizing it to accurately classify the sentiment of the text data into positive or negative categories.
User Interface and Deployment&lt;/li&gt;
&lt;li&gt; Creating a User-Friendly Interface
o   To make the sentiment analysis tool accessible to a broader audience, we developed a user-friendly interface using Gradio. Gradio is an open-source library that simplifies the creation of web-based interfaces for machine learning models.
o   The interface allows users to input a YouTube video URL, and the tool automatically extracts the audio, transcribes it, and predicts the sentiment of the video. This streamlined process makes it easy for users to analyze the sentiment of YouTube videos without requiring technical expertise.
## 8.Deployment on Hugging Face&lt;/li&gt;
&lt;li&gt;The final model, along with the Gradio interface, was deployed on Hugging Face. Hugging Face provides a platform for hosting and sharing machine learning models, making them accessible to the community.&lt;/li&gt;
&lt;li&gt;By deploying the model on Hugging Face, we ensured that it is easily accessible for anyone to use and experiment with, further expanding its utility and reach.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbz9mhfr04qj7bv3esmet.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbz9mhfr04qj7bv3esmet.png" alt="Image description" width="800" height="411"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;The YouTube Video Sentiment Analysis project showcases the potential of combining advanced AI technologies with practical applications. By leveraging tools like Pythonfix tube for audio extraction, OpenAI Whisper for transcription, and BERT for sentiment analysis, we developed a robust system capable of analyzing the sentiment of YouTube videos. The integration of a user-friendly interface through Gradio and deployment on Hugging Face further enhances the accessibility and usability of the tool.&lt;br&gt;
&lt;strong&gt;Here is hugging Face APP:&lt;/strong&gt; &lt;a href="https://huggingface.co/spaces/Saim-11/Youtube-Videos-Sentiment" rel="noopener noreferrer"&gt;https://huggingface.co/spaces/Saim-11/Youtube-Videos-Sentiment&lt;/a&gt;&lt;/p&gt;

</description>
      <category>news</category>
      <category>ai</category>
      <category>llm</category>
      <category>bert</category>
    </item>
    <item>
      <title>Introduction to NEURAL MACHINE TRANSLATION BY JOINTLY LEARNING TO ALIGN AND TRANSLATE</title>
      <dc:creator>Muhammad Saim</dc:creator>
      <pubDate>Fri, 12 Jul 2024 09:17:23 +0000</pubDate>
      <link>https://dev.to/muhammad_saim_7/introduction-to-neural-machine-translation-by-jointly-learning-to-align-and-translate-4akb</link>
      <guid>https://dev.to/muhammad_saim_7/introduction-to-neural-machine-translation-by-jointly-learning-to-align-and-translate-4akb</guid>
      <description>&lt;h3&gt;
  
  
  Introduction
&lt;/h3&gt;

&lt;p&gt;Neural machine translation appears more effective than traditional statistical modeling for translating sentences. This paper introduces the concept of attention in neural machine translation, which is a better approach to translating sentences. Normal neural translators use fixed-length vectors, which do not translate longer sentences correctly. However, this paper uses dynamic-length vectors that better convert longer sentences.&lt;/p&gt;

&lt;p&gt;NMT uses an encoder-decoder architecture in which fixed-length vectors were used. The model needs to compress all the information into one single vector, which can be a difficult task for NMT. The performance of NMT decreases as the input length increases.&lt;/p&gt;

&lt;p&gt;To address this issue, they introduce an extension of the encoder-decoder which learns to align and translate jointly. Each time the proposed model generates the translation of a word, it searches for the relevant information in the context. The model predicts the target word based on the context vector and all previously generated target words.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Encoder-Decoder Framework in Neural Machine Translation
&lt;/h2&gt;

&lt;p&gt;Back then in machine translation statistical techniques are used. Based on specific x  the model learn then it predicts y. Equation is argmax(y | X). RNN uses two components first to encode the variable length source sentence to fixed length vector then decode variable length target sentence.&lt;br&gt;
In Encoder-Decoder framework input sentence in sequence of vectors x = (x1,x2, …. , xn) into a vetor c2 &lt;br&gt;
            ht =  f(xt,ht-1)&lt;br&gt;
             c = q({h1, …. , hTx})&lt;br&gt;
The decoder is trained to predict the next word yt from all the previous words {yt, … ,yt’-1}. In other words decoder defines the joint probability into condition. &lt;br&gt;
                 P(y) = ∏p(yt|{y1,….,yt-1},c)&lt;br&gt;
         p(yt|{y1,….,yt-1},c) =  g(yt-1,st,c)&lt;br&gt;
where g in non linear function the probability of yt and st is hidden state. &lt;/p&gt;

&lt;h3&gt;
  
  
  Learning to align and translate
&lt;/h3&gt;

&lt;p&gt;NTM approaches before this paper uses the normal RNN architecture. they introduce bi-direction RNN in which encoder encodes and decoder that emulates through source sentence and decoding the translation. &lt;br&gt;
The model architecture used in paper is following.&lt;br&gt;
    P(yi|y1,….,yi-1,X) = g(yi-1,si,ci)&lt;br&gt;
Yi-1 is previous hidden state si is RNN hidden state and ci is current context vector.&lt;/p&gt;

&lt;h3&gt;
  
  
  Bi directional RNN
&lt;/h3&gt;

&lt;p&gt;The usual RNN reads the input sequence x from X to Xtx In this paper annotation is not only for single word but it is also for the following words. So bidirectional rnn read the input from (x1, … xn) and calculate the hidden states (h1, … hn) after that RNN f reads the sequence in reverse order (x,…..,x1) compute the hidden state (hn, …. h1).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuhbrmuot8t9os4yye7nq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuhbrmuot8t9os4yye7nq.png" alt="Image description" width="624" height="357"&gt;&lt;/a&gt;&lt;br&gt;
This model shows good BLEU score for the longer sentences getting score for the RNNsearch-50 is quite optimized.&lt;/p&gt;

&lt;h3&gt;
  
  
  Results
&lt;/h3&gt;

&lt;p&gt;There are two kind of models are used RNNsearch and RNNenc. RNNenced have 1000 hidden units each decoder and decoder. The encoder of RNNsearch consist of forward and backward have 1000 units each The results maximizes the condition probability.&lt;/p&gt;

</description>
      <category>attention</category>
      <category>deeplearning</category>
      <category>nlp</category>
      <category>machinetranslation</category>
    </item>
    <item>
      <title>Attention Mechanism</title>
      <dc:creator>Muhammad Saim</dc:creator>
      <pubDate>Thu, 04 Jul 2024 08:33:18 +0000</pubDate>
      <link>https://dev.to/muhammad_saim_7/attention-mechanism-2bdj</link>
      <guid>https://dev.to/muhammad_saim_7/attention-mechanism-2bdj</guid>
      <description>&lt;p&gt;&lt;em&gt;Attention basically refers to considering something important and ignoring other unimportant information.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Abstract
&lt;/h2&gt;

&lt;p&gt;Consider you are stadium and many cricket teams are there and you want to see Pakistan team you just see the players wearing green color kit and ignore rest of all. Brain consider the important thing is green color because it is one thing that make them different from other.&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Same analogy is needed in the deep learning. In deep learning if you want to increase the efficiency then attention mechanism plays important role. This play important role in rising of deep learning. In deep learning it takes all the input break that input into parts and focus on every part then assign the score to these parts. Now higher score parts are consider more important and have higher impact. Therefore, it reduces all the other parts which have low score.&lt;/p&gt;

&lt;h2&gt;
  
  
  Previous work
&lt;/h2&gt;

&lt;p&gt;Previously LSTM/RNN was used in which there are encoder and decoder. Encoder make the summary of input data and passed to decoder but problem in this is if the sentence is long it cannot make the good summary which creates the bad response from decoder. RNNs cannot remember longer sentences and sequences due to the vanishing/exploding gradient problem. &lt;/p&gt;

&lt;h2&gt;
  
  
  Key Concepts
&lt;/h2&gt;

&lt;p&gt;Query, Key, and Value:&lt;br&gt;
&lt;strong&gt;Query (Q)&lt;/strong&gt;: The element for which we are seeking attention.&lt;br&gt;
&lt;strong&gt;Key (K):&lt;/strong&gt; The elements in the input sequence that the model can potentially focus on.&lt;br&gt;
&lt;strong&gt;Value (V):&lt;/strong&gt; The elements in the input sequence that are associated with the keys, from which the output is generated.&lt;/p&gt;

&lt;h2&gt;
  
  
  Attention Score
&lt;/h2&gt;

&lt;p&gt;The attention score is calculated by taking the dot product of the query and the key, which measures how much focus each key should get relative to the query.&lt;br&gt;
These scores are then normalized using a softmax function to produce a probability distribution.&lt;br&gt;
&lt;strong&gt;Weighted Sum:&lt;/strong&gt;&lt;br&gt;
The normalized attention scores are used to create a weighted sum of the values. This weighted sum represents the attention output.&lt;/p&gt;

&lt;h2&gt;
  
  
  Types of Attention
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Self-Attention (or Scaled Dot-Product Attention)&lt;/strong&gt;&lt;br&gt;
Used in transformer models where the query, key, and value all come from the same sequence.&lt;br&gt;
Involves computing attention scores between every pair of elements in the sequence.&lt;br&gt;
&lt;strong&gt;Multi-Head Attention:&lt;/strong&gt;&lt;br&gt;
Extends the self-attention mechanism by using multiple sets of queries, keys, and values.&lt;br&gt;
Each set, or "head," processes the input differently, and the results are concatenated and linearly transformed to produce the final output.&lt;/p&gt;

&lt;h3&gt;
  
  
  Mathematical Formulation
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Score (Q,K) = QkT&lt;br&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Scaled Scores&lt;br&gt;
&lt;/h3&gt;
&lt;br&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Scaled Score (Q,K) = QKT / √dk&lt;br&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Softmax to get Attention Weights:&lt;br&gt;
&lt;/h3&gt;
&lt;br&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Attention Weights = softmax(QKT / √dk)&lt;br&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Weighted Sum to get the final output:&lt;br&gt;
&lt;/h3&gt;
&lt;br&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Attention Output=Attention Weights⋅V&lt;br&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Understanding attention mechanism&lt;br&gt;
&lt;/h2&gt;

&lt;p&gt;There are hidden states in rnn and the final hidden state is passed to decoder and this make decoder to do computation give results.&lt;br&gt;
Take the example of machine translation. Here the sentence is passed and result is not up to the mark because the only final hidden state is passed.&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fllj3zyj0b6zt04zioyku.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fllj3zyj0b6zt04zioyku.png" alt="Image description" width="800" height="311"&gt;&lt;/a&gt;&lt;br&gt;
Now this problem can be solved by attention mechanism by not passing only final hidden state pass all the states to decoder this makes the decoder to solve the problems more efficiently and give the good translation result.&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4pqleqmg6rtdmb2223a6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4pqleqmg6rtdmb2223a6.png" alt="Image description" width="800" height="267"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Transformer Model
&lt;/h2&gt;

&lt;p&gt;In the transformer architecture, attention mechanisms are crucial for both the encoder and the decoder:&lt;br&gt;
• &lt;strong&gt;Encoder&lt;/strong&gt;: Each layer uses self-attention to process the input sequence and generate a representation.&lt;br&gt;
• &lt;strong&gt;Decoder&lt;/strong&gt;: Uses a combination of self-attention (to process the output sequence so far) and encoder-decoder attention (to focus on relevant parts of the input sequence).&lt;br&gt;
The attention mechanism has been instrumental in the success of models like BERT, GPT, and other transformer-based models, enabling them to handle complex tasks such as translation, summarization, and question answering effectively.&lt;/p&gt;

</description>
      <category>nlp</category>
      <category>llm</category>
      <category>machinelearning</category>
      <category>deeplearning</category>
    </item>
    <item>
      <title>Introduction TO Word Embeddings</title>
      <dc:creator>Muhammad Saim</dc:creator>
      <pubDate>Tue, 25 Jun 2024 08:26:33 +0000</pubDate>
      <link>https://dev.to/muhammad_saim_7/introduction-to-word-embeddings-4m86</link>
      <guid>https://dev.to/muhammad_saim_7/introduction-to-word-embeddings-4m86</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Word embedding is a technique in which words and sentences are converted into numbers. Our computer can understand only numbers, so representing this text as numbers is necessary for model training. Another thing is that using word embedding reduces the dimensionality, which is more efficient for the processing of data. There are many traditional and modern techniques, so first, we'll discuss traditional techniques and then modern techniques.&lt;/p&gt;

&lt;p&gt;Traditional techniques for Word Embedding&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;One-Hot Encoding&lt;/li&gt;
&lt;li&gt;TF-IDF vectorizer&lt;/li&gt;
&lt;li&gt;Bag of Words&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  One-Hot Encoding
&lt;/h3&gt;

&lt;p&gt;Using this scheme, all the other values are set to 0 except the current word value which is set to 1. Let's consider we have the sentence ['apple', 'Mango', 'Peach']:&lt;br&gt;
apple: [1,0,0]&lt;br&gt;
Mango: [0,1,0]&lt;br&gt;
Peach: [0,0,1]&lt;/p&gt;

&lt;h3&gt;
  
  
  Bag of Words
&lt;/h3&gt;

&lt;p&gt;In Bag of Words, an unordered set of words and their frequencies are considered. Each word in the sentence is divided by the total occurrences in the text. Below, there is an example.&lt;/p&gt;

&lt;h4&gt;
  
  
  Example:
&lt;/h4&gt;

&lt;p&gt;Consider the following two sentences:&lt;br&gt;
"The cat sat on the mat."&lt;br&gt;
"The cat played with the cat."&lt;/p&gt;

&lt;h4&gt;
  
  
  Step-by-Step Process:
&lt;/h4&gt;

&lt;h4&gt;
  
  
  Tokenization:
&lt;/h4&gt;

&lt;p&gt;Sentence 1: ["The", "cat", "sat", "on", "the", "mat"]&lt;br&gt;
Sentence 2: ["The", "cat", "played", "with", "the", "cat"]&lt;/p&gt;

&lt;h4&gt;
  
  
  Case Normalization (optional):
&lt;/h4&gt;

&lt;p&gt;Sentence 1: ["the", "cat", "sat", "on", "the", "mat"]&lt;br&gt;
Sentence 2: ["the", "cat", "played", "with", "the", "cat"]&lt;br&gt;
Build Vocabulary: Unique words: ["the", "cat", "sat", "on", "mat", "played", "with"]&lt;br&gt;
Count Frequencies:&lt;br&gt;
Sentence 1:&lt;br&gt;
"the": 2&lt;br&gt;
"cat": 1&lt;br&gt;
"sat": 1&lt;br&gt;
"on": 1&lt;br&gt;
"mat": 1&lt;br&gt;
"played": 0&lt;br&gt;
"with": 0&lt;br&gt;
Sentence 2:&lt;br&gt;
"the": 2&lt;br&gt;
"cat": 2&lt;br&gt;
"sat": 0&lt;br&gt;
"on": 0&lt;br&gt;
"mat": 0&lt;br&gt;
"played": 1&lt;br&gt;
"with": 1&lt;/p&gt;

&lt;h4&gt;
  
  
  Calculate Total Word Counts:
&lt;/h4&gt;

&lt;p&gt;Sentence 1: 6 words&lt;br&gt;
Sentence 2: 6 words&lt;/p&gt;

&lt;h4&gt;
  
  
  Normalize Frequencies:
&lt;/h4&gt;

&lt;p&gt;Sentence 1:&lt;br&gt;
"the": 2/6 = 0.333&lt;br&gt;
"cat": 1/6 = 0.167&lt;br&gt;
"sat": 1/6 = 0.167&lt;br&gt;
"on": 1/6 = 0.167&lt;br&gt;
"mat": 1/6 = 0.167&lt;br&gt;
"played": 0/6 = 0.000&lt;br&gt;
"with": 0/6 = 0.000&lt;br&gt;
Sentence 2:&lt;br&gt;
"the": 2/6 = 0.333&lt;br&gt;
"cat": 2/6 = 0.333&lt;br&gt;
"sat": 0/6 = 0.000&lt;br&gt;
"on": 0/6 = 0.000&lt;br&gt;
"mat": 0/6 = 0.000&lt;br&gt;
"played": 1/6 = 0.167&lt;br&gt;
"with": 1/6 = 0.167&lt;/p&gt;

&lt;h4&gt;
  
  
  Representation:
&lt;/h4&gt;

&lt;p&gt;Sentence 1: [0.333, 0.167, 0.167, 0.167, 0.167, 0.000, 0.000]&lt;br&gt;
Sentence 2: [0.333, 0.333, 0.000, 0.000, 0.000, 0.167, 0.167]&lt;br&gt;
Term Frequency and Inverse Document Frequency&lt;/p&gt;

&lt;h3&gt;
  
  
  Term Frequency and Inverse Document Frequency (TF-IDF)
&lt;/h3&gt;

&lt;p&gt;TF-IDF is a numerical statistic that reflects the importance of a term in a document relative to a collection of documents. This method is widely used in text mining and information retrieval. It consists of two components: Term Frequency (TF) and Inverse Document Frequency (IDF).TF-IDF is a numerical statistic that reflects the importance of a term in a document relative to a collection of documents. TF-IDF consists of two components:&lt;br&gt;
Term Frequency (TF): Term Frequency measures how often a term (word) appears in a document.&lt;/p&gt;

&lt;h3&gt;
  
  
  Neural Networks:
&lt;/h3&gt;

&lt;p&gt;In 2013, Google published a paper in which they solved a similar problem. They introduced a new way of word embedding in which they tried to capture the semantic relationship between words. There are two techniques for word2vec: CBOW and skip-gram. The traditional techniques were good but they were not able to capture semantics in words.&lt;/p&gt;

&lt;h3&gt;
  
  
  CBOW
&lt;/h3&gt;

&lt;p&gt;Before understanding the concept of CBOW, we need to understand the concept of windowing. A context window refers to the surrounding words around the target word. For example, if I have the sentence “Pakistan is a great country for tourism”, and I select a context window size of 2 with my target word being ‘great’, the 2 words before ‘great’ (Pakistan is) and the two words after ‘great’ (country for) are in the context window. A sliding window refers to a fixed size window that, after processing one context window, moves to the next window. This allows the model to pass through all the text.&lt;br&gt;
Now, in a neural network, the context windows are passed through the input layer, the target word is placed in the output layer, and between them are the hidden layers. Dimensionality reduction occurs in the hidden layers.&lt;br&gt;
Sentence: "Data science is transforming industries."&lt;/p&gt;

&lt;h4&gt;
  
  
  Training Examples:
&lt;/h4&gt;

&lt;p&gt;Context Words: ["Data", "is"]&lt;br&gt;
Target Word: "science"&lt;br&gt;
Context Words: ["Data", "science", "transforming"]&lt;br&gt;
Target Word: "is"&lt;br&gt;
Context Words: ["science", "is", "industries"]&lt;br&gt;
Target Word: "transforming"&lt;br&gt;
Context Words: ["is", "transforming"]&lt;br&gt;
Target Word: "industries"&lt;br&gt;
In this example, for each target word, the context words within a window size of 2 are used to create the training data for the CBOW model.&lt;/p&gt;

&lt;h3&gt;
  
  
  Skip-gram:
&lt;/h3&gt;

&lt;p&gt;Skip-gram is a technique which is based on predicting surrounding words based on a specific word. It is just like the inverse of CBOW. It predicts the word by analyzing surrounding words. If the sentence is like "king wore a golden crown", skip-gram will take the words "wore" and "golden" and predict "king" and "crown".&lt;/p&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>nlp</category>
      <category>datascience</category>
    </item>
  </channel>
</rss>
