그라운딩 확인
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
그라운딩 확인
더 살펴보기
이 코드 샘플이 포함된 자세한 문서는 다음을 참조하세요.
코드 샘플
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],[],[[["\u003cp\u003eThis code sample demonstrates how to check grounding using the Vertex AI Agent Builder Python API, verifying the accuracy of generated answers against provided facts.\u003c/p\u003e\n"],["\u003cp\u003eThe grounding check process involves setting up a \u003ccode\u003eGroundedGenerationServiceClient\u003c/code\u003e and specifying a grounding configuration, an answer candidate, and relevant facts.\u003c/p\u003e\n"],["\u003cp\u003eAuthentication to Vertex AI Agent Builder requires setting up Application Default Credentials, as detailed in the linked documentation for local development environments.\u003c/p\u003e\n"],["\u003cp\u003eThe provided example sends a \u003ccode\u003eCheckGroundingRequest\u003c/code\u003e with sample data and then prints the server's \u003ccode\u003eresponse\u003c/code\u003e when complete.\u003c/p\u003e\n"]]],[],null,["# Check grounding\n\nExplore further\n---------------\n\n\nFor detailed documentation that includes this code sample, see the following:\n\n- [Check grounding with RAG](/generative-ai-app-builder/docs/check-grounding)\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.GroundedGenerationServiceClient()\n\n # The full resource name of the grounding config.\n # Format: projects/{project_id}/locations/{location}/groundingConfigs/default_grounding_config\n grounding_config = client.grounding_config_path(\n project=project_id,\n location=\"global\",\n grounding_config=\"default_grounding_config\",\n )\n\n request = discoveryengine.CheckGroundingRequest(\n grounding_config=grounding_config,\n answer_candidate=\"Titanic was directed by James Cameron. It was released in 1997.\",\n facts=[\n discoveryengine.GroundingFact(\n fact_text=(\n \"Titanic is a 1997 American epic romantic disaster movie. It was directed, written,\"\n \" and co-produced by James Cameron. The movie is about the 1912 sinking of the\"\n \" RMS Titanic. It stars Kate Winslet and Leonardo DiCaprio. The movie was released\"\n \" on December 19, 1997. It received positive critical reviews. The movie won 11 Academy\"\n \" Awards, and was nominated for fourteen total Academy Awards.\"\n ),\n attributes={\"author\": \"Simple Wikipedia\"},\n ),\n discoveryengine.GroundingFact(\n fact_text=(\n 'James Cameron\\'s \"Titanic\" is an epic, action-packed romance'\n \"set against the ill-fated maiden voyage of the R.M.S. Titanic;\"\n \"the pride and joy of the White Star Line and, at the time,\"\n \"the largest moving object ever built. \"\n 'She was the most luxurious liner of her era -- the \"ship of dreams\" -- '\n \"which ultimately carried over 1,500 people to their death in the \"\n \"ice cold waters of the North Atlantic in the early hours of April 15, 1912.\"\n ),\n attributes={\"author\": \"Simple Wikipedia\"},\n ),\n ],\n grounding_spec=discoveryengine.CheckGroundingSpec(citation_threshold=0.6),\n )\n\n response = client.check_grounding(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)."]]