Downloads · 30 days
292
4% of all-time downloads
Langboat/mengzi-gpt-neo-base
mengzi-gpt-neo-base is a text generation model from Langboat. 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.
Pretrained model on 300G Chinese corpus.
Downloads · 30 days
292
4% of all-time downloads
All-time downloads
7.9K
Public
Repo size
602 MB
Likes
6
Public
Click a slice to open those files.
.bin300 MB · 99%
From the Hugging Face model README
Pretrained model on 300G Chinese corpus.
import torch
import sentencepiece as spm
from transformers import GPTNeoForCausalLM
tokenizer = spm.SentencePieceProcessor(model_file="mengzi_gpt.model")
model = GPTNeoForCausalLM.from_pretrained("Langboat/mengzi-gpt-neo-base")
def lm(prompt, top_k, top_p, max_length, repetition_penalty):
input_ids = torch.tensor(tokenizer.encode([prompt]), dtype=torch.long, device='cuda')
gen_tokens = model.generate(
input_ids,
do_sample=True,
top_k=top_k,
top_p=top_p,
max_length=max_length+len(prompt),
repetition_penalty=repetition_penalty)
result = tokenizer.decode(gen_tokens.tolist())[0]
return result