7.7. 配置 Guardrails Detector Hugging Face service runtime
要使用 Hugging Face 模型 的子集,称为 AutoModelsForSequenceClassification 和 Guardrails Orchestrator,您需要首先配置 Hugging Face service runtime。
guardrails-detector-huggingface-runtime 是 Hugging Face 模型的 KServe 服务运行时,用于检测和缓解文本数据中的某些类型的风险,如 Red Hateful speech。这个运行时与大多数 Hugging Face AutoModelsForSequenceClassification 模型兼容,并允许 ibm-granite/granite-guardian-hap-38m 等模型在 TrustyAI Guardrails 生态系统中使用。
自定义服务运行时示例
此 YAML 文件包含一个自定义服务运行时示例,它带有四个 worker 用于 Prompt Injection detector:
下表描述了 Guardrails Detector Hugging Face service runtime 的配置值:
| 属性 | value |
|---|---|
| 模板名称 |
|
| 运行时名称 |
|
| 显示名称 |
|
| 模型格式 |
|
| 组件 | 配置 | value |
|---|---|---|
| 服务器 | uvicorn |
|
| port | Container |
|
| 指标端口 | Prometheus |
|
| 指标路径 | Prometheus |
|
| 日志配置 | 路径 |
|
| 参数 | 默认 | 描述 |
|---|---|---|
|
| - | 容器镜像(必需) |
|
|
| 模型挂载路径 |
|
|
| HuggingFace 缓存 |
|
|
| Uvicorn worker |
|
|
| 服务器绑定地址 |
|
|
| 服务器端口 |
| 端点 | 方法 | 描述 | Content-Type | Headers |
|---|---|---|---|---|
|
| GET | 健康检查端点 |
|
|
|
| POST | 内容检测端点 |
|
3 types: * |