FriendliAI + Weaviate (Python)
Utilize the Weaviate to build applications with less hallucination open-source vector database.
Integration with Weaviate enables performing Retrieval Augmented Generation (RAG) directly within the Weaviate database. This combines the power of Friendli Engine and Weaviate’s efficient storage and fast retrieval capabilities to generate personalized and context-aware responses.
How to use
Before you start, ensure you’ve already obtained the FRIENDLI_TOKEN
from the Friendli Suite.
Also, set up your Weaviate instance following this guide.
Your Weaviate instance must be configured with the FriendliAI generative AI integration (generative-friendliai
) module.
Instantiation
Now we can instantiate a Weaviate collection using our model. We provide usage examples for each type of endpoint. Choose the one that best suits your needs.
You can specify one of the available models for the serverless endpoints.
The default model (i.e. meta-llama-3.1-70b-instruct
) will be used if no model is specified.
Configurable parameters
Configure the following generative parameters to customize the model behavior.
Retrieval Augmented Generation
After configuring Weaviate, perform RAG operations, either with the single prompt or grouped task method.
Single prompt
To generate text for each object in the search results, use the single prompt method. The example below generates outputs for each of the n search results, where n is specified by the limit parameter.
When creating a single prompt query, use braces {}
to interpolate the object properties you want Weaviate to pass on to the language model.
For example, to pass on the object’s title property, include {title}
in the query.
Grouped task
To generate one text for the entire set of search results, use the grouped task method. In other words, when you have n search results, the generative model generates one output for the entire group.
Further resources
Once the integrations are configured at the collection, the data management and search operations in Weaviate work identically to any other collection. See the following model-agnostic examples: