google_ml_integration 확장 프로그램에는 public 및 google_ml의 두 가지 네임스페이스에 삽입 함수가 포함되어 있습니다. 이 페이지에서는 이러한 네임스페이스의 함수를 사용하여 텍스트 임베딩을 생성하는 방법을 설명합니다.
public 스키마의 embedding() 함수는 엔드포인트를 등록하지 않고도 모든 Vertex AI 임베딩 모델과 함께 사용할 수 있습니다. 작업 유형과 같은 맞춤 정보를 전달하려면 엔드포인트를 등록한 다음 google_ml 스키마에서 google_ml.embedding() 함수를 사용하세요. 엔드포인트 등록에 관한 자세한 내용은 모델 등록을 참고하세요.
삽입 작동 방식
다음과 같은 특성을 가진 AlloyDB에서 실행되는 데이터베이스를 가정해 보세요.
데이터베이스에는 items 테이블이 포함되어 있습니다. 이 테이블의 각 행은 비즈니스에서 판매하는 상품을 설명합니다.
items 테이블에는 complaints 열이 포함되어 있습니다. 이 TEXT 열에는 각 항목에 대해 로깅된 구매자 불만사항이 저장됩니다.
데이터베이스는 Vertex AI Model Garden과 통합되어 gemini-embedding-001 영어 모델에 대한 액세스 권한을 부여합니다.
이 데이터베이스에 항목에 대한 불만사항이 저장되어 있지만 이러한 불만사항은 일반 텍스트로 저장되므로 쿼리하기가 어렵습니다. 예를 들어 잘못된 색상의 상품을 받은 고객이 불만사항을 가장 많이 제기한 상품이 무엇인지 확인하려면 테이블에서 일반 SQL 쿼리를 수행하여 다양한 키워드 검색 유형을 찾으면 됩니다. 하지만 이 방법은 정확한 키워드가 포함된 행만 일치시킵니다.
예를 들어 SELECT * FROM item WHERE complaints LIKE
"%wrong color%"와 같은 기본 SQL 쿼리는 The picture shows a blue one, but the one I received was red만 포함된 complaints 필드가 있는 행을 반환하지 않습니다.
LLM 기반 임베딩을 사용하는 SQL 쿼리는 이러한 쿼리에 대해 의미상 유사한 응답을 반환하는 데 도움이 될 수 있습니다. 임베딩을 적용하면 이 예시에서는 지정된 텍스트 프롬프트(예: It was the
wrong color)와 의미론적으로 유사한 불만사항이 있는 상목의 테이블을 쿼리할 수 있습니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-08-17(UTC)"],[[["AlloyDB can be used as a large language model (LLM) tool to generate vector embeddings of text using a Vertex AI-hosted LLM."],["To use this functionality, the `google_ml_integration` extension (version 1.2 or later) must be installed on the AlloyDB database, and you need to integrate with Vertex AI to access the `text-embedding-005` model."],["Database users need specific permissions granted to execute the `embedding` function, which is used to translate text into a vector embedding."],["The generated embeddings, which are arrays of `real` values, can be stored in a database table column of type `real[]` and can be used with `pgvector` functions for similarity searches."],["Always specify a stable embeddings model, including a version tag, when using the `embedding()` function to avoid inconsistent results due to potential model version updates."]]],[]]