Skip to content

Commit

Permalink
minor edits
Browse files Browse the repository at this point in the history
  • Loading branch information
arnavsinghvi11 authored Oct 26, 2024
1 parent d778a93 commit 8e34835
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions docs/docs/deep-dive/retrieval_models_clients/ClarifaiRM.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# ClarifaiRM

[Clarifai](https://clarifai.com/) is a powerful AI platform that provides vector search capabilities through its search API. ClarifaiRM integrates with DSPy to enable semantic passage retrieval using Clarifai's infrastructure. Clarifai supports efficient text search and retrieval through its specialized indexing and can handle large-scale document collections.
[Clarifai](https://clarifai.com/) is a powerful AI platform that provides vector search capabilities through its search API. DSPy has integrated ClarifaiRM to support efficient text search and retrieval through its specialized indexing and ability to handle large-scale document collections.

To support passage retrieval, ClarifaiRM assumes that documents have been properly ingested into a Clarifai application with:
To support passage retrieval, ClarifaiRM assumes that documents have been properly ingested into a Clarifai application with the following:
- Text data properly indexed and stored
- Appropriate search configurations set up in the Clarifai platform
- Valid authentication credentials (PAT key) with appropriate permissions
Expand All @@ -13,19 +13,21 @@ The ClarifaiRM module requires the `clarifai` Python package. If not already ins
pip install clarifai
```

!!! note
Before using ClarifaiRM, ensure you have:
1. Created a Clarifai account and application
2. Ingested your documents into the application
3. Obtained your User ID, App ID, and Personal Access Token (PAT)
> **Note:**
>
> Before using ClarifaiRM, ensure you have:
> 1. Created a Clarifai account and application
> 2. Ingested your documents into the application
> 3. Obtained your User ID, App ID, and Personal Access Token (PAT)

## Setting up the ClarifaiRM Client

The constructor initializes an instance of the `ClarifaiRM` class, which requires authentication credentials and configuration for connecting to your Clarifai application.
The constructor initializes an instance of the `ClarifaiRM` class, which requires authentication credentials and configuration to connect to your Clarifai application.

- `clarifai_user_id` (_str_): Your unique Clarifai user identifier.
- `clarifai_app_id` (_str_): The ID of your Clarifai application where documents are stored.
- `clarifai_pat` (_Optional[str]_): Your Clarifai Personal Access Token (PAT). If not provided, it will look for `CLARIFAI_PAT` in environment variables.
- `clarifai_pat` (_Optional[str]_): Your Clarifai Personal Access Token (PAT). It will look for `CLARIFAI_PAT` in environment variables if not provided.
- `k` (_int_, _optional_): The number of top passages to retrieve. Defaults to 3.

Example of the ClarifaiRM constructor:
Expand All @@ -39,8 +41,9 @@ ClarifaiRM(
)
```

!!! note
The PAT can be provided either directly to the constructor or through the `CLARIFAI_PAT` environment variable. For security best practices, using environment variables is recommended.
> **Note:**
>
> The PAT can be provided either directly to the constructor or through the `CLARIFAI_PAT` environment variable. For security best practices, using environment variables is recommended.
## Under the Hood

Expand Down Expand Up @@ -144,7 +147,7 @@ num_results = len(results)

### Integration with Other DSPy Components
```python
from dspy import ChainOfThought, Predict
from dspy import ChainOfThought, Predict, Retrieve

# Create a simple QA chain
class QAChain(dspy.Module):
Expand Down Expand Up @@ -176,9 +179,10 @@ except Exception as e:
print(f"Error occurred: {e}")
```

!!! note
These examples assume you have:
- A properly configured Clarifai application
- Valid authentication credentials
- Documents already ingested into your Clarifai app
- The necessary environment variables set up
> **Note:**
>
> These examples assume you have:
> - A properly configured Clarifai application
> - Valid authentication credentials
> - Documents already ingested into your Clarifai app
> - The necessary environment variables set up

0 comments on commit 8e34835

Please sign in to comment.