Uploaded using `kernel-builder`.
Browse files
README.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
tags:
|
| 4 |
+
- kernels
|
| 5 |
+
- triton
|
| 6 |
+
- maxsim
|
| 7 |
+
- colbert
|
| 8 |
+
---
|
| 9 |
+
|
| 10 |
+
# Late Interaction Kernels
|
| 11 |
+
|
| 12 |
+
CUDA MaxSim kernels from v0.4.5 of [H Company's Late Interaction Kernels](https://github.com/hcompai/late-interaction-kernels), packaged for Hugging Face Kernels. The kernel algorithms are H Company's work, distributed under the Apache 2.0 license included here.
|
| 13 |
+
|
| 14 |
+
## Usage
|
| 15 |
+
|
| 16 |
+
```python
|
| 17 |
+
from kernels import get_kernel
|
| 18 |
+
|
| 19 |
+
kernel = get_kernel("sentence-transformers/late-interaction-kernels", version=0)
|
| 20 |
+
|
| 21 |
+
scores = kernel.layers.MaxSim()(queries, documents, query_mask, document_mask)
|
| 22 |
+
paired_scores = kernel.layers.MaxSimPairwise()(queries, paired_documents, query_mask, paired_document_mask)
|
| 23 |
+
```
|
| 24 |
+
|
| 25 |
+
`MaxSim` computes scores between all query-document combinations. `MaxSimPairwise` scores matching query-document pairs. Both support token masks and autograd.
|