dspy
dspy copied to clipboard
Teleprompters with Retrieve
Hi, I am using
retriever_model = ChromadbRM( collection_name='onkopedia_en', persist_directory='./chroma_db', openai_embed_model=DEFAULT_EMBED_MODEL, k=top_k )
and wanted to use
from dspy.teleprompt import BootstrapFewShot teleprompter = BootstrapFewShot(metric=MetricWrapper, max_bootstrapped_demos=1, max_rounds=1) compiled_rag = teleprompter.compile(rag, trainset=trainset)
But get: TypeError: cannot pickle 'sqlite3.Connection' object
Any workarounds on how to use a retrieval database with the optimizers?
Declare the retrieval model outside the class and try?
Here is my code for chromadb
models["gpt-35-turbo"], models["gpt-4"] = load_models()
db_file_or_url = os.path.expanduser(db_file_or_url)
embedding_function = OpenAIEmbeddingFunction(
api_key=os.environ.get("OPENAI_API_KEY"),
model_name="text-embedding-ada-002",
api_base=openai.api_base,
api_type=openai.api_type,
api_version=openai.api_version,
)
rm = ChromadbRM(
collection_name, db_file_or_url, embedding_function=embedding_function, k=num_k
)
dspy.settings.configure(rm=rm, lm=models[lm_model])
Hi works perfectly outside of the class! Thank you ! Paper coming soon :) @okhat