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

FilterSearch -> QdrantSearch, Readme fixes #19

Merged
merged 2 commits into from
Oct 30, 2023
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ cd src/examples && poetry run jupyter lab

## How to use this in your project

To install this as a dependency in your project, you will need to get a [Github access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens).
To install this as a dependency in your project, you need a [Github access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens).

Set your access token:

Expand All @@ -66,7 +66,7 @@ Let's install the package:
pip install git+https://[email protected]/aleph-alpha-intelligence-layer/intelligence-layer.git
```

Now, the intelligence layer should be available and ready to use as a Python package.
Now the Intelligence Layer should be available as a Python package and ready to use.

```py
from intelligence_layer.core.task import Task
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ class EmbeddingBasedClassify(Task[ClassifyInput, ClassifyOutput]):
scoring: Configure how to calculate the final score.

Attributes:
METADATA_LABEL_NAME: The metadata field for label name for the `InMemoryRetriever`
instance.
METADATA_LABEL_NAME: The metadata field name for 'label' in the retriever.

Example:
>>> labels_with_examples = [
Expand Down Expand Up @@ -101,7 +100,7 @@ def __init__(
k=top_k_per_label,
retriever_type=RetrieverType.SYMMETRIC,
)
self._filter_search = QdrantSearch(retriever)
self._qdrant_search = QdrantSearch(retriever)

def run(self, input: ClassifyInput, logger: DebugLogger) -> ClassifyOutput:
self._validate_input_labels(input)
Expand Down Expand Up @@ -147,7 +146,7 @@ def _label_search(
]
),
)
return self._filter_search.run(search_input, logger)
return self._qdrant_search.run(search_input, logger)

def _calculate_scores(
self, results_per_label: Sequence[SearchOutput]
Expand Down
8 changes: 4 additions & 4 deletions src/intelligence_layer/use_cases/search/qdrant_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


class QdrantSearchInput(BaseModel):
"""The input for a `FilterSearch` task.
"""The input for a `QdrantSearch` task.

Attributes:
query: The text to be searched with.
Expand Down Expand Up @@ -39,8 +39,8 @@ class QdrantSearch(Task[QdrantSearchInput, SearchOutput]):
>>> )
>>> ]
>>> retriever = InMemoryRetriever(client, documents)
>>> task = FilterSearch(retriever)
>>> input = FilterSearchInput(
>>> task = QdrantSearch(retriever)
>>> input = QdrantSearchInput(
>>> query="When did East and West Germany reunite?"
>>> filter=models.Filter(
>>> must=[
Expand All @@ -51,7 +51,7 @@ class QdrantSearch(Task[QdrantSearchInput, SearchOutput]):
>>> ]
>>> )
>>> )
>>> logger = InMemoryLogger(name="Filter Search")
>>> logger = InMemoryLogger(name="Qdrant Search")
>>> output = task.run(input, logger)
"""

Expand Down
12 changes: 6 additions & 6 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,24 @@ def prompt_image() -> Image:


@fixture
def asymmetric_qdrant_in_memory_retriever(
client: Client, qdrant_in_memory_retriever_documents: Sequence[Document]
def asymmetric_in_memory_retriever(
client: Client, in_memory_retriever_documents: Sequence[Document]
) -> QdrantInMemoryRetriever:
return QdrantInMemoryRetriever(
client,
qdrant_in_memory_retriever_documents,
in_memory_retriever_documents,
k=2,
retriever_type=RetrieverType.ASYMMETRIC,
)


@fixture
def symmetric_qdrant_in_memory_retriever(
client: Client, qdrant_in_memory_retriever_documents: Sequence[Document]
def symmetric_in_memory_retriever(
client: Client, in_memory_retriever_documents: Sequence[Document]
) -> QdrantInMemoryRetriever:
return QdrantInMemoryRetriever(
client,
qdrant_in_memory_retriever_documents,
in_memory_retriever_documents,
k=2,
retriever_type=RetrieverType.SYMMETRIC,
)
Expand Down
4 changes: 3 additions & 1 deletion tests/use_cases/search/test_qdrant_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ def in_memory_retriever_documents() -> Sequence[Document]:


@fixture
def filter_search(asymmetric_in_memory_retriever: QdrantInMemoryRetriever) -> QdrantSearch:
def filter_search(
asymmetric_in_memory_retriever: QdrantInMemoryRetriever,
) -> QdrantSearch:
return QdrantSearch(asymmetric_in_memory_retriever)


Expand Down