Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tokenization notebook: change title #178

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions notebooks/document-chunking/tokenization.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"id": "s49gpkvZ7q53"
},
"source": [
"# Tokenization for Semantic Search (ELSER and E5)\n",
"# Calculating tokens for Semantic Search (ELSER and E5)\n",
"\n",
"[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/elastic/elasticsearch-labs/blob/main/notebooks/search/tokenization.ipynb)\n",
"\n",
Expand Down Expand Up @@ -217,9 +217,10 @@
"outputs": [],
"source": [
"SEMANTIC_SEARCH_TOKEN_LIMIT = 510 # 512 minus space for the 2 special tokens\n",
"ELSER_TOKEN_OVERLAP = 0.5 # 50% token overlap between chunks is recommended for ELSER\n",
"\n",
"def chunk(tokens, chunk_size=SEMANTIC_SEARCH_TOKEN_LIMIT):\n",
" step_size = round(chunk_size * .5) # 50% token overlap between chunks is recommended for ELSER\n",
"def chunk(tokens, chunk_size=SEMANTIC_SEARCH_TOKEN_LIMIT, overlap_ratio=ELSER_TOKEN_OVERLAP):\n",
" step_size = round(chunk_size * overlap_ratio)\n",
"\n",
" for i in range(0, len(tokens), step_size):\n",
" yield tokens[i:i+chunk_size]"
Expand Down
Loading