Skip to content

Commit e88b85d

Browse files
authored
Merge branch 'main' into node-llama-cpp-option
2 parents 8c1458f + 355c8a9 commit e88b85d

File tree

6 files changed

+63
-57
lines changed

6 files changed

+63
-57
lines changed

README.md

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,24 @@ await uploadFile({
2727
}
2828
});
2929

30-
// Use hosted inference
31-
32-
await inference.translation({
33-
model: 't5-base',
34-
inputs: 'My name is Wolfgang and I live in Berlin'
35-
})
30+
// Use Inference API
31+
32+
await inference.chatCompletion({
33+
model: "meta-llama/Llama-3.1-8B-Instruct",
34+
messages: [
35+
{
36+
role: "user",
37+
content: "Hello, nice to meet you!",
38+
},
39+
],
40+
max_tokens: 512,
41+
temperature: 0.5,
42+
});
3643

3744
await inference.textToImage({
38-
model: 'stabilityai/stable-diffusion-2',
39-
inputs: 'award winning high resolution photo of a giant tortoise/((ladybird)) hybrid, [trending on artstation]',
40-
parameters: {
41-
negative_prompt: 'blurry',
42-
}
43-
})
45+
model: "black-forest-labs/FLUX.1-dev",
46+
inputs: "a picture of a green bird",
47+
});
4448

4549
// and much more…
4650
```
@@ -123,33 +127,33 @@ const inference = new HfInference(HF_TOKEN);
123127

124128
// Chat completion API
125129
const out = await inference.chatCompletion({
126-
model: "mistralai/Mistral-7B-Instruct-v0.2",
127-
messages: [{ role: "user", content: "Complete the this sentence with words one plus one is equal " }],
128-
max_tokens: 100
130+
model: "meta-llama/Llama-3.1-8B-Instruct",
131+
messages: [{ role: "user", content: "Hello, nice to meet you!" }],
132+
max_tokens: 512
129133
});
130134
console.log(out.choices[0].message);
131135

132136
// Streaming chat completion API
133137
for await (const chunk of inference.chatCompletionStream({
134-
model: "mistralai/Mistral-7B-Instruct-v0.2",
135-
messages: [{ role: "user", content: "Complete the this sentence with words one plus one is equal " }],
136-
max_tokens: 100
138+
model: "meta-llama/Llama-3.1-8B-Instruct",
139+
messages: [{ role: "user", content: "Hello, nice to meet you!" }],
140+
max_tokens: 512
137141
})) {
138142
console.log(chunk.choices[0].delta.content);
139143
}
140144

141145
// You can also omit "model" to use the recommended model for the task
142146
await inference.translation({
143-
model: 't5-base',
144-
inputs: 'My name is Wolfgang and I live in Amsterdam'
145-
})
147+
inputs: "My name is Wolfgang and I live in Amsterdam",
148+
parameters: {
149+
src_lang: "en",
150+
tgt_lang: "fr",
151+
},
152+
});
146153

147154
await inference.textToImage({
148-
model: 'stabilityai/stable-diffusion-2',
149-
inputs: 'award winning high resolution photo of a giant tortoise/((ladybird)) hybrid, [trending on artstation]',
150-
parameters: {
151-
negative_prompt: 'blurry',
152-
}
155+
model: 'black-forest-labs/FLUX.1-dev',
156+
inputs: 'a picture of a green bird',
153157
})
154158

155159
await inference.imageToText({
@@ -162,13 +166,13 @@ const gpt2 = inference.endpoint('https://xyz.eu-west-1.aws.endpoints.huggingface
162166
const { generated_text } = await gpt2.textGeneration({inputs: 'The answer to the universe is'});
163167

164168
//Chat Completion
165-
const mistal = inference.endpoint(
166-
"https://api-inference.huggingface.co/models/mistralai/Mistral-7B-Instruct-v0.2"
169+
const llamaEndpoint = inference.endpoint(
170+
"https://api-inference.huggingface.co/models/meta-llama/Llama-3.1-8B-Instruct"
167171
);
168-
const out = await mistal.chatCompletion({
169-
model: "mistralai/Mistral-7B-Instruct-v0.2",
170-
messages: [{ role: "user", content: "Complete the this sentence with words one plus one is equal " }],
171-
max_tokens: 100,
172+
const out = await llamaEndpoint.chatCompletion({
173+
model: "meta-llama/Llama-3.1-8B-Instruct",
174+
messages: [{ role: "user", content: "Hello, nice to meet you!" }],
175+
max_tokens: 512,
172176
});
173177
console.log(out.choices[0].message);
174178
```

