Skip to content

Commit

Permalink
[Paddle Integration] Add Widgets for PaddleNLP (#512)
Browse files Browse the repository at this point in the history
* widgets

* switch to a more general snippet for now
  • Loading branch information
sijunhe authored Nov 21, 2022
1 parent fd64d2a commit 8352147
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions js/src/lib/interfaces/Libraries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export enum ModelLibrary {
"flair" = "Flair",
"keras" = "Keras",
"nemo" = "NeMo",
"paddlenlp" = "PaddleNLP",
"pyannote-audio" = "pyannote.audio",
"sentence-transformers" = "Sentence Transformers",
"sklearn" = "Scikit-learn",
Expand Down Expand Up @@ -148,6 +149,15 @@ const keras = (model: ModelData) =>
model = from_pretrained_keras("${model.id}")
`;

const paddlenlp = (model: ModelData) => {
return [
`from paddlenlp.transformers import AutoModel, AutoTokenizer`,
"",
`tokenizer = AutoTokenizer.from_pretrained("${model.id}"${model.private ? ", use_auth_token=True" : ""}, from_hf_hub=True)`,
`model = AutoModel.from_pretrained("${model.id}"${model.private ? ", use_auth_token=True" : ""}, from_hf_hub=True)`,
].join("\n");
};

const pyannote_audio_pipeline = (model: ModelData) =>
`from pyannote.audio import Pipeline
Expand Down Expand Up @@ -433,6 +443,12 @@ export const MODEL_LIBRARIES_UI_ELEMENTS: { [key in keyof typeof ModelLibrary]?:
repoUrl: "https://github.com/NVIDIA/NeMo",
snippet: nemo,
},
"paddlenlp": {
btnLabel: "paddlenlp",
repoName: "PaddleNLP",
repoUrl: "https://github.com/PaddlePaddle/PaddleNLP",
snippet: paddlenlp,
},
"pyannote-audio": {
btnLabel: "pyannote.audio",
repoName: "pyannote-audio",
Expand Down

0 comments on commit 8352147

Please sign in to comment.