Sentence Similarity
sentence-transformers
Safetensors
French
french
semantic-similarity
deduplication
paraphrase-detection
text-classification
Instructions to use France-ML/French-semantic-engine with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use France-ML/French-semantic-engine with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("France-ML/French-semantic-engine") sentences = [ "C'est une personne heureuse", "C'est un chien heureux", "C'est une personne très heureuse", "Aujourd'hui est une journée ensoleillée" ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [4, 4] - Notebooks
- Google Colab
- Kaggle
|
Download README.md from France-ML/French-semantic-engine: direct link, hf CLI and curl.
- Browser
- Download file 10.9 kB
-
https://huggingface.co/France-ML/French-semantic-engine/resolve/main/README.md
- Command line
-
hf download hf://France-ML/French-semantic-engine/README.md
-
curl -L -o README.md https://huggingface.co/France-ML/French-semantic-engine/resolve/main/README.md
10.9 kB
| language: | |
| - fr | |
| license: apache-2.0 | |
| library_name: sentence-transformers | |
| pipeline_tag: sentence-similarity | |
| tags: | |
| - french | |
| - semantic-similarity | |
| - deduplication | |
| - paraphrase-detection | |
| - sentence-transformers | |
| - text-classification | |
| <div align="center"> | |
| <img src="https://capsule-render.vercel.app/api?type=waving&color=0:0055A4,50:E8EEF9,100:EF4135&height=210§ion=header&text=French-semantic-engine&fontSize=42&fontColor=0B1F4D&animation=fadeIn&fontAlignY=32&desc=France-ML%20%F0%9F%87%AB%F0%9F%87%B7%20%E2%80%A2%20Two-Stage%20Semantic%20Quality%20Engine&descAlignY=55&descSize=17&descColor=0B1F4D" width="100%"/> | |
| <a href="https://huggingface.co/France-ML/French-semantic-engine"> | |
| <img src="https://readme-typing-svg.demolab.com?font=Fira+Code&weight=700&size=22&duration=2800&pause=900&color=3D8BFD¢er=true&vCenter=true&multiline=true&width=900&height=90&lines=French-semantic-engine.;Retrieval+%2B+verification+%2B+rule+guards.;Dedup.+Paraphrase.+Conflict+detection." alt="Typing SVG" /> | |
| </a> | |
| <br/> | |
|  | |
|  | |
|  | |
|  | |
| <br/> | |
| <img src="https://huggingface.co/front/assets/huggingface_logo-noborder.svg" height="60" alt="Hugging Face"/> | |
| </div> | |
| <img src="https://user-images.githubusercontent.com/74038190/212284100-561aa473-3905-4a80-b561-0d28506553ee.gif" width="100%"> | |
| --- | |
| <div align="center"> | |
| ### β‘ At a Glance | |
| | Stage | Model | Role | | |
| |:--:|:--:|:--| | |
| | **1** | `french-semantic-stage1` | Fast semantic retrieval, candidate generation | | |
| | **2** | `french-semantic-stage2` | Meaning verification: SAME / DIFFERENT | | |
| | **+** | rule guards | Deterministic protection for critical changes | | |
| </div> | |
| > π΅ **Quick summary:** Stage 1 finds what is worth comparing. Stage 2 determines whether meaning is preserved. Rule guards add deterministic protection. Together they form a practical two-stage French semantic quality pipeline for dataset cleaning and semantic deduplication. | |
| --- | |
| ## ποΈ Architecture | |
| ```text | |
| French dataset | |
| β | |
| Stage 1 β semantic embeddings | |
| β | |
| FAISS / vector search | |
| β | |
| high-similarity candidate pairs | |
| β | |
| Stage 2 β semantic verifier | |
| β | |
| SAME / DIFFERENT | |
| β | |
| rule guards | |
| β | |
| KEEP / DEDUP / CONFLICT / REVIEW | |
| ``` | |
| --- | |
| ## π Stage 1 β Semantic Retrieval | |
| `France-ML/french-semantic-stage1` | |
| A French SentenceTransformer-based embedding model used for **fast semantic retrieval**. | |
| It converts French sentences into vectors so similar sentences can be found efficiently using FAISS or another vector-search system. Stage 1 is intentionally used as a **candidate generator**, not the final decision-maker. | |
| **Main uses** | |
| - Semantic search | |
| - Duplicate / paraphrase candidate retrieval | |
| - Dataset clustering | |
| - Similarity filtering | |
| - Large-scale candidate generation | |
| --- | |
| ## π§ Stage 2 β Meaning Verification | |
| `France-ML/french-semantic-stage2` | |
| A French pair-classification model that performs deeper semantic verification and predicts: | |
| - `SAME`: meaning is sufficiently preserved | |
| - `DIFFERENT`: meaning has changed | |
| Useful for detecting meaning changes involving **negation, numbers, dates, quantities, units, tense, roles, directions, locations, cause/effect, and conditions**. | |
| **Examples where lexical similarity hides a meaning change:** | |
| ```text | |
| Il a vendu 5 voitures. | |
| Il a vendu 50 voitures. | |
| ``` | |
| ```text | |
| Il n'est pas venu. | |
| Il est venu. | |
| ``` | |
| ```text | |
| Marie a donnΓ© le livre Γ Paul. | |
| Paul a donnΓ© le livre Γ Marie. | |
| ``` | |
| These sentences can be lexically very similar while having different meanings. | |
| --- | |
| ## π‘οΈ Rule Guards | |
| Model decisions can be combined with deterministic checks for important semantic features: | |
| - Numbers | |
| - Dates | |
| - Units | |
| - Negation words | |
| - Quantities | |
| - Named entities | |
| - Directional terms | |
| - Other task-specific constraints | |
| The final decision can be more conservative than relying on neural similarity alone. | |
| **Possible outputs** | |
| | Label | Meaning | | |
| |:--|:--| | |
| | `KEEP` | No problematic match detected | | |
| | `DEDUP` | Sufficiently equivalent duplicate / paraphrase | | |
| | `CONFLICT` | Similar text but meaning-changing information detected | | |
| | `REVIEW` | Uncertain or requires human inspection | | |
| --- | |
| ## π― Applications | |
| - French dataset deduplication | |
| - Training-data cleaning | |
| - Paraphrase detection | |
| - Semantic search preprocessing | |
| - Near-duplicate detection | |
| - Dataset quality control | |
| - Conflict detection | |
| - Retrieval candidate generation | |
| - Filtering noisy training data | |
| - Preparing French NLP datasets for model training | |
| --- | |
| <div align="center"> | |
| ## ποΈ Built for Datasets | |
| </div> | |
| The engine is made for **French dataset work** β cleaning, deduplicating, and quality-checking text corpora before they are used to train or evaluate models. | |
| Most dataset problems are not exact duplicates. They are near-duplicates, paraphrases, and near-identical sentences that quietly disagree on one important detail. String matching misses these. Pure embedding similarity also misses them, because the sentences *look* the same to a vector model even when the meaning changed. | |
| This engine is built to catch that gap. | |
| <table> | |
| <thead> | |
| <tr> | |
| <th align="center" style="background:rgba(0,85,164,0.18);color:#9CC6FF;border-bottom:2px solid #0055A4;">Dataset Problem</th> | |
| <th align="center" style="background:rgba(0,85,164,0.18);color:#9CC6FF;border-bottom:2px solid #0055A4;">How the Engine Handles It</th> | |
| </tr> | |
| </thead> | |
| <tbody> | |
| <tr> | |
| <td style="background:rgba(61,139,253,0.06);color:#9CC6FF;">Exact and near-duplicate rows</td> | |
| <td><span style="color:#9CC6FF;">Stage 1 retrieval surfaces candidates, Stage 2 confirms and labels them <code>DEDUP</code></span></td> | |
| </tr> | |
| <tr> | |
| <td style="background:rgba(61,139,253,0.06);color:#9CC6FF;">Paraphrases that mean the same thing</td> | |
| <td><span style="color:#9CC6FF;">Stage 2 predicts <code>SAME</code> even when wording differs</span></td> | |
| </tr> | |
| <tr> | |
| <td style="background:rgba(239,65,53,0.06);color:#FFB0A9;">Similar sentences with a changed detail (numbers, negation, roles)</td> | |
| <td><span style="color:#FFB0A9;">Stage 2 flags them and rule guards raise <code>CONFLICT</code></span></td> | |
| </tr> | |
| <tr> | |
| <td style="background:rgba(52,211,153,0.06);color:#34d399;">Ambiguous or borderline cases</td> | |
| <td><span style="color:#34d399;">Marked <code>REVIEW</code> instead of forcing a wrong decision</span></td> | |
| </tr> | |
| </tbody> | |
| </table> | |
| ### Why it is built for scale | |
| Running a deep verifier across every possible sentence pair in a large corpus would be far too expensive. The two-stage design avoids that: | |
| ```text | |
| Millions of French sentences | |
| β | |
| Stage 1 β vector search (fast, cheap) | |
| β | |
| small set of likely matches | |
| β | |
| Stage 2 β meaning verification (slow, careful) | |
| β | |
| rule guards | |
| β | |
| KEEP / DEDUP / CONFLICT / REVIEW | |
| ``` | |
| ## β What It Does Well | |
| The system is built around **semantic similarity followed by meaning verification**, not simple string matching. This allows it to identify pairs that: | |
| - Use different wording but preserve meaning | |
| - Are highly similar but contain important semantic changes | |
| - Should be considered potential duplicates | |
| - Should be separated because a critical detail changed | |
| Stage 1 is optimized for efficient retrieval. Stage 2 provides a focused semantic decision. | |
| --- | |
| ## β οΈ Limitations | |
| This is **not a perfect semantic truth detector**. Neural models can still make mistakes, especially with: | |
| - Ambiguous sentences | |
| - Very long or complicated text | |
| - Rare vocabulary | |
| - Unusual French constructions | |
| - World knowledge | |
| - Sarcasm or implicit meaning | |
| - Complex multi-step reasoning | |
| - Subtle factual differences | |
| - Domain-specific terminology | |
| Stage 2 is a **semantic verifier**, not an absolute authority. For high-value datasets, use deterministic rule guards and/or human review for uncertain cases. | |
| **Architecture limitation.** Stage 1 and Stage 2 are designed to work together. Stage 2 should **not** be treated as a general unrelated-text classifier. Its purpose is to verify candidate pairs already flagged as semantically related by Stage 1. | |
| --- | |
| ## π Evaluation | |
| - **Stage 1** was evaluated using validation data, paraphrases, and hard-negative examples. The selected checkpoint prioritized generalization and separation of unrelated text, not just maximal validation similarity. | |
| - **Stage 2** achieved strong results on the project's validation and targeted evaluation sets, including difficult negative examples. | |
| These are **project-specific evaluation** results, not a guarantee of performance on every French dataset or domain. | |
| --- | |
| ## π Contents | |
| ```text | |
| French-semantic-engine/ | |
| βββ stage1/ | |
| β βββ 1_Pooling/ | |
| β βββ config.json | |
| β βββ config_sentence_transformers.json | |
| β βββ model.safetensors | |
| β βββ modules.json | |
| β βββ sentence_bert_config.json | |
| β βββ tokenizer.json | |
| β βββ tokenizer_config.json | |
| β | |
| βββ stage2/ | |
| βββ config.json | |
| βββ model.safetensors | |
| βββ tokenizer.json | |
| βββ tokenizer_config.json | |
| ``` | |
| --- | |
| <div align="center"> | |
| ### π§Ύ Run Summary | |
| | | | | |
| |:--|:--| | |
| | **Model** | France-ML/French-semantic-engine | | |
| | **Pipeline** | Stage 1 β vector search β Stage 2 β rule guards | | |
| | **Language** | French | | |
| | **Task** | sentence-similarity Β· dedup Β· paraphrase Β· conflict detection | | |
| | **Outputs** | KEEP Β· DEDUP Β· CONFLICT Β· REVIEW | | |
| | **Library** | transformers Β· sentence-transformers | | |
| | **License** | Apache 2.0 | | |
| </div> | |
| <img src="https://user-images.githubusercontent.com/74038190/212284100-561aa473-3905-4a80-b561-0d28506553ee.gif" width="100%"> | |
| <div align="center"> | |
| <img src="https://capsule-render.vercel.app/api?type=waving&color=0:0055A4,50:E8EEF9,100:EF4135&height=140§ion=footer&text=France-ML&fontSize=24&fontColor=0B1F4D&animation=twinkling&fontAlignY=60" width="100%"/> | |
| <sub>β If this engine helped you, consider leaving a like on the Hub.</sub> | |
| <br/><br/> | |
| <a href="https://huggingface.co/France-ML"> | |
| <img src="https://huggingface.co/front/assets/huggingface_logo-noborder.svg" height="28" alt="Hugging Face"/> | |
| </a> | |
| | |
| <a href="https://huggingface.co/France-ML/French-semantic-engine"> | |
| <img src="https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-French--semantic--engine-EF4135?style=for-the-badge" alt="Hugging Face model"/> | |
| </a> | |
| <br/><br/> | |
| <img src="https://flagcdn.com/w40/fr.png" height="18" alt="France"/> <b>Made For French ML</b> Β· 2026 | |
| </div> |