Views
No views yet
g1 model series added significant more data and incorporated deep thinking abilities.flash-linear-attention and the latest version of transformers before using this model:1pip install git+https://github.com/fla-org/flash-linear-attention
2pip install 'transformers>=4.48.0'1from transformers import AutoModelForCausalLM, AutoTokenizer
2model = AutoModelForCausalLM.from_pretrained('fla-hub/rwkv7-0.1B-g1a', trust_remote_code=True)
3tokenizer = AutoTokenizer.from_pretrained('fla-hub/rwkv7-0.1B-g1a', trust_remote_code=True)
4model = model.cuda() # Supported on Nvidia/AMD/Intel eg. model.xpu()
5prompt = "What is a large language model?"
6messages = [
7 {"role": "user", "content": prompt}
8]
9text = tokenizer.apply_chat_template(
10 messages,
11 tokenize=False,
12 add_generation_prompt=True,
13 enable_thinking=True # Default is True, set to False to disable thinking
14)
15
16model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
17generated_ids = model.generate(
18 **model_inputs,
19 max_new_tokens=1024,
20 do_sample=True,
21 temperature=1.0,
22 top_p=0.3,
23 repetition_penalty=1.2
24)
25generated_ids = [
26 output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
27]
28
29response = tokenizer.batch_decode(generated_ids, skip_special_tokens=False)[0]
30print(response)pip install 'transformers>=4.48.0'<|rwkv_tokenizer_end_of_text|>User: <Your Question Here>
Assistant: <think<think!<|rwkv_tokenizer_end_of_text|> (Token ID = 0) before your prompt. The model is incapable of attending the first token it receives due to state initialization issues.Mathews lifted a dark brow. "Are you sure about that? I mean, wouldn't it be better to wait until Dale is home safe and sound?"
"The longer I wait to tell her, the worse it will be for both of us."
"Good luck. You're going to need it," said Mathews because it is the very first token of the input.<|rwkv_tokenizer_end_of_text|>Mathews lifted a dark brow. "Are you sure about that? I mean, wouldn't it be better to wait until Dale is home safe and sound?"
"The longer I wait to tell her, the worse it will be for both of us."
"Good luck. You're going to need it," said Mathews as expected.lambada_openai ppl=13.84 acc=48.13%lambada_openai ppl=12.36 acc=49.12%