Upload README.md with huggingface_hub
Browse files1234456787891011121314151617181 unmodified line2021221819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811923242512126271232829125303112732331293435131132133134135363738394013741421394344142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233454647483 unmodified lines525354243555657581 unmodified line60616225125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330463646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123---license: apache-2.0language:- frlicense: apache-2.0multilinguality:- monolingualsize_categories:- 1K<n<10Ktags:- finetuning- legal- french law- droit français- Code de commercesource_datasets:- originalpretty_name: Code de commercetask_categories:- text-generation- table-question-answering1 unmodified line- text-retrieval- question-answering- text-classificationpretty_name: Code de commercetags:- finetuning- legal- french law- droit français- Code de commerceconfigs:- config_name: default data_files: - split: train path: data/train-*dataset_info: features: - name: ref dtype: string - name: texte dtype: string - name: dateDebut dtype: int64 - name: dateFin dtype: int64 - name: num dtype: string - name: id dtype: string - name: cid dtype: string - name: type dtype: string - name: etat dtype: string - name: nota dtype: string - name: version_article dtype: string - name: ordre dtype: int64 - name: conditionDiffere dtype: 'null' - name: infosComplementaires dtype: 'null' - name: surtitre dtype: 'null' - name: nature dtype: string - name: texteHtml dtype: string - name: dateFinExtension dtype: int64 - name: versionPrecedente dtype: string - name: refInjection dtype: string - name: idTexte dtype: 'null' - name: idTechInjection dtype: string - name: origine dtype: string - name: dateDebutExtension dtype: int64 - name: idEliAlias dtype: 'null' - name: cidTexte dtype: 'null' - name: sectionParentId dtype: string - name: multipleVersions dtype: bool - name: comporteLiensSP dtype: bool - name: sectionParentTitre dtype: string - name: infosRestructurationBranche dtype: 'null' - name: idEli dtype: 'null' - name: sectionParentCid dtype: string - name: numeroBo dtype: 'null' - name: infosRestructurationBrancheHtml dtype: 'null' - name: historique dtype: 'null' - name: infosComplementairesHtml dtype: 'null' - name: renvoi dtype: 'null' - name: fullSectionsTitre dtype: string - name: notaHtml dtype: string - name: inap dtype: 'null' splits: - name: train num_bytes: 21046723 num_examples: 7248 download_size: 6328254 dataset_size: 21046723size_categories:- 1K<n<10K---# Code de commerce, non-instruct (2024-08-13)# Code de commerce, non-instruct (2024-08-14)
This project focuses on fine-tuning pre-trained language models to create efficient and accurate models for legal practice. The objective of this project is to provide researchers, professionals and law students with simplified, up-to-date access to all French legal texts, enriched with a wealth of data to facilitate their integration into Community and European projects.
Fine-tuning is the process of adapting a pre-trained model to perform specific tasks or cater to particular domains. It involves adjusting the model's parameters through a further round of training on task-specific or domain-specific data. While conventional fine-tuning strategies involve supervised learning with labeled data, instruction-based fine-tuning introduces a more structured and interpretable approach.Normally, the data is refreshed daily on all legal codes, and aims to simplify the production of training sets and labeling pipelines for the development of free, open-source language models based on open data accessible to all.
Instruction-based fine-tuning leverages the power of human-provided instructions to guide the model's behavior. These instructions can be in the form of text prompts, prompts with explicit task descriptions, or a combination of both. This approach allows for a more controlled and context-aware interaction with the LLM, making it adaptable to a multitude of specialized tasks.## Concurrent reading of the LegalKit
Instruction-based fine-tuning significantly enhances the performance of LLMs in the following ways:[<img src="https://raw.githubusercontent.com/louisbrulenaudet/ragoon/main/assets/badge.svg" alt="Built with RAGoon" width="200" height="32"/>](https://github.com/louisbrulenaudet/ragoon)
- Task-Specific Adaptation: LLMs, when fine-tuned with specific instructions, exhibit remarkable adaptability to diverse tasks. They can switch seamlessly between translation, summarization, and question-answering, guided by the provided instructions.- Reduced Ambiguity: Traditional LLMs might generate ambiguous or contextually inappropriate responses. Instruction-based fine-tuning allows for a clearer and more context-aware generation, reducing the likelihood of nonsensical outputs.- Efficient Knowledge Transfer: Instructions can encapsulate domain-specific knowledge, enabling LLMs to benefit from expert guidance. This knowledge transfer is particularly valuable in fields like tax practice, law, medicine, and more.- Interpretability: Instruction-based fine-tuning also makes LLM behavior more interpretable. Since the instructions are human-readable, it becomes easier to understand and control model outputs.- Adaptive Behavior: LLMs, post instruction-based fine-tuning, exhibit adaptive behavior that is responsive to both explicit task descriptions and implicit cues within the provided text.To use all the legal data published on LegalKit, you can use RAGoon:```bashpip3 install ragoon```
## Concurrent reading of the LegalKitThen, you can load multiple datasets using this code snippet:
To use all the legal data published on LegalKit, you can use this code snippet:```python# -*- coding: utf-8 -*-import concurrent.futuresimport os
import datasetsfrom tqdm.notebook import tqdm
def dataset_loader( name:str, streaming:bool=True) -> datasets.Dataset: """ Helper function to load a single dataset in parallel.
Parameters ---------- name : str Name of the dataset to be loaded.
streaming : bool, optional Determines if datasets are streamed. Default is True.
Returns ------- dataset : datasets.Dataset Loaded dataset object.
Raises ------ Exception If an error occurs during dataset loading. """ try: return datasets.load_dataset( name, split="train", streaming=streaming )
except Exception as exc: logging.error(f"Error loading dataset {name}: {exc}")
return None
def load_datasets( req:list, streaming:bool=True) -> list: """ Downloads datasets specified in a list and creates a list of loaded datasets.
Parameters ---------- req : list A list containing the names of datasets to be downloaded.
streaming : bool, optional Determines if datasets are streamed. Default is True.
Returns ------- datasets_list : list A list containing loaded datasets as per the requested names provided in 'req'.
Raises ------ Exception If an error occurs during dataset loading or processing.
Examples -------- >>> datasets = load_datasets(["dataset1", "dataset2"], streaming=False) """ datasets_list = []
with concurrent.futures.ThreadPoolExecutor() as executor: future_to_dataset = {executor.submit(dataset_loader, name): name for name in req}
for future in tqdm(concurrent.futures.as_completed(future_to_dataset), total=len(req)): name = future_to_dataset[future]
try: dataset = future.result()
if dataset: datasets_list.append(dataset)
except Exception as exc: logging.error(f"Error processing dataset {name}: {exc}")
return datasets_list
from ragoon import load_datasets
req = [ "louisbrulenaudet/code-artisanat",3 unmodified lines
datasets_list = load_datasets( req=req, streaming=True streaming=False)
dataset = datasets.concatenate_datasets(1 unmodified line)```
## Dataset generation
This JSON file is a list of dictionaries, each dictionary contains the following fields:
- `instruction`: `string`, presenting the instruction linked to the element.- `input`: `string`, signifying the input details for the element.- `output`: `string`, indicating the output information for the element.- `start`: `string`, the date of entry into force of the article. - `expiration`: `string`, the date of expiration of the article. - `num`: `string`, the id of the article.
We used the following list of instructions for generating the dataset:```pythoninstructions = [ "Compose l'intégralité de l'article sous forme écrite.", "Écris la totalité du contenu de l'article.", "Formule la totalité du texte présent dans l'article.", "Produis l'intégralité de l'article en écriture.", "Développe l'article dans son ensemble par écrit.", "Génère l'ensemble du texte contenu dans l'article.", "Formule le contenu intégral de l'article en entier.", "Rédige la totalité du texte de l'article en entier.", "Compose l'intégralité du contenu textuel de l'article.", "Rédige l'ensemble du texte qui constitue l'article.", "Formule l'article entier dans son contenu écrit.", "Composez l'intégralité de l'article sous forme écrite.", "Écrivez la totalité du contenu de l'article.", "Formulez la totalité du texte présent dans l'article.", "Développez l'article dans son ensemble par écrit.", "Générez l'ensemble du texte contenu dans l'article.", "Formulez le contenu intégral de l'article en entier.", "Rédigez la totalité du texte de l'article en entier.", "Composez l'intégralité du contenu textuel de l'article.", "Écrivez l'article dans son intégralité en termes de texte.", "Rédigez l'ensemble du texte qui constitue l'article.", "Formulez l'article entier dans son contenu écrit.", "Composer l'intégralité de l'article sous forme écrite.", "Écrire la totalité du contenu de l'article.", "Formuler la totalité du texte présent dans l'article.", "Produire l'intégralité de l'article en écriture.", "Développer l'article dans son ensemble par écrit.", "Générer l'ensemble du texte contenu dans l'article.", "Formuler le contenu intégral de l'article en entier.", "Rédiger la totalité du texte de l'article en entier.", "Composer l'intégralité du contenu textuel de l'article.", "Rédiger l'ensemble du texte qui constitue l'article.", "Formuler l'article entier dans son contenu écrit.", "Quelles sont les dispositions de l'article ?", "Quelles dispositions sont incluses dans l'article ?", "Quelles sont les dispositions énoncées dans l'article ?", "Quel est le texte intégral de l'article ?", "Quelle est la lettre de l'article ?"]```### Data Structure for Article Information
This section provides a detailed overview of the elements contained within the `item` dictionary. Each key represents a specific attribute of the legal article, with its associated value providing detailed information.
1. **Basic Information** - `ref` (string): **Reference** - A reference to the article, combining the title_main and the article `number` (e.g., "Code Général des Impôts, art. 123"). - `texte` (string): **Text Content** - The textual content of the article. - `dateDebut` (string): **Start Date** - The date when the article came into effect. - `dateFin` (string): **End Date** - The date when the article was terminated or superseded. - `num` (string): **Article Number** - The number assigned to the article. - `id` (string): **Article ID** - Unique identifier for the article. - `cid` (string): **Chronical ID** - Chronical identifier for the article. - `type` (string): **Type** - The type or classification of the document (e.g., "AUTONOME"). - `etat` (string): **Legal Status** - The current legal status of the article (e.g., "MODIFIE_MORT_NE").
2. **Content and Notes** - `nota` (string): **Notes** - Additional notes or remarks associated with the article. - `version_article` (string): **Article Version** - The version number of the article. - `ordre` (integer): **Order Number** - A numerical value used to sort articles within their parent section.
3. **Additional Metadata** - `conditionDiffere` (string): **Deferred Condition** - Specific conditions related to collective agreements. - `infosComplementaires` (string): **Additional Information** - Extra information pertinent to the article. - `surtitre` (string): **Subtitle** - A subtitle or additional title information related to collective agreements. - `nature` (string): **Nature** - The nature or category of the document (e.g., "Article"). - `texteHtml` (string): **HTML Content** - The article's content in HTML format.
4. **Versioning and Extensions** - `dateFinExtension` (string): **End Date of Extension** - The end date if the article has an extension. - `versionPrecedente` (string): **Previous Version** - Identifier for the previous version of the article. - `refInjection` (string): **Injection Reference** - Technical reference to identify the date of injection. - `idTexte` (string): **Text ID** - Identifier for the legal text to which the article belongs. - `idTechInjection` (string): **Technical Injection ID** - Technical identifier for the injected element.
5. **Origin and Relationships** - `origine` (string): **Origin** - The origin of the document (e.g., "LEGI"). - `dateDebutExtension` (string): **Start Date of Extension** - The start date if the article has an extension. - `idEliAlias` (string): **ELI Alias** - Alias for the European Legislation Identifier (ELI). - `cidTexte` (string): **Text Chronical ID** - Chronical identifier of the text.
6. **Hierarchical Relationships** - `sectionParentId` (string): **Parent Section ID** - Technical identifier of the parent section. - `multipleVersions` (boolean): **Multiple Versions** - Indicates if the article has multiple versions. - `comporteLiensSP` (boolean): **Contains Public Service Links** - Indicates if the article contains links to public services. - `sectionParentTitre` (string): **Parent Section Title** - Title of the parent section (e.g., "I : Revenu imposable"). - `infosRestructurationBranche` (string): **Branch Restructuring Information** - Information about branch restructuring. - `idEli` (string): **ELI ID** - European Legislation Identifier (ELI) for the article. - `sectionParentCid` (string): **Parent Section Chronical ID** - Chronical identifier of the parent section.
7. **Additional Content and History** - `numeroBo` (string): **Official Bulletin Number** - Number of the official bulletin where the article was published. - `infosRestructurationBrancheHtml` (string): **Branch Restructuring Information (HTML)** - Branch restructuring information in HTML format. - `historique` (string): **History** - Historical context or changes specific to collective agreements. - `infosComplementairesHtml` (string): **Additional Information (HTML)** - Additional information in HTML format. - `renvoi` (string): **Reference** - References to content within the article (e.g., "(1)"). - `fullSectionsTitre` (string): **Full Section Titles** - Concatenation of all titles in the parent chain. - `notaHtml` (string): **Notes (HTML)** - Additional notes or remarks in HTML format. - `inap` (string): **INAP** - A placeholder for INAP-specific information.
## Feedback
README.md+80-264