Contextual AI icon

Contextual AI

Access Contextual AI tools for agents, parsing, querying, and reranking.

Overview

This node provides access to a "Reranker" operation that reorders a list of documents based on their relevance to a given query. It is useful in scenarios where you have multiple text documents and want to prioritize or filter them according to how well they match a specific question or topic. For example, it can be used in search engines, recommendation systems, or any application requiring ranking of textual data by relevance.

The "Rerank documents" operation takes a query string and a set of documents, optionally with metadata and instructions, and returns the documents sorted by their relevance scores. You can also limit the output to the top N results.

Properties

Name Meaning
Query The input question or statement to which the documents should be ranked for relevance.
Documents A comma-separated list of document texts to be reranked based on the query.
Instruction Optional additional instruction to guide the reranking process (e.g., focus on certain aspects).
Model The reranking model to use. Options: ctxl-rerank-v2-instruct-multilingual, ctxl-rerank-v2-instruct-multilingual-mini, ctxl-rerank-v1-instruct.
Top N Number of top-ranked documents to return. Set to 0 to return all documents after reranking.
Metadata Comma-separated metadata strings corresponding to each document, useful for additional context or identification. Must match the number of documents.
Authentication Method of authentication to use; currently supports API Key authentication.

Output

The node outputs an array of JSON objects representing the reranked documents. Each object typically contains the document text along with its associated metadata and a relevance score indicating how well it matches the query.

If binary data were involved, it would be summarized here, but this node focuses on textual JSON output only.

Dependencies

  • Requires an active API key credential for the Contextual AI service.
  • The node depends on external Contextual AI APIs for performing the reranking operation.
  • Proper network connectivity and valid API credentials are necessary for successful execution.

Troubleshooting

  • Common issues:
    • Mismatch between the number of documents and metadata entries can cause errors or unexpected behavior.
    • Providing empty or invalid query or documents fields will likely result in errors or no meaningful output.
    • Using an invalid or expired API key will cause authentication failures.
  • Error messages:
    • Authentication errors indicate problems with the API key; verify and update credentials.
    • Input validation errors may occur if required fields like Query or Documents are missing or improperly formatted.
    • API rate limits or service unavailability might cause request failures; retry after some time or check service status.

Links and References

Discussion