Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Riccorl committed Aug 8, 2024
1 parent 515ac1a commit e746294
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 12 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ Output:
Retrievers and Readers can be used separately.
In the case of retriever-only ReLiK, the output will contain the candidates for the input text.

Reader-only example:
Retriever-only example:

```python
from relik import Relik
Expand Down Expand Up @@ -246,7 +246,7 @@ Output:
),
)

Retriever-only example:
Reader-only example:

```python
from relik import Relik
Expand Down
7 changes: 4 additions & 3 deletions relik/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,10 @@ def download_from_hf(
downloaded_paths.append(downloaded_path)
except OSError:
if ignore_failure:
logger.warn(
f"Couldn't download {filename} from {path_or_repo_id}, ignoring"
)
# logger.warn(
# f"Couldn't download {filename} from {path_or_repo_id}, ignoring"
# )
pass
else:
raise

Expand Down
8 changes: 5 additions & 3 deletions relik/retriever/indexers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,13 +467,15 @@ def from_pretrained(
)

config = OmegaConf.load(config_path)
# add the actual cls class to the config in place of the _target_ if cls is not BaseDocumentIndex

# add the actual cls class to the config in place of the _target_ if cls is not BaseDocumentIndex
target = config.get("_target_", None)
use_faiss = kwargs.get("use_faiss", False) or "FaissDocumentIndex" in target

if cls.__name__ != "BaseDocumentIndex" and target is None:
kwargs["_target_"] = f"{cls.__module__}.{cls.__name__}"

use_faiss = kwargs.get("use_faiss", False) or "FaissDocumentIndex" in target
if use_faiss and "FaissDocumentIndex" not in target:
kwargs["_target_"] = "relik.retriever.indexers.faissindex.FaissDocumentIndex"

kwargs["device"] = device
kwargs["precision"] = precision
Expand Down
4 changes: 2 additions & 2 deletions relik/retriever/indexers/faissindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ def _build_faiss_index(
embeddings.cpu() if isinstance(embeddings, torch.Tensor) else embeddings
)

# convert to float32 if embeddings is a torch.Tensor and is float16
if isinstance(embeddings, torch.Tensor) and embeddings.dtype == torch.float16:
# convert to float32 if embeddings is a torch.Tensor and not already float32
if isinstance(embeddings, torch.Tensor) and embeddings.dtype != torch.float32:
embeddings = embeddings.float()

# logger.info("Training the index.")
Expand Down
2 changes: 1 addition & 1 deletion relik/retriever/indexers/inmemory.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __init__(
separator: str | None = None,
name_or_path: str | os.PathLike | None = None,
device: str = "cpu",
precision: str | int | torch.dtype = 32,
precision: str | int | torch.dtype | None = 32,
*args,
**kwargs,
) -> None:
Expand Down
2 changes: 1 addition & 1 deletion relik/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
_MINOR = "0"
# On main and in a nightly release the patch should be one ahead of the last
# released build.
_PATCH = "5"
_PATCH = "6"
# This is mainly for nightly builds which have the suffix ".dev$DATE". See
# https://semver.org/#is-v123-a-semantic-version for the semantics.
_SUFFIX = os.environ.get("RELIK_VERSION_SUFFIX", "")
Expand Down

0 comments on commit e746294

Please sign in to comment.