Cybertron เป็นแพ็คเกจใน Pure Go ที่สร้างขึ้นบน Spago ที่ให้ผู้พัฒนา Go นักพัฒนาที่มีอินเตอร์เฟสง่าย ๆ ในการใช้เทคโนโลยี NLP โดยไม่จำเป็นต้องใช้ภาษาการเขียนโปรแกรมอื่น ๆ หรือเฟรมเวิร์กที่ซับซ้อน มันถูกออกแบบมาสำหรับการใช้โมเดลหม้อแปลงที่ผ่านการฝึกอบรมมาก่อนที่มีอยู่ในที่เก็บโมเดล HuggingFace
แพ็คเกจนี้มีวัตถุประสงค์หลักในการ อนุมาน กับความเป็นไปได้ในการเพิ่มการปรับแต่งในอนาคต
ทีมเปิดให้ผู้สนับสนุนเร่งการเติบโต
ความต้องการ:
โคลน repo นี้หรือรับห้องสมุด:
go get -u github.com/nlpodyssey/cybertronCybertron รองรับการใช้งานหลักสองกรณีซึ่งมีการอธิบายรายละเอียดเพิ่มเติมในรายการต่อไปนี้
การตั้งค่าจะถูกกำหนดค่าในไฟล์ .env ซึ่งโหลดโดยอัตโนมัติโดย Cybertron อีกทางเลือกหนึ่งก็ยอมรับการกำหนดค่าผ่านธง
สำหรับรายการที่สมบูรณ์รัน:
GOARCH=amd64 go run ./cmd/server -hเอาท์พุท:
Usage of server:
-address value
server listening address
-allowed-origins value
allowed origins (comma separated)
-loglevel value
zerolog global level
-model value
model name (and sub-path of models-dir)
-model-conversion value
model conversion policy ("always"|"missing"|"never")
-model-conversion-precision value
floating-point bits of precision to use if the model is converted ("32"|"64")
-model-download value
model downloading policy ("always"|"missing"|"never")
-models-dir value
models's base directory
-network value
network type for server listening
-task value
type of inference/computation that the model can fulfill ("textgeneration"|"zero-shot-classification"|"question-answering"|"text-classification"|"token-classification"|"text-encoding")
-tls value
whether to enable TLS ("true"|"false")
-tls-cert value
TLS cert filename
-tls-key value
TLS key filename
ตัวอย่างเช่นในการเรียกใช้ Cybertron ในโหมดเซิร์ฟเวอร์สำหรับการแปลเครื่อง (เช่น en ) ด้วยการตั้งค่า it ต้นเพียงสร้างไฟล์ .env ในไดเรกทอรีปัจจุบัน:
echo "CYBERTRON_MODEL=Helsinki-NLP/opus-mt-en-it" > .env
echo "CYBERTRON_MODELS_DIR=models" >> .env
echo "CYBERTRON_MODEL_TASK=text-generation" >> .envและดำเนินการคำสั่งต่อไปนี้:
GOARCH=amd64 go run ./cmd/server -address 0.0.0.0:8080ในการทดสอบเซิร์ฟเวอร์รัน:
curl -X 'POST'
'0.0.0.0:8080/v1/generate'
-H 'accept: application/json'
-H 'Content-Type: application/json'
-d '{
"input": "You must be the change you wish to see in the world.",
"parameters": {}
}' ตัวอย่างหลายตัวอย่างสามารถใช้ประโยชน์จากความสามารถของ NLP ปัจจุบันใน Cybertron รายการการสาธิตดังต่อไปนี้
GOARCH=amd64 go run ./examples/textgeneration
.env ไม่สามารถใช้งานได้ข้อผิดพลาดจะถูกส่งคืน ในกรณีนี้ให้ลบโมเดลที่ระบุออกจากไฟล์การกำหนดค่าดังนั้นจะใช้รุ่นเริ่มต้น
GOARCH=amd64 go run ./examples/zeroshotclassification politics,business,science,technology,health,culture,sports
การพึ่งพาเขตเทศบาลของไซเบอร์ตรอนคือ:
ส่วนที่เหลือเป็นหลักสำหรับการพัฒนา GRPC และ HTTP API
ส่วนนี้มีไว้สำหรับนักพัฒนาที่ต้องการเปลี่ยนแปลงหรือเสริมสร้าง API Cybertron GRPC และ HTTP
ในการเริ่มต้นคุณต้องติดตั้ง BUF ในเครื่องของคุณ
จากนั้นติดตั้งเครื่องมือต่อไปนี้:
go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2
google.golang.org/protobuf/cmd/protoc-gen-go
google.golang.org/grpc/cmd/protoc-gen-go-grpc
จากนั้นเรียกใช้คำสั่งต่อไปนี้เพื่อสร้าง GRPC และ HTTP APIs:
go generate ./...