Mixedbread API 访问
以下是所有可用的 Mixedbread API 存储过程列表
名称 | 描述 |
---|---|
apoc.ml.mixedbread.custom(body, $config) |
用于创建可定制的 Mixedbread API 调用 |
apoc.ml.mixedbread.embedding(texts, $config) |
用于创建生成嵌入的 Mixedbread API 调用 |
$config
参数与要传递给 http 请求的有效负载一致,并且还包含以下配置键。
键 |
描述 |
apiType |
类似于 |
endpoint |
类似于 |
apiVersion |
类似于 |
path |
用于定制添加到基本 URL(由 |
jsonPath |
用于定制响应的 JSONPath。对于 |
由于嵌入是 OpenAI 嵌入的一个超集,它们在底层利用了 apoc.ml.openai.* 存储过程,因此我们也可以创建 APOC 配置 apoc.ml.openai.url
来代替 endpoint
配置。
生成嵌入 API
此存储过程 apoc.ml.mixedbread.embedding
可以接受文本字符串列表,并为每个字符串返回一行,其中嵌入数据是一个 1536 元素的向量。它使用 /embeddings/create
API,该 API 在此处有文档说明。
额外配置会传递给 API,使用的默认模型是 mxbai-embed-large-v1
。
名称 | 描述 |
---|---|
texts |
文本字符串列表 |
apiKey |
OpenAI API 密钥 |
configuration |
可选映射。参见上面的 |
名称 | 描述 |
---|---|
索引 |
原始列表中的索引条目 |
text |
原始列表中的文本行 |
embedding |
浮点数/二进制嵌入列表,或者在有多个 encoding_format 的情况下,是浮点数/二进制嵌入列表的映射 |
CALL apoc.ml.mixedbread.embedding(['Some Text'], $apiKey, {}) yield index, text, embedding;
索引 | text | embedding |
---|---|---|
0 |
"Some Text" |
[-0.0065358975, -7.9563365E-4, …. -0.010693862, -0.005087272] |
CALL apoc.ml.mixedbread.embedding(['Some Text', 'Other Text'],
$apiKey,
{model: 'mxbai-embed-2d-large-v1', dimensions: 4}
)
索引 | text | embedding |
---|---|---|
0 |
"Some Text" |
[0.019943237, -0.08843994, 0.068603516, 0.034942627] |
1 |
"Other Text" |
[0.011482239, -0.09069824, 0.05331421, 0.034088135] |
CALL apoc.ml.mixedbread.embedding(['Some Text', 'garpez'],
$apiKey,
{encoding_format: ["float", "binary", "ubinary", "int8", "uint8", "base64"]}
)
索引 | text | embedding |
---|---|---|
0 |
"Some Text" |
{binary: <binaryResult>, ubinary: <ubinaryResult>, int8: <int8Result>, uint8: <uint8Result>, base64: <base64Result>, float: <floatResult>} |
0 |
"garpez" |
{binary: <binaryResult>, ubinary: <ubinaryResult>, int8: <int8Result>, uint8: <uint8Result>, base64: <base64Result>, float: <floatResult>} |
自定义 API
通过 apoc.ml.mixedbread.custom
,我们可以创建一个可定制的 Mixedbread API 请求,返回一个通用的对象流。
例如,我们可以使用重新排名 API。
CALL apoc.ml.mixedbread.custom($apiKey,
{
endpoint: "https://api.mixedbread.ai/v1/reranking",
model: "mixedbread-ai/mxbai-rerank-large-v1",
query: "Who is the author of To Kill a Mockingbird?",
top_k: 3,
input: [
"To Kill a Mockingbird is a novel by Harper Lee published in 1960. It was immediately successful, winning the Pulitzer Prize, and has become a classic of modern American literature.",
"The novel Moby-Dick was written by Herman Melville and first published in 1851. It is considered a masterpiece of American literature and deals with complex themes of obsession, revenge, and the conflict between good and evil.",
"Harper Lee, an American novelist widely known for her novel To Kill a Mockingbird, was born in 1926 in Monroeville, Alabama. She received the Pulitzer Prize for Fiction in 1961.",
"Jane Austen was an English novelist known primarily for her six major novels, which interpret, critique and comment upon the British landed gentry at the end of the 18th century.",
"The Harry Potter series, which consists of seven fantasy novels written by British author J.K. Rowling, is among the most popular and critically acclaimed books of the modern era.",
"The Great Gatsby, a novel written by American author F. Scott Fitzgerald, was published in 1925. The story is set in the Jazz Age and follows the life of millionaire Jay Gatsby and his pursuit of Daisy Buchanan."
]
}
)
value |
---|
|