You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Or open our intro notebook in Google Colab: [<img align="center" src="https://colab.research.google.com/assets/colab-badge.svg" />](https://colab.research.google.com/github/stanfordnlp/dspy/blob/main/intro.ipynb)
66
72
67
73
By default, DSPy installs the latest `openai` from pip. However, if you install old version before OpenAI changed their API `openai~=0.28.1`, the library will use that just fine. Both are supported.
@@ -95,7 +101,7 @@ The DSPy documentation is divided into **tutorials** (step-by-step illustration
95
101
96
102
- [DSPy talk at ScaleByTheBay Nov 2023](https://www.youtube.com/watch?v=Dt3H2ninoeY).
97
103
- [DSPy webinar with MLOps Learners](https://www.youtube.com/watch?v=im7bCLW2aM4), a bit longer with Q&A.
98
-
- Hands-on Overviews of DSPy by the community: [DSPy Explained! by Connor Shorten](https://www.youtube.com/watch?v=41EfOY0Ldkc), [DSPy explained by code_your_own_ai](https://www.youtube.com/watch?v=ycfnKPxBMck)
104
+
- Hands-on Overviews of DSPy by the community: [DSPy Explained! by Connor Shorten](https://www.youtube.com/watch?v=41EfOY0Ldkc), [DSPy explained by code_your_own_ai](https://www.youtube.com/watch?v=ycfnKPxBMck), [DSPy Crash Course by AI Bites](https://youtu.be/5-zgASQKkKQ?si=3gnmVouT5_rpk_nu)
99
105
- Interviews: [Weaviate Podcast in-person](https://www.youtube.com/watch?v=CDung1LnLbY), and you can find 6-7 other remote podcasts on YouTube from a few different perspectives/audiences.
100
106
- **Tracing in DSPy** with Arize Phoenix: [Tutorial for tracing your prompts and the steps of your DSPy programs](https://colab.research.google.com/github/Arize-ai/phoenix/blob/main/tutorials/tracing/dspy_tracing_tutorial.ipynb)
101
107
- [DSPy: Not Your Average Prompt Engineering](https://jina.ai/news/dspy-not-your-average-prompt-engineering), why it's crucial for future prompt engineering, and yet why it is challenging for prompt engineers to learn.
@@ -142,6 +148,7 @@ You can find other examples tweeted by [@lateinteraction](https://twitter.com/la
142
148
- [DSPy on BIG-Bench Hard Example, by Chris Levy](https://drchrislevy.github.io/posts/dspy/dspy.html)
143
149
- [Using Ollama with DSPy for Mistral (quantized) by @jrknox1977](https://gist.github.com/jrknox1977/78c17e492b5a75ee5bbaf9673aee4641)
144
150
- [Using DSPy, "The Unreasonable Effectiveness of Eccentric Automatic Prompts" (paper) by VMware's Rick Battle & Teja Gollapudi, and interview at TheRegister](https://www.theregister.com/2024/02/22/prompt_engineering_ai_models/)
151
+
- [Optimizing Performance of Open Source LM for Text-to-SQL using DSPy and vLLM, by Juan Ovalle](https://github.com/jjovalle99/DSPy-Text2SQL)
145
152
- Typed DSPy (contributed by [@normal-computing](https://github.com/normal-computing))
146
153
- [Using DSPy to train Gpt 3.5 on HumanEval by Thomas Ahle](https://github.com/stanfordnlp/dspy/blob/main/examples/functional/functional.ipynb)
147
154
- [Building a chess playing agent using DSPy by Franck SN](https://medium.com/thoughts-on-machine-learning/building-a-chess-playing-agent-using-dspy-9b87c868f71e)
@@ -414,7 +421,7 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for a quickstart guide to contributing to
414
421
415
422
**DSPy** is led by **Omar Khattab** at Stanford NLP with **Chris Potts** and **Matei Zaharia**.
416
423
417
-
Key contributors and team members include **Arnav Singhvi**, **Krista Opsahl-Ong**, **Michael Ryan**, **Karel D'Oosterlinck**, **Shangyin Tan**, **Manish Shetty**, **Paridhi Maheshwari**, **Keshav Santhanam**, **Sri Vardhamanan**, **Eric Zhang**, **Hanna Moazam**, **Thomas Joshi**, **Saiful Haq**, **Ashutosh Sharma**, and **Herumb Shandilya**.
424
+
Key contributors and team members include **Arnav Singhvi**, **Krista Opsahl-Ong**, **Michael Ryan**, **Cyrus Nouroozi**, **Kyle Caverly**, **Amir Mehr**, **Karel D'Oosterlinck**, **Shangyin Tan**, **Manish Shetty**, **Herumb Shandilya**, **Paridhi Maheshwari**, **Keshav Santhanam**, **Sri Vardhamanan**, **Eric Zhang**, **Hanna Moazam**, **Thomas Joshi**, **Saiful Haq**, and **Ashutosh Sharma**.
418
425
419
426
**DSPy** includes important contributions from **Rick Battle** and **Igor Kotenkov**. It reflects discussions with **Peter Zhong**, **Haoze He**, **Lisa Li**, **David Hall**, **Ashwin Paranjape**, **Heather Miller**, **Chris Manning**, **Percy Liang**, and many others.
Copy file name to clipboardExpand all lines: docs/docs/building-blocks/1-language_models.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -145,25 +145,25 @@ You need to host these models on your own GPU(s). Below, we include pointers for
145
145
1.`dspy.HFClientTGI`: for HuggingFace models through the Text Generation Inference (TGI) system. [Tutorial: How do I install and launch the TGI server?](https://dspy-docs.vercel.app/docs/deep-dive/language_model_clients/local_models/HFClientTGI)
2.`dspy.HFClientVLLM`: for HuggingFace models through vLLM. [Tutorial: How do I install and launch the vLLM server?](https://dspy-docs.vercel.app/docs/deep-dive/language_model_clients/local_models/HFClientVLLM)
3.`dspy.HFModel` (experimental) [Tutorial: How do I initialize models using HFModel](https://dspy-docs.vercel.app/api/local_language_model_clients/HFModel)
4.`dspy.Ollama` (experimental) for open source models through [Ollama](https://ollama.com). [Tutorial: How do I install and use Ollama on a local computer?](https://dspy-docs.vercel.app/api/local_language_model_clients/Ollama)\n",
164
164
165
165
```python
166
-
mistral_ollama= dspy.OllamaLocal(model='mistral')
166
+
ollama_mistral= dspy.OllamaLocal(model='mistral')
167
167
```
168
168
169
169
5.`dspy.ChatModuleClient` (experimental): [How do I install and use MLC?](https://dspy-docs.vercel.app/api/local_language_model_clients/MLC)
Copy file name to clipboardExpand all lines: docs/docs/deep-dive/retrieval_models_clients/Azure.mdx
+65-5Lines changed: 65 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,32 +22,59 @@ The constructor initializes an instance of the `AzureAISearchRM` class and sets
22
22
-`search_api_key` (str): The API key for accessing the Azure AI Search service.
23
23
-`search_index_name` (str): The name of the search index in the Azure AI Search service.
24
24
-`field_text` (str): The name of the field containing text content in the search index. This field will be mapped to the "content" field in the dsp framework.
25
+
-`field_vector` (Optional[str]): The name of the field containing vector content in the search index.
25
26
-`k` (int, optional): The default number of top passages to retrieve. Defaults to 3.
27
+
-`azure_openai_client` (Optional[openai.AzureOpenAI]): An instance of the AzureOpenAI client. Either openai_client or embedding_func must be provided. Defaults to None.
28
+
-`openai_embed_model` (Optional[str]): The name of the OpenAI embedding model. Defaults to "text-embedding-ada-002".
29
+
-`embedding_func` (Optional[Callable]): A function for generating embeddings. Either openai_client or embedding_func must be provided. Defaults to None.
26
30
-`semantic_ranker` (bool, optional): Whether to use semantic ranking. Defaults to False.
27
31
-`filter` (str, optional): Additional filter query. Defaults to None.
28
32
-`query_language` (str, optional): The language of the query. Defaults to "en-Us".
29
33
-`query_speller` (str, optional): The speller mode. Defaults to "lexicon".
30
34
-`use_semantic_captions` (bool, optional): Whether to use semantic captions. Defaults to False.
31
35
-`query_type` (Optional[QueryType], optional): The type of query. Defaults to QueryType.FULL.
32
36
-`semantic_configuration_name` (str, optional): The name of the semantic configuration. Defaults to None.
37
+
-`is_vector_search` (Optional[bool]): Whether to enable vector search. Defaults to False.
38
+
-`is_hybrid_search` (Optional[bool]): Whether to enable hybrid search. Defaults to False.
39
+
-`is_fulltext_search` (Optional[bool]): Whether to enable fulltext search. Defaults to True.
40
+
-`vector_filter_mode` (Optional[VectorFilterMode]): The vector filter mode. Defaults to None.
33
41
34
-
Available Query Types:
35
42
36
-
SIMPLE
43
+
**Available Query Types:**
44
+
45
+
- SIMPLE
37
46
"""Uses the simple query syntax for searches. Search text is interpreted using a simple query
38
47
#: language that allows for symbols such as +, * and "". Queries are evaluated across all
39
48
#: searchable fields by default, unless the searchFields parameter is specified."""
40
-
FULL
49
+
- FULL
41
50
"""Uses the full Lucene query syntax for searches. Search text is interpreted using the Lucene
42
51
#: query language which allows field-specific and weighted searches, as well as other advanced
43
52
#: features."""
44
-
SEMANTIC
53
+
- SEMANTIC
45
54
"""Best suited for queries expressed in natural language as opposed to keywords. Improves
46
55
#: precision of search results by re-ranking the top search results using a ranking model trained
47
56
#: on the Web corpus.""
48
57
49
58
More Details: https://learn.microsoft.com/en-us/azure/search/search-query-overview
50
59
60
+
**Available Vector Filter Mode:**
61
+
62
+
- POST_FILTER = "postFilter"
63
+
"""The filter will be applied after the candidate set of vector results is returned. Depending on
64
+
#: the filter selectivity, this can result in fewer results than requested by the parameter 'k'."""
65
+
66
+
- PRE_FILTER = "preFilter"
67
+
"""The filter will be applied before the search query."""
68
+
69
+
More Details: https://learn.microsoft.com/en-us/azure/search/vector-search-filters
70
+
71
+
**Note**
72
+
73
+
- The `AzureAISearchRM` client allows you to perform Vector search, Hybrid search, or Full text search.
74
+
- By default, the `AzureAISearchRM` client uses the Azure OpenAI Client for generating embeddings. If you want to use something else, you can provide your custom embedding_func, but either the openai_client or embedding_func must be provided.
75
+
- If you need to enable semantic search, either with vector, hybrid, or full text search, then set the `semantic_ranker` flag to True.
76
+
- If `semantic_ranker` is True, always set the `query_type` to QueryType.SEMANTIC and always provide the `semantic_configuration_name`.
Copy file name to clipboardExpand all lines: docs/docs/deep-dive/teleprompter/signature-optimizer.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -82,7 +82,7 @@ Now we have the baseline pipeline ready to use, so let's try using the `COPRO` t
82
82
Let's start by importing and initializing our teleprompter, for the metric we'll be using the same `validate_context_and_answer` imported and used above:
Copy file name to clipboardExpand all lines: docs/docs/faqs.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -70,7 +70,7 @@ Open source libraries such as [RAGautouille](https://github.com/bclavie/ragatoui
70
70
71
71
-**How do I turn off the cache? How do I export the cache?**
72
72
73
-
You can turn off the cache by setting the [`cache_turn_on` flag to `False`](https://github.com/stanfordnlp/dspy/blob/9d8a40c477b9dd6dcdc007647b5b9ddad2b5657a/dsp/modules/cache_utils.py#L10).
73
+
You can turn off the cache by setting the [`DSP_CACHEBOOL`](https://github.com/stanfordnlp/dspy/blob/main/dsp/modules/cache_utils.py#L9) environment variable to `False`, which disables the `cache_turn_on` flag.
74
74
75
75
Your local cache will be saved to the global env directory `os.environ["DSP_NOTEBOOK_CACHEDIR"]` which you can usually set to `os.path.join(repo_path, 'cache')` and export this cache from here.
Let's take a look at what `gsm8k_trainset` and `gsm8k_devset` are:
31
+
32
+
```python
33
+
print(gsm8k_trainset)
34
+
```
35
+
36
+
The `gsm8k_trainset` and `gsm8k_devset` datasets contain a list of Examples with each example having `question` and `answer` field. We'll use these datasets to train and evaluate our model.
37
+
30
38
## Define the Module
31
39
32
-
With our environment set up, let's define a custom program that utilizes the `ChainOfThought` module to perform step-by-step reasoning to generate answers:
40
+
With our environment set up, let's define a custom program that utilizes the [`ChainOfThought`](/api/modules/ChainOfThought) module to perform step-by-step reasoning to generate answers:
33
41
34
42
```python
35
43
classCoT(dspy.Module):
@@ -43,7 +51,7 @@ class CoT(dspy.Module):
43
51
44
52
## Compile and Evaluate the Model
45
53
46
-
With our simple program in place, let's move on to optimizing it using the `BootstrapFewShotWithRandomSearch` teleprompter:
54
+
With our simple program in place, let's move on to optimizing it using the [`BootstrapFewShot`](/api/optimizers/BootstrapFewShot) teleprompter:
Copy file name to clipboardExpand all lines: docs/docs/tutorials/other_tutorial.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,6 +22,6 @@ sidebar_position: 99999
22
22
23
23
-[DSPy talk at ScaleByTheBay Nov 2023](https://www.youtube.com/watch?v=Dt3H2ninoeY).
24
24
-[DSPy webinar with MLOps Learners](https://www.youtube.com/watch?v=im7bCLW2aM4), a bit longer with Q&A.
25
-
- Hands-on Overviews of DSPy by the community: [DSPy Explained! by Connor Shorten](https://www.youtube.com/watch?v=41EfOY0Ldkc), [DSPy explained by code_your_own_ai](https://www.youtube.com/watch?v=ycfnKPxBMck)
25
+
- Hands-on Overviews of DSPy by the community: [DSPy Explained! by Connor Shorten](https://www.youtube.com/watch?v=41EfOY0Ldkc), [DSPy explained by code_your_own_ai](https://www.youtube.com/watch?v=ycfnKPxBMck), [DSPy Crash Course by AI Bites](https://youtu.be/5-zgASQKkKQ?si=3gnmVouT5_rpk_nu)
26
26
- Interviews: [Weaviate Podcast in-person](https://www.youtube.com/watch?v=CDung1LnLbY), and you can find 6-7 other remote podcasts on YouTube from a few different perspectives/audiences.
27
27
-**Tracing in DSPy** with Arize Phoenix: [Tutorial for tracing your prompts and the steps of your DSPy programs](https://colab.research.google.com/github/Arize-ai/phoenix/blob/main/tutorials/tracing/dspy_tracing_tutorial.ipynb)
Copy file name to clipboardExpand all lines: docs/docs/tutorials/rag.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ RAG ensures LLMs can dynamically utilize real-time knowledge even if not origina
10
10
11
11
## Configuring LM and RM
12
12
13
-
We'll start by setting up the language model (LM) and retrieval model (RM), which **DSPy** supports through multiple [LM](https://dspy-docs.vercel.app/docs/category/language-model-clients) and [RM](https://dspy-docs.vercel.app/docs/category/retrieval-model-clients) APIs and [local models hosting](https://dspy-docs.vercel.app/docs/category/local-language-model-clients).
13
+
We'll start by setting up the language model (LM) and retrieval model (RM), which **DSPy** supports through multiple [LM](https://dspy-docs.vercel.app/docs/category/language-model-clients) and [RM](https://dspy-docs.vercel.app/docs/category/retrieval-model-clients) APIs and [local models hosting](https://dspy-docs.vercel.app/docs/deep-dive/language_model_clients/local_models/HFClientTGI).
14
14
15
15
In this notebook, we'll work with GPT-3.5 (`gpt-3.5-turbo`) and the `ColBERTv2` retriever (a free server hosting a Wikipedia 2017 "abstracts" search index containing the first paragraph of each article from this [2017 dump](https://hotpotqa.github.io/wiki-readme.html)). We configure the LM and RM within DSPy, allowing DSPy to internally call the respective module when needed for generation or retrieval.
0 commit comments