Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

add cp/ edge to supported libs. #864

Merged
merged 6 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
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
Vaibhavs10 marked this conversation as resolved.
Show resolved Hide resolved
from cartesia_pytorch import ReneLMHeadModel
from transformers import AutoTokenizer

model = ReneLMHeadModel.from_pretrained("${model.id}")
tokenizer = AutoTokenizer.from_pretrained("allenai/OLMo-1B-hf")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest pushing the tokenizer to the new repo. Usually tokenizers also come in the model repo


in_message = ["Rene Descartes was"]
inputs = tokenizer(in_message, return_tensors="pt")

outputs = model.generate(inputs.input_ids.cuda(), max_length=50, top_k=100, top_p=0.99)
Vaibhavs10 marked this conversation as resolved.
Show resolved Hide resolved
out_message = tokenizer.batch_decode(outputs, skip_special_tokens=True)[0]

print(out_message)
Vaibhavs10 marked this conversation as resolved.
Show resolved Hide resolved
)`,
];

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this necessary? (just curious)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to their official snippet, yes! but I haven't been able to test it till now.


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: {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unsure if this is the correct library_name - I will wait for confirmation before the merge.

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
Loading