<?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: GeorgePearse</title>
    <description>The latest articles on DEV Community by GeorgePearse (@georgepearse).</description>
    <link>https://dev.to/georgepearse</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%2F446200%2F4f4510e0-3212-42d0-96d2-d9055c03690f.png</url>
      <title>DEV Community: GeorgePearse</title>
      <link>https://dev.to/georgepearse</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/georgepearse"/>
    <language>en</language>
    <item>
      <title>Vector Databases for Data-Centric AI (Part 2)</title>
      <dc:creator>GeorgePearse</dc:creator>
      <pubDate>Fri, 26 Aug 2022 13:36:00 +0000</pubDate>
      <link>https://dev.to/georgepearse/vector-databases-for-data-centric-ai-part-2-4a2j</link>
      <guid>https://dev.to/georgepearse/vector-databases-for-data-centric-ai-part-2-4a2j</guid>
      <description>&lt;p&gt;Building applications with QDrant, Hugging-Face and Streamlit.&lt;/p&gt;

&lt;p&gt;This article also lives here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://medium.com/@george.pearse"&gt;https://medium.com/@george.pearse&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;QDrant have created an excellent vector database and I suspect ML Engineers are only beginning to scratch its potential applications.&lt;/p&gt;

&lt;p&gt;Vector databases support hybrid similarity search and provide a CRUD API to run updates to your datasets. They are a significant improvement upon first-wave Approximate Nearest Neighbour tools like Faiss and Annoy which enable very high performance in-memory vector search but little in the way of support for update flows, nor metadata filters.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Hybrid search is vector or "semantic" search combined with attribute filtering.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The semantic search implemented by QDrant requires a list of positive and negative examples. Each positive datapoint is an example of what you want the responses to be similar to, each negative datapoint is an example of what you want the responses to be different to.&lt;/p&gt;

