小编Con*_*in'的帖子

如何使用 OpenAI 的 API 进行批量嵌入?

我正在使用 OpenAI API 来获取一堆句子的嵌入。我所说的一堆句子,是指一堆句子,比如数千个。有没有办法让它更快或者让它同时进行嵌入或者其他什么?

我尝试循环遍历并发送每个句子的请求,但这非常慢,但发送句子列表也是如此。对于这两种情况,我都使用了以下代码:'''

response = requests.post(
    "https://api.openai.com/v1/embeddings",
    json={
        "model": "text-embedding-ada-002",
        "input": ["text:This is a test", "text:This is another test", "text:This is a third test", "text:This is a fourth test", "text:This is a fifth test", "text:This is a sixth test", "text:This is a seventh test", "text:This is a eighth test", "text:This is a ninth test", "text:This is a tenth test", "text:This is a eleventh test", "text:This is a twelfth test", "text:This is a thirteenth test", "text:This is a fourteenth …
Run Code Online (Sandbox Code Playgroud)

python embedding openai-api

11
推荐指数
1
解决办法
8870
查看次数

标签 统计

embedding ×1

openai-api ×1

python ×1