Our terms of service are changing. Learn more.



Mismatch-first Farthest-search in Active Learning

Last Updated on December 23, 2021 by Editorial Team

Author(s): Edward Ma

Originally published on Towards AI the World’s Leading AI and Technology News and Media Company. If you are building an AI-related product or service, we invite you to consider becoming an AI sponsor. At Towards AI, we help scale AI and technology startups. Let us help you unleash your technology to the masses.

Machine Learning

Mis-match First Farthest Traversal Method

Photo by John-Mark Smith on Unsplash

Active Learning is one of the teaching strategies which engage learners (e.g. students) to participate in the learning process actively. Compared to the traditional learning process, learners do not just sit and listen but work together with teachers interactively. Progress of learning can be adjusted according to the feedback from learners. Therefore, the cycle of active learning is very important. If you are not familiar with active learning, you may visit this post.

Overall Architecture

Besides Semi-supervised Learning in Active Learning, we will walk through another approach that leverages unsupervised learning and supervised learning together in active learning. Shuyang et al. (2018) proposed to use k -medoids(similar to k-mean but the cluster centric must be one of the data points) to identify cluster centric and then estimate the most unlikely data point from the same cluster for annotation.

Overall labeling process (Shuyang et al., 2018)


K-medoids approach is applied to identify cluster centroid. Unlike the classific K-medoids implementation, it is based on farthest-first traversal. After identifying centroids, Subject matter experts (SMEs) will work on the annotation. Usually, we will start with a small cluster says 4. Shuyang et al. (2018) estimate the number of clusters by a median neighborhood test method. In short,

Mis-match First

After SMEs annotated some data points, it can be used to train classification models and predict the rest of the unannotated data points. The nearest-neighbor classifier and model-based (e.g. logistic regression) classifier are trained for prediction. If predicted labels are not aligned, they will be picked as candidates for another round of annotation.

Farthest Search

Having a set of mismatch data points, Shuyang et al. (2018) proposed to select those far away from the cluster centroids. The assumption is that the label propagating the largest distance is most likely does not belong to a particular category.

Python code by NLPatl

NLPatl provides mismatch first farthest learning like in active learning. It is not exactly the same implementation but follows a similar architecture and more flexibility.

You just need to fit your data to it and you can annotate the most valuable data points and self-learned data points. Let prepare to get your hands dirty. I will walk through how can you apply active learning in NLP with a few lines of code. You can visit this notebook for the full version of the code.

learning = MismatchFarthestLearning(
embeddings='bert-base-uncased', embeddings_type='transformers',
embeddings_model_config={'nn_fwk': 'pt', 'padding': True,
clustering='kmeans', clustering_model_config={'n_clusters': 3},


Like to learn?

I am Data Scientist in Bay Area. Focusing on the state-of-the-art in Data Science, Artificial Intelligence, especially in NLP and platform related. Feel free to connect with me on LinkedIn or Github.

Mismatch-first Farthest-search in Active Learning was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.

Join thousands of data leaders on the AI newsletter. It’s free, we don’t spam, and we never share your email address. Keep up to date with the latest work in AI. From research to projects and ideas. If you are building an AI startup, an AI-related product, or a service, we invite you to consider becoming a sponsor.

Published via Towards AI

Feedback ↓