跳至主要内容

ChromeAI

信息

此功能为 **实验性** 功能,可能随时更改。

注意

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

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

入门

获得访问权限后,请按照 Google 提供的说明下载模型。

下载完成后,您可以在浏览器中按如下方式开始使用 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 上.