Skip to content

Commit

Permalink
add cp/ edge to supported libs. (#864)
Browse files Browse the repository at this point in the history
Co-authored-by: Pedro Cuenca <[email protected]>
  • Loading branch information
Vaibhavs10 and pcuenca authored Aug 28, 2024
1 parent 78f0458 commit 9bed74e
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
39 changes: 39 additions & 0 deletions packages/tasks/src/model-libraries-snippets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 [
Expand Down
12 changes: 12 additions & 0 deletions packages/tasks/src/model-libraries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 9bed74e

Please sign in to comment.