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

Patch/llama index and device #155

Merged
merged 7 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
"outputs": [],
"source": [
"import instructor\n",
"# If you're using llamaindex 0.10 or above, these need to be imported from llama_index.core instead!\n",
"from llama_index import Document\n",
"from llama_index.text_splitter import SentenceSplitter\n",
"from openai import OpenAI\n",
Expand Down Expand Up @@ -459,7 +460,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.13"
"version": "3.11.7"
}
},
"nbformat": 4,
Expand Down
5 changes: 1 addition & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,4 @@ unfixable = [
"T201",
"T203",
]
ignore-init-module-imports = true

[tool.ruff.lint.isort]
section-order = ["future", "standard-library", "third-party", "first-party", "local-folder"]
ignore-init-module-imports = true
8 changes: 6 additions & 2 deletions ragatouille/data/preprocessors.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
from llama_index import Document
from llama_index.text_splitter import SentenceSplitter
try:
from llama_index import Document
from llama_index.text_splitter import SentenceSplitter
except ImportError:
from llama_index.core import Document
from llama_index.core.text_splitter import SentenceSplitter


def llama_index_sentence_splitter(
Expand Down
8 changes: 4 additions & 4 deletions ragatouille/models/colbert.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ def add_to_index(
bsize=bsize,
)
else:
if self.config.index_bsize != bsize: # Update bsize if it's different
self.config.index_bsize = bsize
if self.config.index_bsize != bsize: # Update bsize if it's different
self.config.index_bsize = bsize

updater = IndexUpdater(
config=self.config, searcher=searcher, checkpoint=self.checkpoint
Expand Down Expand Up @@ -757,7 +757,7 @@ def encode(
- encodings.shape[1],
encodings.shape[2],
)
),
).to(device=encodings.device),
],
dim=1,
)
Expand All @@ -771,7 +771,7 @@ def encode(
- doc_masks.shape[1],
),
-float("inf"),
),
).to(device=encodings.device),
],
dim=1,
)
Expand Down
Loading