Unlocking the Power of Hard Negative Mining with NV-Retriever in Korean Financial Text

Listen to this Post

2025-01-12

In the ever-evolving world of natural language processing (NLP), the quest for more accurate and nuanced text embeddings continues to drive innovation. One of the most promising techniques in this domain is contrastive learning, which aims to fine-tune sentence embeddings by pushing semantically similar sentences closer together and dissimilar ones further apart. However, the effectiveness of this approach hinges on the quality of the training data, particularly the selection of positive and negative pairs. This article delves into the concept of Hard Negative Mining, explores the NV-Retriever as a “positive-aware” approach, and examines its experimental application in the Korean financial domain.

The Rationale Behind Hard Negative Mining

Contrastive Learning & the Hard Negative Problem

Contrastive learning, popularized by models like SimCSE, relies on the principle of pulling positive pairs (semantically close sentences) together and pushing negative pairs (semantically distant sentences) apart in the embedding space. The challenge lies in defining what constitutes “similar” or “not similar.” Random negative pairs, such as selecting any sentence from a large corpus, often fail to provide sufficient training signal because the model easily recognizes them as dissimilar. This is where Hard Negatives come into play—these are sentence pairs that share superficial similarities but are ultimately unrelated in meaning, making them invaluable for refining the model’s performance.

Earlier Attempts & Limitations

Several methods have been attempted to mine Hard Negatives, each with its own set of limitations:

– Naive top-k: Picks the top-k most similar passages, excluding the known positive. This approach has a high chance of introducing false negatives.
– Top-K shifted by N: Skips the top N hits and then picks the top k. This method ignores similarity scores beyond an absolute rank cutoff, potentially losing valuable negatives or retaining false ones.
– Top-k abs: Excludes negative passages above a certain similarity threshold. This method is heavily reliant on a hyper-sensitive threshold.

Moreover, traditional methods like BM25 or naive approaches from DPR and ANCE often yield a large portion of false negatives. For instance, RocketQA found that nearly 70% of BM25-based “hard negatives” were actually positives upon manual inspection.

NV-Retriever: Positive-aware Hard Negatives

NV-Retriever proposes a positive-aware negative mining approach where each query’s positive similarity guides the maximum negative similarity threshold. The process involves:

1. Selecting a larger Teacher Model (e.g., e5-based or Mistral-based).
2. Encoding queries and passages with the teacher embeddings.
3. Defining a max negative similarity threshold based on the positive score (pos_score):

– Top-K MarginPos: `max_neg_score_threshold = pos_score – absolute_margin`

– Top-K PercPos: `max_neg_score_threshold = pos_score percentage_margin`

4. Selecting top-k Hard Negatives from the filtered negative candidates.

In the original NV-Retriever experiments, the best performance was achieved using the Mistral Teacher Model and the TopK-PercPos mining method with a margin of 0.95.

Korean Financial Domain Experiments

Teacher Model & Base Model

To test the applicability of NV-Retriever in the Korean financial domain, several Teacher Model candidates were considered:

– BM25 (Okapi): Despite its poor performance in the original NV-Retriever, its keyword-based approach was tested for its potential in a domain heavily reliant on financial keywords.
– bge-m3 (BAAI/bge-m3): A multilingual embedding model with 568M parameters.

– KURE-v1 (nlpai-lab/KURE-v1): A Korean-finetuned version of bge-m3.

Base Model candidates for fine-tuning included ME5-large and bge-m3.

Data

Two main data types were used:

1. QA Dataset: BCCard/BCCard-Finance-Kor-QnA, consisting of (Query – Answer) pairs as positives.
2. Non-QA Dataset: Naver finance news crawling (2024), consisting of ( – Passage) pairs as positives.

Hard Negative Mining

The mining method employed was TopK-PercPos with a percentage_margin of 0.95, allowing each query to retrieve up to 4 Hard Negatives. A partial code snippet using BM25 for demonstration was provided.

Results & Observations

