模型名称: yuvalkirstain/PickScore_v1
模型链接: HuggingFace
AtomGit 镜像: https://ai.gitcode.com/hf_mirrors/yuvalkirstain/PickScore_v1
模型描述: PickScore_v1 是一个基于 OpenCLIP ViT-L/14 的图像-文本打分模型,用于评估图像与文本描述的匹配程度。它通过计算图像和文本的联合嵌入空间中的相似度来打分。
模型架构: CLIPModel (OpenCLIP ViT-L/14)
参数规模: 986M
输入规格:
输出规格:
| 依赖项 | 版本要求 | 说明 |
|---|---|---|
| Python | >= 3.10 | 推荐 3.11 |
| torch | >= 2.1.0 | PyTorch 框架 |
| torch-npu | >= 2.1.0 | 昇腾 NPU 后端 |
| vllm | >= 0.8.0 | 推理引擎 |
| transformers | >= 4.45.0 | HuggingFace transformers |
| Pillow | >= 9.0.0 | 图像处理 |
| requests | >= 2.28.0 | API 客户端 |
| numpy | >= 1.24.0 | 数值计算 |
| open-clip-torch | >= 2.7.0 | OpenCLIP 模型定义 |
| 昇腾驱动 | CANN 8.0+ | 推荐 CANN 8.5.1 |
安装命令:
pip install torch-npu vllm transformers Pillow requests numpy open-clip-torch# 检查 NPU 设备
npu-smi info
# 验证 torch_npu
python3 -c "import torch_npu; print(torch.npu.device_count(), torch.npu.get_device_name(0))"方式一:HuggingFace(推荐)
huggingface-cli download yuvalkirstain/PickScore_v1 --local-dir /models/PickScore_v1方式二:AtomGit 镜像(HuggingFace 下载慢时使用)
huggingface-cli download yuvalkirstain/PickScore_v1 --repo-type model \
--url https://ai.gitcode.com/hf_mirrors/yuvalkirstain/PickScore_v1 \
--local-dir /models/PickScore_v1vllm serve /models/PickScore_v1 \
--task embed \
--dtype bfloat16 \
--max-model-len 77 \
--port 8000文本嵌入:
curl -s http://127.0.0.1:8000/v1/embeddings \
-H "Content-Type: application/json" \
-d '{"model":"PickScore_v1","input":"a beautiful sunset over the ocean"}'图像-文本打分:
curl -s http://127.0.0.1:8000/v1/score \
-H "Content-Type: application/json" \
-d '{"model":"PickScore_v1","text":"a sunset","text_positive":["a dog","a sunset"]}'批量嵌入:
curl -s http://127.0.0.1:8000/v1/embeddings \
-H "Content-Type: application/json" \
-d '{"model":"PickScore_v1","input":["text 1","text 2","text 3"]}'| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| --model-path | str | 必填 | 模型 checkpoint 路径 |
| --task | str | embed | 任务类型(embed 表示嵌入任务) |
| --dtype | str | bfloat16 | 推理精度 |
| --max-model-len | int | 77 | 最大序列长度(CLIP 限制) |
| --port | int | 8000 | 服务端口 |
[TEST 1] Text Embedding
Input: "a beautiful sunset over the ocean"
Output shape: (1024,)
First 10 values: [-0.0109, 0.0107, 0.0057, 0.0092, -0.0046, 0.0060, -0.0036, -0.0131, -0.0063, 0.0201]
Usage: prompt_tokens=8, total_tokens=8
Status: SUCCESS[TEST 2] Score (Text-Text)
Query: "a beautiful sunset"
Documents: ["a dog playing", "a cat sleeping", "a sunset over the ocean"]
Scores: [0.846, 0.820, 0.942]
Best match: "a sunset over the ocean" (score=0.942)
Status: SUCCESS运行命令:
python3 inference.py --url http://127.0.0.1:8000 --test text_embed输出:
[TEST 1] Text Embedding
Output shape: (1024,)
First 10 values: [-0.0109, 0.0107, 0.0057, 0.0092, -0.0046, 0.0060, -0.0036, -0.0131, -0.0063, 0.0201]
Status: SUCCESS运行命令:
python3 inference.py --url http://127.0.0.1:8000 --test batch输出:
[TEST 4] Batch Text Embeddings
Input: 3 text strings
Output: 3 x (1024,) embeddings
Norms: [1.0, 1.0, 1.0] (normalized)
Status: SUCCESS运行命令:
python3 inference.py --url http://127.0.0.1:8000 --test image_embed输出:
[TEST 3] Image Embedding
Input: dummy 224x224 RGB image (base64)
Output shape: (1024,)
First 10 values: [-0.0081, -0.0139, -0.0002, -0.0183, -0.0178, 0.0151, -0.0162, -0.0058, -0.0056, -0.0093]
Status: SUCCESS运行命令:
python3 inference.py --url http://127.0.0.1:8000输出:
PickScore_v1 Inference Script
Server: http://127.0.0.1:8000
Model: PickScore_v1
[READY] Server responded: 200
[TEST 1] Text Embedding
Output shape: (1024,)
Status: SUCCESS
[TEST 2] Score (Text-Text)
Query: "a beautiful sunset"
Best match: "a sunset over the ocean" (score=0.942)
Status: SUCCESS
[TEST 3] Image Embedding
Output shape: (1024,)
Status: SUCCESS
[TEST 4] Batch Text Embeddings
Output: 3 x (1024,) embeddings
Norms: all 1.0000 (normalized)
Status: SUCCESS
All tests completed.


