Can anyone explain the embedding usage stats?

Hello:

Can anyone explain the usage stats from this image?

I only performed three 8000 token embeddings.

williamj

That is a lot of requests and a lot of tokens. Did your API key get out? Regenerate a new one (and delete the old one)

Or is your code stuck in some error and it keeps retrying?

1 Like

I created a new API key two days ago.

I’m not sure on my code being stuck.

Here is my code:

I did get a warning on the split_list embedding assignment.

williamj

You were right!

Here is what GPT-3 said:

“To reduce the token usage, consider optimizing the code by only accessing the ‘combined’ column once per DataFrame and storing the result in a variable, rather than accessing it for each element. Additionally, consider using a more efficient algorithm for retrieving the embedding, such as using a pre-trained model.”

Could you provide the dataframe Python code that does this?

I thought this was already implemented.

williamj

I don’t think you need a dataframe, you need a database! To prevent calling something over and over, you need to keep track of what you’ve done in the past, and at each call of the code it looks at the past and decides to send the call to the API if hasn’t been done yet.

In a nutshell, create a hash of what you have done (hash the thing sent to the API) and check the existence of this hash before you send it. Dataframes are short term in-memory objects, databases are long term.

Store your embeddings in-memory for speed, and when you get the closest ones retrieve the values in the database for your prompting efforts. It looks like you keep embedding over and over. The tutorial does everything for you, but look at what it is doing each time you run it to understand.