Nomic
NomicEmbeddings
类使用 Nomic AI API 为给定文本生成嵌入向量。
¥The NomicEmbeddings
class uses the Nomic AI API to generate embeddings for a given text.
设置
¥Setup
为了使用 Nomic API,你需要一个 API 密钥。你可以注册一个 Nomic 账户并创建 API 密钥 此处。
¥In order to use the Nomic API you'll need an API key. You can sign up for a Nomic account and create an API key here.
你首先需要安装 @langchain/nomic
软件包:
¥You'll first need to install the @langchain/nomic
package:
tip
- npm
- Yarn
- pnpm
npm install @langchain/nomic @langchain/core
yarn add @langchain/nomic @langchain/core
pnpm add @langchain/nomic @langchain/core
用法
¥Usage
import { NomicEmbeddings } from "@langchain/nomic";
/* Embed queries */
const nomicEmbeddings = new NomicEmbeddings();
const res = await nomicEmbeddings.embedQuery("Hello world");
console.log(res);
/* Embed documents */
const documentRes = await nomicEmbeddings.embedDocuments([
"Hello world",
"Bye bye",
]);
console.log(documentRes);
API Reference:
- NomicEmbeddings from
@langchain/nomic
相关
¥Related
嵌入模型 概念指南
¥Embedding model conceptual guide
嵌入模型 操作指南
¥Embedding model how-to guides