交互式操作
提交托管编码器计划
向新的交互式编码器任务提交 GLiNER2 托管训练计划,然后轮询返回的 future_id,直到计划完成。
POST
https://api.fastino.ai
/
v1
/
training
/
jobs
/
{job_id}
/
managed-plan
提交托管编码器计划
curl --request POST \
--url https://api.fastino.ai/v1/training/jobs/{job_id}/managed-plan \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"version": 123,
"fingerprint": "<string>",
"source_fingerprint": "<string>",
"architecture": "<string>",
"word_splitter": "<string>",
"config": {},
"max_steps": 123,
"examples": [
{}
],
"batches": [
{
"indices": [
123
],
"epoch": 123,
"update": true,
"evaluate": true
}
],
"eval_examples": [
{}
],
"eval_batch_size": 123,
"save_best": true,
"greater_is_better": true,
"early_stopping_patience": {},
"early_stopping_threshold": 123
}
'import requests
url = "https://api.fastino.ai/v1/training/jobs/{job_id}/managed-plan"
payload = {
"version": 123,
"fingerprint": "<string>",
"source_fingerprint": "<string>",
"architecture": "<string>",
"word_splitter": "<string>",
"config": {},
"max_steps": 123,
"examples": [{}],
"batches": [
{
"indices": [123],
"epoch": 123,
"update": True,
"evaluate": True
}
],
"eval_examples": [{}],
"eval_batch_size": 123,
"save_best": True,
"greater_is_better": True,
"early_stopping_patience": {},
"early_stopping_threshold": 123
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
version: 123,
fingerprint: '<string>',
source_fingerprint: '<string>',
architecture: '<string>',
word_splitter: '<string>',
config: {},
max_steps: 123,
examples: [{}],
batches: [{indices: [123], epoch: 123, update: true, evaluate: true}],
eval_examples: [{}],
eval_batch_size: 123,
save_best: true,
greater_is_better: true,
early_stopping_patience: {},
early_stopping_threshold: 123
})
};
fetch('https://api.fastino.ai/v1/training/jobs/{job_id}/managed-plan', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.fastino.ai/v1/training/jobs/{job_id}/managed-plan",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'version' => 123,
'fingerprint' => '<string>',
'source_fingerprint' => '<string>',
'architecture' => '<string>',
'word_splitter' => '<string>',
'config' => [
],
'max_steps' => 123,
'examples' => [
[
]
],
'batches' => [
[
'indices' => [
123
],
'epoch' => 123,
'update' => true,
'evaluate' => true
]
],
'eval_examples' => [
[
]
],
'eval_batch_size' => 123,
'save_best' => true,
'greater_is_better' => true,
'early_stopping_patience' => [
],
'early_stopping_threshold' => 123
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.fastino.ai/v1/training/jobs/{job_id}/managed-plan"
payload := strings.NewReader("{\n \"version\": 123,\n \"fingerprint\": \"<string>\",\n \"source_fingerprint\": \"<string>\",\n \"architecture\": \"<string>\",\n \"word_splitter\": \"<string>\",\n \"config\": {},\n \"max_steps\": 123,\n \"examples\": [\n {}\n ],\n \"batches\": [\n {\n \"indices\": [\n 123\n ],\n \"epoch\": 123,\n \"update\": true,\n \"evaluate\": true\n }\n ],\n \"eval_examples\": [\n {}\n ],\n \"eval_batch_size\": 123,\n \"save_best\": true,\n \"greater_is_better\": true,\n \"early_stopping_patience\": {},\n \"early_stopping_threshold\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.fastino.ai/v1/training/jobs/{job_id}/managed-plan")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"version\": 123,\n \"fingerprint\": \"<string>\",\n \"source_fingerprint\": \"<string>\",\n \"architecture\": \"<string>\",\n \"word_splitter\": \"<string>\",\n \"config\": {},\n \"max_steps\": 123,\n \"examples\": [\n {}\n ],\n \"batches\": [\n {\n \"indices\": [\n 123\n ],\n \"epoch\": 123,\n \"update\": true,\n \"evaluate\": true\n }\n ],\n \"eval_examples\": [\n {}\n ],\n \"eval_batch_size\": 123,\n \"save_best\": true,\n \"greater_is_better\": true,\n \"early_stopping_patience\": {},\n \"early_stopping_threshold\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.fastino.ai/v1/training/jobs/{job_id}/managed-plan")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"version\": 123,\n \"fingerprint\": \"<string>\",\n \"source_fingerprint\": \"<string>\",\n \"architecture\": \"<string>\",\n \"word_splitter\": \"<string>\",\n \"config\": {},\n \"max_steps\": 123,\n \"examples\": [\n {}\n ],\n \"batches\": [\n {\n \"indices\": [\n 123\n ],\n \"epoch\": 123,\n \"update\": true,\n \"evaluate\": true\n }\n ],\n \"eval_examples\": [\n {}\n ],\n \"eval_batch_size\": 123,\n \"save_best\": true,\n \"greater_is_better\": true,\n \"early_stopping_patience\": {},\n \"early_stopping_threshold\": 123\n}"
response = http.request(request)
puts response.read_body{
"future_id": "<string>",
"job_id": "<string>",
"type": "<string>"
}POST /v1/training/jobs/{job_id}/managed-plan
通过一次调用,在交互式编码器任务上运行完整的 GLiNER2 训练计划。
计划由 GLiNER2 库的 ManagedTrainingPlan 生成,包含训练和评估示例、精确的批次安排、评估设置以及计划内容的指纹。响应是一个 future。可通过以下接口读取其状态,并在完成后读取选定的检查点和续训检查点:
GET /v1/training/jobs/{job_id}/futures/{future_id}.
- Fastino 托管 API 不提供交互式编码器任务,因此托管计划无法在其上运行。如需在托管 API 上训练 GLiNER 模型,请使用
POST /v1/training/jobs并提供数据集。 - 在提供交互式编码器任务的环境中,将计划发送到使用
POST /v1/training/jobs/create-model、编码器基础模型和encoder_config创建的新编码器任务。计划必须与任务的编码器和 LoRA 设置一致,这些设置不可更改。 - 一个计划会占用任务,直到计划完成或任务停止。在此期间,该任务上的其他交互式操作会被拒绝。
- 再次发送同一计划会返回同一个 future。向同一任务发送不同的计划会返回
409。 - 计划最大为 8 MiB。
- 此路由不会转换由数据集创建的训练任务。
请求
响应
202 Accepted
错误
| 状态 | 含义 |
|---|---|
409 | 任务已停止、其会话处于非活动状态,或已向其发送了不同的计划。 |
413 | 计划超过 8 MiB。 |
422 | 请求体无效:指纹与内容不一致、update 批次数不等于 max_steps、最后一个批次没有更新、某个批次引用了不存在的示例,或某个示例与编码器不匹配。 |
此页面对您有帮助吗?
⌘I
提交托管编码器计划
curl --request POST \
--url https://api.fastino.ai/v1/training/jobs/{job_id}/managed-plan \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"version": 123,
"fingerprint": "<string>",
"source_fingerprint": "<string>",
"architecture": "<string>",
"word_splitter": "<string>",
"config": {},
"max_steps": 123,
"examples": [
{}
],
"batches": [
{
"indices": [
123
],
"epoch": 123,
"update": true,
"evaluate": true
}
],
"eval_examples": [
{}
],
"eval_batch_size": 123,
"save_best": true,
"greater_is_better": true,
"early_stopping_patience": {},
"early_stopping_threshold": 123
}
'import requests
url = "https://api.fastino.ai/v1/training/jobs/{job_id}/managed-plan"
payload = {
"version": 123,
"fingerprint": "<string>",
"source_fingerprint": "<string>",
"architecture": "<string>",
"word_splitter": "<string>",
"config": {},
"max_steps": 123,
"examples": [{}],
"batches": [
{
"indices": [123],
"epoch": 123,
"update": True,
"evaluate": True
}
],
"eval_examples": [{}],
"eval_batch_size": 123,
"save_best": True,
"greater_is_better": True,
"early_stopping_patience": {},
"early_stopping_threshold": 123
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
version: 123,
fingerprint: '<string>',
source_fingerprint: '<string>',
architecture: '<string>',
word_splitter: '<string>',
config: {},
max_steps: 123,
examples: [{}],
batches: [{indices: [123], epoch: 123, update: true, evaluate: true}],
eval_examples: [{}],
eval_batch_size: 123,
save_best: true,
greater_is_better: true,
early_stopping_patience: {},
early_stopping_threshold: 123
})
};
fetch('https://api.fastino.ai/v1/training/jobs/{job_id}/managed-plan', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.fastino.ai/v1/training/jobs/{job_id}/managed-plan",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'version' => 123,
'fingerprint' => '<string>',
'source_fingerprint' => '<string>',
'architecture' => '<string>',
'word_splitter' => '<string>',
'config' => [
],
'max_steps' => 123,
'examples' => [
[
]
],
'batches' => [
[
'indices' => [
123
],
'epoch' => 123,
'update' => true,
'evaluate' => true
]
],
'eval_examples' => [
[
]
],
'eval_batch_size' => 123,
'save_best' => true,
'greater_is_better' => true,
'early_stopping_patience' => [
],
'early_stopping_threshold' => 123
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.fastino.ai/v1/training/jobs/{job_id}/managed-plan"
payload := strings.NewReader("{\n \"version\": 123,\n \"fingerprint\": \"<string>\",\n \"source_fingerprint\": \"<string>\",\n \"architecture\": \"<string>\",\n \"word_splitter\": \"<string>\",\n \"config\": {},\n \"max_steps\": 123,\n \"examples\": [\n {}\n ],\n \"batches\": [\n {\n \"indices\": [\n 123\n ],\n \"epoch\": 123,\n \"update\": true,\n \"evaluate\": true\n }\n ],\n \"eval_examples\": [\n {}\n ],\n \"eval_batch_size\": 123,\n \"save_best\": true,\n \"greater_is_better\": true,\n \"early_stopping_patience\": {},\n \"early_stopping_threshold\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.fastino.ai/v1/training/jobs/{job_id}/managed-plan")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"version\": 123,\n \"fingerprint\": \"<string>\",\n \"source_fingerprint\": \"<string>\",\n \"architecture\": \"<string>\",\n \"word_splitter\": \"<string>\",\n \"config\": {},\n \"max_steps\": 123,\n \"examples\": [\n {}\n ],\n \"batches\": [\n {\n \"indices\": [\n 123\n ],\n \"epoch\": 123,\n \"update\": true,\n \"evaluate\": true\n }\n ],\n \"eval_examples\": [\n {}\n ],\n \"eval_batch_size\": 123,\n \"save_best\": true,\n \"greater_is_better\": true,\n \"early_stopping_patience\": {},\n \"early_stopping_threshold\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.fastino.ai/v1/training/jobs/{job_id}/managed-plan")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"version\": 123,\n \"fingerprint\": \"<string>\",\n \"source_fingerprint\": \"<string>\",\n \"architecture\": \"<string>\",\n \"word_splitter\": \"<string>\",\n \"config\": {},\n \"max_steps\": 123,\n \"examples\": [\n {}\n ],\n \"batches\": [\n {\n \"indices\": [\n 123\n ],\n \"epoch\": 123,\n \"update\": true,\n \"evaluate\": true\n }\n ],\n \"eval_examples\": [\n {}\n ],\n \"eval_batch_size\": 123,\n \"save_best\": true,\n \"greater_is_better\": true,\n \"early_stopping_patience\": {},\n \"early_stopping_threshold\": 123\n}"
response = http.request(request)
puts response.read_body{
"future_id": "<string>",
"job_id": "<string>",
"type": "<string>"
}
