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 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().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(rm=colbertv2_wiki17_abstracts)
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...
dspy.Prediction(generated_tweet=generated_tweet, context=context)
dspy.Prediction
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(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...
dspy.Predict(AssessTweet)
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...
dspy.Predict("question -> answer")
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.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.ChainOfThought("context, question -> answer")
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...
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...
BootstrapFewShotWithRandomSearch(metric = overall_metric, max_bootstrapped_demos=2, num_candidate_programs=6)
dspy.teleprompt.BootstrapFewShotWithRandomSearch
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.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...
Evaluate(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_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().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.Prediction(generated_tweet=generated_tweet, context=context)
dspy.Prediction
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') 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...
BootstrapFewShotWithRandomSearch(metric=metric_EM, max_bootstrapped_demos=2, num_candidate_programs=8, num_threads=NUM_THREADS)
dspy.teleprompt.BootstrapFewShotWithRandomSearch
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.OpenAI(model='gpt-3.5-turbo', max_tokens=500)
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(desc="may contain relevant facts")
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...
Evaluate(metric=metric, devset=devset[38:39], 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') 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 -> answer')
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.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...
BootstrapFewShot(metric=validate_context_and_answer)
dspy.teleprompt.BootstrapFewShot
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().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.OutputField()
dspy.OutputField
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('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=llm, 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...
BootstrapFewShotWithRandomSearch(metric = answer_correctness, max_bootstrapped_demos=2, num_candidate_programs=6)
dspy.teleprompt.BootstrapFewShotWithRandomSearch
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.InputField(desc="may contain relevant facts")
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...
BootstrapFewShot(metric=validate_context_and_answer_and_hops)
dspy.teleprompt.BootstrapFewShot
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/gcp/generate/models/gemini-pro", api_key=PAT, n=2)
dspy.Clarifai
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 -> 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...
dspy.Prediction(context=context, answer=prediction.answer)
dspy.Prediction
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(BasicQA)
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.evaluate.answer_exact_match(example, pred)
dspy.evaluate.answer_exact_match
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...
KNNFewShot(KNN, 7, trainset)
dspy.teleprompt.KNNFewShot
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.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.OutputField(desc="boolean indicating if text is faithful to context")
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...
dspy.OutputField(desc="Yes or No")
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.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.settings.configure(rm=colbertv2_wiki17_abstracts)
dspy.settings.configure
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
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.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("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...
dspy.ChainOfThought("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...
dspy.ChainOfThought(GenerateSearchQuery)
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
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)
dspy.configure
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().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=mistral_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.Prediction(context=context, paragraph=pred.paragraph)
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...
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...
Evaluate(metric=metric, devset=devset, num_threads=1, display_progress=True, display_table=5)
dspy.evaluate.evaluate.Evaluate
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.Predict(BasicQA)
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...
dspy.settings.configure(lm=lm)
dspy.settings.configure
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.ChainOfThought(GenerateAnswerChoices)
dspy.ChainOfThought
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='beir-v1.0.0-nfcorpus.contriever-msmarco', query_encoder='facebook/contriever-msmarco', id_field='_id', text_fields=['title', 'text'])
dspy.Pyserini
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().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.OutputField(desc="Answer in one or two lines")
dspy.OutputField
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...
Evaluate(metric=metric, devset=devset, num_threads=8, display_progress=True, display_table=5)
dspy.evaluate.evaluate.Evaluate
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...
dspy.ChainOfThought(GenerateAnswerChoices)
dspy.ChainOfThought
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, train_size=20, eval_seed=2023, dev_size=50, test_size=0)
dspy.datasets.HotPotQA
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.OutputField()
dspy.OutputField
import dspy from dspy.evaluate import Evaluate from dspy.datasets.gsm8k import GSM8K, gsm8k_metric from dspy.teleprompt import BootstrapFewShotWithRandomSearch gms8k = GSM8K() turbo = dspy.OpenAI(model='gpt-3.5-turbo-instruct', max_tokens=250) trainset, devset = gms8k.train, gms8k.dev dspy.settings.configure(lm=tur...
Evaluate(devset=devset[:], metric=gsm8k_metric, num_threads=NUM_THREADS, display_progress=True, display_table=0)
dspy.evaluate.Evaluate
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().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
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...
LangChainModule(zeroshot_chain)
dspy.predict.langchain.LangChainModule
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 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...
dspy.Retrieve(k=5)
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.InputField()
dspy.InputField
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(desc="often between 1 and 5 words")
dspy.OutputField
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)
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.Example(question=question, answer=answer)
dspy.Example
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...
HotPotQA(train_seed=1, train_size=300, eval_seed=2023, dev_size=300, test_size=0, keep_details=True)
dspy.datasets.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.evaluate.answer_passage_match(example, pred)
dspy.evaluate.answer_passage_match
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...
HotPotQA(train_seed=1, train_size=300, eval_seed=2023, dev_size=300, test_size=0)
dspy.datasets.HotPotQA
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...
BootstrapFinetune(metric=None)
dspy.teleprompt.BootstrapFinetune
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.settings.configure(lm=turbo)
dspy.settings.configure
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.Example(question=x.question)
dspy.Example
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.InputField(desc="may contain relevant facts")
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...
HotPotQA(train_seed=1, train_size=300, eval_seed=2023, dev_size=300, test_size=0, keep_details=True)
dspy.datasets.HotPotQA
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...
Evaluate(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_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.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...
HotPotQA(train_seed=1, train_size=300, eval_seed=2023, dev_size=300, test_size=0, keep_details=True)
dspy.datasets.HotPotQA
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...
BootstrapFewShotWithRandomSearch(metric=metric, max_bootstrapped_demos=3, num_candidate_programs=3)
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...
BootstrapFewShotWithRandomSearch(metric=metric_EM, max_bootstrapped_demos=2, num_candidate_programs=8, 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.ChainOfThought("question -> search_query")
dspy.ChainOfThought
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(GenerateSearchQuery)
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.OpenAI(model='gpt-3.5-turbo', max_tokens=500)
dspy.OpenAI
import dspy from dspy.evaluate import Evaluate from dspy.datasets.gsm8k import GSM8K, gsm8k_metric from dspy.teleprompt import BootstrapFewShotWithRandomSearch gms8k = GSM8K() turbo = dspy.OpenAI(model='gpt-3.5-turbo-instruct', max_tokens=250) trainset, devset = gms8k.train, gms8k.dev
dspy.settings.configure(lm=turbo)
dspy.settings.configure
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.HFModel(checkpoint=ckpt_path, model='t5-large')
dspy.HFModel
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(GenerateCitedParagraph)
dspy.ChainOfThought
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.OutputField()
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.OutputField(desc="includes citations")
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...
BootstrapFewShot(metric=metric_EM, max_bootstrapped_demos=2)
dspy.teleprompt.BootstrapFewShot
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