ESRE, ELSER, RRF??
Elastic Education Architect
Koji Kawamura @ijokarumawak
June 28 2023
Slide 2
Slide 2 text
Elastic と GAI
Slide 3
Slide 3 text
Generative AI (GAI) って?
Lots of articles, books, audio and videos are transforming into a human shaped
cloud floating in the sky
Slide 4
Slide 4 text
Generative AI 使ってますか?
Slide 5
Slide 5 text
LLM の弱点
Slide 6
Slide 6 text
コンテキストを加える (8.8 リリースブログをコピペ)
(以下略)
Slide 7
Slide 7 text
8.8 セキュリティリリース日本語概要
Slide 8
Slide 8 text
What are the key aspects of
the company's 401k policy
for an employee in my
location and how do I enroll?
Question as search query
original question
context window
✓ GAI response based on
the most relevant data
✓ Additional user
personalization
✓ Reduces required
compute resources
Most relevant data to
the query
Elastic + Generative AI increases relevance
and scalability at a lower cost
Domain Specific, Private Content
Elasticsearch
Elasticsearch Relevance Engine™
Gives developers a powerful set of machine learning
tools to build AI-powered search applications that
integrate with large language models & Generative AI
Reflects two years of R&D
Vector database Ability to host your own
transformer model
Ability to integrate with
3rd party transformer
models (OpenAI)
RRF - hybrid scoring
model (vector &
textual search)
Elastic’s proprietary
ML model
Integration with 3rd
party tooling like
LangChain
Dense? Sparse?
Check out the other posts in this Information Retrieval series:
Part 1: Steps to improve search relevance
Dense model の解説、pre-train, task-specific, domain-specific (fine-tune)
Q&Aタスク固有の学習では MSMARCO (bing のクエリと結果) がよく使われる
Part 2: Benchmarking passage retrieval
BM25 と dense モデルの IR性能比較方法、 MSMARCO 以外での比較が必要
BEIR paper, 18のデータセットに対する zero-shot での IR性能比較
Dense モデルは BM25 よりドメインの異なるデータセットでの IR性能が劣る
Zero-shot で BM25 と KNN を組み合わせると関連度が下がる傾向がある
Fine-tune の必要性、しかし一般ユーザーにはコストが高い
Part 3: Introducing Elastic Learned Sparse Encoder, our new retrieval model
なぜ ELSER、次ページ以降で解説
Slide 16
Slide 16 text
BM25 vs Dense models
Part 2: Benchmarking passage retrieval より抜粋
Dense は学習に利用した MSMARCO 以外では BM25 より劣る結果に
Slide 17
Slide 17 text
BM25 vs ELSER
Part 3: Introducing Elastic Learned Sparse Encoder, our new retrieval model より抜粋
Slide 18
Slide 18 text
Sparse vs Dense?
Slide 19
Slide 19 text
Embedding
Model
Dense Vector Search (Semantical)
Text 1 [1.23, 0.21, … ]
Query
Dense Vector
Text 2 [3.11, 5.04, … ]
[1.11, 2.16, … ]
T1
Q
T2
Dense Vector space
テキストの意味を元にベクト
ル化、近い文書を検索
Slide 20
Slide 20 text
Doc 2: my favorite pokemon
Sparse Vector Search (Lexical)
Analyzer
Doc 1: The newest chapter
in the Pokémon series
Inverted Index
Query: the latest pokemon
game
Token Docs
chapter 1
favorit 2
my 2
newest 1
pokemon 2
pokémon 1
seri 1
latest, pokemon, game
転置インデックスで検索
BM25 でスコアリング
Slide 21
Slide 21 text
Doc 2: my favorite pokemon
Sparse Vector Search (ELSER)
ELSER
Doc 1: The newest chapter
in the Pokémon series
Inverted Index
Query: the latest pokemon
game
Token Docs
chapter 1 (2.11)
pokemon 1 (2.33)
2 (2.42)
… etc
※生成された token の一部のみ表示
Search Result
Doc Score
1 16.2088
2 10.0872
Slide 22
Slide 22 text
Sparse Vector Search (ELSER scoring)
Search Result
Doc Score
1 16.2088
2 10.0872
token query w doc w qw * dw
pokemon 2.6080 2.3329 6.0842
latest 1.9030 1.1554 2.1987
anime 1.0525 1.1673 1.2285
release 0.9056 0.9164 0.8298
… …
Doc 1: The newest
chapter in the
Pokémon series
Query: the latest
pokemon game
sum()
Slide 23
Slide 23 text
Sparse Vector Search with ELSER
TODO
生成される単語種類数はモデルのボキャ
ブラリ数に等しい
Lucene の posting list の中に TF や
rank_features のデータを持っている
クエリ内の term(i) スコアとマッチした
rank term(i) スコアの積の合計
Reciprocal Rank Fusion
(RRF)
Ranking Algorithm 1
Doc Score r(d)
A 1 1
B 0.7 2
C 0.5 3
D 0.2 4
E 0.01 5
Doc
A
C
B
F
D
D - set of docs
R - set of rankings as permutation on 1..|D|
K - typically set to 60 by default
Ranking Algorithm 2
Doc Score r(d)
C 1,341 1
A 739 2
F 732 3
G 192 4
H 183 5
What are the key aspects of
the company's 401k policy
for an employee in my
location and how do I enroll?
Question as search query
original question
context window
✓ GAI response based on
the most relevant data
✓ Additional user
personalization
✓ Reduces required
compute resources
Most relevant data to
the query
Elastic + Generative AI increases relevance
and scalability at a lower cost
Domain Specific, Private Content
Elasticsearch
おまけ GPT4All はどう?
Model Me
An irritated male adult
leaning forward and
waiting for an answer
to his question from a
young child who is
speaking very slowly.
In digital art style.