Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase training stability and avoid timeout caused by OpenAI API calling rate limit #90

Closed
EricGao888 opened this issue Feb 15, 2023 · 1 comment · Fixed by #91
Closed

Comments

@EricGao888
Copy link
Contributor

EricGao888 commented Feb 15, 2023

  • For users without pro accounts, requests to OpenAI API frequently time out due to calling rate limit.
  • We could add a retry policy to increase stability.
    for i in tqdm(docs, desc="Embedding 🦖", unit="docs", total=len(docs), bar_format='{l_bar}{bar}| Time Left: {remaining}'):
    try:
    import time
    store.add_texts([i.page_content], metadatas=[i.metadata])
    except Exception as e:
    print(e)
    print("Error on ", i)
    print("Saving progress")
    print(f"stopped at {c1} out of {len(docs)}")
    faiss.write_index(store.index, "docs.index")
    store_index_bak = store.index
    store.index = None
    with open("faiss_store.pkl", "wb") as f:
    pickle.dump(store, f)
    print("Sleeping for 60 seconds and trying again")
    time.sleep(60)
    faiss.write_index(store_index_bak, "docs.index")
    store.index = store_index_bak
    store.add_texts([i.page_content], metadatas=[i.metadata])
@EricGao888
Copy link
Contributor Author

BTW, adding a retry policy will significantly reduce the chance of getting into the exception handling logic and will be a workaround for #55

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant