Skip to content

Commit 9bed74e

Browse files
Vaibhavs10pcuenca
andauthored
add cp/ edge to supported libs. (#864)
Co-authored-by: Pedro Cuenca <[email protected]>
1 parent 78f0458 commit 9bed74e

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

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

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,45 @@ export const diffusers = (model: ModelData): string[] => {
170170
}
171171
};
172172

173+
export const cartesia_pytorch = (model: ModelData): string[] => [
174+
`# pip install --no-binary :all: cartesia-pytorch
175+
from cartesia_pytorch import ReneLMHeadModel
176+
from transformers import AutoTokenizer
177+
178+
model = ReneLMHeadModel.from_pretrained("${model.id}")
179+
tokenizer = AutoTokenizer.from_pretrained("allenai/OLMo-1B-hf")
180+
181+
in_message = ["Rene Descartes was"]
182+
inputs = tokenizer(in_message, return_tensors="pt")
183+
184+
outputs = model.generate(inputs.input_ids, max_length=50, top_k=100, top_p=0.99)
185+
out_message = tokenizer.batch_decode(outputs, skip_special_tokens=True)[0]
186+
187+
print(out_message)
188+
)`,
189+
];
190+
191+
export const cartesia_mlx = (model: ModelData): string[] => [
192+
`import mlx.core as mx
193+
import cartesia_mlx as cmx
194+
195+
model = cmx.from_pretrained("${model.id}")
196+
model.set_dtype(mx.float32)
197+
198+
prompt = "Rene Descartes was"
199+
200+
for text in model.generate(
201+
prompt,
202+
max_tokens=500,
203+
eval_every_n=5,
204+
verbose=True,
205+
top_p=0.99,
206+
temperature=0.85,
207+
):
208+
print(text, end="", flush=True)
209+
`,
210+
];
211+
173212
export const edsnlp = (model: ModelData): string[] => {
174213
const packageName = nameWithoutNamespace(model.id).replaceAll("-", "_");
175214
return [

packages/tasks/src/model-libraries.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,18 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = {
179179
repoName: "doctr",
180180
repoUrl: "https://github.com/mindee/doctr",
181181
},
182+
cartesia_pytorch: {
183+
prettyLabel: "Cartesia Pytorch",
184+
repoName: "Cartesia Pytorch",
185+
repoUrl: "https://github.com/cartesia-ai/cartesia_pytorch",
186+
snippets: snippets.cartesia_pytorch,
187+
},
188+
cartesia_mlx: {
189+
prettyLabel: "Cartesia MLX",
190+
repoName: "Cartesia MLX",
191+
repoUrl: "https://github.com/cartesia-ai/cartesia_mlx",
192+
snippets: snippets.cartesia_mlx,
193+
},
182194
edsnlp: {
183195
prettyLabel: "EDS-NLP",
184196
repoName: "edsnlp",

0 commit comments

Comments
 (0)