Datasets:
Tasks:
Question Answering
Modalities:
Text
Formats:
parquet
Languages:
French
Size:
10K - 100K
License:
Update README.md
Browse files
README.md
CHANGED
|
@@ -44,4 +44,241 @@ size_categories:
|
|
| 44 |
|
| 45 |
## Dataset Description
|
| 46 |
- **Repository:** https://huggingface.co/datasets/louisbrulenaudet/lemone-docs-embeded
|
| 47 |
-
- **Point of Contact:** [Louis Brulé Naudet](mailto:[email protected])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
## Dataset Description
|
| 46 |
- **Repository:** https://huggingface.co/datasets/louisbrulenaudet/lemone-docs-embeded
|
| 47 |
+
- **Point of Contact:** [Louis Brulé Naudet](mailto:[email protected])
|
| 48 |
+
|
| 49 |
+
<img src="assets/thumbnail.webp">
|
| 50 |
+
|
| 51 |
+
# Lemone-embeded, pre-built embeddings dataset for French taxation.
|
| 52 |
+
|
| 53 |
+
<div class="not-prose bg-gradient-to-r from-gray-50-to-white text-gray-900 border" style="border-radius: 8px; padding: 0.5rem 1rem;">
|
| 54 |
+
<p>This database presents the embeddings generated by the Lemone-embed-pro model and aims at a large-scale distribution of the model even for the GPU-poor.</p>
|
| 55 |
+
</div>
|
| 56 |
+
|
| 57 |
+
This sentence transformers model, specifically designed for French taxation, has been fine-tuned on a dataset comprising 43 million tokens, integrating a blend of semi-synthetic and fully synthetic data generated by GPT-4 Turbo and Llama 3.1 70B, which have been further refined through evol-instruction tuning and manual curation.
|
| 58 |
+
|
| 59 |
+
The model is tailored to meet the specific demands of information retrieval across large-scale tax-related corpora, supporting the implementation of production-ready Retrieval-Augmented Generation (RAG) applications. Its primary purpose is to enhance the efficiency and accuracy of legal processes in the taxation domain, with an emphasis on delivering consistent performance in real-world settings, while also contributing to advancements in legal natural language processing research.
|
| 60 |
+
|
| 61 |
+
This is a sentence-transformers model finetuned from Alibaba-NLP/gte-multilingual-base. It maps sentences & paragraphs to a 768-dimensional dense vector space and can be used for semantic textual similarity, semantic search, paraphrase mining, text classification, clustering, and more.
|
| 62 |
+
|
| 63 |
+
## Usage with ChromaDB
|
| 64 |
+
|
| 65 |
+
We recommend integration via a vector-store to produce an optimal RAG pipeline. Here's a code extract for producing such a database with ChromaDB:
|
| 66 |
+
|
| 67 |
+
```python
|
| 68 |
+
import chromadb
|
| 69 |
+
import polars as pl
|
| 70 |
+
|
| 71 |
+
from chromadb.config import Settings
|
| 72 |
+
from chromadb.utils import embedding_functions
|
| 73 |
+
from torch.cuda import is_available
|
| 74 |
+
|
| 75 |
+
client = chromadb.PersistentClient(
|
| 76 |
+
path="./chroma.db",
|
| 77 |
+
settings=Settings(anonymized_telemetry=False)
|
| 78 |
+
)
|
| 79 |
+
|
| 80 |
+
sentence_transformer_ef = embedding_functions.SentenceTransformerEmbeddingFunction(
|
| 81 |
+
model_name="louisbrulenaudet/lemone-embed-pro",
|
| 82 |
+
device="cuda" if is_available() else "cpu",
|
| 83 |
+
trust_remote_code=True
|
| 84 |
+
)
|
| 85 |
+
|
| 86 |
+
collection = client.get_or_create_collection(
|
| 87 |
+
name="tax",
|
| 88 |
+
embedding_function=sentence_transformer_ef
|
| 89 |
+
)
|
| 90 |
+
|
| 91 |
+
dataframe = pl.scan_parquet('hf://datasets/louisbrulenaudet/lemone-docs-embeded/data/train-00000-of-00001.parquet').filter(
|
| 92 |
+
pl.col(
|
| 93 |
+
"text"
|
| 94 |
+
).is_not_null()
|
| 95 |
+
).collect()
|
| 96 |
+
|
| 97 |
+
collection.add(
|
| 98 |
+
embeddings=dataframe["lemone_pro_embeddings"].to_list(),
|
| 99 |
+
documents=dataframe["text"].to_list(),
|
| 100 |
+
metadatas=dataframe.drop(
|
| 101 |
+
[
|
| 102 |
+
"lemone_pro_embeddings",
|
| 103 |
+
"text"
|
| 104 |
+
]
|
| 105 |
+
).to_dicts(),
|
| 106 |
+
ids=[
|
| 107 |
+
str(i) for i in range(0, dataframe.shape[0])
|
| 108 |
+
]
|
| 109 |
+
)
|
| 110 |
+
```
|
| 111 |
+
|
| 112 |
+
Here is a code for reproduction of this dataset:
|
| 113 |
+
|
| 114 |
+
```python
|
| 115 |
+
import hashlib
|
| 116 |
+
|
| 117 |
+
from datetime import datetime
|
| 118 |
+
from typing import (
|
| 119 |
+
IO,
|
| 120 |
+
TYPE_CHECKING,
|
| 121 |
+
Any,
|
| 122 |
+
Dict,
|
| 123 |
+
List,
|
| 124 |
+
Type,
|
| 125 |
+
Tuple,
|
| 126 |
+
Union,
|
| 127 |
+
Mapping,
|
| 128 |
+
TypeVar,
|
| 129 |
+
Callable,
|
| 130 |
+
Optional,
|
| 131 |
+
Sequence,
|
| 132 |
+
)
|
| 133 |
+
|
| 134 |
+
import chromadb
|
| 135 |
+
import polars as pl
|
| 136 |
+
|
| 137 |
+
from chromadb.config import Settings
|
| 138 |
+
from chromadb.utils import embedding_functions
|
| 139 |
+
from torch.cuda import is_available
|
| 140 |
+
|
| 141 |
+
client = chromadb.Client(
|
| 142 |
+
settings=Settings(anonymized_telemetry=False)
|
| 143 |
+
)
|
| 144 |
+
|
| 145 |
+
sentence_transformer_ef = embedding_functions.SentenceTransformerEmbeddingFunction(
|
| 146 |
+
model_name="louisbrulenaudet/lemone-embed-pro",
|
| 147 |
+
device="cuda" if is_available() else "cpu",
|
| 148 |
+
trust_remote_code=True
|
| 149 |
+
)
|
| 150 |
+
|
| 151 |
+
collection = client.get_or_create_collection(
|
| 152 |
+
name="tax",
|
| 153 |
+
embedding_function=sentence_transformer_ef
|
| 154 |
+
)
|
| 155 |
+
|
| 156 |
+
bofip_dataframe = pl.scan_parquet(
|
| 157 |
+
"hf://datasets/louisbrulenaudet/bofip/data/train-00000-of-00001.parquet"
|
| 158 |
+
).with_columns(
|
| 159 |
+
[
|
| 160 |
+
(
|
| 161 |
+
pl.lit("Bulletin officiel des finances publiques - impôts").alias(
|
| 162 |
+
"title_main"
|
| 163 |
+
)
|
| 164 |
+
),
|
| 165 |
+
(
|
| 166 |
+
pl.col("debut_de_validite")
|
| 167 |
+
.str.strptime(pl.Date, format="%Y-%m-%d")
|
| 168 |
+
.dt.strftime("%Y-%m-%d 00:00:00")
|
| 169 |
+
).alias("date_publication"),
|
| 170 |
+
(
|
| 171 |
+
pl.col("contenu")
|
| 172 |
+
.map_elements(lambda x: hashlib.sha256(str(x).encode()).hexdigest(), return_dtype=pl.Utf8)
|
| 173 |
+
.alias("hash")
|
| 174 |
+
)
|
| 175 |
+
]
|
| 176 |
+
).rename(
|
| 177 |
+
{
|
| 178 |
+
"contenu": "text",
|
| 179 |
+
"permalien": "url_sourcepage",
|
| 180 |
+
"identifiant_juridique": "id_sub",
|
| 181 |
+
}
|
| 182 |
+
).select(
|
| 183 |
+
[
|
| 184 |
+
"text",
|
| 185 |
+
"title_main",
|
| 186 |
+
"id_sub",
|
| 187 |
+
"url_sourcepage",
|
| 188 |
+
"date_publication",
|
| 189 |
+
"hash"
|
| 190 |
+
]
|
| 191 |
+
)
|
| 192 |
+
|
| 193 |
+
books: List[str] = [
|
| 194 |
+
"hf://datasets/louisbrulenaudet/code-douanes/data/train-00000-of-00001.parquet",
|
| 195 |
+
"hf://datasets/louisbrulenaudet/code-impots/data/train-00000-of-00001.parquet",
|
| 196 |
+
"hf://datasets/louisbrulenaudet/code-impots-annexe-i/data/train-00000-of-00001.parquet",
|
| 197 |
+
"hf://datasets/louisbrulenaudet/code-impots-annexe-ii/data/train-00000-of-00001.parquet",
|
| 198 |
+
"hf://datasets/louisbrulenaudet/code-impots-annexe-iii/data/train-00000-of-00001.parquet",
|
| 199 |
+
"hf://datasets/louisbrulenaudet/code-impots-annexe-iv/data/train-00000-of-00001.parquet",
|
| 200 |
+
"hf://datasets/louisbrulenaudet/code-impositions-biens-services/data/train-00000-of-00001.parquet",
|
| 201 |
+
"hf://datasets/louisbrulenaudet/livre-procedures-fiscales/data/train-00000-of-00001.parquet"
|
| 202 |
+
]
|
| 203 |
+
|
| 204 |
+
legi_dataframe = pl.concat(
|
| 205 |
+
[
|
| 206 |
+
pl.scan_parquet(
|
| 207 |
+
book
|
| 208 |
+
) for book in books
|
| 209 |
+
]
|
| 210 |
+
).with_columns(
|
| 211 |
+
[
|
| 212 |
+
(
|
| 213 |
+
pl.lit("https://www.legifrance.gouv.fr/codes/article_lc/")
|
| 214 |
+
.add(pl.col("id"))
|
| 215 |
+
.alias("url_sourcepage")
|
| 216 |
+
),
|
| 217 |
+
(
|
| 218 |
+
pl.col("dateDebut")
|
| 219 |
+
.cast(pl.Int64)
|
| 220 |
+
.map_elements(
|
| 221 |
+
lambda x: datetime.fromtimestamp(x / 1000).strftime("%Y-%m-%d %H:%M:%S"),
|
| 222 |
+
return_dtype=pl.Utf8
|
| 223 |
+
)
|
| 224 |
+
.alias("date_publication")
|
| 225 |
+
),
|
| 226 |
+
(
|
| 227 |
+
pl.col("texte")
|
| 228 |
+
.map_elements(lambda x: hashlib.sha256(str(x).encode()).hexdigest(), return_dtype=pl.Utf8)
|
| 229 |
+
.alias("hash")
|
| 230 |
+
)
|
| 231 |
+
]
|
| 232 |
+
).rename(
|
| 233 |
+
{
|
| 234 |
+
"texte": "text",
|
| 235 |
+
"num": "id_sub",
|
| 236 |
+
}
|
| 237 |
+
).select(
|
| 238 |
+
[
|
| 239 |
+
"text",
|
| 240 |
+
"title_main",
|
| 241 |
+
"id_sub",
|
| 242 |
+
"url_sourcepage",
|
| 243 |
+
"date_publication",
|
| 244 |
+
"hash"
|
| 245 |
+
]
|
| 246 |
+
)
|
| 247 |
+
|
| 248 |
+
print("Starting embeddings production...")
|
| 249 |
+
|
| 250 |
+
dataframe = pl.concat(
|
| 251 |
+
[
|
| 252 |
+
bofip_dataframe,
|
| 253 |
+
legi_dataframe
|
| 254 |
+
]
|
| 255 |
+
).filter(
|
| 256 |
+
pl.col(
|
| 257 |
+
"text"
|
| 258 |
+
).is_not_null()
|
| 259 |
+
).with_columns(
|
| 260 |
+
pl.col("text").map_elements(
|
| 261 |
+
lambda x: sentence_transformer_ef(
|
| 262 |
+
[x]
|
| 263 |
+
)[0].tolist(),
|
| 264 |
+
return_dtype=pl.List(pl.Float64)
|
| 265 |
+
).alias("lemone_pro_embeddings")
|
| 266 |
+
).collect()
|
| 267 |
+
```
|
| 268 |
+
|
| 269 |
+
## Citation
|
| 270 |
+
|
| 271 |
+
If you use this code in your research, please use the following BibTeX entry.
|
| 272 |
+
|
| 273 |
+
```BibTeX
|
| 274 |
+
@misc{louisbrulenaudet2024,
|
| 275 |
+
author = {Louis Brulé Naudet},
|
| 276 |
+
title = {Lemone-Embed: A Series of Fine-Tuned Embedding Models for French Taxation},
|
| 277 |
+
year = {2024}
|
| 278 |
+
howpublished = {\url{https://huggingface.co/datasets/louisbrulenaudet/lemone-embed-pro}},
|
| 279 |
+
}
|
| 280 |
+
```
|
| 281 |
+
|
| 282 |
+
## Feedback
|
| 283 |
+
|
| 284 |
+
If you have any feedback, please reach out at [[email protected]](mailto:[email protected]).
|