From 9bed74eb75967b3b5de25df532b51802128b6e36 Mon Sep 17 00:00:00 2001 From: Vaibhav Srivastav Date: Wed, 28 Aug 2024 09:28:30 +0200 Subject: [PATCH] add cp/ edge to supported libs. (#864) Co-authored-by: Pedro Cuenca --- .../tasks/src/model-libraries-snippets.ts | 39 +++++++++++++++++++ packages/tasks/src/model-libraries.ts | 12 ++++++ 2 files changed, 51 insertions(+) diff --git a/packages/tasks/src/model-libraries-snippets.ts b/packages/tasks/src/model-libraries-snippets.ts index 3dbb03920..cf5b256f6 100644 --- a/packages/tasks/src/model-libraries-snippets.ts +++ b/packages/tasks/src/model-libraries-snippets.ts @@ -170,6 +170,45 @@ export const diffusers = (model: ModelData): string[] => { } }; +export const cartesia_pytorch = (model: ModelData): string[] => [ + `# pip install --no-binary :all: cartesia-pytorch +from cartesia_pytorch import ReneLMHeadModel +from transformers import AutoTokenizer + +model = ReneLMHeadModel.from_pretrained("${model.id}") +tokenizer = AutoTokenizer.from_pretrained("allenai/OLMo-1B-hf") + +in_message = ["Rene Descartes was"] +inputs = tokenizer(in_message, return_tensors="pt") + +outputs = model.generate(inputs.input_ids, max_length=50, top_k=100, top_p=0.99) +out_message = tokenizer.batch_decode(outputs, skip_special_tokens=True)[0] + +print(out_message) +)`, +]; + +export const cartesia_mlx = (model: ModelData): string[] => [ + `import mlx.core as mx +import cartesia_mlx as cmx + +model = cmx.from_pretrained("${model.id}") +model.set_dtype(mx.float32) + +prompt = "Rene Descartes was" + +for text in model.generate( + prompt, + max_tokens=500, + eval_every_n=5, + verbose=True, + top_p=0.99, + temperature=0.85, +): + print(text, end="", flush=True) +`, +]; + export const edsnlp = (model: ModelData): string[] => { const packageName = nameWithoutNamespace(model.id).replaceAll("-", "_"); return [ diff --git a/packages/tasks/src/model-libraries.ts b/packages/tasks/src/model-libraries.ts index 00f7e81f1..52442ffd2 100644 --- a/packages/tasks/src/model-libraries.ts +++ b/packages/tasks/src/model-libraries.ts @@ -179,6 +179,18 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = { repoName: "doctr", repoUrl: "https://github.com/mindee/doctr", }, + cartesia_pytorch: { + prettyLabel: "Cartesia Pytorch", + repoName: "Cartesia Pytorch", + repoUrl: "https://github.com/cartesia-ai/cartesia_pytorch", + snippets: snippets.cartesia_pytorch, + }, + cartesia_mlx: { + prettyLabel: "Cartesia MLX", + repoName: "Cartesia MLX", + repoUrl: "https://github.com/cartesia-ai/cartesia_mlx", + snippets: snippets.cartesia_mlx, + }, edsnlp: { prettyLabel: "EDS-NLP", repoName: "edsnlp",