【评测】Qwen3-Embedding模型初体验

回到目录

Qwen3-Embedding的ollama部署方法可以参考【部署】dify+ollama部署Qwen3-Embedding-8B

【评测】Qwen3-Embedding模型初体验

模型的介绍页面
0.6B运行配置:笔记本i5-8265U,16G内存,无GPU核显运行,win10操作系统
8B运行配置:AMD8700G,64G内存,4090D 24G显存,ubuntu24.04操作系统

下面直接使用介绍页面的sample代码体验一下模型的威力。

1. modelscope下载模型

$ modelscope download --model Qwen/Qwen3-Embedding-0.6B
$ modelscope download --model Qwen/Qwen3-Embedding-8B
0.6B模型 1.12GB 8B模型 14.1GB

2. 修改sample代码从本地加载模型

默认代码运行报错:
OSError: We couldn’t connect to ‘https://huggingface.co’ to load the files, and couldn’t find them in the cached files.

# test_qwen3-embedding.py

# Requires transformers>=4.51.0
# Requires sentence-transformers>=2.7.0

from sentence_transformers import SentenceTransformer

# Load the model
#model = SentenceTransformer("Qwen/Qwen3-Embedding-8B")  改为下面代码本地加载模型
model = SentenceTransformer("C:\\Users\\Administrator\\.cache\\modelscope\\hub\models\\Qwen\\Qwen3-Embedding-8B")

# We recommend enabling flash_attention_2 for better acceleration and memory saving,
# together with setting `padding_side` to "left":
# model = SentenceTransformer(
#     "Qwen/Qwen3-Embedding-8B",
#     model_kwargs={"attn_implementation": "flash_attention_2", "device_map": "auto"},
#     tokenizer_kwargs={"padding_side": "left"},
# )

# The queries and documents to embed
queries = [
    "What is the capital of China?",
    "Explain gravity",
]
documents = [
    "The capital of China is Beijing.",
    "Gravity is a force that attracts two bodies towards each other. It gives weight to physical objects and is responsible for the movement of planets around the sun.",
]

# Encode the queries and documents. Note that queries benefit from using a prompt
# Here we use the prompt called "query" stored under `model.prompts`, but you can
# also pass your own prompt via the `prompt` argument
query_embeddings = model.encode(queries, prompt_name="query")
document_embeddings = model.encode(documents)

# Compute the (cosine) similarity between the query and document embeddings
similarity = model.similarity(query_embeddings, document_embeddings)
print(similarity)
# tensor([[0.7493, 0.0751],
#         [0.0880, 0.6318]])

可能是机器配置太低问题,无法正常执行出结果
D:\workspace\test_qwen3-embedding.py:8: SyntaxWarning: invalid escape sequence ‘\m’
model = SentenceTransformer(“C:\Users\Administrator\.cache\modelscope\hub\models\Qwen\Qwen3-Embedding-8B”)
Loading checkpoint shards: 25%|██████████████▎ | 1/4 [00:14<00:42, 14.24s/it]

进度条第一步后,就直接退出程序。

3. 修改sample代码为0.6B模型

# test_qwen3-embedding.py
。。。
# Load the model
#model = SentenceTransformer("Qwen/Qwen3-Embedding-8B")  改为下面代码本地加载模型
model = SentenceTransformer("C:\\Users\\Administrator\\.cache\\modelscope\\hub\models\\Qwen\\Qwen3-Embedding-0.6B")
。。。

(workspace) PS D:\workspace> uv run .\test_qwen3-embedding.py
D:\workspace\test_qwen3-embedding.py:8: SyntaxWarning: invalid escape sequence ‘\m’
model = SentenceTransformer(“C:\Users\Administrator\.cache\modelscope\hub\models\Qwen\Qwen3-Embedding-0.6B”)
tensor([[0.7646, 0.1414],
[0.1355, 0.6000]])

运行成功,几秒钟出结果,CPU呼呼的转

4. 4090D机器上运行8B模型

