Downloads · 30 days
3
10% of all-time downloads
wangru8080/Lingxi-0.4B-Instruct
Lingxi-0.4B-Instruct is a machine learning model from wangru8080. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as apache-2.0.
灵犀大模型-0.4B,V1版本,过程详见:https://github.com/wangru8080/LLMTrainer 2024.10.30 更新model参数权重
Downloads · 30 days
3
10% of all-time downloads
All-time downloads
31
Public
Parameters
597M
2.4 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors1.2 GB · 99%
From the Hugging Face model README
灵犀大模型-0.4B,V1版本,过程详见:https://github.com/wangru8080/LLM_Trainer
2024.10.30 更新model参数权重
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_name = "wangru8080/Lingxi-0.4B-Instruct"
model = AutoModelForCausalLM.from_pretrained(
model_name,
torch_dtype=torch.bfloat16,
device_map="auto",
trust_remote_code=True
)
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
prompt = "介绍北京"
messages = [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": prompt}
]
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
generated_ids = model.generate(
**model_inputs,
max_new_tokens=512
)
generated_ids = [
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
]
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]