public class Inference
extends java.lang.Object
This class utilizes the InferenceApi to make API calls to the Pinecone inference service.
| Constructor and Description |
|---|
Inference(PineconeConfig config)
Constructs an instance of
Inference class using PineconeConfig object. |
| Modifier and Type | Method and Description |
|---|---|
EmbeddingsList |
embed(java.lang.String model,
java.util.Map<java.lang.String,java.lang.Object> parameters,
java.util.List<java.lang.String> inputs)
Sends input data and parameters to the embedding model and returns a list of embeddings.
|
RerankResult |
rerank(java.lang.String model,
java.lang.String query,
java.util.List<java.util.Map<java.lang.String,java.lang.String>> documents)
Reranks a list of documents based on the relevance to a query using the specified model.
|
RerankResult |
rerank(java.lang.String model,
java.lang.String query,
java.util.List<java.util.Map<java.lang.String,java.lang.String>> documents,
java.util.List<java.lang.String> rankFields,
int topN,
boolean returnDocuments,
java.util.Map<java.lang.String,java.lang.String> parameters)
Reranks a list of documents based on the relevance to a query using the specified model with additional options.
|
public Inference(PineconeConfig config)
Inference class using PineconeConfig object.config - The Pinecone configuration object for interacting with inference api.public EmbeddingsList embed(java.lang.String model, java.util.Map<java.lang.String,java.lang.Object> parameters, java.util.List<java.lang.String> inputs) throws ApiException
model - The embedding model to use.parameters - A map containing model-specific parameters.inputs - A list of input strings to generate embeddings for.ApiException - If the API call fails, an ApiException is thrown.public RerankResult rerank(java.lang.String model, java.lang.String query, java.util.List<java.util.Map<java.lang.String,java.lang.String>> documents) throws ApiException
model - The model to be used for reranking the documents.query - The query string to rank the documents against.documents - A list of maps representing the documents to be ranked.
Each map should contain document attributes, such as "text".ApiException - If the API call fails, an ApiException is thrown.public RerankResult rerank(java.lang.String model, java.lang.String query, java.util.List<java.util.Map<java.lang.String,java.lang.String>> documents, java.util.List<java.lang.String> rankFields, int topN, boolean returnDocuments, java.util.Map<java.lang.String,java.lang.String> parameters) throws ApiException
model - The model to be used for reranking the documents.query - The query string to rank the documents against.documents - A list of maps representing the documents to be ranked.
Each map should contain document attributes, such as "text".rankFields - A list of fields in the documents to be used for ranking, typically "text".topN - The number of top-ranked documents to return.returnDocuments - Whether to return the documents along with the ranking scores.parameters - A map containing additional model-specific parameters for reranking.ApiException - If the API call fails, an ApiException is thrown.