Dokumente bewerten
Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Dokumente einstufen
Weitere Informationen
Eine ausführliche Dokumentation, die dieses Codebeispiel enthält, finden Sie hier:
Codebeispiel
Nächste Schritte
Wenn Sie nach Codebeispielen für andere Google Cloud -Produkte suchen und filtern möchten, können Sie den Google Cloud -Beispielbrowser verwenden.
Sofern nicht anders angegeben, sind die Inhalte dieser Seite unter der Creative Commons Attribution 4.0 License und Codebeispiele unter der Apache 2.0 License lizenziert. Weitere Informationen finden Sie in den Websiterichtlinien von Google Developers. Java ist eine eingetragene Marke von Oracle und/oder seinen Partnern.
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],[],[[["\u003cp\u003eThis page provides information and a code sample on how to rank documents using the Vertex AI Agent Builder.\u003c/p\u003e\n"],["\u003cp\u003eThe code sample demonstrates ranking documents using the \u003ccode\u003eRankServiceClient\u003c/code\u003e from the \u003ccode\u003egoogle.cloud.discoveryengine_v1\u003c/code\u003e library.\u003c/p\u003e\n"],["\u003cp\u003eAuthentication to Vertex AI Agent Builder requires setting up Application Default Credentials, detailed instructions are available in the provided link.\u003c/p\u003e\n"],["\u003cp\u003eThe provided Python code allows for ranking documents based on a query using a specified model such as \u003ccode\u003esemantic-ranker-512@latest\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe user can view further information on the topic of ranking and reranking documents with RAG by following a link to detailed documentation.\u003c/p\u003e\n"]]],[],null,["# Rank documents\n\nExplore further\n---------------\n\n\nFor detailed documentation that includes this code sample, see the following:\n\n- [Improve search and RAG quality with ranking API](/generative-ai-app-builder/docs/ranking)\n\nCode sample\n-----------\n\n### Python\n\n\nFor more information, see the\n[AI Applications Python API\nreference documentation](/python/docs/reference/discoveryengine/latest).\n\n\nTo authenticate to AI Applications, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n from google.cloud import discoveryengine_v1 as discoveryengine\n\n # TODO(developer): Uncomment these variables before running the sample.\n # project_id = \"YOUR_PROJECT_ID\"\n\n client = discoveryengine.RankServiceClient()\n\n # The full resource name of the ranking config.\n # Format: projects/{project_id}/locations/{location}/rankingConfigs/default_ranking_config\n ranking_config = client.ranking_config_path(\n project=project_id,\n location=\"global\",\n ranking_config=\"default_ranking_config\",\n )\n request = discoveryengine.RankRequest(\n ranking_config=ranking_config,\n model=\"semantic-ranker-default@latest\",\n top_n=10,\n query=\"What is Google Gemini?\",\n records=[\n discoveryengine.RankingRecord(\n id=\"1\",\n title=\"Gemini\",\n content=\"The Gemini zodiac symbol often depicts two figures standing side-by-side.\",\n ),\n discoveryengine.RankingRecord(\n id=\"2\",\n title=\"Gemini\",\n content=\"Gemini is a cutting edge large language model created by Google.\",\n ),\n discoveryengine.RankingRecord(\n id=\"3\",\n title=\"Gemini Constellation\",\n content=\"Gemini is a constellation that can be seen in the night sky.\",\n ),\n ],\n )\n\n response = client.rank(request=request)\n\n # Handle the response\n print(response)\n\nWhat's next\n-----------\n\n\nTo search and filter code samples for other Google Cloud products, see the\n[Google Cloud sample browser](/docs/samples?product=genappbuilder)."]]