prompt
stringlengths
131
11.8k
completion
stringlengths
7
173
api
stringlengths
11
48
get_ipython().run_line_magic('load_ext', 'autoreload') get_ipython().run_line_magic('autoreload', '2') import dspy from dspy.evaluate import Evaluate from dspy.datasets.hotpotqa import HotPotQA from dspy.teleprompt import BootstrapFewShotWithRandomSearch, BootstrapFinetune ports = [7140, 7141, 7142, 7143, 7144, 71...
HotPotQA(train_seed=1, train_size=3000, eval_seed=2023, dev_size=0, test_size=0)
dspy.datasets.hotpotqa.HotPotQA
get_ipython().run_line_magic('load_ext', 'autoreload') get_ipython().run_line_magic('autoreload', '2') import sys import os try: # When on google Colab, let's clone the notebook so we download the cache. import google.colab repo_path = 'dspy' get_ipython().system('git -C $repo_path pull origin || git clon...
dspy.Retrieve(k=num_passages)
dspy.Retrieve
get_ipython().system('git clone https://huggingface.co/arnavs11/DSPy_QuizGen_Cache') get_ipython().run_line_magic('cd', 'DSPy_QuizGen_Cache/') get_ipython().system('git checkout master') get_ipython().run_line_magic('cd', '..') import os repo_clone_path = '/content/DSPy_QuizGen_Cache' if not os.access('/content', os.W...
dspy.InputField()
dspy.InputField
get_ipython().system('pip install clarifai') get_ipython().system('pip install dspy-ai') import dspy from dspy.retrieve.clarifai_rm import ClarifaiRM MODEL_URL = "https://clarifai.com/meta/Llama-2/models/llama2-70b-chat" PAT = "CLARIFAI_PAT" USER_ID = "YOUR_ID" APP_ID = "YOUR_APP" from langchain.text_spli...
dspy.ChainOfThought(GenerateAnswer)
dspy.ChainOfThought
import dspy from dspy.evaluate.evaluate import Evaluate from dspy.teleprompt import BootstrapFewShotWithRandomSearch colbertv2 = dspy.ColBERTv2(url='http://20.102.90.50:2017/wiki17_abstracts') dspy.configure(rm=colbertv2) from langchain_openai import OpenAI from langchain.globals import set_llm_cache from langcha...
LangChainPredict(prompt, llm)
dspy.predict.langchain.LangChainPredict
get_ipython().run_line_magic('load_ext', 'autoreload') get_ipython().run_line_magic('autoreload', '2') import sys import pkg_resources try: # When on Colab, let's install pyserini, Pytorch, and Faiss import google.colab repo_path = 'dspy' get_ipython().system('git -C $repo_path pull origin || git clone h...
dspy.Pyserini(index='indexes/faiss.nfcorpus.contriever-msmarco', query_encoder='facebook/contriever-msmarco', dataset=dataset, id_field='_id', text_fields=['title', 'text'])
dspy.Pyserini
get_ipython().system('pip install clarifai') get_ipython().system('pip install dspy-ai') import dspy from dspy.retrieve.clarifai_rm import ClarifaiRM MODEL_URL = "https://clarifai.com/meta/Llama-2/models/llama2-70b-chat" PAT = "CLARIFAI_PAT" USER_ID = "YOUR_ID" APP_ID = "YOUR_APP" from langchain.text_spli...
dspy.settings.configure(lm=gemini_lm, rm=retriever_model)
dspy.settings.configure
get_ipython().system('git clone https://huggingface.co/arnavs11/DSPy_LongFormQA_Cache') get_ipython().run_line_magic('cd', 'DSPy_LongFormQA_Cache/') get_ipython().system('git checkout master') get_ipython().run_line_magic('cd', '..') import os repo_clone_path = '/content/DSPy_LongFormQA_Cache' if not os.access('/conte...
dspy.Retrieve(k=passages_per_hop)
dspy.Retrieve
import dspy from dsp.utils import deduplicate from dspy.datasets import HotPotQA from dspy.predict.retry import Retry from dspy.teleprompt import BootstrapFewShot, BootstrapFewShotWithRandomSearch from dspy.evaluate.evaluate import Evaluate from dspy.primitives.assertions import assert_transform_module, backtrack_hand...
dspy.OutputField()
dspy.OutputField
get_ipython().run_line_magic('load_ext', 'autoreload') get_ipython().run_line_magic('autoreload', '2') import sys import os try: # When on google Colab, let's clone the notebook so we download the cache. import google.colab repo_path = 'dspy' get_ipython().system('git -C $repo_path pull origin || git clon...
dspy.evaluate.answer_exact_match_str(hops[idx], hops[:idx], frac=0.8)
dspy.evaluate.answer_exact_match_str
get_ipython().system('git clone https://huggingface.co/arnavs11/DSPy_TweetGen_Cache') get_ipython().run_line_magic('cd', 'DSPy_TweetGen_Cache/') get_ipython().system('git checkout master') get_ipython().run_line_magic('cd', '..') import os repo_clone_path = '/content/DSPy_TweetGen_Cache' if not os.access('/content', o...
dspy.Retrieve(k=passages_per_hop)
dspy.Retrieve
get_ipython().system('git clone https://huggingface.co/arnavs11/DSPy_TweetGen_Cache') get_ipython().run_line_magic('cd', 'DSPy_TweetGen_Cache/') get_ipython().system('git checkout master') get_ipython().run_line_magic('cd', '..') import os repo_clone_path = '/content/DSPy_TweetGen_Cache' if not os.access('/content', o...
dspy.ChainOfThought(GenerateTweet)
dspy.ChainOfThought
import dspy from dsp.utils import deduplicate from dspy.datasets import HotPotQA from dspy.predict.retry import Retry from dspy.teleprompt import BootstrapFewShot, BootstrapFewShotWithRandomSearch from dspy.evaluate.evaluate import Evaluate from dspy.primitives.assertions import assert_transform_module, backtrack_hand...
dspy.ColBERTv2(url='http://20.102.90.50:2017/wiki17_abstracts')
dspy.ColBERTv2
get_ipython().run_line_magic('load_ext', 'autoreload') get_ipython().run_line_magic('autoreload', '2') import sys import os try: # When on google Colab, let's clone the notebook so we download the cache. import google.colab repo_path = 'dspy' get_ipython().system('git -C $repo_path pull origin || git clon...
dspy.ChainOfThought("context, question -> search_query")
dspy.ChainOfThought
get_ipython().system('git clone https://huggingface.co/arnavs11/DSPy_QuizGen_Cache') get_ipython().run_line_magic('cd', 'DSPy_QuizGen_Cache/') get_ipython().system('git checkout master') get_ipython().run_line_magic('cd', '..') import os repo_clone_path = '/content/DSPy_QuizGen_Cache' if not os.access('/content', os.W...
dspy.InputField()
dspy.InputField
get_ipython().system('git clone https://huggingface.co/arnavs11/DSPy_LongFormQA_Cache') get_ipython().run_line_magic('cd', 'DSPy_LongFormQA_Cache/') get_ipython().system('git checkout master') get_ipython().run_line_magic('cd', '..') import os repo_clone_path = '/content/DSPy_LongFormQA_Cache' if not os.access('/conte...
dspy.settings.configure(lm=turbo, trace=[], temperature=0.7)
dspy.settings.configure
get_ipython().system('git clone https://huggingface.co/arnavs11/DSPy_TweetGen_Cache') get_ipython().run_line_magic('cd', 'DSPy_TweetGen_Cache/') get_ipython().system('git checkout master') get_ipython().run_line_magic('cd', '..') import os repo_clone_path = '/content/DSPy_TweetGen_Cache' if not os.access('/content', o...
BootstrapFewShotWithRandomSearch(metric = overall_metric, max_bootstrapped_demos=2, num_candidate_programs=6)
dspy.teleprompt.BootstrapFewShotWithRandomSearch
get_ipython().run_line_magic('load_ext', 'autoreload') get_ipython().run_line_magic('autoreload', '2') import dspy from dspy.evaluate import Evaluate from dspy.datasets.hotpotqa import HotPotQA from dspy.teleprompt import BootstrapFewShotWithRandomSearch, BootstrapFinetune ports = [7140, 7141, 7142, 7143, 7144, 71...
dspy.settings.configure(rm=colbertv2, lm=llamaChat)
dspy.settings.configure
get_ipython().run_line_magic('load_ext', 'autoreload') get_ipython().run_line_magic('autoreload', '2') import sys import os try: # When on google Colab, let's clone the notebook so we download the cache. import google.colab repo_path = 'dspy' get_ipython().system('git -C $repo_path pull origin || git clon...
dspy.Retrieve(k=3)
dspy.Retrieve
get_ipython().system('pip install clarifai') get_ipython().system('pip install dspy-ai') import dspy from dspy.retrieve.clarifai_rm import ClarifaiRM MODEL_URL = "https://clarifai.com/meta/Llama-2/models/llama2-70b-chat" PAT = "CLARIFAI_PAT" USER_ID = "YOUR_ID" APP_ID = "YOUR_APP" from langchain.text_spli...
dspy.InputField(desc="may contain relevant facts about user query")
dspy.InputField
import glob import os import pandas as pd import random import dspy from dspy.evaluate import Evaluate from dspy.teleprompt import BootstrapFewShotWithRandomSearch os.environ["DSP_NOTEBOOK_CACHEDIR"] = os.path.join('.', 'cache') turbo = dspy.OpenAI(model='gpt-3.5-turbo-1106', max_tokens=250, model_type='chat') d...
dspy.ChainOfThought(ScoNeSignature)
dspy.ChainOfThought
get_ipython().run_line_magic('load_ext', 'autoreload') get_ipython().run_line_magic('autoreload', '2') get_ipython().run_line_magic('pip', 'install datasets') import datasets ds = datasets.load_dataset("openai_humaneval") ds['test'][0] import dspy, dotenv, os dotenv.load_dotenv(os.path.expanduser("~/.env")) # lo...
TypedPredictor(CodeSignature)
dspy.functional.TypedPredictor
get_ipython().system('git clone https://huggingface.co/arnavs11/DSPy_TweetGen_Cache') get_ipython().run_line_magic('cd', 'DSPy_TweetGen_Cache/') get_ipython().system('git checkout master') get_ipython().run_line_magic('cd', '..') import os repo_clone_path = '/content/DSPy_TweetGen_Cache' if not os.access('/content', o...
Evaluate(metric=metric, devset=devset[10:11], num_threads=1, display_progress=True, display_table=5)
dspy.evaluate.evaluate.Evaluate
get_ipython().system('git clone https://huggingface.co/arnavs11/DSPy_TweetGen_Cache') get_ipython().run_line_magic('cd', 'DSPy_TweetGen_Cache/') get_ipython().system('git checkout master') get_ipython().run_line_magic('cd', '..') import os repo_clone_path = '/content/DSPy_TweetGen_Cache' if not os.access('/content', o...
dspy.Predict(AssessTweet)
dspy.Predict
import openai import dspy import json with open("creds.json", "r") as creds: api_key = json.loads(creds.read())["openai_key"] lm = dspy.OpenAI(model='gpt-4', api_key=api_key, model_type='chat', max_tokens = 500) dspy.settings.configure(lm=lm) from dspy.datasets import HotPotQA dataset = HotPotQA(train_seed=1...
dspy.OutputField(desc="often between 1 and 5 words")
dspy.OutputField
get_ipython().run_line_magic('load_ext', 'autoreload') get_ipython().run_line_magic('autoreload', '2') import sys import os try: # When on google Colab, let's clone the notebook so we download the cache. import google.colab repo_path = 'dspy' get_ipython().system('git -C $repo_path pull origin || git clon...
dspy.Retrieve(k=num_passages)
dspy.Retrieve
import dspy from dsp.utils import deduplicate from dspy.datasets import HotPotQA from dspy.predict.retry import Retry from dspy.teleprompt import BootstrapFewShot, BootstrapFewShotWithRandomSearch from dspy.evaluate.evaluate import Evaluate from dspy.primitives.assertions import assert_transform_module, backtrack_hand...
dspy.evaluate.answer_exact_match(example, pred)
dspy.evaluate.answer_exact_match
get_ipython().run_line_magic('load_ext', 'autoreload') get_ipython().run_line_magic('autoreload', '2') import sys import os try: # When on google Colab, let's clone the notebook so we download the cache. import google.colab repo_path = 'dspy' get_ipython().system('git -C $repo_path pull origin || git clon...
dspy.settings.configure(rm=colbertv2, lm=llama)
dspy.settings.configure
get_ipython().run_line_magic('load_ext', 'autoreload') get_ipython().run_line_magic('autoreload', '2') import sys import os try: # When on google Colab, let's clone the notebook so we download the cache. import google.colab repo_path = 'dspy' get_ipython().system('git -C $repo_path pull origin || git clon...
dspy.evaluate.answer_exact_match(example, pred)
dspy.evaluate.answer_exact_match
get_ipython().system('git clone https://huggingface.co/arnavs11/DSPy_TweetGen_Cache') get_ipython().run_line_magic('cd', 'DSPy_TweetGen_Cache/') get_ipython().system('git checkout master') get_ipython().run_line_magic('cd', '..') import os repo_clone_path = '/content/DSPy_TweetGen_Cache' if not os.access('/content', o...
dspy.Predict(AssessTweet)
dspy.Predict
import dspy from dsp.utils import deduplicate from dspy.datasets import HotPotQA from dspy.predict.retry import Retry from dspy.teleprompt import BootstrapFewShot, BootstrapFewShotWithRandomSearch from dspy.evaluate.evaluate import Evaluate from dspy.primitives.assertions import assert_transform_module, backtrack_hand...
Evaluate(devset=devset, num_threads=10, display_progress=True, display_table=False)
dspy.evaluate.evaluate.Evaluate
get_ipython().system('pip install clarifai') get_ipython().system('pip install dspy-ai') import dspy from dspy.retrieve.clarifai_rm import ClarifaiRM MODEL_URL = "https://clarifai.com/meta/Llama-2/models/llama2-70b-chat" PAT = "CLARIFAI_PAT" USER_ID = "YOUR_ID" APP_ID = "YOUR_APP" from langchain.text_spli...
dspy.Retrieve()
dspy.Retrieve
get_ipython().system('git clone https://huggingface.co/arnavs11/DSPy_TweetGen_Cache') get_ipython().run_line_magic('cd', 'DSPy_TweetGen_Cache/') get_ipython().system('git checkout master') get_ipython().run_line_magic('cd', '..') import os repo_clone_path = '/content/DSPy_TweetGen_Cache' if not os.access('/content', o...
dspy.Predict(AssessTweet)
dspy.Predict
get_ipython().system('git clone https://huggingface.co/arnavs11/DSPy_QuizGen_Cache') get_ipython().run_line_magic('cd', 'DSPy_QuizGen_Cache/') get_ipython().system('git checkout master') get_ipython().run_line_magic('cd', '..') import os repo_clone_path = '/content/DSPy_QuizGen_Cache' if not os.access('/content', os.W...
dspy.InputField()
dspy.InputField
get_ipython().system('git clone https://huggingface.co/arnavs11/DSPy_QuizGen_Cache') get_ipython().run_line_magic('cd', 'DSPy_QuizGen_Cache/') get_ipython().system('git checkout master') get_ipython().run_line_magic('cd', '..') import os repo_clone_path = '/content/DSPy_QuizGen_Cache' if not os.access('/content', os.W...
dspy.Predict(AssessQuizChoices)
dspy.Predict
get_ipython().system('git clone https://huggingface.co/arnavs11/DSPy_QuizGen_Cache') get_ipython().run_line_magic('cd', 'DSPy_QuizGen_Cache/') get_ipython().system('git checkout master') get_ipython().run_line_magic('cd', '..') import os repo_clone_path = '/content/DSPy_QuizGen_Cache' if not os.access('/content', os.W...
Evaluate(metric=metric, devset=devset, num_threads=1, display_progress=True, display_table=5)
dspy.evaluate.evaluate.Evaluate
get_ipython().system('git clone https://huggingface.co/arnavs11/DSPy_QuizGen_Cache') get_ipython().run_line_magic('cd', 'DSPy_QuizGen_Cache/') get_ipython().system('git checkout master') get_ipython().run_line_magic('cd', '..') import os repo_clone_path = '/content/DSPy_QuizGen_Cache' if not os.access('/content', os.W...
Evaluate(metric=metric, devset=devset[38:39], num_threads=1, display_progress=True, display_table=30)
dspy.evaluate.evaluate.Evaluate
get_ipython().system('git clone https://huggingface.co/arnavs11/DSPy_TweetGen_Cache') get_ipython().run_line_magic('cd', 'DSPy_TweetGen_Cache/') get_ipython().system('git checkout master') get_ipython().run_line_magic('cd', '..') import os repo_clone_path = '/content/DSPy_TweetGen_Cache' if not os.access('/content', o...
Evaluate(metric=metric, devset=devset, num_threads=1, display_progress=True, display_table=5)
dspy.evaluate.evaluate.Evaluate
get_ipython().system('pip install clarifai') get_ipython().system('pip install dspy-ai') import dspy from dspy.retrieve.clarifai_rm import ClarifaiRM MODEL_URL = "https://clarifai.com/meta/Llama-2/models/llama2-70b-chat" PAT = "CLARIFAI_PAT" USER_ID = "YOUR_ID" APP_ID = "YOUR_APP" from langchain.text_spli...
dspy.Clarifai(model="https://clarifai.com/mistralai/completion/models/mistral-7B-Instruct", api_key=PAT, n=2, inference_params={'temperature':0.6})
dspy.Clarifai
get_ipython().run_line_magic('load_ext', 'autoreload') get_ipython().run_line_magic('autoreload', '2') import sys import os try: # When on google Colab, let's clone the notebook so we download the cache. import google.colab repo_path = 'dspy' get_ipython().system('git -C $repo_path pull origin || git clon...
dspy.OpenAI(model='gpt-3.5-turbo')
dspy.OpenAI
import glob import os import pandas as pd import random import dspy from dspy.evaluate import Evaluate from dspy.teleprompt import BootstrapFewShotWithRandomSearch os.environ["DSP_NOTEBOOK_CACHEDIR"] = os.path.join('.', 'cache') turbo = dspy.OpenAI(model='gpt-3.5-turbo-1106', max_tokens=250, model_type='chat') d...
dspy.InputField()
dspy.InputField
get_ipython().run_line_magic('load_ext', 'autoreload') get_ipython().run_line_magic('autoreload', '2') import sys import os try: # When on google Colab, let's clone the notebook so we download the cache. import google.colab repo_path = 'dspy' get_ipython().system('git -C $repo_path pull origin || git clon...
dspy.ColBERTv2(url='http://20.102.90.50:2017/wiki17_abstracts')
dspy.ColBERTv2
import glob import os import pandas as pd import random import dspy from dspy.evaluate import Evaluate from dspy.teleprompt import BootstrapFewShotWithRandomSearch os.environ["DSP_NOTEBOOK_CACHEDIR"] = os.path.join('.', 'cache') turbo =
dspy.OpenAI(model='gpt-3.5-turbo-1106', max_tokens=250, model_type='chat')
dspy.OpenAI
get_ipython().system('pip install clarifai') get_ipython().system('pip install dspy-ai') import dspy from dspy.retrieve.clarifai_rm import ClarifaiRM MODEL_URL = "https://clarifai.com/meta/Llama-2/models/llama2-70b-chat" PAT = "CLARIFAI_PAT" USER_ID = "YOUR_ID" APP_ID = "YOUR_APP" from langchain.text_spli...
dspy.InputField(desc="User query")
dspy.InputField
get_ipython().system('git clone https://huggingface.co/arnavs11/DSPy_TweetGen_Cache') get_ipython().run_line_magic('cd', 'DSPy_TweetGen_Cache/') get_ipython().system('git checkout master') get_ipython().run_line_magic('cd', '..') import os repo_clone_path = '/content/DSPy_TweetGen_Cache' if not os.access('/content', o...
dspy.settings.configure(rm=colbertv2_wiki17_abstracts)
dspy.settings.configure
get_ipython().run_line_magic('load_ext', 'autoreload') get_ipython().run_line_magic('autoreload', '2') import sys import os try: # When on google Colab, let's clone the notebook so we download the cache. import google.colab repo_path = 'dspy' get_ipython().system('git -C $repo_path pull origin || git clon...
dspy.ColBERTv2(url='http://20.102.90.50:2017/wiki17_abstracts')
dspy.ColBERTv2
get_ipython().system('git clone https://huggingface.co/arnavs11/DSPy_LongFormQA_Cache') get_ipython().run_line_magic('cd', 'DSPy_LongFormQA_Cache/') get_ipython().system('git checkout master') get_ipython().run_line_magic('cd', '..') import os repo_clone_path = '/content/DSPy_LongFormQA_Cache' if not os.access('/conte...
dspy.InputField(desc="between 1 to 2 sentences")
dspy.InputField
get_ipython().system('git clone https://huggingface.co/arnavs11/DSPy_LongFormQA_Cache') get_ipython().run_line_magic('cd', 'DSPy_LongFormQA_Cache/') get_ipython().system('git checkout master') get_ipython().run_line_magic('cd', '..') import os repo_clone_path = '/content/DSPy_LongFormQA_Cache' if not os.access('/conte...
dspy.OpenAI(model='gpt-3.5-turbo', max_tokens=500)
dspy.OpenAI
import dspy from dsp.utils import deduplicate from dspy.datasets import HotPotQA from dspy.predict.retry import Retry from dspy.teleprompt import BootstrapFewShot, BootstrapFewShotWithRandomSearch from dspy.evaluate.evaluate import Evaluate from dspy.primitives.assertions import assert_transform_module, backtrack_hand...
dspy.Retrieve(k=passages_per_hop)
dspy.Retrieve
get_ipython().run_line_magic('load_ext', 'autoreload') get_ipython().run_line_magic('autoreload', '2') import sys import os try: # When on google Colab, let's clone the notebook so we download the cache. import google.colab repo_path = 'dspy' get_ipython().system('git -C $repo_path pull origin || git clon...
dspy.settings.configure(lm=turbo, rm=colbertv2_wiki17_abstracts)
dspy.settings.configure
get_ipython().system('pip install clarifai') get_ipython().system('pip install dspy-ai') import dspy from dspy.retrieve.clarifai_rm import ClarifaiRM MODEL_URL = "https://clarifai.com/meta/Llama-2/models/llama2-70b-chat" PAT = "CLARIFAI_PAT" USER_ID = "YOUR_ID" APP_ID = "YOUR_APP" from langchain.text_spli...
dspy.Prediction(context=context, answer=prediction.answer)
dspy.Prediction
import openai import dspy import json with open("creds.json", "r") as creds: api_key = json.loads(creds.read())["openai_key"] lm = dspy.OpenAI(model='gpt-4', api_key=api_key, model_type='chat', max_tokens = 500) dspy.settings.configure(lm=lm) from dspy.datasets import HotPotQA dataset = HotPotQA(train_seed=1...
dspy.InputField()
dspy.InputField
get_ipython().system('git clone https://huggingface.co/arnavs11/DSPy_LongFormQA_Cache') get_ipython().run_line_magic('cd', 'DSPy_LongFormQA_Cache/') get_ipython().system('git checkout master') get_ipython().run_line_magic('cd', '..') import os repo_clone_path = '/content/DSPy_LongFormQA_Cache' if not os.access('/conte...
dspy.Prediction(context=context, paragraph=pred.paragraph)
dspy.Prediction
get_ipython().system('pip install clarifai') get_ipython().system('pip install dspy-ai') import dspy from dspy.retrieve.clarifai_rm import ClarifaiRM MODEL_URL = "https://clarifai.com/meta/Llama-2/models/llama2-70b-chat" PAT = "CLARIFAI_PAT" USER_ID = "YOUR_ID" APP_ID = "YOUR_APP" from langchain.text_spli...
dspy.Clarifai(model=MODEL_URL, api_key=PAT, n=2, inference_params={"max_tokens":100,'temperature':0.6})
dspy.Clarifai
get_ipython().run_line_magic('load_ext', 'autoreload') get_ipython().run_line_magic('autoreload', '2') import sys import os try: # When on google Colab, let's clone the notebook so we download the cache. import google.colab repo_path = 'dspy' get_ipython().system('git -C $repo_path pull origin || git clon...
dspy.ChainOfThought(GenerateAnswer)
dspy.ChainOfThought
import dspy from dsp.utils import deduplicate from dspy.datasets import HotPotQA from dspy.predict.retry import Retry from dspy.teleprompt import BootstrapFewShot, BootstrapFewShotWithRandomSearch from dspy.evaluate.evaluate import Evaluate from dspy.primitives.assertions import assert_transform_module, backtrack_hand...
dspy.ChainOfThought(GenerateSearchQuery)
dspy.ChainOfThought
get_ipython().system('git clone https://huggingface.co/arnavs11/DSPy_TweetGen_Cache') get_ipython().run_line_magic('cd', 'DSPy_TweetGen_Cache/') get_ipython().system('git checkout master') get_ipython().run_line_magic('cd', '..') import os repo_clone_path = '/content/DSPy_TweetGen_Cache' if not os.access('/content', o...
dspy.Predict(AssessTweet)
dspy.Predict
get_ipython().system('git clone https://huggingface.co/arnavs11/DSPy_LongFormQA_Cache') get_ipython().run_line_magic('cd', 'DSPy_LongFormQA_Cache/') get_ipython().system('git checkout master') get_ipython().run_line_magic('cd', '..') import os repo_clone_path = '/content/DSPy_LongFormQA_Cache' if not os.access('/conte...
BootstrapFewShotWithRandomSearch(metric = answer_correctness, max_bootstrapped_demos=2, num_candidate_programs=6)
dspy.teleprompt.BootstrapFewShotWithRandomSearch
get_ipython().run_line_magic('load_ext', 'autoreload') get_ipython().run_line_magic('autoreload', '2') import sys import os try: # When on google Colab, let's clone the notebook so we download the cache. import google.colab repo_path = 'dspy' get_ipython().system('git -C $repo_path pull origin || git clon...
dspy.Retrieve(k=num_passages)
dspy.Retrieve
get_ipython().run_line_magic('load_ext', 'autoreload') get_ipython().run_line_magic('autoreload', '2') import dspy from dspy.evaluate import Evaluate from dspy.datasets.hotpotqa import HotPotQA from dspy.teleprompt import BootstrapFewShotWithRandomSearch, BootstrapFinetune ports = [7140, 7141, 7142, 7143, 7144, 71...
BootstrapFewShotWithRandomSearch(metric=metric_EM, max_bootstrapped_demos=2, num_threads=NUM_THREADS)
dspy.teleprompt.BootstrapFewShotWithRandomSearch
get_ipython().run_line_magic('load_ext', 'autoreload') get_ipython().run_line_magic('autoreload', '2') import sys import os try: # When on google Colab, let's clone the notebook so we download the cache. import google.colab repo_path = 'dspy' get_ipython().system('git -C $repo_path pull origin || git clon...
dspy.OutputField(desc="often between 1 and 5 words")
dspy.OutputField
get_ipython().system('git clone https://huggingface.co/arnavs11/DSPy_LongFormQA_Cache') get_ipython().run_line_magic('cd', 'DSPy_LongFormQA_Cache/') get_ipython().system('git checkout master') get_ipython().run_line_magic('cd', '..') import os repo_clone_path = '/content/DSPy_LongFormQA_Cache' if not os.access('/conte...
dspy.InputField(desc="may contain relevant facts")
dspy.InputField
get_ipython().run_line_magic('load_ext', 'autoreload') get_ipython().run_line_magic('autoreload', '2') import dspy from dspy.evaluate import Evaluate from dspy.datasets.hotpotqa import HotPotQA from dspy.teleprompt import BootstrapFewShotWithRandomSearch, BootstrapFinetune ports = [7140, 7141, 7142, 7143, 7144, 71...
dspy.ChainOfThought("context, question -> search_query")
dspy.ChainOfThought
get_ipython().run_line_magic('load_ext', 'autoreload') get_ipython().run_line_magic('autoreload', '2') import sys import os try: # When on google Colab, let's clone the notebook so we download the cache. import google.colab repo_path = 'dspy' get_ipython().system('git -C $repo_path pull origin || git clon...
BootstrapFewShot(metric=metric_EM, max_bootstrapped_demos=2)
dspy.teleprompt.BootstrapFewShot
get_ipython().system('git clone https://huggingface.co/arnavs11/DSPy_QuizGen_Cache') get_ipython().run_line_magic('cd', 'DSPy_QuizGen_Cache/') get_ipython().system('git checkout master') get_ipython().run_line_magic('cd', '..') import os repo_clone_path = '/content/DSPy_QuizGen_Cache' if not os.access('/content', os.W...
dspy.Predict(AssessQuizChoices)
dspy.Predict
get_ipython().system('git clone https://huggingface.co/arnavs11/DSPy_TweetGen_Cache') get_ipython().run_line_magic('cd', 'DSPy_TweetGen_Cache/') get_ipython().system('git checkout master') get_ipython().run_line_magic('cd', '..') import os repo_clone_path = '/content/DSPy_TweetGen_Cache' if not os.access('/content', o...
dspy.ChainOfThought(GenerateTweet)
dspy.ChainOfThought
get_ipython().system('git clone https://huggingface.co/arnavs11/DSPy_TweetGen_Cache') get_ipython().run_line_magic('cd', 'DSPy_TweetGen_Cache/') get_ipython().system('git checkout master') get_ipython().run_line_magic('cd', '..') import os repo_clone_path = '/content/DSPy_TweetGen_Cache' if not os.access('/content', o...
dspy.settings.configure(lm=turbo, trace=[], temperature=0.7)
dspy.settings.configure
get_ipython().run_line_magic('load_ext', 'autoreload') get_ipython().run_line_magic('autoreload', '2') import sys import os try: # When on google Colab, let's clone the notebook so we download the cache. import google.colab repo_path = 'dspy' get_ipython().system('git -C $repo_path pull origin || git clon...
dspy.OutputField()
dspy.OutputField
import glob import os import pandas as pd import random import dspy from dspy.evaluate import Evaluate from dspy.teleprompt import BootstrapFewShotWithRandomSearch os.environ["DSP_NOTEBOOK_CACHEDIR"] = os.path.join('.', 'cache') turbo = dspy.OpenAI(model='gpt-3.5-turbo-1106', max_tokens=250, model_type='chat') d...
Evaluate(devset=test, num_threads=1, display_progress=True, display_table=0)
dspy.evaluate.Evaluate
get_ipython().system('pip install clarifai') get_ipython().system('pip install dspy-ai') import dspy from dspy.retrieve.clarifai_rm import ClarifaiRM MODEL_URL = "https://clarifai.com/meta/Llama-2/models/llama2-70b-chat" PAT = "CLARIFAI_PAT" USER_ID = "YOUR_ID" APP_ID = "YOUR_APP" from langchain.text_spli...
ClarifaiRM(clarifai_user_id=USER_ID, clarfiai_app_id=APP_ID, clarifai_pat=PAT, k=2)
dspy.retrieve.clarifai_rm.ClarifaiRM
get_ipython().system('git clone https://huggingface.co/arnavs11/DSPy_QuizGen_Cache') get_ipython().run_line_magic('cd', 'DSPy_QuizGen_Cache/') get_ipython().system('git checkout master') get_ipython().run_line_magic('cd', '..') import os repo_clone_path = '/content/DSPy_QuizGen_Cache' if not os.access('/content', os.W...
dspy.OutputField(desc='JSON key-value pairs')
dspy.OutputField
import dspy from dsp.utils import deduplicate from dspy.datasets import HotPotQA from dspy.predict.retry import Retry from dspy.teleprompt import BootstrapFewShot, BootstrapFewShotWithRandomSearch from dspy.evaluate.evaluate import Evaluate from dspy.primitives.assertions import assert_transform_module, backtrack_hand...
dspy.InputField(desc="may contain relevant facts")
dspy.InputField
import glob import os import pandas as pd import random import dspy from dspy.evaluate import Evaluate from dspy.teleprompt import BootstrapFewShotWithRandomSearch os.environ["DSP_NOTEBOOK_CACHEDIR"] = os.path.join('.', 'cache') turbo = dspy.OpenAI(model='gpt-3.5-turbo-1106', max_tokens=250, model_type='chat') d...
dspy.OpenAI(model='gpt-4-1106-preview', max_tokens=350, model_type='chat')
dspy.OpenAI
get_ipython().run_line_magic('load_ext', 'autoreload') get_ipython().run_line_magic('autoreload', '2') import sys import os try: # When on google Colab, let's clone the notebook so we download the cache. import google.colab repo_path = 'dspy' get_ipython().system('git -C $repo_path pull origin || git clon...
dspy.InputField()
dspy.InputField
get_ipython().system('git clone https://huggingface.co/arnavs11/DSPy_TweetGen_Cache') get_ipython().run_line_magic('cd', 'DSPy_TweetGen_Cache/') get_ipython().system('git checkout master') get_ipython().run_line_magic('cd', '..') import os repo_clone_path = '/content/DSPy_TweetGen_Cache' if not os.access('/content', o...
dspy.ChainOfThought(GenerateSearchQuery)
dspy.ChainOfThought
get_ipython().run_line_magic('load_ext', 'autoreload') get_ipython().run_line_magic('autoreload', '2') import dspy from dspy.evaluate import Evaluate from dspy.datasets.hotpotqa import HotPotQA from dspy.teleprompt import BootstrapFewShotWithRandomSearch, BootstrapFinetune ports = [7140, 7141, 7142, 7143, 7144, 71...
HotPotQA(train_seed=1, train_size=200, eval_seed=2023, dev_size=1000, test_size=0)
dspy.datasets.hotpotqa.HotPotQA
import dspy from dsp.utils import deduplicate from dspy.datasets import HotPotQA from dspy.predict.retry import Retry from dspy.teleprompt import BootstrapFewShot, BootstrapFewShotWithRandomSearch from dspy.evaluate.evaluate import Evaluate from dspy.primitives.assertions import assert_transform_module, backtrack_hand...
dspy.settings.configure(rm=colbertv2_wiki17_abstracts)
dspy.settings.configure
get_ipython().run_line_magic('load_ext', 'autoreload') get_ipython().run_line_magic('autoreload', '2') get_ipython().run_line_magic('pip', 'install datasets') import datasets ds = datasets.load_dataset("openai_humaneval") ds['test'][0] import dspy, dotenv, os dotenv.load_dotenv(os.path.expanduser("~/.env")) # lo...
InputField()
dspy.InputField
get_ipython().system('git clone https://huggingface.co/arnavs11/DSPy_TweetGen_Cache') get_ipython().run_line_magic('cd', 'DSPy_TweetGen_Cache/') get_ipython().system('git checkout master') get_ipython().run_line_magic('cd', '..') import os repo_clone_path = '/content/DSPy_TweetGen_Cache' if not os.access('/content', o...
dspy.ColBERTv2(url='http://20.102.90.50:2017/wiki17_abstracts')
dspy.ColBERTv2
import dspy from dsp.utils import deduplicate from dspy.datasets import HotPotQA from dspy.predict.retry import Retry from dspy.teleprompt import BootstrapFewShot, BootstrapFewShotWithRandomSearch from dspy.evaluate.evaluate import Evaluate from dspy.primitives.assertions import assert_transform_module, backtrack_hand...
dspy.Prediction(context=context, answer=pred.answer)
dspy.Prediction
get_ipython().system('git clone https://huggingface.co/arnavs11/DSPy_QuizGen_Cache') get_ipython().run_line_magic('cd', 'DSPy_QuizGen_Cache/') get_ipython().system('git checkout master') get_ipython().run_line_magic('cd', '..') import os repo_clone_path = '/content/DSPy_QuizGen_Cache' if not os.access('/content', os.W...
BootstrapFewShotWithRandomSearch(metric = overall_metric, max_bootstrapped_demos=2, num_candidate_programs=6)
dspy.teleprompt.BootstrapFewShotWithRandomSearch
get_ipython().run_line_magic('load_ext', 'autoreload') get_ipython().run_line_magic('autoreload', '2') import sys import os try: # When on google Colab, let's clone the notebook so we download the cache. import google.colab repo_path = 'dspy' get_ipython().system('git -C $repo_path pull origin || git clon...
dspy.evaluate.answer_passage_match(example, pred)
dspy.evaluate.answer_passage_match
get_ipython().run_line_magic('load_ext', 'autoreload') get_ipython().run_line_magic('autoreload', '2') import sys import os try: # When on google Colab, let's clone the notebook so we download the cache. import google.colab repo_path = 'dspy' get_ipython().system('git -C $repo_path pull origin || git clon...
dspy.ChainOfThought("question -> search_query")
dspy.ChainOfThought
get_ipython().system('pip install clarifai') get_ipython().system('pip install dspy-ai') import dspy from dspy.retrieve.clarifai_rm import ClarifaiRM MODEL_URL = "https://clarifai.com/meta/Llama-2/models/llama2-70b-chat" PAT = "CLARIFAI_PAT" USER_ID = "YOUR_ID" APP_ID = "YOUR_APP" from langchain.text_spli...
dspy.Predict('sentence -> sentiment')
dspy.Predict
get_ipython().run_line_magic('load_ext', 'autoreload') get_ipython().run_line_magic('autoreload', '2') import sys import os try: # When on google Colab, let's clone the notebook so we download the cache. import google.colab repo_path = 'dspy' get_ipython().system('git -C $repo_path pull origin || git clon...
dspy.Predict('question -> answer')
dspy.Predict
get_ipython().run_line_magic('load_ext', 'autoreload') get_ipython().run_line_magic('autoreload', '2') get_ipython().run_line_magic('pip', 'install datasets') import datasets ds = datasets.load_dataset("openai_humaneval") ds['test'][0] import dspy, dotenv, os dotenv.load_dotenv(os.path.expanduser("~/.env")) # lo...
InputField()
dspy.InputField
get_ipython().run_line_magic('load_ext', 'autoreload') get_ipython().run_line_magic('autoreload', '2') import dspy from dspy.evaluate import Evaluate from dspy.datasets.hotpotqa import HotPotQA from dspy.teleprompt import BootstrapFewShotWithRandomSearch, BootstrapFinetune ports = [7140, 7141, 7142, 7143, 7144, 71...
dspy.Retrieve(k=passages_per_hop)
dspy.Retrieve
get_ipython().run_line_magic('load_ext', 'autoreload') get_ipython().run_line_magic('autoreload', '2') import sys import os try: # When on google Colab, let's clone the notebook so we download the cache. import google.colab repo_path = 'dspy' get_ipython().system('git -C $repo_path pull origin || git clon...
dspy.ChainOfThought("context, question -> answer")
dspy.ChainOfThought
get_ipython().system('git clone https://huggingface.co/arnavs11/DSPy_TweetGen_Cache') get_ipython().run_line_magic('cd', 'DSPy_TweetGen_Cache/') get_ipython().system('git checkout master') get_ipython().run_line_magic('cd', '..') import os repo_clone_path = '/content/DSPy_TweetGen_Cache' if not os.access('/content', o...
BootstrapFewShotWithRandomSearch(metric = overall_metric, max_bootstrapped_demos=2, num_candidate_programs=6, num_threads=1)
dspy.teleprompt.BootstrapFewShotWithRandomSearch
get_ipython().run_line_magic('load_ext', 'autoreload') get_ipython().run_line_magic('autoreload', '2') import sys import pkg_resources try: # When on Colab, let's install pyserini, Pytorch, and Faiss import google.colab repo_path = 'dspy' get_ipython().system('git -C $repo_path pull origin || git clone h...
dspy.Retrieve(k=3)
dspy.Retrieve
get_ipython().system('git clone https://huggingface.co/arnavs11/DSPy_LongFormQA_Cache') get_ipython().run_line_magic('cd', 'DSPy_LongFormQA_Cache/') get_ipython().system('git checkout master') get_ipython().run_line_magic('cd', '..') import os repo_clone_path = '/content/DSPy_LongFormQA_Cache' if not os.access('/conte...
dspy.ChainOfThought(CheckCitationFaithfulness)
dspy.ChainOfThought
get_ipython().run_line_magic('load_ext', 'autoreload') get_ipython().run_line_magic('autoreload', '2') import sys import os try: # When on google Colab, let's clone the notebook so we download the cache. import google.colab repo_path = 'dspy' get_ipython().system('git -C $repo_path pull origin || git clon...
dspy.Example(question=question, answer=answer)
dspy.Example
import dspy from dsp.utils import deduplicate from dspy.datasets import HotPotQA from dspy.predict.retry import Retry from dspy.teleprompt import BootstrapFewShot, BootstrapFewShotWithRandomSearch from dspy.evaluate.evaluate import Evaluate from dspy.primitives.assertions import assert_transform_module, backtrack_hand...
dspy.InputField()
dspy.InputField
get_ipython().system('git clone https://huggingface.co/arnavs11/DSPy_TweetGen_Cache') get_ipython().run_line_magic('cd', 'DSPy_TweetGen_Cache/') get_ipython().system('git checkout master') get_ipython().run_line_magic('cd', '..') import os repo_clone_path = '/content/DSPy_TweetGen_Cache' if not os.access('/content', o...
Evaluate(metric=metric, devset=devset, num_threads=1, display_progress=True, display_table=5)
dspy.evaluate.evaluate.Evaluate
get_ipython().run_line_magic('load_ext', 'autoreload') get_ipython().run_line_magic('autoreload', '2') get_ipython().run_line_magic('pip', 'install datasets') import datasets ds = datasets.load_dataset("openai_humaneval") ds['test'][0] import dspy, dotenv, os dotenv.load_dotenv(os.path.expanduser("~/.env")) # lo...
OutputField()
dspy.OutputField
get_ipython().run_line_magic('load_ext', 'autoreload') get_ipython().run_line_magic('autoreload', '2') import sys import os try: # When on google Colab, let's clone the notebook so we download the cache. import google.colab repo_path = 'dspy' get_ipython().system('git -C $repo_path pull origin || git clon...
dspy.Predict(BasicQA)
dspy.Predict
get_ipython().system('git clone https://huggingface.co/arnavs11/DSPy_TweetGen_Cache') get_ipython().run_line_magic('cd', 'DSPy_TweetGen_Cache/') get_ipython().system('git checkout master') get_ipython().run_line_magic('cd', '..') import os repo_clone_path = '/content/DSPy_TweetGen_Cache' if not os.access('/content', o...
dspy.Predict(AssessTweet)
dspy.Predict
get_ipython().run_line_magic('load_ext', 'autoreload') get_ipython().run_line_magic('autoreload', '2') import dspy from dspy.evaluate import Evaluate from dspy.datasets.hotpotqa import HotPotQA from dspy.teleprompt import BootstrapFewShotWithRandomSearch, BootstrapFinetune ports = [7140, 7141, 7142, 7143, 7144, 71...
dspy.ColBERTv2(url='http://20.102.90.50:2017/wiki17_abstracts')
dspy.ColBERTv2
get_ipython().run_line_magic('load_ext', 'autoreload') get_ipython().run_line_magic('autoreload', '2') import sys import os try: # When on google Colab, let's clone the notebook so we download the cache. import google.colab repo_path = 'dspy' get_ipython().system('git -C $repo_path pull origin || git clon...
dspy.ChainOfThought("context, question -> answer")
dspy.ChainOfThought
get_ipython().run_line_magic('load_ext', 'autoreload') get_ipython().run_line_magic('autoreload', '2') import sys import os try: # When on google Colab, let's clone the notebook so we download the cache. import google.colab repo_path = 'dspy' get_ipython().system('git -C $repo_path pull origin || git clon...
Evaluate(devset=dev, metric=metric_EM, num_threads=NUM_THREADS, display_progress=True, display_table=15)
dspy.evaluate.Evaluate