Instructions to use CreeJee/KURE-Reranker-nano-ONNX with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers.js
How to use CreeJee/KURE-Reranker-nano-ONNX with Transformers.js:
// npm i @huggingface/transformers import { AutoTokenizer, AutoModelForSequenceClassification } from '@huggingface/transformers'; const tokenizer = await AutoTokenizer.from_pretrained('CreeJee/KURE-Reranker-nano-ONNX'); const model = await AutoModelForSequenceClassification.from_pretrained('CreeJee/KURE-Reranker-nano-ONNX'); const query = 'Which planet is known as the Red Planet?'; const documents = [ 'Mars, known for its reddish appearance, is often referred to as the Red Planet.', 'Venus is often called the twin of Earth because of its similar size and proximity.', ]; const inputs = tokenizer(new Array(documents.length).fill(query), { text_pair: documents, padding: true, truncation: true }); const { logits } = await model(inputs); console.log(logits.sigmoid().tolist()); // one relevance score per document
KURE-Reranker-nano (ONNX)
ONNX weights of nlpai-lab/KURE-Reranker-nano, a Korean and English cross-encoder reranker (ModernBERT, one relevance logit per query and passage pair), for ONNX Runtime and Transformers.js.
The original repository publishes only model.safetensors. This repository adds ONNX exports of the same weights. The model, its training and its evaluation are the work of NLP & AI Lab, Korea University; see the original model card for them.
Files
| File | Precision | Size |
|---|---|---|
onnx/model.onnx |
fp32 | 598 MB |
onnx/model_fp16.onnx |
fp16 weights and activations, fp32 inputs and outputs | 299 MB |
config.json, tokenizer.json, tokenizer_config.json and special_tokens_map.json come from the export. The tokenizer is the original's. config.json differs only in the recorded Transformers version and dtype field.
How the files were made
From revision 8514b9e113f3b27c441ed9c2b50f81d80388b2fd of the original:
optimum-cli export onnx --model nlpai-lab/KURE-Reranker-nano --task text-classification out
The fp16 file converts the fp32 export with ONNX Runtime's converter:
import onnx
from onnxruntime.transformers.float16 import convert_float_to_float16
model = onnx.load("onnx/model.onnx")
onnx.save(convert_float_to_float16(model, keep_io_types=True), "onnx/model_fp16.onnx")
No weights were trained or changed beyond that precision conversion.
Usage with Transformers.js
import { AutoModelForSequenceClassification, AutoTokenizer } from "@huggingface/transformers";
const id = "CreeJee/KURE-Reranker-nano-ONNX";
const tokenizer = await AutoTokenizer.from_pretrained(id);
const model = await AutoModelForSequenceClassification.from_pretrained(id, {
dtype: "fp16",
device: "webgpu",
});
const query = "λνλ―Όκ΅μ μλλ μ΄λμΈκ°?";
const passages = ["μμΈμ λνλ―Όκ΅μ μλμ΄λ€.", "λΆμ°μ νꡬ λμμ΄λ€."];
const inputs = tokenizer(
passages.map(() => query),
{ text_pair: passages, padding: true, truncation: true, max_length: 256 },
);
const { logits } = await model(inputs);
// One logit per pair; higher is more relevant.
console.log(Array.from(logits.data));
License
Apache-2.0, as the original. The ONNX files are a modified form of the original weights: they were converted to ONNX, and model_fp16.onnx to half precision.
- Downloads last month
- -