DSPy: The framework for programming—not prompting—language models
Python
Add the documentation
Erika Cardenas1a83af9bfb18
diff --git a/docs/docs/deep-dive/retrieval_models_clients/WeaviateRM.mdx b/docs/docs/deep-dive/retrieval_models_clients/WeaviateRM.mdxindex dce4b0f77..c5b0d1f6a 100644--- a/docs/docs/deep-dive/retrieval_models_clients/WeaviateRM.mdx+++ b/docs/docs/deep-dive/retrieval_models_clients/WeaviateRM.mdx@@ -3,6 +3,57 @@ sidebar_position: 1---# Weaviate Retrieval Model+[Weaviate](https://weaviate.io/) is an open-source vector database that can be used to retrieve relevant passages before passing it to the language model. Weaviate supports a variety of [embedding models](https://weaviate.io/developers/weaviate/model-providers) from OpenAI, Cohere, Google and more! Before building your DSPy program, you will need a Weaviate cluster running with data. You can follow this [notebook](https://github.com/weaviate/recipes/blob/main/integrations/llm-frameworks/dspy/Weaviate-Import.ipynb) as an example.+## Configuring the Weaviate Client+Weaviate is available via a hosted service ([WCD](https://console.weaviate.cloud/)) or as a self managed instance. You can learn about the different installation methods [here](https://weaviate.io/developers/weaviate/installation#installation-methods).+* `weaviate_collection_name` (str): The name of the Weaviate collection+* `weaviate_client` (WeaviateClient): An instance of the Weaviate client+* `k` (int, optional): The number of top passages to retrieve. The default is set to `3`++An example of the WeaviateRM constructor:++```python+WeaviateRM(+ collection_name: str+ weaviate_client: str,+ k: int = 5+)+```++## Under the Hood++`forward(self, query_or_queries: Union[str, List[str]], k: Optional[int] = None, **kwargs) -> dspy.Prediction`++### Parameters+* `query_or_queries` (Union[str, List[str]]): The query or queries to search for+* `k (Optional[int]): The number of top passages to retrieve. It defaults to `self.k`+* `**kwargs`: Additional keyword arguments like `rerank` for example++### Returns+* `dspy.Prediction`: An object containing the retrieved passages+++## Sending Retrieval Requests via the WeaviateRM Client++Here is an example of the Weaviate constructor using embedded:++```python+import weaviate+import dspy+from dspy.retrieve.weaviate_rm import WeaviateRM++weaviate_client = weaviate.connect_to_embedded() # you can also use local or WCD++retriever_model = WeaviateRM(+ collection_name="<WEAVIATE_COLLECTION>",+ weaviate_client=weaviate_client+)++results = retriever_model("Explore the significance of quantum computing", k=5)++for result in results:+ print("Document:", result.long_text, "\n")+```