– QA Sets: BM25 often yielded extreme similarity scores (0 or 1), making Hard Negative sampling somewhat meaningless. bge-m3 and KURE-v1 produced more stable similarity distributions, enabling more realistic Hard Negative mining.
– Non-QA News Dataset: Positive similarity scores were generally lower due to the longer and more topically diverse text. Distinguishing false negatives from genuinely negative pairs was more challenging.

Conclusion

– Contrastive Learning thrives on well-chosen negatives, and random negative sampling can limit the model’s potential.
– NV-Retriever addresses the shortcomings of naive negative mining by setting an upper bound on negative similarity relative to the positive.
– In the Korean financial domain, embedding-based teacher models (bge-m3, KURE-v1) outperformed BM25 in Hard Negative curation. However, the more domain- and topic-diverse the data, the more complicated it is to define “truly negative” pairs.

Despite these challenges, NV-Retriever’s “positive-aware threshold” approach proved to be a solid improvement over older “top-k” methods, underscoring the importance of refining negative sampling for enhanced embedding quality.

What Undercode Say:

The Importance of Hard Negative Mining in NLP

Hard Negative Mining is a critical component in the training of modern text embedding models. The ability to distinguish between superficially similar but semantically unrelated sentences is what allows models to achieve higher accuracy and better generalization. NV-Retriever’s positive-aware approach represents a significant advancement in this area, particularly in specialized domains like finance where the nuances of language can be particularly challenging.

Analytical Insights

1. Teacher Model Selection: The choice of Teacher Model plays a crucial role in the effectiveness of Hard Negative Mining. In the Korean financial domain, embedding-based models like bge-m3 and KURE-v1 outperformed traditional keyword-based methods like BM25. This suggests that in domains with complex and nuanced language, more sophisticated models are necessary to capture the subtleties of semantic similarity.

2. Data Diversity and Complexity: The experiments highlighted the challenges posed by diverse and complex datasets. In the Non-QA news dataset, the longer and more topically diverse text made it harder to define “truly negative” pairs. This underscores the importance of careful data curation and the potential benefits of explicit type/metadata labeling to reduce false negatives.

3. Threshold Sensitivity: The success of NV-Retriever’s TopK-PercPos method with a margin of 0.95 indicates the importance of setting an appropriate threshold for negative similarity. This threshold must be carefully calibrated to balance the need for challenging negatives without introducing too many false negatives.

4. Domain-Specific Challenges: The Korean financial domain presents unique challenges due to the specialized terminology and the need for high precision in semantic understanding. The experiments demonstrated that while NV-Retriever’s approach is effective, there is still room for improvement, particularly in handling domain-specific complexities.

Future Directions

– Enhanced Data Curation: Future research could focus on developing more sophisticated data curation techniques to better handle diverse and complex datasets. This could involve the use of metadata, domain-specific ontologies, or even semi-supervised learning approaches to improve the quality of negative sampling.
– Model Fine-Tuning: Further fine-tuning of embedding models on domain-specific data could enhance their ability to capture the nuances of specialized language. This could involve transfer learning techniques or the development of new models specifically designed for financial NLP.
– Threshold Optimization: Continued research into optimizing the threshold for negative similarity could yield further improvements in model performance. This could involve dynamic thresholding techniques that adapt to the characteristics of the dataset.

In conclusion, Hard Negative Mining is a vital technique for improving the performance of text embedding models, particularly in specialized domains like finance. NV-Retriever’s positive-aware approach represents a significant step forward, but there is still much to be explored and refined. As the field of NLP continues to evolve, the development of more sophisticated techniques for negative sampling will be key to unlocking the full potential of text embedding models.

References:

Reported By: Huggingface.co
https://www.facebook.com
Wikipedia: https://www.wikipedia.org
Undercode AI: https://ai.undercodetesting.com

Image Source:

OpenAI: https://craiyon.com
Undercode AI DI v2: https://ai.undercode.helpFeatured Image