Content-Length: 379328 | pFad | http://github.com/etronhatton/huggingface/commit/d724ce3c8497857f068b5cb6635a24dacd3ff545

76 🧱 Integrate SetFit library (#387) · etronhatton/huggingface@d724ce3 · GitHub
Skip to content

Commit d724ce3

Browse files
authored
🧱 Integrate SetFit library (#387)
Hello! ## Pull Request overview * Integrate with the [SetFit](https://github.com/huggingface/setfit) library for Text Classification. ## Details [SetFit](https://github.com/huggingface/setfit) is a library for text classification with ~1200 models on the Hub at the time of writing. A v1.0.0 release is upcoming, and it's a good time to add this widget support, etc. It can be used like so: ```python from setfit import SetFitModel model = SetFitModel.from_pretrained("tomaarsen/span-marker-bert-base-fewnerd-fine-super") ``` ``` model.predict(["That was an awful movie"]) # => ["negative"] ``` I've previously integrated a library by only editing hub-docs and api-inference-community, but I see that there's been some refactors since. I hope that with these changes, I've edited the correct places. I also noticed this file: https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/src/library-to-tasks.ts#L36, but it seems that it's automatically updated. So, I didn't touch that one. Let me know if there's any more changes needed! Related PRs: * huggingface/api-inference-community#359 * huggingface/hub-docs#1150 - Tom Aarsen
1 parent a12dd81 commit d724ce3

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

‎packages/tasks/src/library-to-tasks.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export const LIBRARY_TASK_MAPPING_EXCLUDING_TRANSFORMERS: Partial<Record<ModelLi
3131
peft: ["text-generation"],
3232
"pyannote-audio": ["automatic-speech-recognition"],
3333
"sentence-transformers": ["feature-extraction", "sentence-similarity"],
34+
setfit: ["text-classification"],
3435
sklearn: ["tabular-classification", "tabular-regression", "text-classification"],
3536
spacy: ["token-classification", "text-classification", "sentence-similarity"],
3637
"span-marker": ["token-classification"],

‎packages/tasks/src/library-ui-elements.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,12 @@ const sentenceTransformers = (model: ModelData) => [
358358
model = SentenceTransformer("${model.id}")`,
359359
];
360360

361+
const setfit = (model: ModelData) => [
362+
`from setfit import SetFitModel
363+
364+
model = SetFitModel.from_pretrained("${model.id}")`,
365+
];
366+
361367
const spacy = (model: ModelData) => [
362368
`!pip install https://huggingface.co/${model.id}/resolve/main/${nameWithoutNamespace(model.id)}-any-py3-none-any.whl
363369
@@ -661,6 +667,13 @@ export const MODEL_LIBRARIES_UI_ELEMENTS: Partial<Record<ModelLibraryKey, Librar
661667
docsUrl: "https://huggingface.co/docs/hub/sentence-transformers",
662668
snippets: sentenceTransformers,
663669
},
670+
setfit: {
671+
btnLabel: "setfit",
672+
repoName: "setfit",
673+
repoUrl: "https://github.com/huggingface/setfit",
674+
docsUrl: "https://huggingface.co/docs/hub/setfit",
675+
snippets: setfit,
676+
},
664677
sklearn: {
665678
btnLabel: "Scikit-learn",
666679
repoName: "Scikit-learn",

‎packages/tasks/src/model-libraries.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export enum ModelLibrary {
2323
"pyannote-audio" = "pyannote.audio",
2424
"sample-factory" = "Sample Factory",
2525
"sentence-transformers" = "Sentence Transformers",
26+
"setfit" = "SetFit",
2627
"sklearn" = "Scikit-learn",
2728
"spacy" = "spaCy",
2829
"span-marker" = "SpanMarker",

‎packages/tasks/src/tasks/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export const TASKS_MODEL_LIBRARIES: Record<PipelineType, ModelLibraryKey[]> = {
6969
"tabular-classification": ["sklearn"],
7070
"tabular-regression": ["sklearn"],
7171
"tabular-to-text": ["transformers"],
72-
"text-classification": ["adapter-transformers", "spacy", "transformers", "transformers.js"],
72+
"text-classification": ["adapter-transformers", "setfit", "spacy", "transformers", "transformers.js"],
7373
"text-generation": ["transformers", "transformers.js"],
7474
"text-retrieval": [],
7575
"text-to-image": ["diffusers"],

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/etronhatton/huggingface/commit/d724ce3c8497857f068b5cb6635a24dacd3ff545

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy