Downloads · 30 days
110
2% of all-time downloads
pankajmathur/nanochat-d34-sft-hf
nanochat-d34-sft-hf is a text generation model from pankajmathur. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as apache-2.0.
This is the pankajmathur/nanochat-d34-finetuned converted to HuggingFace Transformers format.
Downloads · 30 days
110
2% of all-time downloads
All-time downloads
5.5K
Public
Parameters
2.2B
4.4 GB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors4.4 GB · 100%
From the Hugging Face model README
This is the pankajmathur/nanochat-d34-finetuned converted to HuggingFace Transformers format.
Install Transformer Library from Github with nanochat support
!pip install -q git+https://github.com/huggingface/transformers.git
Use dedicated NanoChatForCausalLM and PreTrainedTokenizerFast packages from Transformer Library
import torch
from transformers import NanoChatForCausalLM, PreTrainedTokenizerFast
# Load the converted model and tokenizer
tokenizer = PreTrainedTokenizerFast.from_pretrained("pankajmathur/nanochat-d34-sft-hf")
model = NanoChatForCausalLM.from_pretrained(
"pankajmathur/nanochat-d34-sft-hf",
torch_dtype=torch.bfloat16,
device_map="auto"
)
# Generate text
prompt = "Hello, who are you?"
inputs = tokenizer(prompt, return_tensors="pt")
input_ids = inputs["input_ids"].to(model.device)
with torch.no_grad():
outputs = model.generate(
input_ids,
max_new_tokens=100,
do_sample=True,
temperature=0.7,
top_p=0.9,
pad_token_id=tokenizer.eos_token_id
)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(f"🤖 Response:\n{response}")
If you use this model, please cite accordingly.