packages/inference/README.md

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -91,23 +91,21 @@ Using the `chatCompletion` method, you can generate text with models compatible
9191
```typescript
9292
// Non-streaming API
9393
const out = await hf.chatCompletion({
94-
model: "mistralai/Mistral-7B-Instruct-v0.2",
95-
messages: [{ role: "user", content: "Complete the this sentence with words one plus one is equal " }],
96-
max_tokens: 500,
94+
model: "meta-llama/Llama-3.1-8B-Instruct",
95+
messages: [{ role: "user", content: "Hello, nice to meet you!" }],
96+
max_tokens: 512,
9797
temperature: 0.1,
98-
seed: 0,
9998
});
10099

101100
// Streaming API
102101
let out = "";
103102
for await (const chunk of hf.chatCompletionStream({
104-
model: "mistralai/Mistral-7B-Instruct-v0.2",
103+
model: "meta-llama/Llama-3.1-8B-Instruct",
105104
messages: [
106-
{ role: "user", content: "Complete the equation 1+1= ,just the answer" },
105+
{ role: "user", content: "Can you help me solve an equation?" },
107106
],
108-
max_tokens: 500,
107+
max_tokens: 512,
109108
temperature: 0.1,
110-
seed: 0,
111109
})) {
112110
if (chunk.choices && chunk.choices.length > 0) {
113111
out += chunk.choices[0].delta.content;
@@ -396,11 +394,8 @@ Creates an image from a text prompt.
396394

397395
```typescript
398396
await hf.textToImage({
399-
inputs: 'award winning high resolution photo of a giant tortoise/((ladybird)) hybrid, [trending on artstation]',
400-
model: 'stabilityai/stable-diffusion-2',
401-
parameters: {
402-
negative_prompt: 'blurry',
403-
}
397+
model: 'black-forest-labs/FLUX.1-dev',
398+
inputs: 'a picture of a green bird'
404399
})
405400
```
406401

@@ -583,7 +578,7 @@ const { generated_text } = await gpt2.textGeneration({inputs: 'The answer to the
583578

584579
// Chat Completion Example
585580
const ep = hf.endpoint(
586-
"https://api-inference.huggingface.co/models/mistralai/Mistral-7B-Instruct-v0.2"
581+
"https://api-inference.huggingface.co/models/meta-llama/Llama-3.1-8B-Instruct"
587582
);
588583
const stream = ep.chatCompletionStream({
589584
model: "tgi",

packages/tasks/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@huggingface/tasks",
33
"packageManager": "[email protected]",
4-
"version": "0.12.17",
4+
"version": "0.12.20",
55
"description": "List of ML tasks for huggingface.co/tasks",
66
"repository": "https://github.com/huggingface/huggingface.js.git",
77
"publishConfig": {

packages/tasks/src/local-apps.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ const snippetLocalAI = (model: ModelData, filepath?: string): LocalAppSnippet[]
162162
const snippetVllm = (model: ModelData): LocalAppSnippet[] => {
163163
const runCommand = [
164164
"# Call the server using curl:",
165-
`curl -X POST "http://localhost:8000/v1/chat/completions" \\ `,
166-
` -H "Content-Type: application/json" \\ `,
165+
`curl -X POST "http://localhost:8000/v1/chat/completions" \\`,
166+
` -H "Content-Type: application/json" \\`,
167167
` --data '{`,
168168
` "model": "${model.id}",`,
169169
` "messages": [`,
@@ -229,12 +229,13 @@ export const LOCAL_APPS = {
229229
docsUrl: "https://docs.vllm.ai",
230230
mainTask: "text-generation",
231231
displayOnModelPage: (model: ModelData) =>
232-
isAwqModel(model) ||
233-
isGptqModel(model) ||
234-
isAqlmModel(model) ||
235-
isMarlinModel(model) ||
236-
isLlamaCppGgufModel(model) ||
237-
isTransformersModel(model),
232+
(isAwqModel(model) ||
233+
isGptqModel(model) ||
234+
isAqlmModel(model) ||
235+
isMarlinModel(model) ||
236+
isLlamaCppGgufModel(model) ||
237+
isTransformersModel(model)) &&
238+
(model.pipeline_tag === "text-generation" || model.pipeline_tag === "image-text-to-text"),
238239
snippet: snippetVllm,
239240
},
240241
lmstudio: {

packages/tasks/src/model-libraries.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,12 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = {
516516
filter: false,
517517
countDownloads: `path:"model.safetensors"`,
518518
},
519+
reverb: {
520+
prettyLabel: "Reverb",
521+
repoName: "Reverb",
522+
repoUrl: "https://github.com/revdotcom/reverb",
523+
filter: false,
524+
},
519525
saelens: {
520526
prettyLabel: "SAELens",
521527
repoName: "SAELens",

packages/tasks/src/tasks/image-text-to-text/data.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ const taskData: TaskDataCustom = {
4343
metrics: [],
4444
models: [
4545
{
46-
description: "Cutting-edge vision language model that can take multiple image inputs.",
47-
id: "facebook/chameleon-7b",
46+
description: "Powerful vision language model with great visual understanding and reasoning capabilities.",
47+
id: "meta-llama/Llama-3.2-11B-Vision-Instruct",
4848
},
4949
{
5050
description: "Cutting-edge conversational vision language model that can take multiple image inputs.",

0 commit comments

Comments
 (0)