&lt;p&gt;This allows you to build up arbitrarily complex decision boundaries within your feature space.&lt;br&gt;
An example QDrant query:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{"positive": [0],    
"negative": [1],    
"top": 10,   
"with_payload": true}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;This enables the interactive definition of classes&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Start with a single positive datapoint.&lt;/li&gt;
&lt;li&gt;Look through the responses.&lt;/li&gt;
&lt;li&gt;Add those that you consider to be similar to the list of positives&lt;/li&gt;
&lt;li&gt;Add those you consider to be different to the list of negatives&lt;/li&gt;
&lt;li&gt;Run that new query, and repeat.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;After a batch of labelling you would also be in a position to improve your embeddings and continue the process with a 'better' separated dataset (I'll be experimenting more with this next).&lt;/p&gt;

&lt;p&gt;I've built a mini Streamlit application to support this flow and enable you to save each query once complete along with a CSV containing its results.&lt;/p&gt;
&lt;h2&gt;
  
  
  QDrant-NLP. A short demo
&lt;/h2&gt;

&lt;p&gt;&lt;iframe src="https://player.vimeo.com/video/743387784" width="710" height="399"&gt;
&lt;/iframe&gt;
&lt;/p&gt;
&lt;h2&gt;
  
  
  How to Run
&lt;/h2&gt;

&lt;p&gt;Just clone the repo &lt;a href="https://github.com/GeorgePearse/QDrant-NLP"&gt;QDrant-NLP&lt;/a&gt;&lt;br&gt;
and run:&lt;br&gt;
&lt;code&gt;docker-compose up&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
I would like to increase the number of datasets this can be tried on, either with GPU backed lambda functions or by saving many example datasets to S3. So far I've only made a 6K subset of ag_news available. ag_news · Datasets at Hugging Face&lt;br&gt;
This is the code snippet used to generate the embeddings via hugging-face:&lt;/p&gt;

&lt;p&gt;The embeddings were generated with this code snippet. &lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;h2&gt;
  
  
  Where to Use
&lt;/h2&gt;

&lt;p&gt;Shout out to both Kern.AI (an excellent open-source NLP labelling tool)&lt;br&gt;
&lt;a href="https://github.com/code-kern-ai/refinery"&gt;https://github.com/code-kern-ai/refinery&lt;/a&gt;&lt;br&gt;
and Voxel51 (an excellent open-source Computer Vision analysis tool)&lt;br&gt;
&lt;a href="https://github.com/voxel51/fiftyone"&gt;https://github.com/voxel51/fiftyone&lt;/a&gt;&lt;br&gt;
for being early adopters of the technology in their platforms, but I don't believe either have yet made use of all of the value it can provide.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>nlp</category>
      <category>machinelearning</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Vector Databases for Data-Centric AI</title>
      <dc:creator>GeorgePearse</dc:creator>
      <pubDate>Fri, 26 Aug 2022 13:12:00 +0000</pubDate>
      <link>https://dev.to/georgepearse/vector-databases-for-data-centric-ai-1epe</link>
      <guid>https://dev.to/georgepearse/vector-databases-for-data-centric-ai-1epe</guid>
      <description>&lt;p&gt;Other homes for this article: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://medium.com/@george.pearse"&gt;https://medium.com/@george.pearse&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Vector Databases are one of the newest tools in the MLOps / Data Engineering space. They're designed to be efficient at nearest neighbour queries over embeddings while providing a simple CRUD interface for maintainability.&lt;/p&gt;

&lt;p&gt;Embeddings are the outputs of a layer of a Deep Learning model with respect to an input (single datapoint). They are learned representations within which objects of the same class are projected near to each other.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PLoHBWOh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7tv12p1o4bnj3pq25lrn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PLoHBWOh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7tv12p1o4bnj3pq25lrn.png" alt="Image description" width="880" height="772"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The best vector databases enable you to combine metadata queries, e.g. the dataset split or class you want the results to belong to, along with a nearest neighbour request e.g. return the nearest neighbours to this input example that do not have the same label. This is hard to achieve with nearest neighbour libraries such as Faiss and Annoy because the index is built up-front and cannot be filtered. To achieve an equivalent result you would need to return an excess of nearest neighbours and then apply the filter after.&lt;/p&gt;

&lt;p&gt;I'd recommend the tensorflow embedding projector to develop an intuition if you're not familiar (MNIST with images is best).&lt;br&gt;
Embedding projector - visualization of high-dimensional data&lt;br&gt;
Visualize high dimensional &lt;a href="//data.projector.tensorflow.org"&gt;TensorFlow Projector&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Though it's important to note that the embeddings undergo dimensionality reduction via PCA, T-SNE or U-MAP in order to be projected into 3 dimensions.&lt;/p&gt;

&lt;p&gt;This article:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://medium.com/p/9c65a3bd0696"&gt;Not All Vector Databases Are Made Equal&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A detailed comparison of Milvus, Pinecone, Vespa, Weaviate, Vald, GSI and Qdrant&lt;/p&gt;

&lt;p&gt;Does an excellent job of comparing the best offerings currently available but what might you actually want to use a Vector Database for? The below are most relevant to image classification problems.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Active Learning&lt;/strong&gt;&lt;br&gt;
Got an error in a validation set and want to fix it? Get the nearest neighbours to your error in your unlabelled dataset labelled, and retrain. Repeat until the problem is reduced or resolved. If the nearest neighbour query does not return many similar examples, consider using a package that enables you to increase the number of augmentations, or weighting, of these instances.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Unit Test Construction&lt;/strong&gt;&lt;br&gt;
Identified a specific type of problem that's particularly costly (e.g. can't distinguish between spoons and forks) and want to monitor your progress against it? Retrieve the nearest neighbours to an instance of the error case within the labelled set, provide a description of the problem and track how performance changes over time.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Closest Counterfactual&lt;/strong&gt;&lt;br&gt;
Think the labels of your training dataset may be inconsistent? Look at the nearest instances with a different label. Consider getting your experts to review the examples and come to consensus, add further descriptions to your labelling rules or keep them as examples to use in the training of labellers. &lt;strong&gt;NB:&lt;/strong&gt; here you may be better off using something like KNN conformity or simply looking at the cases where there's the largest disagreement between your model and the label. Closest counterfactual is great but it is quite manual and doesn't scale well compared to more systematic approaches.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Finding Mislabelled Instances&lt;/strong&gt;&lt;br&gt;
Is your model making an error that seems like an easy case? Check the nearest neighbours within the training sets for mislabelled instances and check that you actually have some instances that are similar in the training set in the first place.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Ideally you want your Vector Database to be updated directly from your live ML service so that you always have access to the latest embeddings and don't have to maintain a separate batch pipeline just for the task. Let me know if you have any other uses of Vector Databases (particularly if valuable in image classification) and I'll add them to the list.&lt;br&gt;
Let me know your thoughts. Please click follow if the content interests you.&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>nlp</category>
      <category>programming</category>
      <category>python</category>
    </item>
  </channel>
</rss>
