CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-dev-langchain4j--langchain4j-vertex-ai

LangChain4j integration for Google Vertex AI models including chat, language, embedding, image, and scoring capabilities

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

overview.mddocs/models/scoring/

Scoring Model Overview

Text ranking and scoring using Google Vertex AI Ranking API. Scores and ranks text segments by relevance to queries. Implements LangChain4j ScoringModel.

Class

public class VertexAiScoringModel implements ScoringModel {
    public Response<List<Double>> scoreAll(List<TextSegment> segments, String query);
    public static Builder builder();
}

Imports

import dev.langchain4j.model.vertexai.VertexAiScoringModel;
import dev.langchain4j.data.segment.TextSegment;
import dev.langchain4j.model.scoring.ScoringModel;
import dev.langchain4j.model.output.Response;

Minimal Example

VertexAiScoringModel model = VertexAiScoringModel.builder()
    .projectId("your-project-id")
    .projectNumber("123456789012")
    .location("us-central1")
    .model("semantic-ranker-512@latest")
    .build();

String query = "What is machine learning?";
List<TextSegment> documents = List.of(
    TextSegment.from("Machine learning is a branch of AI..."),
    TextSegment.from("Deep learning uses neural networks..."),
    TextSegment.from("Supervised learning requires labels...")
);

Response<List<Double>> response = model.scoreAll(documents, query);
List<Double> scores = response.content();  // Relevance scores

Supported Models

  • semantic-ranker-512@latest - Semantic ranking model (512 dimensions)

Configuration Parameters

Required

  • projectId (String) - Google Cloud Project ID
  • projectNumber (String) - Google Cloud Project number (12-digit)
  • location (String) - GCP region
  • model (String) - Ranking model name

Optional

  • titleMetadataKey (String) - Metadata key for document titles (default: "title")

Note: Configuration differs from other models - requires both projectId and projectNumber.

Finding Project Number

# Via gcloud CLI
gcloud projects describe PROJECT_ID --format="value(projectNumber)"

# Or check Google Cloud Console project dashboard

Use Cases

  • Search result re-ranking
  • Retrieval Augmented Generation (RAG)
  • Document recommendation
  • Relevance scoring
  • Query-document matching

See Also

  • Examples - Detailed usage examples
  • API Reference - Complete API documentation

Install with Tessl CLI

npx tessl i tessl/maven-dev-langchain4j--langchain4j-vertex-ai@1.11.0

docs

index.md

quick-reference.md

tile.json