Construct Annoy wrapper from raw documents.
from_texts(
cls,
texts: List[str],
embedding: Embeddings,
metadatas: Optional[List[dict]] = None,
metric: str = DEFAULT_METRIC,
trees: int = 100,
n_jobs: int = 1,
**kwargs: Any = {}
) -> AnnoyThis is a user friendly interface that:
This is intended to be a quick way to get started.
Example:
.. code-block:: python
from langchain_community.vectorstores import Annoy from langchain_community.embeddings import OpenAIEmbeddings embeddings = OpenAIEmbeddings() index = Annoy.from_texts(texts, embeddings)
| Name | Type | Description |
|---|---|---|
texts* | List[str] | List of documents to index. |
embedding* | Embeddings | Embedding function to use. |
metadatas | Optional[List[dict]] | Default: NoneList of metadata dictionaries to associate with documents. |
metric | str | Default: DEFAULT_METRICMetric to use for indexing. Defaults to "angular". |
trees | int | Default: 100Number of trees to use for indexing. Defaults to 100. |
n_jobs | int | Default: -1Number of jobs to use for indexing. Defaults to -1. |