Skip to content

Commit e80852f

Browse files
authored
add pylate code snippet (#1798)
1 parent a5e366a commit e80852f

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,6 +1364,28 @@ function get_widget_examples_from_st_model(model: ModelData): string[] | undefin
13641364

13651365
export const sentenceTransformers = (model: ModelData): string[] => {
13661366
const remote_code_snippet = model.tags.includes(TAG_CUSTOM_CODE) ? ", trust_remote_code=True" : "";
1367+
1368+
if (model.tags.includes("PyLate")) {
1369+
return [
1370+
`from pylate import models
1371+
1372+
queries = [
1373+
"Which planet is known as the Red Planet?",
1374+
"What is the largest planet in our solar system?",
1375+
]
1376+
1377+
documents = [
1378+
["Mars is the Red Planet.", "Venus is Earth's twin."],
1379+
["Jupiter is the largest planet.", "Saturn has rings."],
1380+
]
1381+
1382+
model = models.ColBERT(model_name_or_path="${model.id}")
1383+
1384+
queries_emb = model.encode(queries, is_query=True)
1385+
docs_emb = model.encode(documents, is_query=False)`,
1386+
];
1387+
}
1388+
13671389
if (model.tags.includes("cross-encoder") || model.pipeline_tag == "text-ranking") {
13681390
return [
13691391
`from sentence_transformers import CrossEncoder

0 commit comments

Comments
 (0)