- add ledger
- deposit fund (optional)
- refund fund (optional)
- list services
- generate header
- transfer fund to sub account
- call openai SDK
- verify response
- add ledger
- deposit fund (optional)
- refund fund (optional)
- list services
- acknowledge provider signer
- [
call provider url/v1/quote
] call provider quote api to download quote (contains provider signer) - [
TBD
] verify the quote using third party service (TODO: Jiahao discuss with Phala) - [
call contract
] acknowledge the provider signer in contract
- [
- [
use 0g storage sdk
] upload dataset, get dataset root hash - create task
- get preTrained model root hash based on the model
- [
call contract
] calculate fee - [
call contract
] transfer fund from ledger to fine-tuning provider - [
call provider url/v1/task
]call provider task creation api to create task
- [
call provider url/v1/task-progress
] call provider task progress api to get task progress - acknowledge encrypted model with root hash
- [
call contract
] get deliverable with root hash - [
use 0g storage sdk
] download model, calculate root hash, compare with provided root hash - [
call contract
] acknowledge the model in contract
- [
- decrypt model
- [
call contract
] get deliverable with encryptedSecret - decrypt the encryptedSecret
- decrypt model with secret [TODO: Discuss LiuYuan]
- [
- storage-client
- provider-client
- encryption
- broker (main)
- ledger (1-3)
- service listService (4) acknowledgeProviderSigner (5) createTask (7) getTaskProgress (8)
- model uploadDataset (6) acknowledgeModel (9) decryptModel (10)
-
Leger structure
struct Ledger { address user; uint availableBalance; uint totalBalance; uint[2] inferenceSigner; string additionalInfo; address[] inferenceProviders; address[] fineTuningProviders; }
-
Service structure
struct Service { address provider; string name; string url; Quota quota; uint pricePerToken; address providerSigner; bool occupied; }
-
FineTuning account structure
struct Account { address user; address provider; uint nonce; uint balance; uint pendingRefund; Refund[] refunds; string additionalInfo; address providerSigner; Deliverable[] deliverables; } struct Deliverable { bytes modelRootHash; bytes encryptedSecret; bool acknowledged; }
-
Task Model: https://github.com/0glabs/0g-serving-broker/blob/main/api/fine-tuning/schema/task.go#L12
-
Task creation example:
curl -X POST http://Domain/v1/task -d '{ "customerAddress": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", "datasetHash": "0xe080961aa45248f8855dbd540fb40c4927b980c6dc773740da79f19c0b2570c2", "isTurbo": true, "preTrainedModelHash": "0xe080961aa45248f8855dbd540fb40c4927b980c6dc773740da79f19c0b2570c2", "trainingParams": "{ "CustomerAddress": "0xabc", "PreTrainedModelHash": "0x7f2244b25cd2219dfd9d14c052982ecce409356e0f08e839b79796e270d110a7", "DatasetHash": "0xaae9b4e031e06f84b20f10ec629f36c57719ea512992a6b7e2baea93f447a5fa", "IsTurbo": true, "TrainingParams": "{\"num_train_epochs\": 3, \"per_device_train_batch_size\": 16, \"per_device_eval_batch_size\": 16, \"warmup_steps\": 500, \"weight_decay\": 0.01, \"logging_dir\": \"./logs\", \"logging_steps\": 100, \"evaluation_strategy\": \"no\", \"save_strategy\": \"steps\", \"save_steps\": 500, \"eval_steps\": 500, \"load_best_model_at_end\": false, \"metric_for_best_model\": \"accuracy\", \"greater_is_better\": true, \"report_to\": [\"none\"]}" }" }'