import transformers
#from transformers import AutoModelWithHeads
model.load_adapter("./",adapter_name='lora')
peft_model_path="./"
tokenizer = AutoTokenizer.from_pretrained("EleutherAI/gpt-j-6B")
tokenizer.pad_token = tokenizer.eos_token
tokenizer.pad_token_id = tokenizer.eos_token_id
input_text = "フィリピンから10年前来日しました。日本の生活にも慣れ、将来も日本に住み続けたいと考えています。そこで、日本国籍を取得したいと思うのですが、どういう要件が必要でしょうか?"
input_ids = tokenizer(input_text, return_tensors='pt')
generated_output = model.generate(**input_ids, max_length=400)
output = tokenizer.decode(generated_output[0], skip_special_tokens=True)
print(output)
The result is like this:
日本国籍を取得するには、日本国籍法により、日本国籍を取得するには、日本国籍法により、日本国籍を取得するには、日本国籍法により、日本国籍を取得するには、日本国籍法により、日本国籍を取得するには、日本国籍法により、日本国籍を取得するには、日本国籍法により、日本国籍を取得するには、日本国籍法により、日本国籍を取得するには、日本国籍法
you can see that the generated text repeated a 20-tokens text "日本国籍を取得するには、日本国籍法により、日本国籍を取得するには、日本国籍法により、日本国籍を取得するには、日本国籍法により、日本国籍を取得するには、日本国籍法により、日本国籍を取得するには、日本国籍法により、日本国籍を取得するには、日本国籍法により、日本国籍を取得するには、日本国籍法により、日本国籍を取得するには、日本国籍法"
I try to use GPTJ-lora model to generate txt, wish to get a 400-tokens generated text。But the results is not so. Sometimes, the response can be over 40-50 tokens, but it can not be any longer. Otherwise, it will repeat the last sentence again and again. sometimes, the length of the repeated sentence is more than 20 tokens, but sometimes, it is shorter than 20 tokens. what is the problem? The base model is GPT-J, and is trained by databricks-dolly-15k.jsonl, which has been modified into Japanese.