Notebooks
W
Weaviate
Wandb Logging RAG Dspy Cohere

Wandb Logging RAG Dspy Cohere

vector-searchvector-databaseretrieval-augmented-generationllm-frameworksoperationsfunction-callingweaviate-recipesintegrationsPythongenerative-aiweights_and_biases

Open In Colab

Weave is now integrated in DSPy. Please refer to this page on how to add traces to your DSPy program.

Setup

There are 4 basic steps to compile an LLM program with DSPy.

  1. Connect DSPy to any LLMs or tools, such as Weaviate :), that you want to use.
  2. Load your dataset, wrapping each example in a dspy.Example object.
  3. Define your LLM program.
  4. Define your Metric.

1. Connect DSPy to Command R and Weaviate

[22]
[23]
["Hello! How's it going? I hope you're having a fantastic day! 😊"]
['Hello! How can I help you today?']

2. Load your Dataset

[24]

3. Define your LLM Program

[26]

4. Define your Metric

[27]
[28]

Great! You are all setup to use DSPy's Compilers

Connect to Weights & Biases and start a run

[34]
wandb: WARNING Calling wandb.login() after wandb.init() has no effect.
/Users/cshorten/Desktop/DSPy-local/myenv/lib/python3.10/site-packages/wandb/sdk/lib/ipython.py:77: DeprecationWarning: Importing display from IPython.core.display is deprecated since IPython 7.14, please import from IPython display
  from IPython.core.display import HTML, display  # type: ignore
/Users/cshorten/Desktop/DSPy-local/myenv/lib/python3.10/site-packages/wandb/sdk/lib/ipython.py:77: DeprecationWarning: Importing display from IPython.core.display is deprecated since IPython 7.14, please import from IPython display
  from IPython.core.display import HTML, display  # type: ignore

Bootstrap with Command R+

[35]
100%|███████████████████████████████████████████| 25/25 [03:01<00:00,  7.25s/it]
[36]
Compiled RAG Score at Demos = 49: 455.0

Bootstrap with Command R

[37]
/Users/cshorten/Desktop/DSPy-local/myenv/lib/python3.10/site-packages/wandb/sdk/lib/ipython.py:77: DeprecationWarning: Importing display from IPython.core.display is deprecated since IPython 7.14, please import from IPython display
  from IPython.core.display import HTML, display  # type: ignore
/Users/cshorten/Desktop/DSPy-local/myenv/lib/python3.10/site-packages/wandb/sdk/lib/ipython.py:77: DeprecationWarning: Importing display from IPython.core.display is deprecated since IPython 7.14, please import from IPython display
  from IPython.core.display import HTML, display  # type: ignore
[38]
 52%|██████████████████████▎                    | 13/25 [00:19<00:17,  1.47s/it]
[39]
Compiled RAG Score at Demos = 49: 420.0

[42]
Output
[ ]