跳到主要内容

ChromeAI

信息

此功能为实验性,可能会发生变化。

注意

谷歌的 Built-in AI Early Preview Program 目前处于 beta 测试阶段。要申请访问权限或查找更多信息,请访问此链接

ChromeAI 利用 Gemini Nano 直接在浏览器或 worker 中运行 LLM,而无需互联网连接。这允许运行更快、更私有的模型,而无需让数据离开消费者设备。

开始使用

获得该计划的访问权限后,请按照谷歌提供的说明下载模型。

下载完成后,您可以开始在浏览器中使用 ChromeAI,如下所示

import { ChromeAI } from "@langchain/community/experimental/llms/chrome_ai";

const model = new ChromeAI({
temperature: 0.5, // Optional, defaults to 0.5
topK: 40, // Optional, defaults to 40
});

const response = await model.invoke("Write me a short poem please");

/*
In the realm where moonlight weaves its hue,
Where dreams and secrets gently intertwine,
There's a place of tranquility and grace,
Where whispers of the night find their place.

Beneath the canopy of starlit skies,
Where dreams take flight and worries cease,
A haven of tranquility, pure and true,
Where the heart finds solace, finding dew.

In this realm where dreams find their release,
Where the soul finds peace, at every peace,
Let us wander, lost in its embrace,
Finding solace in this tranquil space.
*/

流式传输

ChromeAI 也支持流式输出

import { ChromeAI } from "@langchain/community/experimental/llms/chrome_ai";

const model = new ChromeAI({
temperature: 0.5, // Optional, defaults to 0.5
topK: 40, // Optional, defaults to 40
});

for await (const chunk of await model.stream("How are you?")) {
console.log(chunk);
}

/*
As
an
AI
language
model
,
I
don
'
t
have
personal
experiences
or
the
ability
to
experience
emotions
.
Therefore
,
I
cannot
directly
answer
the
question
"
How
are
you
?".



May
I
suggest
answering
something
else
?
*/

此页内容是否有帮助?


您也可以留下详细的反馈 在 GitHub 上.