Bonsai-27B-GGUF
lmstudio-community · 工具包
面向 LM Studio 的 27B Bonsai 模型 GGUF 转换版,含 3.80 GB 的 Q1_0 语言文件和 0.93 GB 的 BF16 视觉投影器。已测试文本、视觉和并行工具调用。
预测英文文本或代码中被隐藏的词,微调之后可作为长上下文编码器,用于搜索、分类和检索。适合需要快速 BERT 风格编码器的开发者和研究者。
ModernBERT-base 是一款工具包,属于开发类,由 Mindket 上架。可免费获取。当前为第 1 版,最近更新于 。在本页下载,是一个装着它全部文件的 zip 压缩包。这些文件不会自己运行。
pip install -U huggingface_hub hf download answerdotai/ModernBERT-base
ModernBERT-base 是更新过的 BERT 风格编码器,有 22 层、1.49 亿参数。它在 2 万亿个英文文本和代码 token 上预训练,原生支持最长 8,192 个 token 的输入。它开箱即可预测被遮住的词,你还可以把它微调用于分类、检索或问答等任务。
它适合构建搜索、分类或检索系统、想要一个能读长文档和代码的快速编码器的开发者和研究者。
| Industry | Who uses it | How they use it | Example |
|---|---|---|---|
| 搜索 | 检索工程师 | 为语义搜索嵌入长文档 | 为大量文章建立索引 |
| 软件 | 开发者 | 搜索代码以及文本加代码的混合内容 | 按含义查找代码片段 |
| 数据科学 | 机器学习工程师 | 在长文本上微调分类器 | 按主题给客服工单打标签 |
| 研究 | NLP 研究者 | 在标准基准上比较编码器模型 | 测试 GLUE 和 BEIR 分数 |
如果你需要能写作或聊天的模型,可以跳过它,因为它只负责编码文本。
它通过 transformers 库在 Python 里运行,CPU 或 GPU 都行。
| Use case | Who | What they get back |
|---|---|---|
| 填空预测 | 开发者 | 被隐藏位置上最可能的词 |
| 检索和语义搜索 | 搜索团队 | 微调之后得到长文档的向量 |
| 分类 | 机器学习团队 | 一个用于打标签的微调编码器 |
你需要 Python,以及 4.48.0 或更新版本的 transformers。如果你的 GPU 支持,模型卡建议再加上 Flash Attention 2。
pip install -U huggingface_hub hf download answerdotai/ModernBERT-base
pip install -U transformers>=4.48.0
pip install flash-attn
使用 fill-mask 流水线,或者用 AutoModelForMaskedLM 加载模型。这是模型类的用法。
from transformers import AutoTokenizer, AutoModelForMaskedLM
model_id = "answerdotai/ModernBERT-base"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForMaskedLM.from_pretrained(model_id)
text = "The capital of France is [MASK]."
inputs = tokenizer(text, return_tensors="pt")
outputs = model(**inputs)
# To get predictions for the mask:
masked_index = inputs["input_ids"][0].tolist().index(tokenizer.mask_token_id)
predicted_token_id = outputs.logits[0, masked_index].argmax(axis=-1)
predicted_token = tokenizer.decode(predicted_token_id)
print("Predicted token:", predicted_token)流水线的用法更短。
import torch
from transformers import pipeline
from pprint import pprint
pipe = pipeline(
"fill-mask",
model="answerdotai/ModernBERT-base",
torch_dtype=torch.bfloat16,
)
input_text = "He walked to the [MASK]."
results = pipe(input_text)
pprint(results)| Tool | What it does |
|---|---|
| fill-mask pipeline | 预测被遮罩藏起来的词 |
| AutoModelForMaskedLM | 加载模型用于遮罩词预测 |
| flash-attn | 可选的包,在支持的 GPU 上加快注意力计算 |
| hf download | 把模型文件下载到你的电脑 |
你输入句子 "The capital of France is [MASK]."。模型为被遮住的位置给候选词打分,模型卡的示例把 Paris 作为预测的词打印出来。
填空的意思是模型根据周围的词猜出被隐藏的词。可以用你自己的句子试试流水线的例子,并保留其中的遮罩标记。
这个模型用旋转位置编码来处理长输入,用局部层和全局层交替的注意力,并用去填充加 Flash Attention 来加快推理。它不使用 token 类型 ID,所以可以省掉这个参数。下游任务按标准的 BERT 微调方法来做。
模型卡在语言理解、通用检索、长上下文检索和代码检索上评估了这个模型。
预测英文文本或代码中被隐藏的词,微调之后可作为长上下文编码器,用于搜索、分类和检索。适合需要快速 BERT 风格编码器的开发者和研究者。
由 answerdotai 在 Hugging Face 上制作。这些说明是 Mindket 根据它的模型页面和模型卡写的,模型自己的文件和许可证在 Hugging Face 上。
它是什么:ModernBERT-base 是更新过的 BERT 风格编码器,有 22 层、1.49 亿参数。它在 2 万亿个英文文本和代码 token 上预训练,原生支持最长 8,192 个 token 的输入。它开箱即可预测被遮住的词,你还可以把它微调用于分类、检索或问答等任务。
适合谁:它适合构建搜索、分类或检索系统、想要一个能读长文档和代码的快速编码器的开发者和研究者。
Industry | Who uses it | How they use it | Example
搜索 | 检索工程师 | 为语义搜索嵌入长文档 | 为大量文章建立索引
软件 | 开发者 | 搜索代码以及文本加代码的混合内容 | 按含义查找代码片段
数据科学 | 机器学习工程师 | 在长文本上微调分类器 | 按主题给客服工单打标签
研究 | NLP 研究者 | 在标准基准上比较编码器模型 | 测试 GLUE 和 BEIR 分数
如果你需要能写作或聊天的模型,可以跳过它,因为它只负责编码文本。
用在哪里:它通过 transformers 库在 Python 里运行,CPU 或 GPU 都行。
Use case | Who | What they get back
填空预测 | 开发者 | 被隐藏位置上最可能的词
检索和语义搜索 | 搜索团队 | 微调之后得到长文档的向量
分类 | 机器学习团队 | 一个用于打标签的微调编码器
如何设置:你需要 Python,以及 4.48.0 或更新版本的 transformers。如果你的 GPU 支持,模型卡建议再加上 Flash Attention 2。
pip install -U huggingface_hub
hf download answerdotai/ModernBERT-base
pip install -U transformers>=4.48.0
pip install flash-attn
如何使用:使用 fill-mask 流水线,或者用 AutoModelForMaskedLM 加载模型。这是模型类的用法。
from transformers import AutoTokenizer, AutoModelForMaskedLM
model_id = "answerdotai/ModernBERT-base"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForMaskedLM.from_pretrained(model_id)
text = "The capital of France is [MASK]."
inputs = tokenizer(text, return_tensors="pt")
outputs = model(**inputs)
# To get predictions for the mask:
masked_index = inputs["input_ids"][0].tolist().index(tokenizer.mask_token_id)
predicted_token_id = outputs.logits[0, masked_index].argmax(axis=-1)
predicted_token = tokenizer.decode(predicted_token_id)
print("Predicted token:", predicted_token)
流水线的用法更短。
import torch
from transformers import pipeline
from pprint import pprint
pipe = pipeline(
"fill-mask",
model="answerdotai/ModernBERT-base",
torch_dtype=torch.bfloat16,
)
input_text = "He walked to the [MASK]."
results = pipe(input_text)
pprint(results)
Tool | What it does
fill-mask pipeline | 预测被遮罩藏起来的词
AutoModelForMaskedLM | 加载模型用于遮罩词预测
flash-attn | 可选的包,在支持的 GPU 上加快注意力计算
hf download | 把模型文件下载到你的电脑
示例:你输入句子 "The capital of France is [MASK]."。模型为被遮住的位置给候选词打分,模型卡的示例把 Paris 作为预测的词打印出来。
新手与专家:填空的意思是模型根据周围的词猜出被隐藏的词。可以用你自己的句子试试流水线的例子,并保留其中的遮罩标记。
这个模型用旋转位置编码来处理长输入,用局部层和全局层交替的注意力,并用去填充加 Flash Attention 来加快推理。它不使用 token 类型 ID,所以可以省掉这个参数。下游任务按标准的 BERT 微调方法来做。
对带遮罩标记的文本分词
编码器读取整个句子
为每个词输出分数
取最高分的词,或继续微调
注意事项:模型卡在语言理解、通用检索、长上下文检索和代码检索上评估了这个模型。
用 Hugging Face 的命令行下载它的文件:
pip install -U huggingface_hub
hf download answerdotai/ModernBERT-base
然后按它的模型卡使用它。这个工具包里没有会自己运行的东西。
README.md 6 KB
同一分类里与本产品共有标签最多的已上架 Hugging Face 模型。
| 产品 | 最近 30 天下载 | 点赞 | 参数量 | 许可证 | 最近更新 |
|---|---|---|---|---|---|
| ModernBERT-base 本页 | 2,939,636 | 1,155 | 150M | apache-2.0 | |
| ModernBERT-large共有 masked-lm · fill-mask · modernbert | 572,085 | 504 | 396M | apache-2.0 | |
| mmBERT-base共有 fill-mask · modernbert · pytorch | 353,305 | 283 | — | mit | |
| BERT base model (uncased)共有 fill-mask · pytorch · onnx | 31,346,528 | 3,071 | 110M | apache-2.0 | |
| UltraBERT-380M共有 fill-mask · long-context · transformers | 15,830 | 82 | 430M | apache-2.0 | |
| auto-150m-3共有 modernbert · long-context · transformers | 207 | 4 | 150M | apache-2.0 |
Hacker News、Bluesky、X、Reddit、Facebook 和 YouTube 上提到这个项目的帖子和评论,来自每周一次的搜索和 Trendshift。它们不是 Mindket 写的,也未经核实,点开即可在原帖处阅读。
lmstudio-community · 工具包
面向 LM Studio 的 27B Bonsai 模型 GGUF 转换版,含 3.80 GB 的 Q1_0 语言文件和 0.93 GB 的 BF16 视觉投影器。已测试文本、视觉和并行工具调用。
LibertAIDAI · 工具包
以每权重 2.9 位的 EXL3 量化运行 DeepSeek-V4.1-Flash-1017,这是一份 196 GiB 的副本,适合在自己硬件上部署大模型的人。困惑度与原模型相差不大。
facebook · 工具包
根据文字描述或音频提示生成短音乐片段,是 facebook MusicGen 的 small 检查点。适合想在自己电脑上试用文字生成音乐的开发者和音乐爱好者。
alpindale · 工具包
用一个只有约 984 个权重的小型神经网络,为 C 源代码的每个字符打上语法高亮标签,通过一个小小的 C 程序运行。适合对手工设计的网络好奇的开发者和研究者。
prithivMLmods · 工具包
在浏览器或你自己的电脑上,用一个 Gradio 应用试用 FLUX.2 Klein 图像模型的一组 LoRA。适合制作或测试 AI 图片的人。
Sokheng · 工具包
这个模型从文档、收据和路牌照片里读取高棉语和英语文字,用一个检测器找文本行,再用识别器读每一行。适合需要在 Python 里做高棉语 OCR 的开发者。