混合面包 API 访问
以下是所有可用的混合面包 API 过程的列表
名称 | 描述 |
---|---|
apoc.ml.mixedbread.custom(body, $config) |
创建可自定义的混合面包 API 调用 |
apoc.ml.mixedbread.embedding(texts, $config) |
创建混合面包 API 调用以生成嵌入 |
$config
参数与要传递给 http 请求的有效负载一致,此外还有以下配置键。
键 |
描述 |
apiType |
类似于 |
端点 |
类似于 |
apiVersion |
类似于 |
路径 |
自定义添加到基本 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 |
可选映射。请参见上面的 |
名称 | 描述 |
---|---|
index |
原始列表中的索引条目 |
text |
原始列表中的文本行 |
embedding |
浮点数/二进制的嵌入列表,或者在多个编码格式的情况下,嵌入浮点数/二进制列表的映射 |
CALL apoc.ml.mixedbread.embedding(['Some Text'], $apiKey, {}) yield index, text, embedding;
index | 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}
)
index | 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"]}
)
index | 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 |
---|
|