报错:torch.OutOfMemoryError: CUDA out of memory. Tried to allocate 192.00 MiB. GPU 0 has a total capacity of 23.64 GiB of which 72.94 MiB is free. Process 3052744 has 434.64 MiB memory in use. Including non-PyTorch memory, this process has 23.12 GiB memory in use. Of the allocated memory 22.78 GiB is allocated by PyTorch, and 1.10 MiB is reserved by PyTorch but unallocated. If reserved but unallocated memory is large try setting PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True to avoid fragmentation. See documentation for Memory Management (https://pytorch.org/docs/stable/notes/cuda.html#environment-variables)
(

# test_qwen3-embedding.py
。。。
# Load the model
model = SentenceTransformer("/mnt/wd4t/models/modlescope/Qwen3-Embedding-8B", device="cuda", model_kwargs={"torch_dtype": "auto"})   <-- 修改加载模型代码

$ uv run test_qwen3_embedding.py
Loading checkpoint shards: 100%|██████████████████████████████████████████████████████████| 4/4 [00:01<00:00,  2.48it/s]

tensor([[0.7471, 0.0770],
        [0.0894, 0.6321]])

运行出来的结果与sample源代码的结果基本一致。

回到目录

内容概要:本文深入探讨了折扣店快消品定价的研究,涵盖快消品与折扣店行业的概述、定价影响因素、定价策略、定价方法、定价技巧及案例分析。快消品行业涉及日常生活用品、食品、饮料等,具有高频次和重复购买的特点。折扣店市场规模不断扩大,主要参与者包括赵一鸣、好特卖等。影响定价的因素包括成本(生产、库存、物流)、市场需求(规模、购买力、需求弹性)、竞争(对手定价策略、市场份额)、产品特性(差异化、品牌形象)、渠道与分销成本、政府政策等。定价策略分为成本导向(成本加成、目标收益)、需求导向(理解价值、需求差异)和竞争导向(随行就市、投标定价)。定价方法包括市场调研、成本加成、竞争比较和价值定价。定价技巧涵盖高价撇脂、渗透定价、价格歧视和捆绑定价。最后通过好特卖、嗨特购、零食很忙的案例分析,展示了不同折扣店的定价策略及其效果。 适合人群:从事快消品行业、折扣店运营的管理人员及对定价策略感兴趣的商业人士。 使用场景及目标:①帮助折扣店管理者了解定价的基本理论和实际操作方法;②为快消品企业提供定价决策支持,优化定价策略;③通过案例分析,提供实际操作中的经验和教训。 其他说明:折扣店在制定快消品定价时,应综合考虑多种因素,灵活运用不同的定价策略和技巧,以应对市场变化,提升竞争力。建议企业定期监控市场动态,分析消费者反馈,不断优化定价方案。
### MLLM与ICCV会议及其计算机视觉相关应用 #### 多模态大语言模型(MLLM)概述 多模态大语言模型(Multimodal Large Language Models, MLLMs)是一种融合了多种感知模式(如文本、图像、音频等)的大规模预训练模型。这些模型通过学习跨模态表示,能够在多个领域实现复杂的任务处理[^3]。 #### ICCV中的MLLM技术进展 国际计算机视觉大会(International Conference on Computer Vision, ICCV)作为顶级学术会议之一,在推动计算机视觉及相关领域的技术创新方面具有重要作用。近年来,随着多模态技术和自然语言处理的发展,许多研究工作开始探索如何利用MLLM来提升计算机视觉系统的性能和功能多样性。例如: - **MGIE框架的应用** 苹果提出的MGIE(MLLM-Guided Image Editing)方法展示了如何借助MLLM解决传统图像编辑中存在的指令引导不足问题。这种方法不仅增强了用户体验,还为未来更复杂的人机交互提供了新的思路[^1]。 - **评估标准的进步** 在评价这类新型模型时,《LLM - 理解 多模态大语言模型(MLLM) 的 评估》提到,为了克服现有公开数据集中可能存在的偏差或泄漏风险,研究人员开发出了专门针对多模态场景下的评测基准——MME (Multimodal Large Language Model Evaluation Benchmark)[^2]。该工具覆盖了广泛的子任务类别,并采用精心设计的手动标注方式确保结果可靠性。 #### 技术细节分析 具体到某些关键技术层面,则有如下亮点值得关注: - **位置编码创新** Qwen2-VL引入了一种名为“多模态旋转位置编码”(Multi-modal Rotational Positional Encoding, M-RoPE)的新机制。它通过对不同维度的空间关系建模,使得网络可以更好地理解并关联来自异构源的信息流。以下是其实现的一个简化版本伪代码片段: ```python def multi_modal_rotary_position_embedding(positions, dimensions): """ Multi-modal Rotary Position Embedding function. Args: positions (list): List of positional indices across modalities. dimensions (int): Dimensionality of the embedding space. Returns: torch.Tensor: Computed embeddings tensor with shape [len(positions), dimensions]. """ import math from torch import Tensor freqs = [(1 / 10000 ** (i / dimensions)) for i in range(dimensions)] pos_encodings = [] for p in positions: encoding = [math.sin(p * f) if j % 2 == 0 else math.cos(p * f) for j, f in enumerate(freqs[:dimensions])] pos_encodings.append(encoding) return Tensor(pos_encodings) ``` 此函数定义了一个基础版的多模态旋转位置编码逻辑,实际部署过程中还需要考虑更多因素比如输入长度限制以及硬件加速支持等问题。 #### 总结 综上所述,当前阶段围绕着MLLM展开的研究成果已经深入到了包括但不限于图像生成、语义分割等多个细分方向之中;而像ICCV这样的高水平论坛则持续扮演着促进交流分享的角色,不断催生出更加先进实用的技术方案出来供业界采纳实践。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值