所有笔记本都对初学者友好!添加您的数据集,点击“全部运行”,您将获得一个速度提升 2 倍的微调模型,该模型可导出为 GGUF、vLLM 格式或上传至 Hugging Face。
| Unsloth 支持的模型 | 免费笔记本 | 性能提升 | 内存占用减少 |
|---|---|---|---|
| Gemma 7b | ▶️ 在 Colab 上开始 | 2.4 倍速 | 58% |
| Mistral 7b | ▶️ 在 Colab 上开始 | 2.2 倍速 | 62% |
| Llama-2 7b | ▶️ 在 Colab 上开始 | 2.2 倍速 | 43% |
| TinyLlama | ▶️ 在 Colab 上开始 | 3.9 倍速 | 74% |
| CodeLlama 34b A100 | ▶️ 在 Colab 上开始 | 1.9 倍速 | 27% |
| Mistral 7b 1xT4 | ▶️ 在 Kaggle 上开始 | 5 倍速* | 62% |
| DPO - Zephyr | ▶️ 在 Colab 上开始 | 1.9 倍速 | 19% |
import torch
from openmind import AutoTokenizer, AutoModelForCausalLM, is_torch_npu_available
if is_torch_npu_available():
device = "npu:0"
else:
device = "cpu"
tokenizer = AutoTokenizer.from_pretrained("SY_AICC/gemma-7b-it")
model = AutoModelForCausalLM.from_pretrained(
"SY_AICC/gemma-7b-it",
device_map=device,
torch_dtype=torch.float16
)
input_text = "Write me a poem about Machine Learning."
input_ids = tokenizer(input_text, return_tensors="pt").to(device)
outputs = model.generate(**input_ids)
print(tokenizer.decode(outputs[0]))