openvino-genai-node
Version:
OpenVINO™ GenAI pipelines for using from Node.js environment
43 lines (42 loc) • 1.7 kB
TypeScript
import { TextRerankPipelineConfig, TextRerankResults, TextRerankPipeline as TextRerankPipelineWrapper } from "../addon.js";
/**
* Options for initializing TextRerankPipeline.
*/
export type TextRerankPipelineOptions = {
/** Device to run the model on (e.g., "CPU", "GPU"). */
device?: string;
/** Optional pipeline configuration. */
config?: TextRerankPipelineConfig;
/** Plugin properties. */
ovProperties?: object;
};
/**
* Text rerank pipeline for reranking documents based on query relevance.
*/
export declare class TextRerankPipeline {
modelPath: string;
device: string;
config: TextRerankPipelineConfig;
ovProperties: object;
pipeline: TextRerankPipelineWrapper | null;
/**
* Constructs a TextRerankPipeline from xml/bin files, tokenizer and configuration in the same directory.
* @param modelPath - Path to the directory containing model xml/bin files and tokenizer.
* @param options - Pipeline initialization options.
*/
constructor(modelPath: string, options: TextRerankPipelineOptions);
/**
* Initializes the pipeline.
* @throws {Error} If the pipeline is already initialized.
*/
init(): Promise<void>;
/**
* Reranks a vector of documents based on the query.
* @param query - The query string.
* @param documents - Array of document strings to rerank.
* @returns A promise that resolves to an array of tuples containing document indices and their relevance scores,
* sorted by score in descending order.
* @throws {Error} If the pipeline is not initialized.
*/
rerank(query: string, documents: string[]): Promise<TextRerankResults>;
}