Skip to content

Commit f1c3367

Browse files
committed
basic-snippet--token-classification
1 parent 281ce27 commit f1c3367

File tree

3 files changed

+36
-11
lines changed

3 files changed

+36
-11
lines changed

packages/tasks-gen/scripts/generate-snippets-fixtures.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -167,17 +167,17 @@ const TEST_CASES: {
167167
providers: ["hf-inference"],
168168
languages: ["sh", "js", "py"],
169169
},
170-
// {
171-
// testName: "basic-snippet--token-classification",
172-
// model: {
173-
// id: "FacebookAI/xlm-roberta-large-finetuned-conll03-english",
174-
// pipeline_tag: "token-classification",
175-
// tags: [],
176-
// inference: "",
177-
// },
178-
// providers: ["hf-inference"],
179-
// languages: ["py"],
180-
// },
170+
{
171+
testName: "basic-snippet--token-classification",
172+
model: {
173+
id: "FacebookAI/xlm-roberta-large-finetuned-conll03-english",
174+
pipeline_tag: "token-classification",
175+
tags: [],
176+
inference: "",
177+
},
178+
providers: ["hf-inference"],
179+
languages: ["py"],
180+
},
181181
// {
182182
// testName: "zero-shot-classification",
183183
// model: {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from huggingface_hub import InferenceClient
2+
3+
client = InferenceClient(
4+
provider="hf-inference",
5+
api_key="api_token",
6+
)
7+
8+
result = client.token_classification(
9+
inputs="My name is Sarah Jessica Parker but you can call me Jessica",
10+
model="FacebookAI/xlm-roberta-large-finetuned-conll03-english",
11+
)
12+
13+
print(result)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import requests
2+
3+
API_URL = "https://router.huggingface.co/hf-inference/models/FacebookAI/xlm-roberta-large-finetuned-conll03-english"
4+
headers = {"Authorization": "Bearer api_token"}
5+
6+
def query(payload):
7+
response = requests.post(API_URL, headers=headers, json=payload)
8+
return response.json()
9+
10+
output = query({
11+
"inputs": "My name is Sarah Jessica Parker but you can call me Jessica",
12+
})

0 commit comments

Comments
 (0)