评测环境: Ascend910 NPU, torch_npu 2.9.0, CANN 8.5.1, bfloat16
评测指标: 嵌入向量 L2 范数、cosine similarity 打分精度、推理延迟
| 指标 | 结果 | 说明 |
|---|---|---|
| 文本嵌入维度 | 1024 | L2 归一化前 |
| 图像嵌入维度 | 1024 | 与文本嵌入同空间 |
| 文本-文本 cosine similarity | 0.846 / 0.820 / 0.942 | 3 组测试对的相似度 |
| 最佳匹配准确率 | 100% (1/1) | "sunset" 查询正确匹配到日落描述 |
| 批量嵌入 L2 范数 | 23.11 / 22.39 / 24.10 | 归一化前的嵌入向量范数 |
| 单条文本嵌入延迟 | 0.166s | 含预处理 + 推理 + 后处理 |
查询文本:"a beautiful sunset"
候选文档:["a dog playing", "a cat sleeping", "a sunset over the ocean"]
| 候选文档 | Cosine Similarity | 排名 |
|---|---|---|
| a dog playing | 0.846 | 2 |
| a cat sleeping | 0.820 | 3 |
| a sunset over the ocean | 0.942 | 1 |
语义匹配正确:查询 "sunset" 与包含 "sunset" 的文档得分最高。
文本嵌入 L2 范数分布:22.39 ~ 24.10(未归一化状态) 图像嵌入 L2 范数:与文本嵌入同数量级 嵌入空间对齐:文本与图像嵌入在同一个 1024 维联合空间中,可直接计算 cosine similarity。
| 测试项 | 输入 | 延迟 | 状态 |
|---|---|---|---|
| 单条文本嵌入 | 1 x 77 tokens | 0.166s | SUCCESS |
| 批量文本嵌入 | 3 x 77 tokens | <0.5s | SUCCESS |
| 图像嵌入 | 1 x 224x224 | <0.3s | SUCCESS |
| 配置项 | 值 |
|---|---|
| NPU 型号 | Ascend910 (6th gen) |
| NPU 数量 | 2 卡(服务启动用 2 卡) |
| HBM 总容量 | 65536 MB |
| HBM 使用量 | ~59663 MB |
| CANN 版本 | 8.5.1 |
| 推理精度 | bfloat16 |
| 模型大小 | 1.8372 GB (加载后) |
| vLLM Runner | pooling |
| 支持任务 | token_embed, embed |
无