Comments (12)
456171 tokens, wow! That seems incredibly large. Something went really wrong in your run.
Are you able to share more details? I think some of your parameters have to be really off, maybe the number of demonstrations.
Also, this seems like it's using turbo. Is that true?
from dspy.
yes, it's using turbo, but even when i was running text-davinci-002, the token window often exceeded
from dspy.
I see. Before we dig into that, why/how is it 456,00 tokens? I'd understand if it was 5,000 for example. Are you able to share more information? How many demonstrations are you using?
from dspy.
i'm using 5 demonstrations
from dspy.
Can you reduce it to 1?
from dspy.
even when I reduced the number of demos to 1
x.demos = dsp.annotate(multihop_attempt)(demos, k=1, return_all=True)
it still exceeds the count
InvalidRequestError: This model's maximum context length is 4097 tokens. However, your messages resulted in 456675 tokens. Please reduce the length of the messages.
from dspy.
Can you return_all = False?
from dspy.
ive tried and the same thing still returns
from dspy.
Okay… can you print the prompt inside the generate function? This is a bit absurd, with 450,000 tokens! That’s like 200 times more than it normally is
from dspy.
I'm not sure why but after the first retrieval of passages for the annotation of the demos after sampling, the program passes all the questions and answers of the entire training set to gpt, including those that were not in demos
from dspy.
Ah okay. That makes sense. It’s got to do with your annotate call. Is it setting k=1 and return_all=False? If so, you can add an assert that the length of the output is 1 demo.
from dspy.
in multihop_demonstrate, i have changed it to
def multihop_demonstrate(question: str, x: dsp.Example, n: int) -> dsp.Example:
demos = knn_search(question, train, dev, n)
x.demos = dsp.annotate(multihop_attempt)(demos, k=1, return_all=False)
assert len(x.demos) == 1, "Output length is not 1"
return x
but the same error is appearing. the other variable is the knn_search
function, but it works with all the other programs in the notebook
for reference, the function was formulated following the knn_demonstrations notebook
def knn_search(question: str, train: list[Example], dev: list[Example], k):
dsp.settings.configure(vectorizer=dsp.NaiveGetFieldVectorizer())
knn_func = dsp.knn(train)
def find_query_location(value, data):
for index, item in enumerate(data):
if isinstance(item, dict):
# Check if the value is in the dictionary
if value in item.values():
return [index]
else:
# Recursively search the dictionary
result = find_query_location(value, item)
if result:
return [index] + result
elif isinstance(item, list):
# Recursively search the list
result = find_query_location(value, item)
if result:
return [index] + result
else:
return None
QUERY_IDX = find_query_location(question, dev)[0]
knn_res_dev = knn_func(dev[QUERY_IDX], k)
print(question) # the query itself
# similar questions
print('-'*80)
print([train.index(i) for i in knn_res_dev])
for i in [train[train.index(i)].question for i in knn_res_dev]:
print(i)
return knn_res_dev
from dspy.
Related Issues (20)
- DSPY Copro Tutorial for Hotpot QA doesn't work with Bedrock Claude Sonnet Model HOT 4
- ETA on new release? HOT 2
- RAG.forward() missing 1 required positional argument: 'question' HOT 5
- Enhancement: Would be great if we can load dspy dataset directly from pandas dataframe
- Clarification on the use of hard-written output field prompt in TextToSQLAnswer Signature HOT 1
- dspy and langfuse integration HOT 6
- about openai version
- Best practice for train and validation set separation HOT 5
- Triggering the Azure OpenAi (GPT 4) Triggers content warning and DSPy exception
- DSPy COPRO Tutorial for Hotpot QA doesn't work with VertexAI Gemini
- ZeroDivisionError: division by zero when using MIPROv2 HOT 2
- DatabricksRM retrieval using dspy.Retrieve() throws TypeError HOT 2
- Unwanted STDOUT output when using Claude adapter in DSPy HOT 2
- Adding textgrad as an optimizer? HOT 3
- Inconsistent Weaviate dependency HOT 1
- Error installing dspy from git due to setup.py {VERSION_PLACEHOLDER} HOT 1
- How do I load a previously compiled agent? HOT 3
- Cannot disable Caching HOT 2
- No module named 'mlc_chat' HOT 4
- how to set training epoch when using miprov2 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dspy.