-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rm onnxruntime, no longer used in 2+
- Loading branch information
Showing
7 changed files
with
755 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,5 +8,4 @@ Requests | |
beautifulsoup4 | ||
huggingface_hub | ||
tiktoken | ||
onnxruntime==1.17.1 | ||
tokenizers==0.15.2 | ||
tokenizers==0.15.2 |
Binary file not shown.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,217 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stderr", | ||
"output_type": "stream", | ||
"text": [ | ||
"/Users/sdan/miniforge3/lib/python3.10/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", | ||
" from .autonotebook import tqdm as notebook_tqdm\n" | ||
] | ||
}, | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Not using OCR for data/attention2.pdf\n", | ||
"Initial length of the texts: 4\n", | ||
"Initial length of the embeddings: 4\n", | ||
"Extended length of the texts: 500000\n", | ||
"Extended length of the embeddings: 500000\n" | ||
] | ||
}, | ||
{ | ||
"name": "stderr", | ||
"output_type": "stream", | ||
"text": [ | ||
"huggingface/tokenizers: The current process just got forked, after parallelism has already been used. Disabling parallelism to avoid deadlocks...\n", | ||
"To disable this warning, you can either:\n", | ||
"\t- Avoid using `tokenizers` before the fork if possible\n", | ||
"\t- Explicitly set the environment variable TOKENIZERS_PARALLELISM=(true | false)\n" | ||
] | ||
}, | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Number of items in the VLite instance: 500000\n", | ||
"[VLite.info] Collection Information:\n", | ||
"[VLite.info] Items: 500000\n", | ||
"[VLite.info] Collection file: vlite_20240417_211628\n", | ||
"[VLite.info] Embedding model: <vlite.model.EmbeddingModel object at 0x104301480>\n", | ||
"Execution time: 1.197732925415039 seconds\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"import sys\n", | ||
"sys.path.insert(0, '..')\n", | ||
"\n", | ||
"from vlite import VLite\n", | ||
"from vlite import EmbeddingModel\n", | ||
"from vlite.utils import process_file, process_pdf, process_webpage\n", | ||
"import time\n", | ||
"\n", | ||
"# Load and process data\n", | ||
"corpus = process_file(\"data/attention2.pdf\")\n", | ||
"emd = EmbeddingModel()\n", | ||
"embeddings = emd.embed(corpus)\n", | ||
"\n", | ||
"# Verify the initial lengths\n", | ||
"print(f\"Initial length of the texts: {len(corpus)}\")\n", | ||
"print(f\"Initial length of the embeddings: {len(embeddings)}\")\n", | ||
"\n", | ||
"# Multiply texts and embeddings\n", | ||
"multiplier = 125000\n", | ||
"extended_corpus = corpus * multiplier\n", | ||
"# Correctly extend the list of embeddings\n", | ||
"extended_embeddings = [emb for emb in embeddings for _ in range(multiplier)]\n", | ||
"\n", | ||
"# Verify the extended lengths\n", | ||
"print(f\"Extended length of the texts: {len(extended_corpus)}\")\n", | ||
"print(f\"Extended length of the embeddings: {len(extended_embeddings)}\")\n", | ||
"\n", | ||
"# Create VLite instance and use set_batch\n", | ||
"vdb = VLite()\n", | ||
"vdb.set_batch(texts=extended_corpus, embeddings=extended_embeddings)\n", | ||
"\n", | ||
"# Check and display results\n", | ||
"print(f\"Number of items in the VLite instance: {vdb.count()}\")\n", | ||
"vdb.info()\n", | ||
"\n", | ||
"start_time = time.time()\n", | ||
"\n", | ||
"vdb.retrieve(\"attention\", top_k=1)\n", | ||
"\n", | ||
"end_time = time.time()\n", | ||
"execution_time = end_time - start_time\n", | ||
"\n", | ||
"print(f\"Execution time: {execution_time} seconds\")\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Not using OCR for data/attention2.pdf\n", | ||
"Initial length of the texts: 4\n", | ||
"Initial length of the embeddings: 4\n", | ||
"Extended length of the texts: 1000000\n", | ||
"Extended length of the embeddings: 1000000\n" | ||
] | ||
}, | ||
{ | ||
"name": "stderr", | ||
"output_type": "stream", | ||
"text": [ | ||
"huggingface/tokenizers: The current process just got forked, after parallelism has already been used. Disabling parallelism to avoid deadlocks...\n", | ||
"To disable this warning, you can either:\n", | ||
"\t- Avoid using `tokenizers` before the fork if possible\n", | ||
"\t- Explicitly set the environment variable TOKENIZERS_PARALLELISM=(true | false)\n" | ||
] | ||
}, | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Number of items in the VLite instance: 1000000\n", | ||
"[VLite.info] Collection Information:\n", | ||
"[VLite.info] Items: 1000000\n", | ||
"[VLite.info] Collection file: vlite_20240417_211918\n", | ||
"[VLite.info] Embedding model: <vlite.model.EmbeddingModel object at 0x1043021a0>\n", | ||
"Execution time: 2.6589159965515137 seconds\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"import sys\n", | ||
"sys.path.insert(0, '..')\n", | ||
"\n", | ||
"from vlite import VLite\n", | ||
"from vlite import EmbeddingModel\n", | ||
"from vlite.utils import process_file, process_pdf, process_webpage\n", | ||
"import time\n", | ||
"\n", | ||
"# Load and process data\n", | ||
"corpus = process_file(\"data/attention2.pdf\")\n", | ||
"emd = EmbeddingModel()\n", | ||
"embeddings = emd.embed(corpus)\n", | ||
"\n", | ||
"# Verify the initial lengths\n", | ||
"print(f\"Initial length of the texts: {len(corpus)}\")\n", | ||
"print(f\"Initial length of the embeddings: {len(embeddings)}\")\n", | ||
"\n", | ||
"# Multiply texts and embeddings\n", | ||
"multiplier = 125000*2\n", | ||
"extended_corpus = corpus * multiplier\n", | ||
"# Correctly extend the list of embeddings\n", | ||
"extended_embeddings = [emb for emb in embeddings for _ in range(multiplier)]\n", | ||
"\n", | ||
"# Verify the extended lengths\n", | ||
"print(f\"Extended length of the texts: {len(extended_corpus)}\")\n", | ||
"print(f\"Extended length of the embeddings: {len(extended_embeddings)}\")\n", | ||
"\n", | ||
"# Create VLite instance and use set_batch\n", | ||
"vdb = VLite()\n", | ||
"vdb.set_batch(texts=extended_corpus, embeddings=extended_embeddings)\n", | ||
"\n", | ||
"# Check and display results\n", | ||
"print(f\"Number of items in the VLite instance: {vdb.count()}\")\n", | ||
"vdb.info()\n", | ||
"\n", | ||
"start_time = time.time()\n", | ||
"\n", | ||
"vdb.retrieve(\"attention\", top_k=1)\n", | ||
"\n", | ||
"end_time = time.time()\n", | ||
"execution_time = end_time - start_time\n", | ||
"\n", | ||
"print(f\"Execution time: {execution_time} seconds\")\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "base", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.10.6" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |