Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add Adapter Transformers snippet #62

Merged
merged 6 commits into from
Jun 1, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions interfaces/Libraries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Add your new library here.
*/
export enum ModelLibrary {
'adapter-transformers' = 'Adapter Transformers',
'asteroid' = 'Asteroid',
'espnet' = 'ESPnet',
'flair' = 'Flair',
Expand Down Expand Up @@ -37,6 +38,10 @@ interface ModelData {
* this is transformers-specific
*/
autoArchitecture: string;
/**
* this dictionary has useful information about the model configuration
*/
config: Record<string, any>;
}


Expand Down Expand Up @@ -70,6 +75,13 @@ function nameWithoutNamespace(modelId: string): string {

//#region snippets

const adapter_transformers = (model: ModelData) =>
`from transformers import ${model.config.adapter_transformers.model_class}

model = ${model.config.adapter_transformers.model_class}.from_pretrained("${model.config.adapter_transformers.model_name}")
model.load_adapter("${model.modelId}", source="hf")`;


const asteroid = (model: ModelData) =>
`from asteroid.models import BaseModel

Expand Down Expand Up @@ -184,6 +196,12 @@ model = ${model.autoArchitecture}.from_pretrained("${model.modelId}"${model.priv


export const MODEL_LIBRARIES_UI_ELEMENTS: { [key in keyof typeof ModelLibrary]: LibraryUiElement } = {
"adapter-transformers": {
btnLabel: "Adapter Transformers",
repoName: "adapter-transformers",
repoUrl: "https://github.com/Adapter-Hub/adapter-transformers",
snippet: adapter_transformers,
},
asteroid: {
btnLabel: "Asteroid",
repoName: "Asteroid",
Expand Down