Skip to main content

Arcee Retriever

This notebook demonstrates how to use the ArceeRetriever class to retrieve relevant document(s) for Arceeโ€™s Domain Adapted Language Models (DALMs).


Before using ArceeRetriever, make sure the Arcee API key is set as ARCEE_API_KEY environment variable. You can also pass the api key as a named parameter.

from langchain.retrievers import ArceeRetriever

retriever = ArceeRetriever(
# arcee_api_key="ARCEE-API-KEY" # if not already set in the environment

Additional Configurationโ€‹

You can also configure ArceeRetrieverโ€™s parameters such as arcee_api_url, arcee_app_url, and model_kwargs as needed. Setting the model_kwargs at the object initialization uses the filters and size as default for all the subsequent retrievals.

retriever = ArceeRetriever(
# arcee_api_key="ARCEE-API-KEY", # if not already set in the environment
arcee_api_url="", # default is
arcee_app_url="", # default is
"size": 5,
"filters": [
"field_name": "document",
"filter_type": "fuzzy_search",
"value": "Einstein",

Retrieving documentsโ€‹

You can retrieve relevant documents from uploaded contexts by providing a query. Hereโ€™s an example:

query = "Can AI-driven music therapy contribute to the rehabilitation of patients with disorders of consciousness?"
documents = retriever.get_relevant_documents(query=query)

Additional parametersโ€‹

Arcee allows you to apply filters and set the size (in terms of count) of retrieved document(s). Filters help narrow down the results. Hereโ€™s how to use these parameters:

# Define filters
filters = [
{"field_name": "document", "filter_type": "fuzzy_search", "value": "Music"},
{"field_name": "year", "filter_type": "strict_search", "value": "1905"},

# Retrieve documents with filters and size params
documents = retriever.get_relevant_documents(query=query, size=5, filters=filters)