<?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 Subhasis on Medium]]></title>
        <description><![CDATA[Stories by Subhasis on Medium]]></description>
        <link>https://medium.com/@subhasis.jethy?source=rss-c19049bab357------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*4vhl3LkogK-aTN_Ktg-qZw.jpeg</url>
            <title>Stories by Subhasis on Medium</title>
            <link>https://medium.com/@subhasis.jethy?source=rss-c19049bab357------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 07:21:29 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@subhasis.jethy/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[Few-Shot Learning: Semantic Search]]></title>
            <link>https://medium.com/@subhasis.jethy/few-shot-learning-semantic-search-9a54a22d6b9f?source=rss-c19049bab357------2</link>
            <guid isPermaLink="false">https://medium.com/p/9a54a22d6b9f</guid>
            <category><![CDATA[few-shot-learning]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[semantic-search]]></category>
            <category><![CDATA[transformers]]></category>
            <category><![CDATA[naturallanguageprocessing]]></category>
            <dc:creator><![CDATA[Subhasis]]></dc:creator>
            <pubDate>Wed, 04 Jan 2023 17:33:50 GMT</pubDate>
            <atom:updated>2023-01-04T20:37:24.058Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2ahlpqsthFQiDVQE" /><figcaption>Photo by <a href="https://unsplash.com/@dlerman6?utm_source=medium&amp;utm_medium=referral">Daniel Lerman</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Semantic Seach is a great way to get started with few-shot learning. We can use semantic search to find similar documents to a query document. We can then use the labeled results of the search to train a classifier.</p><p>For our scenario, we will use the English version of IMDB sentiment dataset with Reviews as text and Sentiment as labels. We will use the reviews to create an index made up of Dense Vector Embeddings for the semantic search model and we will try to classify the sentiments of Spanish Reviews using the results of the semantic search.</p><p>We will make use of a Transformer model with Multilingual Capabilities to embed the text into Dense Vectors in the same space when dealing with multiple languages.</p><pre>import pandas as pd<br><br>imdb_data_en = pd.read_csv(&quot;./Data/IMDB Dataset.csv&quot;)<br>imdb_data_en.head()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*VsFNHIOonilhOUuyjeIy_w.png" /></figure><p>We will shuffle the dataset in a stratified manner and keep only 5000 samples.</p><pre>imdb_data_en = imdb_data_en.sample(frac=1, random_state=42).reset_index(drop=True)<br>imdb_data_en = imdb_data_en[:5000]<br>imdb_data_en.head()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*_Q3N5Ok9DZoBQ-6UjBICUA.png" /><figcaption>IMDB English Dataset</figcaption></figure><pre>imdb_data_en.sentiment.value_counts()</pre><pre>positive    2519<br>negative    2481<br>Name: sentiment, dtype: int64</pre><p>save the excel file for translation.</p><pre># save the excel file for translation<br>imdb_data_en.to_excel(&quot;./Data/IMDB Dataset.xlsx&quot;, index=False)</pre><p>We will use this excel with Google Translate to translate our data into Spanish.</p><pre># load the spanish translated excel file<br>imdb_data_es = pd.read_excel(&quot;./Data/IMDB-Dataset-Spanish-Translated.xlsx&quot;)<br># rename the columns revisión to review and sentimiento to sentiment<br>imdb_data_es.rename(columns={&quot;revisión&quot;: &quot;review&quot;, &quot; sentimiento&quot;: &quot;sentiment&quot;}, inplace=True)<br># rename the values positivo to positive and negativo to negative<br>imdb_data_es.sentiment = imdb_data_es.sentiment.apply(lambda x: &quot;positive&quot; if x == &quot;positivo&quot; else &quot;negative&quot;)<br>imdb_data_es.head()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*hd-nn0npVm7yFQNBA_6zkg.png" /></figure><p>We will create a huggingface dataset from the dataframe imdb_data_en.</p><pre># create a huggingface dataset from the dataframe imdb_data_en<br>from datasets import Dataset<br><br>dataset_en = Dataset.from_pandas(imdb_data_en)<br>dataset_en</pre><pre>Dataset({<br>    features: [&#39;review&#39;, &#39;sentiment&#39;],<br>    num_rows: 5000<br>})</pre><p>As explained earlier, we will load a multilingual model from Sentence Transformers.</p><pre># Load a multilingual model from Sentence Transformers and use it to encode all english sentences in the dataset<br>from sentence_transformers import SentenceTransformer<br><br>model = SentenceTransformer(&quot;distiluse-base-multilingual-cased-v1&quot;)</pre><p>The above downloads the model from the hub and loads it into memory. We will use this model to encode all the English sentences in the dataset.</p><p>The model is now downloaded.</p><p>Let us look at one sentence from the English dataset and encode it.</p><pre># Lets consider one sentence from english dataset and encode it<br>sentence_0_english = dataset_en[0][&quot;review&quot;]<br>sentence_0_english</pre><pre>&quot;I really liked this Summerslam due to the look of the arena, the curtains and just the look overall was interesting to me for some reason. Anyways, this could have been one of the best Summerslam&#39;s ever if the WWF didn&#39;t have Lex Luger in the main event against Yokozuna, now for it&#39;s time it was ok to have a huge fat man vs a strong man but I&#39;m glad times have changed. It was a terrible main event just like every match Luger is in is terrible. Other matches on the card were Razor Ramon vs Ted Dibiase, Steiner Brothers vs Heavenly Bodies, Shawn Michaels vs Curt Hening, this was the event where Shawn named his big monster of a body guard Diesel, IRS vs 1-2-3 Kid, Bret Hart first takes on Doink then takes on Jerry Lawler and stuff with the Harts and Lawler was always very interesting, then Ludvig Borga destroyed Marty Jannetty, Undertaker took on Giant Gonzalez in another terrible match, The Smoking Gunns and Tatanka took on Bam Bam Bigelow and the Headshrinkers, and Yokozuna defended the world title against Lex Luger this match was boring and it has a terrible ending. However it deserves 8/10&quot;</pre><pre>sentence_0_english_embedding = model.encode(sentence_0_english)<br>sentence_0_english_embedding.shape</pre><pre>(512,)</pre><pre>sentence_0_spanish = imdb_data_es[&quot;review&quot;][0]<br>sentence_0_spanish</pre><pre>&#39;Realmente me gustó este Summerslam debido a la apariencia de la arena, las cortinas y simplemente la apariencia general me resultó interesante por alguna razón. De todos modos, este podría haber sido uno de los mejores Summerslam de la historia si la WWF no hubiera tenido a Lex Luger en el evento principal contra Yokozuna, ahora es el momento, estaba bien tener un hombre gordo enorme contra un hombre fuerte, pero me alegro. los tiempos han cambiado. Fue un evento principal terrible al igual que cada partido en el que participa Luger es terrible. Otros combates en la cartelera fueron Razor Ramon vs Ted Dibiase, Steiner Brothers vs Heavenly Bodies, Shawn Michaels vs Curt Hening, este fue el evento en el que Shawn nombró a su gran monstruo de guardaespaldas Diesel, IRS vs 1-2-3 Kid, Bret Hart primero se enfrenta a Doink, luego a Jerry Lawler y las cosas con los Hart y Lawler siempre fueron muy interesantes, luego Ludvig Borga destruyó a Marty Jannetty, Undertaker se enfrentó a Giant Gonzalez en otra lucha terrible, The Smoking Gunns y Tatanka se enfrentaron a Bam Bam Bigelow y the Headshrinkers y Yokozuna defendieron el título mundial contra Lex Luger, este partido fue aburrido y tiene un final terrible. Sin embargo se merece un 8/10&#39;</pre><pre>sentence_0_spanish_embedding = model.encode(sentence_0_spanish)<br>sentence_0_spanish_embedding.shape</pre><pre>(512,)</pre><p>We can see that the encoded vector is a 512 dimensional dense vector. Now that we have two dense vectors in the same space, we can compute the cosine similarity between them. Let us compute the cosine similarity between the two sentences.</p><pre># Lets compute the cosine similarity between the two sentences<br>from sentence_transformers import util<br><br>print(f&#39;Cosine Similarity between sentences in EN vs Spanish is {util.pytorch_cos_sim(sentence_0_english_embedding, sentence_0_spanish_embedding)[0][0]}&#39;)</pre><pre>Cosine Similarity between sentences in EN vs Spanish is 0.9477757215499878</pre><p>Wow, that’s a high similarity score. We can use this to find similar sentences in our dataset. Let us now look at an example with completely different sentences. We will use the same model to encode the sentences. We will then compute the cosine similarity between the two sentence and then compare the similarity score with the previous example. We should see a lower similarity score.</p><pre># now lets compare the cosine similarity with a different spanish sentence this time and see the difference<br>sentence_1_spanish_2 = imdb_data_es[&quot;review&quot;][1]<br>sentence_1_spanish_2</pre><pre>&#39;No hay muchos programas de televisión que atraigan a tantos tipos diferentes de fanáticos como lo hace Farscape... Conozco a jóvenes y mayores de 30/40 años; fanáticos tanto masculinos como femeninos en tantos países diferentes como puedas pensar que simplemente adoran este televisor. mini series. Tiene elementos que se pueden encontrar en casi todos los demás programas de televisión, drama impulsado por personajes que podría ser de una telenovela australiana; ¡sin embargo, en el mismo episodio tiene ciencia ficción y realidad que haría que incluso el &quot;Trekkie&quot; más resistente corriera por su dinero en las apuestas de Brainbender! Teoría de agujeros de gusano, viaje en el tiempo en forma ecuacional verdadera... Magnífico. Abarca culturas de todo el mapa, ya que las posibilidades son infinitas al tener múltiples estrellas y, por lo tanto, miles de planetas para elegir.&lt;br /&gt;&lt;br /&gt;Con un alcance tan amplio; Se esperaría que nada fuera capaz de mantener la ilusión por mucho tiempo, pero aquí es donde &quot;Farscape&quot; realmente entra en su propio elemento... Tiene éxito donde todos los demás han fallado, especialmente Star Trek (un universo ¡con prácticamente cero elemento Kaos!) Se quedaron sin ideas bastante rápido + ¡seguían repitiéndolas! En el transcurso de 4 temporadas, logran mantener la atención de la audiencia utilizando una buena continuidad y una evolución constante de los personajes con múltiples hilos en cada episodio con toques personales únicos a la cámara que son específicos para ciertos grupos de personajes dentro del conjunto. Esta estructura permite un área extremadamente amplia de temas, ya que las lealtades se forjan y se rompen de muchas maneras en muchos temas. Por casualidad vi el piloto (Premiere) de pasada y tuve que seguir sintonizando después de eso para ver si Crichton alguna vez &quot;atraparía a la chica&quot;, después de verlos a todos en la televisión, estaba encantado de verlos disponibles en DVD y tengo admitir que fue lo único que me mantuvo cuerdo mientras tenía que hacer un turno de noche de 12 horas y desarrollé insomnio crónico... Farscape fue lo único que me ayudó a pasar esas noches extremadamente largas...&lt;br /&gt;&lt; br /&gt;Hazte un favor; Mire el piloto y vea lo que quiero decir...&lt;br /&gt;&lt;br /&gt;Farscape Comet&#39;</pre><pre># Now we encode the second spanish sentence and compute the cosine similarity<br>sentence_1_spanish_2_embedding = model.encode(sentence_1_spanish_2)<br>print(f&#39;Cosine Similarity between sentences in EN vs Spanish is {util.pytorch_cos_sim(sentence_0_english_embedding, sentence_1_spanish_2_embedding)[0][0]}&#39;)</pre><pre>Cosine Similarity between sentences in EN vs Spanish is 0.06476996839046478</pre><p>See we are now able to compute the cosine similarity between the english and spanish sentences and the similarity is much lower than before as the sentences are not similar in meaning.</p><p>With this hypothesis we can now use the model to find similar sentences in a corpus of documents. We will encode all english sentences in the corpus and then compute the cosine similarity between the english and spanish sentences.</p><p>The top 5 sentences with the highest similarity will be the most similar sentences in the corpus and we can observe their labels to label any unseen spanish sentence.</p><p>Lets encode all the english sentences in the dataset, we can leverage the map function of the datasets for efficient encoding.</p><pre># Lets encode all the english sentences in the dataset, we can leverage the map function of the datasets for efficient encoding<br>def embed(x):<br>    return {&quot;embedding&quot;: model.encode(x[&quot;review&quot;]) }<br><br>dataset_en_embeddings = dataset_en.map(embed, batched=True)<br># We can now add these embeddings to the dataset as FAISS index, which again is an inbuilt function of the datasets library<br>dataset_en_embeddings.add_faiss_index(&quot;embedding&quot;)</pre><p>Here we have encoded all the english sentences in the dataset and created a FAISS index for efficient similarity search. FAISS index is an integral part of the semantic search pipeline. It is a library for efficient similarity search and clustering of dense vectors. It contains algorithms that search in sets of vectors of any size, up to ones that possibly do not fit in RAM. It also contains supporting code for evaluation and parameter tuning. FAISS is written in C++ with complete wrappers for Python/numpy. Some of the most useful algorithms are implemented on the GPU. It is developed by Facebook AI Research.</p><p>And the best part is it is integrated with Hugging Face’s Dataset library.</p><p>Theoretically, we must compare the query vector to each of the n vectors in the database in order to determine the vectors in the database that are closest to the query vector. This is not an issue for a dataset, but if we expanded it up to hundreds or even millions of records, each query would take a while to process.</p><p>FAISS addresses this issue with several tricks. The main idea is to partition the dataset. If we only need to compare the query vector to a subset of the database, we can speed up the process significantly. But if we just randomly partition the dataset, how can we decide which partition to search, and what guarantees do we get for finding the most similar entries? Evidently, there must be a better solution: apply k-means clustering to the dataset! This clusters the embeddings into groups by similarity. Furthermore, for each group we get a centroid vector, which is the average of all members of the group.</p><pre># Lets cluster the encodings to reduce the search space<br>from sklearn.cluster import KMeans<br><br># find K using the elbow method<br>wcss = []<br>for i in range(1, 11):<br>    kmeans = KMeans(n_clusters=i, init=&quot;k-means++&quot;, random_state=42)<br>    kmeans.fit(dataset_en_embeddings[&quot;embedding&quot;])<br>    wcss.append(kmeans.inertia_)<br><br>import matplotlib.pyplot as plt<br><br>plt.plot(range(1, 11), wcss)<br>plt.title(&quot;The Elbow Method&quot;)<br>plt.xlabel(&quot;Number of clusters&quot;)<br>plt.ylabel(&quot;WCSS&quot;)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*S8c2WRQ9ZSELa3JPwh7zng.png" /></figure><p>We choose K as 4 and train a KMeans model on the encoded english sentences.</p><pre>k = 4<br>kmeans = KMeans(n_clusters=k, init=&quot;k-means++&quot;, random_state=42)<br>kmeans.fit(dataset_en_embeddings[&quot;embedding&quot;])<br>KMeans(n_clusters=4, random_state=42)</pre><pre># Create a new column in the dataset to store the cluster number<br>dataset_en_embeddings = dataset_en_embeddings.add_column(&quot;cluster&quot;, kmeans.labels_)<br>dataset_en_embeddings</pre><pre>Dataset({<br>    features: [&#39;review&#39;, &#39;sentiment&#39;, &#39;embedding&#39;, &#39;cluster&#39;],<br>    num_rows: 5000<br>})</pre><pre># Get the centroids of the clusters<br>centroids = kmeans.cluster_centers_<br>centroids.shape</pre><pre>(4, 512)</pre><pre># Create a dataset for spanish and add the FAISS index<br>dataset_es = Dataset.from_pandas(imdb_data_es)<br>dataset_es_embeddings = dataset_es.map(embed, batched=True)<br>dataset_es_embeddings.add_faiss_index(&quot;embedding&quot;)</pre><p>The below code, takes an encoded Query text and finds the top 5 similar sentences in the corpus. We first compute the cosine similarity between the query and all the centroids of the Clusters. Then we use the query vector to find the closest sentences within that cluster using the FAISS index.</p><pre>import numpy as np<br>from collections import Counter<br><br># Create a function for the above <br>def get_nearest_examples(query, k=5,centroids=centroids,debug=True):<br>    query_embedding =  np.array(query[&quot;embedding&quot;], dtype=np.float32)<br>    # We will first get the closest centroid and then get the nearest examples in the cluster<br>    centroids = centroids.astype(&quot;float32&quot;)<br>    centroid_distances = util.pytorch_cos_sim(query_embedding, centroids)[0]<br>    closest_centroid = np.argsort(centroid_distances)[0]<br>    # Get the nearest examples in the cluster<br>    # Filter the dataset by cluster label and then get the nearest examples<br>    dataset_cluster = dataset_en_embeddings.filter(lambda x: x[&quot;cluster&quot;] == closest_centroid)<br>    if debug:<br>        print(dataset_cluster.shape)<br>    dataset_cluster.add_faiss_index(&quot;embedding&quot;)<br>    scores, samples = dataset_cluster.get_nearest_examples(&quot;embedding&quot;, query_embedding, k=k)<br>    # scores, samples = dataset_en_embeddings.get_nearest_examples(&quot;embedding&quot;, query_embedding, k=k)<br>    if debug:<br>        print(f&quot;QUERY LABELS: {query[&#39;sentiment&#39;]}&quot;)<br>        print(f&quot;QUERY TEXT:\n{query[&#39;review&#39;][:200]} [...]\n&quot;)<br>        print(&quot;=&quot;*50)<br>        print(f&quot;Retrieved documents:&quot;)<br>        for score, label, text in zip(scores, samples[&quot;sentiment&quot;], samples[&quot;review&quot;]):<br>            print(&quot;=&quot;*50)<br>            print(f&quot;TEXT:\n{text[:200]} [...]&quot;)<br>            print(f&quot;SCORE: {score:.2f}&quot;)<br>            print(f&quot;LABELS: {label}&quot;)<br>    # Selected label is most occuring string sentiment in the retrieved documents<br>    counts = Counter(samples[&quot;sentiment&quot;])<br>    selected_label = counts.most_common(1)[0][0]<br>    if debug:<br>        print(&quot;=&quot;*50)<br>        print(f&quot;SELECTED LABEL: {selected_label}&quot;)<br>    return selected_label<br>    <br>predicted_label = get_nearest_examples(dataset_es_embeddings[10])</pre><pre><br><br>QUERY LABELS: negative<br>QUERY TEXT:<br> Dios, esto fue inmensamente aburrido. el protagonista (Christian Schoyen) tiene que ser el peor actor que he visto en mi vida. y otra cosa, si el personaje de la película se mudara a Estados Unidos c [...]<br><br>==================================================<br>Retrieved documents:<br>==================================================<br>TEXT:<br>... when dubbed into another language. Let&#39;s face it: Neither Nielsen nor Schwarzenegger are really good actors when it comes to dialog. And given the campy lines they are supposed to utter this is a  [...]<br>SCORE: 0.78<br>LABELS: negative<br>==================================================<br>TEXT:<br>This TVM seems to have polarised opinions amongst the commentators on this page so perhaps I can settle everything by saying this is a very stupid not very well made television movie . How bad is it ? [...]<br>SCORE: 0.83<br>LABELS: negative<br>==================================================<br>TEXT:<br>It&#39;s the single unfunniest thing I ever watched. It&#39;s sad how he tries so hard to come up with a good joke and all he does is curse and thinks his disgusting vulgarity is funny. He is the most bitter  [...]<br>SCORE: 0.85<br>LABELS: negative<br>==================================================<br>TEXT:<br>Cusack does his best David Niven in this one, although I don&#39;t know if anyone besides me noticed it.&lt;br /&gt;&lt;br /&gt;When seen with this in mind, its a deliciously over saturated &#39;wants to be taken more se [...]<br>SCORE: 0.86<br>LABELS: positive<br>==================================================<br>TEXT:<br>Director Vincenzo Natali&#39;s Cypher is a complex and imaginative thriller which, although requiring some suspension of belief and plenty of concentration, manages to be a thoroughly entertaining experie [...]<br>SCORE: 0.87<br>LABELS: positive<br>==================================================<br>SELECTED LABEL: negative</pre><pre>predicted_label = get_nearest_examples(dataset_es_embeddings[12],k=3)</pre><pre><br><br>QUERY LABELS: negative<br>QUERY TEXT:<br> Se hizo en 2007 y el CG es malo para una película hecha en 1998. En una parte de la película hay una toma en stop motion de un dinosaurio que en realidad se ve bien, pero esto solo hace que el trabaj [...]<br><br>==================================================<br>Retrieved documents:<br>==================================================<br>TEXT:<br>I remember watching ATTACK when it first came out and caught it again recently. The sci fi channel has run worse, but not by much. A shameless ripoff of Jurassic Park, ATTACK substitutes sabertooth ca [...]<br>SCORE: 0.67<br>LABELS: negative<br>==================================================<br>TEXT:<br>I saw this series in 1999 in London TV and was blown away. Like another user commented - This is what i would have liked to see when i first watched &quot;Jurassic Park&quot; - Life and death of Dinosaurs in th [...]<br>SCORE: 0.75<br>LABELS: positive<br>==================================================<br>TEXT:<br>OH MY GOD! After having such a promising start, Critters 2 reiterated the Karmic rule of what goes around comes around. Clearly, very few things were thought out when this movie was made, and what was [...]<br>SCORE: 0.83<br>LABELS: negative<br>==================================================<br>SELECTED LABEL: negative</pre><p>In the above examples, we see the query text along with its original label and its similar sentences and their labels. The selected label is the maximum occurring label among the top 5 results. Now let’s calculate the accuracy of the method on a sample of the Translated Spanish Reviews. We will use the top 3 similar sentences to label the Spanish reviews. If the majority of the top 3 sentences are of the same label, we will label the Spanish review with that label.</p><pre># Calculate the accuracy of the prediction<br>def get_accuracy(dataset_es_embeddings):<br>    correct = 0<br>    for i in range(len(dataset_es_embeddings)):<br>        predicted_label = get_nearest_examples(dataset_es_embeddings[i],k=3,debug=False)<br>        if predicted_label == dataset_es_embeddings[i][&quot;sentiment&quot;]:<br>            correct += 1<br>    return correct/len(dataset_es_embeddings)<br><br># Drop the FAISS index<br># dataset_es_embeddings.drop_index(&quot;embedding&quot;)<br># Get 100 rows from the dataset<br>dataset_es_embeddings_100 = dataset_es_embeddings.select(range(100))<br># Add the index to the dataset<br>dataset_es_embeddings_100.add_faiss_index(&quot;embedding&quot;)<br>print(f&#39;Accuracy :{get_accuracy(dataset_es_embeddings_100)}&#39;)</pre><pre>Accuracy :0.67</pre><p>Wow!, we get an accuracy of 67% on the 100 rows of the dataset. This is a great start. We can now try to improve the accuracy by using a larger dataset and also by using a larger model. We can use these embeddings along with the labels to build a classifier or a regressor to predict the sentiment of the review.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9a54a22d6b9f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to learn Machine Learning and AI in 2023?]]></title>
            <link>https://medium.com/@subhasis.jethy/how-to-learn-machine-learning-and-ai-in-2023-f295540110b9?source=rss-c19049bab357------2</link>
            <guid isPermaLink="false">https://medium.com/p/f295540110b9</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[learning-and-development]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Subhasis]]></dc:creator>
            <pubDate>Fri, 30 Dec 2022 18:46:05 GMT</pubDate>
            <atom:updated>2022-12-31T06:53:10.485Z</atom:updated>
            <content:encoded><![CDATA[<p>From Zero to Hero(almost)…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QEsf_m1-Ksot1p-I" /></figure><p>Machine learning is a rapidly growing field that is transforming many aspects of our lives, from healthcare to transportation to finance. If you’re interested in learning machine learning in 2023, here are a few resources to get you started:</p><h3><strong>Online courses</strong></h3><p>There are many online courses and MOOCs (massive open online courses) available that can teach you the fundamentals of AI. These courses often include a mix of video lectures, quizzes, and hands-on programming exercises. Some popular platforms for learning AI online include Coursera, Udemy, edX, and Udacity. These courses vary in terms of their length, difficulty, and focus, so it’s important to choose one that is appropriate for your goals and background. Many of these courses are free to enroll in, but may also offer paid options for additional features such as assessments and certificates. Here are some links to online courses that can teach you the fundamentals of artificial intelligence (AI) and machine learning:</p><ol><li><strong>Coursera</strong>: <a href="https://www.coursera.org/courses?query=artificial%20intelligence">https://www.coursera.org/courses?query=artificial%20intelligence</a></li><li><strong>edX</strong>: <a href="https://www.edx.org/learn/artificial-intelligence">https://www.edx.org/learn/artificial-intelligence</a></li><li><strong>Udacity</strong>: <a href="https://www.udacity.com/courses/artificial-intelligence">https://www.udacity.com/courses/artificial-intelligence</a></li><li><strong>Kaggle</strong>: <a href="https://www.kaggle.com/learn/overview">https://www.kaggle.com/learn/overview</a></li><li><strong>Google’s Machine Learning Crash Course</strong>: <a href="https://developers.google.com/machine-learning/crash-course/">https://developers.google.com/machine-learning/crash-course/</a></li><li><strong>Hugging Face’s Course on Transformers </strong>(Personal Favorite!): <a href="https://huggingface.co/course/chapter1/1">https://huggingface.co/course/chapter1/1</a></li></ol><h3><strong>Books</strong></h3><p>There are also many books available that cover the basics of AI and machine learning. These can be a good way to get a broad overview of the field and learn about the key concepts and techniques.</p><p>Here are some books that can be helpful for learning artificial intelligence (AI) and machine learning:</p><ol><li>“Hands-On Machine Learning with Scikit-Learn, Keras, and TensorFlow” by Aurélien Géron: This book provides a comprehensive introduction to machine learning, including both supervised and unsupervised techniques. It covers a wide range of topics, including linear regression, classification, clustering, and deep learning.</li><li>“Introduction to Artificial Intelligence” by Russell and Norvig: This book is a classic introduction to AI and covers a wide range of topics, including search algorithms, game playing, and natural language processing.</li><li>“Deep Learning” by Ian Goodfellow, Yoshua Bengio, and Aaron Courville: This book provides a comprehensive overview of deep learning, including both the theoretical foundations and practical applications. It covers a wide range of topics, including convolutional neural networks, recurrent neural networks, and generative models.</li><li>“The Master Algorithm” by Pedro Domingos: This book provides an overview of the various approaches to machine learning and how they can be unified under a single “master algorithm.” It covers a wide range of topics, including decision trees, neural networks, and evolutionary algorithms.</li><li>“Python Machine Learning” by Sebastian Raschka: This book provides a practical introduction to machine learning using Python. It covers a wide range of topics, including supervised and unsupervised methods.</li></ol><h3><strong>Universities and other institutions</strong></h3><p>Many universities and other institutions offer degree programs in AI or related fields, such as computer science or data science. These programs can be a more structured way to learn AI, but may also be more expensive and time-consuming.</p><h3>Here are a few tips to help you with your preparation:</h3><ol><li>Start with the basics: Before diving into more advanced topics, it’s important to get a solid foundation in the basics of machine learning. This includes understanding key concepts such as supervised and unsupervised learning, training and test sets, and overfitting and underfitting. There are many online courses and books available that can help you get started with the basics of machine learning.</li><li>Practice, practice, practice: Machine learning is a hands-on field, so it’s important to get as much practice as you can. This can include working through tutorials and exercises online, participating in hackathons and competitions, or even building your own projects.</li><li>Use real-world data: While it’s important to start with toy datasets and simple examples, it’s also important to work with real-world data as soon as you can. This can help you better understand the challenges and complexities of machine learning in the real world.</li><li>Stay up to date: The field of machine learning is constantly evolving, so it’s important to stay up to date with the latest developments. This can include reading articles and papers, attending conferences and workshops, and following experts in the field on social media.</li><li>Find a community: It can be helpful to find a community of like-minded people who are also interested in machine learning. This can include joining online forums and groups, attending meetups and workshops, or even collaborating with others on projects.</li></ol><p>Overall, machine learning in 2023 will require a combination of foundational knowledge, hands-on practice, and staying up-to-date with the latest developments in the field. With the right approach and dedication, you can become proficient in machine learning and make a meaningful impact in your career and beyond.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f295540110b9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Few-Shot Learning: Part 1]]></title>
            <link>https://medium.com/@subhasis.jethy/few-shot-learning-part-1-f2796c324bfa?source=rss-c19049bab357------2</link>
            <guid isPermaLink="false">https://medium.com/p/f2796c324bfa</guid>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[few-shot-learning]]></category>
            <category><![CDATA[hugging-face]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[transformers]]></category>
            <dc:creator><![CDATA[Subhasis]]></dc:creator>
            <pubDate>Fri, 30 Dec 2022 18:07:20 GMT</pubDate>
            <atom:updated>2022-12-30T18:07:20.586Z</atom:updated>
            <content:encoded><![CDATA[<p><em>A beginners guide</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*efOk-a0Q2YLYg3S7" /><figcaption>Photo by <a href="https://unsplash.com/@askkell?utm_source=medium&amp;utm_medium=referral">Andy Kelly</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><blockquote>Few-shot learning is a subfield of machine learning that focuses on training models to learn new tasks or classify new classes with only a few examples. This is in contrast to traditional machine learning methods, which often require a large amount of labeled data.</blockquote><p>One of the main challenges in machine learning is the lack of sufficient data for the model to learn from. To overcome this, researchers often utilize transfer learning or meta-learning schemes where the model is first trained on a large dataset and then fine-tuned on the few examples available for the new task or class.</p><p>One of the key benefits of few-shot learning is that it can enable the development of flexible and adaptive models that can learn quickly and effectively in a variety of different environments and situations. This can be especially useful in situations where obtaining large amounts of labeled data is difficult or impractical, such as in medical diagnosis or in the study of rare or endangered species. Overall, few-shot learning is an important and active area of research in machine learning and has the potential to revolutionize the way we approach learning and adaptation in a wide range of applications.</p><p>One tool that has been widely used for few-shot learning with transformers is FAISS (Facebook Artificial Intelligence Similarity Search). FAISS is a package for high-dimensional vector similarity search and clustering. It has been demonstrated to be efficient for tasks like image classification and language translation, where it can be used to compare the representations of several examples in a few-shot learning context.</p><p>It is very easy to use FAISS with transformers using the Datasets library. We can use it for performing a semantic search on any dataset using Transformer based embeddings. Here is an <a href="https://huggingface.co/course/chapter5/6?fw=pt#semantic-search-with-faiss">example </a>by Huggingface.</p><p>There are some other use cases where few-shot learning and semantic search techniques can come in handy like quickly creating some labeled data for training a model and performing error analysis. We shall look at some of these examples in the next parts of this post.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f2796c324bfa" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>