File size: 1,506 Bytes
cce4818 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# NanoLM-70M-Instruct-v1
[English](README.md) | 简体中文
## Introduction
为了探究小模型的潜能,我尝试构建一系列小模型,并存放于 [NanoLM Collections](https://huggingface.co/collections/Mxode/nanolm-66d6d75b4a69536bca2705b2)。
这是 NanoLM-70M-Instruct-v1。该模型目前仅支持**英文**。
## 模型详情
NanoLM-70M-Instruct-v1 的分词器和模型架构与 [SmolLM-135M](https://huggingface.co/HuggingFaceTB/SmolLM-135M) 相同,但层数从30减少到12。
因此,NanoLM-70M-Instruct-v1 的参数量只有 70 M。
尽管如此,NanoLM-70M-Instruct-v1 仍展示了指令跟随能力。
## 如何使用
```python
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_path = 'Mxode/NanoLM-70M-Instruct-v1'
model = AutoModelForCausalLM.from_pretrained(model_path).to('cuda:0', torch.bfloat16)
tokenizer = AutoTokenizer.from_pretrained(model_path)
text = "Why is it important for entrepreneurs to prioritize financial management?"
prompt = tokenizer.apply_chat_template(
[
{'role': 'system', 'content': 'You are a helpful assistant.'},
{'role': 'user', 'content': text}
],
add_generation_prompt=True,
tokenize=True,
return_tensors='pt'
).to('cuda:0')
outputs = model.generate(
prompt,
max_new_tokens=1024,
do_sample=True,
temperature=0.7,
repetition_penalty=1.1,
eos_token_id=tokenizer.eos_token_id,
)
response = tokenizer.decode(outputs[0])
print(response)
``` |