Neural sparse search using raw vectors
출처: 문서
본문
원시 벡터를 사용한 Neural sparse search
직접 호스팅하는 sparse embedding 모델을 사용하는 경우, neural sparse search에서 사용할 원시 sparse 벡터를 수집할 수 있어요.
예제
다음 예제는 sparse 벡터를 OpenSearch 인덱스에 수집한 다음, sparse 벡터를 사용해 일치하는 문서를 검색해요.
1단계: 인덱스 생성
원시 sparse 벡터가 포함된 문서를 수집하려면 rank features 인덱스를 생성하세요.
PUT /my-nlp-index
{
"mappings": {
"properties": {
"id": {
"type": "text"
},
"passage_embedding": {
"type": "rank_features"
},
"passage_text": {
"type": "text"
}
}
}
}
{% include copy-curl.html %}
2단계: 인덱스에 문서 수집
이전 단계에서 생성한 인덱스에 문서를 수집하려면 다음 요청을 보내세요.
PUT /my-nlp-index/_doc/1
{
"passage_text": "Hello world",
"id": "s1",
"passage_embedding": {
"hi" : 4.338913,
"planets" : 2.7755864,
"planet" : 5.0969057,
"mars" : 1.7405145,
"earth" : 2.6087382,
"hello" : 3.3210192
}
}
{% include copy-curl.html %}
3단계: sparse 벡터로 데이터 검색
sparse 벡터로 문서를 검색하려면 neural_sparse 쿼리에 sparse embedding을 지정하세요.
GET my-nlp-index/_search
{
"query": {
"neural_sparse": {
"passage_embedding": {
"query_tokens": {
"hi" : 4.338913,
"planets" : 2.7755864,
"planet" : 5.0969057,
"mars" : 1.7405145,
"earth" : 2.6087382,
"hello" : 3.3210192
}
}
}
}
}
{% include copy-curl.html %}
Neural sparse search 가속화
neural sparse search의 검색 시간을 개선하는 방법을 더 자세히 알아보려면 Neural sparse search 가속화 문서를 참고하세요.
다음 단계
- AI 검색 애플리케이션을 만드는 방법을 배우려면 튜토리얼을 살펴보세요.