---
language:
- en
license: apache-2.0
tags:
- sentence-transformers
- sentence-similarity
- feature-extraction
- generated_from_trainer
- dataset_size:2130621
- loss:ContrastiveLoss
base_model: sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2
widget:
- source_sentence: Kim Chol-sam
sentences:
- Stankevich Sergey Nikolayevich
- Kim Chin-So’k
- Julen Lopetegui Agote
- source_sentence: دينا بنت عبد الحميد
sentences:
- Alexia van Amsberg
- Anthony Nicholas Colin Maitland Biddulph, 5th Baron Biddulph
- Dina bint Abdul-Hamíd
- source_sentence: Մուհամեդ բեն Նաիֆ Ալ Սաուդ
sentences:
- Karpov Anatoly Evgenyevich
- GNPower Mariveles Coal Plant [former]
- Muhammed bin Nayef bin Abdul Aziz Al Saud
- source_sentence: Edward Gnehm
sentences:
- Шауэрте, Хартмут
- Ханзада Филипп, Эдинбург герцогі
- AFX
- source_sentence: Schori i Lidingö
sentences:
- Yordan Canev
- ကားပေါ့ အန်နာတိုလီ
- BYSTROV, Mikhail Ivanovich
pipeline_tag: sentence-similarity
library_name: sentence-transformers
metrics:
- cosine_accuracy
- cosine_accuracy_threshold
- cosine_f1
- cosine_f1_threshold
- cosine_precision
- cosine_recall
- cosine_ap
- cosine_mcc
model-index:
- name: Graphlet-AI/eridu
results:
- task:
type: binary-classification
name: Binary Classification
dataset:
name: sentence transformers paraphrase multilingual MiniLM L12 v2
type: sentence-transformers-paraphrase-multilingual-MiniLM-L12-v2
metrics:
- type: cosine_accuracy
value: 0.9885216725241056
name: Cosine Accuracy
- type: cosine_accuracy_threshold
value: 0.7183246612548828
name: Cosine Accuracy Threshold
- type: cosine_f1
value: 0.9824706124974221
name: Cosine F1
- type: cosine_f1_threshold
value: 0.7085607051849365
name: Cosine F1 Threshold
- type: cosine_precision
value: 0.9782229269572558
name: Cosine Precision
- type: cosine_recall
value: 0.9867553479166427
name: Cosine Recall
- type: cosine_ap
value: 0.9971022799526896
name: Cosine Ap
- type: cosine_mcc
value: 0.9739458779668466
name: Cosine Mcc
---
# Graphlet-AI/eridu
Deep fuzzy matching people and company names for multilingual entity resolution using representation learning... that incorporates a deep understanding of people and company names and can work _much better_ than string distance methods!
This is a [sentence-transformers](https://www.SBERT.net) model finetuned from [sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2](https://huggingface.co/sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2) for person and company name matching using the [Open Sanctions matcher training data](https://www.opensanctions.org/docs/pairs/). It maps sentences & paragraphs to a 384-dimensional dense vector space and can be used as part of a deep, fuzzy entity resolution process.
NOTE: this model is a work in progress. It is not yet ready for production use!
## Model Details
### TLDR: 5 Lines of Code
```python
from sentence_transformers import SentenceTransformer
# Download from the 🤗 Hub
model = SentenceTransformer("Graphlet-AI/eridu")
names = [
"Russell Jurney",
"Russ Jurney",
"Русс Джерни",
]
embeddings = model.encode(names)
print(embeddings.shape)
# [3, 384]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [3, 3]
print(similarities.numpy())
# [[0.9999999 0.99406826 0.99406105]
# [0.9940683 1. 0.9969202 ]
# [0.99406105 0.9969202 1. ]]
```
### Project Eridu Overview
This project is a deep fuzzy matching system for person and company names for entity resolution using representation learning. It is designed to match people and company names across languages and character sets, using a pre-trained text embedding model from HuggingFace that we fine-tune using contrastive learning on 2 million labeled pairs of person and company names from the [Open Sanctions Matcher training data](https://www.opensanctions.org/docs/pairs/). The project includes a command-line interface (CLI) utility for training the model and comparing pairs of names using cosine similarity.
Matching people and company names is an intractable problem using traditional parsing based methods: there is too much variation across cultures and jurisdictions to solve the problem by humans programming. This results in complex, cost prohibitive enterprise solutions for name matching like [IBM InfoSphere Global Name Management](https://www.ibm.com/products/ibm-infosphere-global-name-management). Machine learning is used on problems like this one of cultural relevance, where the time to manually programming a solution appproaches infinity, to automatically write a program. Since 2008 there has been an explosion of deep learning methods that automate feature engineering via representation learning methods including such as text embeddings.
This project loads the pre-trained [paraphrase-multilingual-MiniLM-L12-v2](https://huggingface.co/sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2) paraphrase model from HuggingFace and fine-tunes it for the name matching task using contrastive learning on more than 2 million labeled pairs of matching and non-matching (just as important) person and company names from the [Open Sanctions Matcher training data](https://www.opensanctions.org/docs/pairs/) to create a deep fuzzy matching system for entity resolution.
This model is available on HuggingFace Hub as [Graphlet-AI/eridu](https://huggingface.co/Graphlet-AI/eridu) and can be used in any Python project using the [Sentence Transformers](https://sbert.net/) library in five lines of code. The model is designed to be used for entity resolution tasks, such as matching people and company names across different languages and character sets when matching records.
### Model Description
- **Model Type:** Sentence Transformer
- **Base model:** [sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2](https://huggingface.co/sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2)
- **Maximum Sequence Length:** 128 tokens
- **Output Dimensionality:** 384 dimensions
- **Similarity Function:** Cosine Similarity
- **Language:** en
- **License:** apache-2.0
### Model Sources
- **Documentation:** [Graphlet-AI/eridu Documentation](https://github.com/Graphlet-AI/eridu)
- **Repository:** [Graphlet-AI/eridu on GitHub](https://github.com/Graphlet-AI/eridu)
- **Hugging Face:** [Graphlet-AI/eridu on Hugging Face](https://huggingface.co/Graphlet-AI/eridu)
- **PyPi Package:** [Graphlet-AI/eridu on PyPi](https://pypi.org/project/eridu/)
### Full Model Architecture
```
SentenceTransformer(
(0): Transformer({'max_seq_length': 128, 'do_lower_case': False}) with Transformer model: BertModel
(1): Pooling({'word_embedding_dimension': 384, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': False, 'include_prompt': True})
)
```
## Usage
### Direct Usage (Sentence Transformers)
First install the Sentence Transformers library:
```bash
pip install -U sentence-transformers
```
Then you can load this model and run inference.
```python
from sentence_transformers import SentenceTransformer
# Download from the 🤗 Hub
model = SentenceTransformer("Graphlet-AI/eridu")
# Run inference
sentences = [
'Schori i Lidingö',
'Yordan Canev',
'ကားပေါ့ အန်နာတိုလီ',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 384]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [3, 3]
```
## Evaluation
### Metrics
#### Binary Classification
- Dataset: `sentence-transformers-paraphrase-multilingual-MiniLM-L12-v2`
- Evaluated with [BinaryClassificationEvaluator
](https://sbert.net/docs/package_reference/sentence_transformer/evaluation.html#sentence_transformers.evaluation.BinaryClassificationEvaluator)
| Metric | Value |
|:--------------------------|:-----------|
| cosine_accuracy | 0.9885 |
| cosine_accuracy_threshold | 0.7183 |
| cosine_f1 | 0.9825 |
| cosine_f1_threshold | 0.7086 |
| cosine_precision | 0.9782 |
| cosine_recall | 0.9868 |
| **cosine_ap** | **0.9971** |
| cosine_mcc | 0.9739 |
## Training Details
### Training Dataset
#### Unnamed Dataset
- Size: 2,130,621 training samples
- Columns: sentence1
, sentence2
, and label
- Approximate statistics based on the first 1000 samples:
| | sentence1 | sentence2 | label |
|:--------|:---------------------------------------------------------------------------------|:---------------------------------------------------------------------------------|:---------------------------------------------------------------|
| type | string | string | float |
| details |
캐스린 설리번
| Kathryn D. Sullivanová
| 1.0
|
| ଶିବରାଜ ଅଧାଲରାଓ ପାଟିଲ
| Aleksander Lubocki
| 0.0
|
| Пырванов, Георги
| アナトーリー・セルジュコフ
| 0.0
|
- Loss: [ContrastiveLoss
](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#contrastiveloss) with these parameters:
```json
{
"distance_metric": "SiameseDistanceMetric.COSINE_DISTANCE",
"margin": 0.5,
"size_average": true
}
```
### Evaluation Dataset
#### Unnamed Dataset
- Size: 2,663,276 evaluation samples
- Columns: sentence1
, sentence2
, and label
- Approximate statistics based on the first 1000 samples:
| | sentence1 | sentence2 | label |
|:--------|:----------------------------------------------------------------------------------|:----------------------------------------------------------------------------------|:---------------------------------------------------------------|
| type | string | string | float |
| details | Ева Херман
| I Xuan Karlos
| 0.0
|
| Кличков Андрій Євгенович
| Андрэй Яўгенавіч Клычкоў
| 1.0
|
| Кинах А.
| Senator John Hickenlooper
| 0.0
|
- Loss: [ContrastiveLoss
](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#contrastiveloss) with these parameters:
```json
{
"distance_metric": "SiameseDistanceMetric.COSINE_DISTANCE",
"margin": 0.5,
"size_average": true
}
```
### Training Hyperparameters
#### Non-Default Hyperparameters
- `eval_strategy`: epoch
- `per_device_train_batch_size`: 768
- `per_device_eval_batch_size`: 768
- `gradient_accumulation_steps`: 4
- `learning_rate`: 3e-05
- `weight_decay`: 0.01
- `num_train_epochs`: 4
- `warmup_ratio`: 0.1
- `fp16`: True
- `load_best_model_at_end`: True
- `optim`: adafactor
#### All Hyperparameters