From 1f4eb84e4b3109f32c77780bfc46b67783f0ca9f Mon Sep 17 00:00:00 2001 From: Perceval Wajsburt Date: Mon, 17 Jun 2024 14:55:24 +0200 Subject: [PATCH] Add support for EDS-NLP library (#696) Hi, This PR adds support for the edsnlp library (related to https://github.com/huggingface/api-inference-community/pull/424), an NLP library developed at the Greater Paris University Hospitals (AP-HP) with a specific focus on hybrid models (rule-based + ML) and multi-tasking, widely used in the structuring of clinical language at scale (NER, entity linking, document classification, event extraction, ...). I saw that the file https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/src/library-to-tasks.ts was automatically generated from a GitHub CI as mentioned on the docs, but didn't see how the action would edit it so I took the liberty of modifying it myself. Let me know if you need more information or if I need to change anything about this PR, thanks ! --------- Co-authored-by: Lucain Co-authored-by: Omar Sanseviero --- packages/tasks/src/model-libraries-snippets.ts | 18 ++++++++++++++++++ packages/tasks/src/model-libraries.ts | 11 +++++++++++ 2 files changed, 29 insertions(+) diff --git a/packages/tasks/src/model-libraries-snippets.ts b/packages/tasks/src/model-libraries-snippets.ts index 975c08f45..bc57c176e 100644 --- a/packages/tasks/src/model-libraries-snippets.ts +++ b/packages/tasks/src/model-libraries-snippets.ts @@ -97,6 +97,24 @@ export const diffusers = (model: ModelData): string[] => { } }; +export const edsnlp = (model: ModelData): string[] => { + const packageName = nameWithoutNamespace(model.id).replaceAll("-", "_"); + return [ + `# Load it from the Hub directly +import edsnlp +nlp = edsnlp.load("${model.id}") +`, + `# Or install it as a package +!pip install git+https://huggingface.co/${model.id} + +# and import it as a module +import ${packageName} + +nlp = ${packageName}.load() # or edsnlp.load("${packageName}") +`, + ]; +}; + export const espnetTTS = (model: ModelData): string[] => [ `from espnet2.bin.tts_inference import Text2Speech diff --git a/packages/tasks/src/model-libraries.ts b/packages/tasks/src/model-libraries.ts index 6f2a42ca6..51cd69c42 100644 --- a/packages/tasks/src/model-libraries.ts +++ b/packages/tasks/src/model-libraries.ts @@ -133,6 +133,17 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = { repoName: "doctr", repoUrl: "https://github.com/mindee/doctr", }, + edsnlp: { + prettyLabel: "EDS-NLP", + repoName: "edsnlp", + repoUrl: "https://github.com/aphp/edsnlp", + docsUrl: "https://aphp.github.io/edsnlp/latest/", + filter: false, + snippets: snippets.edsnlp, + countDownloads: { + wildcard: { path: "*/config.cfg" }, + }, + }, elm: { prettyLabel: "ELM", repoName: "elm",