Skip to content

Commit b97d0c8

Browse files
fschlattWauplin
andauthored
add lightning-ir library (#1320)
This PR adds a better integration of the Lightning IR library. @NielsRogge webis-de/lightning-ir#17 --------- Co-authored-by: Lucain <[email protected]> Co-authored-by: Lucain <[email protected]>
1 parent 6c9b6bf commit b97d0c8

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,39 @@ export const keras_hub = (model: ModelData): string[] => {
550550
return snippets;
551551
};
552552

553+
export const lightning_ir = (model: ModelData): string[] => {
554+
if (model.tags.includes("bi-encoder")) {
555+
return [
556+
`#install from https://github.com/webis-de/lightning-ir
557+
558+
from lightning_ir import BiEncoderModule
559+
model = BiEncoderModule("${model.id}")
560+
561+
model.score("query", ["doc1", "doc2", "doc3"])`,
562+
];
563+
} else if (model.tags.includes("cross-encoder")) {
564+
return [
565+
`#install from https://github.com/webis-de/lightning-ir
566+
567+
from lightning_ir import CrossEncoderModule
568+
model = CrossEncoderModule("${model.id}")
569+
570+
model.score("query", ["doc1", "doc2", "doc3"])`,
571+
];
572+
}
573+
return [
574+
`#install from https://github.com/webis-de/lightning-ir
575+
576+
from lightning_ir import BiEncoderModule, CrossEncoderModule
577+
578+
# depending on the model type, use either BiEncoderModule or CrossEncoderModule
579+
model = BiEncoderModule("${model.id}")
580+
# model = CrossEncoderModule("${model.id}")
581+
582+
model.score("query", ["doc1", "doc2", "doc3"])`,
583+
];
584+
};
585+
553586
export const llama_cpp_python = (model: ModelData): string[] => {
554587
const snippets = [
555588
`from llama_cpp import Llama

packages/tasks/src/model-libraries.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,12 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = {
444444
repoName: "k2",
445445
repoUrl: "https://github.com/k2-fsa/k2",
446446
},
447+
"lightning-ir": {
448+
prettyLabel: "Lightning IR",
449+
repoName: "Lightning IR",
450+
repoUrl: "https://github.com/webis-de/lightning-ir",
451+
snippets: snippets.lightning_ir,
452+
},
447453
liveportrait: {
448454
prettyLabel: "LivePortrait",
449455
repoName: "LivePortrait",

0 commit comments

Comments
 (0)