0

我正在尝试在 Colab中运行此笔记本。

from openai.embeddings_utils import get_embedding

# This will take just under 10 minutes
df['babbage_similarity'] = df.combined.apply(lambda x: get_embedding(x, engine='text-similarity-babbage-001'))
df['babbage_search'] = df.combined.apply(lambda x: get_embedding(x, engine='text-search-babbage-doc-001'))
df.to_csv('/content/documents.csv')

当我尝试运行此代码块时失败 - 我收到此错误:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-31-b04fdb9f95d8> in <module>()
      5
      6 
----> 7 from openai.embeddings_utils import get_embedding
      8 
      9 # This will take just under 10 minutes

10 frames
/usr/local/lib/python3.7/dist-packages/distributed/config.py in <module>()
     18 
     19 with open(fn) as f:
---> 20     defaults = yaml.load(f)
     21 
     22 dask.config.update_defaults(defaults)

TypeError: load() missing 1 required positional argument: 'Loader'

根据谷歌搜索,这似乎是 Colab 特有的版本问题。但我一直无法修复它。有人有什么想法吗?

4

1 回答 1

0

config.py

替换这个:

with open(fn) as f:
    defaults = yaml.load(f)

有了这个:

with open(fn) as f:
    defaults = yaml.safe_load(f)
于 2022-02-28T19:26:15.010 回答