|
# Clarifai |
|
|
|
>[Clarifai](https: |
|
> |
|
> `Clarifai` provides 1,000s of AI models for many different use cases. You can [explore them here](https: |
|
> |
|
>Also note that given there are many models for images, video, text and audio understanding, you can build some interested AI agents that utilize the variety of AI models as experts to understand those data types. |
|
|
|
|
|
## Installation and Setup |
|
- Install the Python SDK: |
|
```bash |
|
pip install clarifai |
|
``` |
|
[Sign-up](https: |
|
|
|
|
|
## LLMs |
|
|
|
To find the selection of LLMs in the Clarifai platform you can select the text to text model type [here](https: |
|
|
|
```python |
|
from langchain_community.llms import Clarifai |
|
llm = Clarifai(pat=CLARIFAI_PAT, user_id=USER_ID, app_id=APP_ID, model_id=MODEL_ID) |
|
``` |
|
|
|
For more details, the docs on the Clarifai LLM wrapper provide a [detailed walkthrough](/docs/integrations/llms/clarifai). |
|
|
|
|
|
## Embedding Models |
|
|
|
To find the selection of embeddings models in the Clarifai platform you can select the text to embedding model type [here](https: |
|
|
|
There is a Clarifai Embedding model in LangChain, which you can access with: |
|
```python |
|
from langchain_community.embeddings import ClarifaiEmbeddings |
|
embeddings = ClarifaiEmbeddings(pat=CLARIFAI_PAT, user_id=USER_ID, app_id=APP_ID, model_id=MODEL_ID) |
|
``` |
|
|
|
See a [usage example](/docs/integrations/document_loaders/couchbase). |
|
|
|
|
|
## Vectorstore |
|
|
|
Clarifai's vector DB was launched in 2016 and has been optimized to support live search queries. With workflows in the Clarifai platform, you data is automatically indexed by am embedding model and optionally other models as well to index that information in the DB for search. You can query the DB not only via the vectors but also filter by metadata matches, other AI predicted concepts, and even do geo-coordinate search. Simply create an application, select the appropriate base workflow for your type of data, and upload it (through the API as [documented here](https: |
|
|
|
You can also add data directly from LangChain as well, and the auto-indexing will take place for you. You'll notice this is a little different than other vectorstores where you need to provide an embedding model in their constructor and have LangChain coordinate getting the embeddings from text and writing those to the index. Not only is it more convenient, but it's much more scalable to use Clarifai's distributed cloud to do all the index in the background. |
|
|
|
```python |
|
from langchain_community.vectorstores import Clarifai |
|
clarifai_vector_db = Clarifai.from_texts(user_id=USER_ID, app_id=APP_ID, texts=texts, pat=CLARIFAI_PAT, number_of_docs=NUMBER_OF_DOCS, metadatas = metadatas) |
|
``` |
|
For more details, the docs on the Clarifai vector store provide a [detailed walkthrough](/docs/integrations/vectorstores/clarifai). |
|
|